Re: [PATCH v2 20/24] serdev: Make match_id accessible by drivers
From: Andy Shevchenko
Date: Mon Jun 11 2018 - 08:47:33 EST
On Mon, Jun 11, 2018 at 2:52 PM, Ricardo Ribalda Delgado
<ricardo.ribalda@xxxxxxxxx> wrote:
> Drivers that make use of the driver_data field require to transverse the
> id_table. There is no reason to have one implementation per driver.
> +const struct serdev_device_id *serdev_match_id(
> + const struct serdev_device_id *id,
> + const struct serdev_device *sdev)
I think slightly better would be
const strunct serdev_device *
serdev_match_id(const struct serdev_device_id *id,
const struct serdev_device *sdev)
> {
> while (id->name[0]) {
> if (!strcmp(sdev->modalias, id->name))
> - return 1;
> + return id;
> id++;
> }
>
> - return 0;
> + return NULL;
> }
> +EXPORT_SYMBOL_GPL(serdev_match_id);
Can we avoid ping-pong changes in the series? I mean to introduce this
helper in this form in the first place?
> - return serdev_match_id(sdrv->id_table, sdev);
> + return serdev_match_id(sdrv->id_table, sdev) != NULL;
return !!serdev_match_id(...);
?
> +const struct serdev_device_id *serdev_match_id(
> + const struct serdev_device_id *id,
> + const struct serdev_device *sdev);
Same as above.
--
With Best Regards,
Andy Shevchenko