Re: [PATCH v2 27/36] drivers: Add a generic helper to match device by fwnode handle
From: Rafael J. Wysocki
Date: Tue Apr 16 2019 - 06:45:37 EST
On Tue, Apr 16, 2019 at 12:31 PM Suzuki K Poulose
<suzuki.poulose@xxxxxxx> wrote:
>
> Hi Rafael
>
> On 04/16/2019 11:20 AM, Rafael J. Wysocki wrote:
> > On Mon, Apr 15, 2019 at 6:06 PM Suzuki K Poulose <suzuki.poulose@xxxxxxx> wrote:
> >>
> >> Make the device_fwnode_match() a generic helper to match device
> >> by fwnode handle for use with bus_find_device(). This will be
> >> also used by coresight.
> >>
> >> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> >> Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
> >
> > Can you resend this with a CC to linux-acpi@xxxxxxxxxxxxxxx, please?
> >
> > There's some device properties material for 5.2 collected already and
> > it would be good to keep all that together.
> >
>
> Sure, will do. Btw, I have a question w.r.t the match function.
>
> We have :
>
>
> class_find_device(struct class *class, struct device *start,
> const void *data,
> int (*match)(struct device *, const void *))
> and
>
> bus_find_device(struct bus_type *bus,
> struct device *start, void *data,
> int (*match)(struct device *dev, void *data))
>
> Just because the "match" has slightly different constraint for the
> data (i.e, const void * vs void *), we can't reuse the same match
> function for class_find_device. Do you think we should converge the
> types to reuse the same match every where (Of course in a separate
> patch series) ?
AFAICS, (void *) pointers can be passed to functions taking (const
void *) arguments, so yes, it looks like that could be consolidated
and it also would be a valuable cleanup IMO.