Message ID | 1559577023-558-47-git-send-email-suzuki.poulose@arm.com |
---|---|
State | New |
Headers | show |
Series | [RFC,01/57] drivers: s390/cio: Use driver_for_each_device | expand |
On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: > Add a wrappers to lookup a device by name for a given driver, by various > generic properties of a device. This can avoid the proliferation of custom > match functions throughout the drivers. > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > --- > include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) You should put the "here are the new functions that everyone can use" much earlier in the patch series, otherwise it's hard to dig out. And if you send just those as an individual series, and they look good, I can queue them up now so that everyone else can take the individual patches through their respective trees. thanks, greg k-h
On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: > Add a wrappers to lookup a device by name for a given driver, by various > generic properties of a device. This can avoid the proliferation of custom > match functions throughout the drivers. > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > --- > include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/include/linux/device.h b/include/linux/device.h > index 52d59d5..68d6e04 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv, > struct device *start, void *data, > int (*match)(struct device *dev, const void *data)); > > +/** > + * driver_find_device_by_name - device iterator for locating a particular device > + * of a specific name. > + * @driver: the driver we're iterating > + * @start: Device to begin with > + * @name: name of the device to match > + */ > +static inline struct device *driver_find_device_by_name(struct device_driver *drv, > + struct device *start, > + const char *name) > +{ > + return driver_find_device(drv, start, (void *)name, device_match_name); Why is the cast needed? > +} > + > +/** > + * driver_find_device_by_of_node- device iterator for locating a particular device > + * by of_node pointer. > + * @driver: the driver we're iterating > + * @start: Device to begin with > + * @np: of_node pointer to match. > + */ > +static inline struct device * > +driver_find_device_by_of_node(struct device_driver *drv, > + struct device *start, > + const struct device_node *np) > +{ > + return driver_find_device(drv, start, (void *)np, device_match_of_node); Same here. > +} > + > +/** > + * driver_find_device_by_fwnode- device iterator for locating a particular device > + * by fwnode pointer. > + * @driver: the driver we're iterating > + * @start: Device to begin with > + * @fwnode: fwnode pointer to match. > + */ > +static inline struct device * > +driver_find_device_by_fwnode(struct device_driver *drv, > + struct device *start, > + const struct fwnode_handle *fwnode) > +{ > + return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode); And here thanks, greg k-h
On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: > Add a wrappers to lookup a device by name for a given driver, by various > generic properties of a device. This can avoid the proliferation of custom > match functions throughout the drivers. > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > --- > include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/include/linux/device.h b/include/linux/device.h > index 52d59d5..68d6e04 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv, > struct device *start, void *data, > int (*match)(struct device *dev, const void *data)); > > +/** > + * driver_find_device_by_name - device iterator for locating a particular device > + * of a specific name. > + * @driver: the driver we're iterating > + * @start: Device to begin with > + * @name: name of the device to match > + */ > +static inline struct device *driver_find_device_by_name(struct device_driver *drv, > + struct device *start, > + const char *name) > +{ > + return driver_find_device(drv, start, (void *)name, device_match_name); > +} Are any of the users you are finding for these new functions ever using the 'start' parameter? If not, let's just drop it, as it's normally a rare thing to care about, right? thanks, greg k-h
On 03/06/2019 20:12, Greg KH wrote: > On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: >> Add a wrappers to lookup a device by name for a given driver, by various >> generic properties of a device. This can avoid the proliferation of custom >> match functions throughout the drivers. >> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> Cc: "Rafael J. Wysocki" <rafael@kernel.org> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >> --- >> include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 44 insertions(+) >> >> diff --git a/include/linux/device.h b/include/linux/device.h >> index 52d59d5..68d6e04 100644 >> --- a/include/linux/device.h >> +++ b/include/linux/device.h >> @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv, >> struct device *start, void *data, >> int (*match)(struct device *dev, const void *data)); >> >> +/** >> + * driver_find_device_by_name - device iterator for locating a particular device >> + * of a specific name. >> + * @driver: the driver we're iterating >> + * @start: Device to begin with >> + * @name: name of the device to match >> + */ >> +static inline struct device *driver_find_device_by_name(struct device_driver *drv, >> + struct device *start, >> + const char *name) >> +{ >> + return driver_find_device(drv, start, (void *)name, device_match_name); >> +} > > Are any of the users you are finding for these new functions ever using > the 'start' parameter? If not, let's just drop it, as it's normally a > rare thing to care about, right? No, they don't except for the bus_find_next_device() at the end of the series. I could clean this up. Cheers Suzuki
On 03/06/2019 20:11, Greg KH wrote: > On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: >> Add a wrappers to lookup a device by name for a given driver, by various >> generic properties of a device. This can avoid the proliferation of custom >> match functions throughout the drivers. >> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> Cc: "Rafael J. Wysocki" <rafael@kernel.org> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >> --- >> include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 44 insertions(+) >> >> diff --git a/include/linux/device.h b/include/linux/device.h >> index 52d59d5..68d6e04 100644 >> --- a/include/linux/device.h >> +++ b/include/linux/device.h >> @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv, >> struct device *start, void *data, >> int (*match)(struct device *dev, const void *data)); >> >> +/** >> + * driver_find_device_by_name - device iterator for locating a particular device >> + * of a specific name. >> + * @driver: the driver we're iterating >> + * @start: Device to begin with >> + * @name: name of the device to match >> + */ >> +static inline struct device *driver_find_device_by_name(struct device_driver *drv, >> + struct device *start, >> + const char *name) >> +{ >> + return driver_find_device(drv, start, (void *)name, device_match_name); > > Why is the cast needed? > >> +} >> + >> +/** >> + * driver_find_device_by_of_node- device iterator for locating a particular device >> + * by of_node pointer. >> + * @driver: the driver we're iterating >> + * @start: Device to begin with >> + * @np: of_node pointer to match. >> + */ >> +static inline struct device * >> +driver_find_device_by_of_node(struct device_driver *drv, >> + struct device *start, >> + const struct device_node *np) >> +{ >> + return driver_find_device(drv, start, (void *)np, device_match_of_node); > > Same here. > >> +} >> + >> +/** >> + * driver_find_device_by_fwnode- device iterator for locating a particular device >> + * by fwnode pointer. >> + * @driver: the driver we're iterating >> + * @start: Device to begin with >> + * @fwnode: fwnode pointer to match. >> + */ >> +static inline struct device * >> +driver_find_device_by_fwnode(struct device_driver *drv, >> + struct device *start, >> + const struct fwnode_handle *fwnode) >> +{ >> + return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode); > > And here Because the driver_find_device() expects a "void *" and not a "const void *". May be we could promote that to "const void *" in the core API too, since we have converted the "match" to const void * already. Thoughts ? Suzuki
On 03/06/2019 20:10, Greg KH wrote: > On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: >> Add a wrappers to lookup a device by name for a given driver, by various >> generic properties of a device. This can avoid the proliferation of custom >> match functions throughout the drivers. >> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> Cc: "Rafael J. Wysocki" <rafael@kernel.org> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >> --- >> include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 44 insertions(+) > > You should put the "here are the new functions that everyone can use" > much earlier in the patch series, otherwise it's hard to dig out. Sure, I will add it in the respective commits. > > And if you send just those as an individual series, and they look good, > I can queue them up now so that everyone else can take the individual > patches through their respective trees. I see. I think I may be able to do that. Cheers Suzuki
On Tue, Jun 04, 2019 at 09:36:08AM +0100, Suzuki K Poulose wrote: > > > On 03/06/2019 20:11, Greg KH wrote: > > On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: > > > Add a wrappers to lookup a device by name for a given driver, by various > > > generic properties of a device. This can avoid the proliferation of custom > > > match functions throughout the drivers. > > > > > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > > > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > > > --- > > > include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 44 insertions(+) > > > > > > diff --git a/include/linux/device.h b/include/linux/device.h > > > index 52d59d5..68d6e04 100644 > > > --- a/include/linux/device.h > > > +++ b/include/linux/device.h > > > @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv, > > > struct device *start, void *data, > > > int (*match)(struct device *dev, const void *data)); > > > +/** > > > + * driver_find_device_by_name - device iterator for locating a particular device > > > + * of a specific name. > > > + * @driver: the driver we're iterating > > > + * @start: Device to begin with > > > + * @name: name of the device to match > > > + */ > > > +static inline struct device *driver_find_device_by_name(struct device_driver *drv, > > > + struct device *start, > > > + const char *name) > > > +{ > > > + return driver_find_device(drv, start, (void *)name, device_match_name); > > > > Why is the cast needed? > > > > > +} > > > + > > > +/** > > > + * driver_find_device_by_of_node- device iterator for locating a particular device > > > + * by of_node pointer. > > > + * @driver: the driver we're iterating > > > + * @start: Device to begin with > > > + * @np: of_node pointer to match. > > > + */ > > > +static inline struct device * > > > +driver_find_device_by_of_node(struct device_driver *drv, > > > + struct device *start, > > > + const struct device_node *np) > > > +{ > > > + return driver_find_device(drv, start, (void *)np, device_match_of_node); > > > > Same here. > > > > > +} > > > + > > > +/** > > > + * driver_find_device_by_fwnode- device iterator for locating a particular device > > > + * by fwnode pointer. > > > + * @driver: the driver we're iterating > > > + * @start: Device to begin with > > > + * @fwnode: fwnode pointer to match. > > > + */ > > > +static inline struct device * > > > +driver_find_device_by_fwnode(struct device_driver *drv, > > > + struct device *start, > > > + const struct fwnode_handle *fwnode) > > > +{ > > > + return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode); > > > > And here > > Because the driver_find_device() expects a "void *" and not a "const void *". Can we fix that? > May be we could promote that to "const void *" in the core API too, since we > have converted the "match" to const void * already. Thoughts ? Yes, let's fix the core if possible. thanks, greg k-h
On 04/06/2019 09:45, Suzuki K Poulose wrote: > > > On 03/06/2019 20:10, Greg KH wrote: >> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: >>> Add a wrappers to lookup a device by name for a given driver, by various >>> generic properties of a device. This can avoid the proliferation of custom >>> match functions throughout the drivers. >>> >>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >>> Cc: "Rafael J. Wysocki" <rafael@kernel.org> >>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >>> --- >>> include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 44 insertions(+) >> >> You should put the "here are the new functions that everyone can use" >> much earlier in the patch series, otherwise it's hard to dig out. > > Sure, I will add it in the respective commits. > >> >> And if you send just those as an individual series, and they look good, >> I can queue them up now so that everyone else can take the individual >> patches through their respective trees. > > I see. I think I may be able to do that. The API change patch (i.e, "drivers: Unify the match prototype for bus_find_device with class_find_device" ) is tricky and prevents us from doing this. So, that patch has to come via your tree as it must be a one shot change. And that would make the individual subsystem patches conflict with your tree. Also, it would break the builds until the individual subsystem trees are merged with your tree with the new API. So I am not quite sure what the best approach here would be. Cheers Suzuki
On Tue, Jun 04, 2019 at 11:55:36AM +0100, Suzuki K Poulose wrote: > > > On 04/06/2019 09:45, Suzuki K Poulose wrote: > > > > > > On 03/06/2019 20:10, Greg KH wrote: > > > On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: > > > > Add a wrappers to lookup a device by name for a given driver, by various > > > > generic properties of a device. This can avoid the proliferation of custom > > > > match functions throughout the drivers. > > > > > > > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > > > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > > > > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > > > > --- > > > > include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 44 insertions(+) > > > > > > You should put the "here are the new functions that everyone can use" > > > much earlier in the patch series, otherwise it's hard to dig out. > > > > Sure, I will add it in the respective commits. > > > > > > > > And if you send just those as an individual series, and they look good, > > > I can queue them up now so that everyone else can take the individual > > > patches through their respective trees. > > > > I see. I think I may be able to do that. > > The API change patch (i.e, "drivers: Unify the match prototype for > bus_find_device with class_find_device" ) is tricky and prevents us from > doing > this. So, that patch has to come via your tree as it must be a one shot change. > And that would make the individual subsystem patches conflict with your tree. > Also, it would break the builds until the individual subsystem trees are merged > with your tree with the new API. > > So I am not quite sure what the best approach here would be. That's for you to work out :) one-shot changes are usually not a good idea, there are lots of ways to prevent this from being required. good luck! greg k-h
On Tue, Jun 4, 2019 at 12:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote: > > > > On 04/06/2019 09:45, Suzuki K Poulose wrote: > > > > > > On 03/06/2019 20:10, Greg KH wrote: > >> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: > >>> Add a wrappers to lookup a device by name for a given driver, by various > >>> generic properties of a device. This can avoid the proliferation of custom > >>> match functions throughout the drivers. > >>> > >>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > >>> Cc: "Rafael J. Wysocki" <rafael@kernel.org> > >>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > >>> --- > >>> include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ > >>> 1 file changed, 44 insertions(+) > >> > >> You should put the "here are the new functions that everyone can use" > >> much earlier in the patch series, otherwise it's hard to dig out. > > > > Sure, I will add it in the respective commits. > > > >> > >> And if you send just those as an individual series, and they look good, > >> I can queue them up now so that everyone else can take the individual > >> patches through their respective trees. > > > > I see. I think I may be able to do that. > > The API change patch (i.e, "drivers: Unify the match prototype for > bus_find_device with class_find_device" ) is tricky and prevents us from doing > this. So, that patch has to come via your tree as it must be a one shot change. > And that would make the individual subsystem patches conflict with your tree. > Also, it would break the builds until the individual subsystem trees are merged > with your tree with the new API. > > So I am not quite sure what the best approach here would be. It looks like you need to consolidate the prototypes of bus_find_device() and class_find_device() in the first place, so all of the changes this depends one need to go into one series and through the Greg's tree. Then, you need the new helpers to be defined on top of that and I would introduce them in another patch series once the first step above has been completed. Finally, some code in multiple places needs to be changed to use the new helpers and that can be done in many smaller steps with individual changes going in through the respective subsystem trees of theirs.
On 04/06/2019 12:32, Greg KH wrote: > On Tue, Jun 04, 2019 at 11:55:36AM +0100, Suzuki K Poulose wrote: >> >> >> On 04/06/2019 09:45, Suzuki K Poulose wrote: >>> >>> >>> On 03/06/2019 20:10, Greg KH wrote: >>>> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote: >>>>> Add a wrappers to lookup a device by name for a given driver, by various >>>>> generic properties of a device. This can avoid the proliferation of custom >>>>> match functions throughout the drivers. >>>>> >>>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >>>>> Cc: "Rafael J. Wysocki" <rafael@kernel.org> >>>>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >>>>> --- >>>>> include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ >>>>> 1 file changed, 44 insertions(+) >>>> >>>> You should put the "here are the new functions that everyone can use" >>>> much earlier in the patch series, otherwise it's hard to dig out. >>> >>> Sure, I will add it in the respective commits. >>> >>>> >>>> And if you send just those as an individual series, and they look good, >>>> I can queue them up now so that everyone else can take the individual >>>> patches through their respective trees. >>> >>> I see. I think I may be able to do that. >> >> The API change patch (i.e, "drivers: Unify the match prototype for >> bus_find_device with class_find_device" ) is tricky and prevents us from >> doing >> this. So, that patch has to come via your tree as it must be a one shot change. >> And that would make the individual subsystem patches conflict with your tree. >> Also, it would break the builds until the individual subsystem trees are merged >> with your tree with the new API. >> >> So I am not quite sure what the best approach here would be. I was under the assumption that the changes are minimal for the subsystems to allow the series queued as one shot through your tree, with Acks from the individual maintainers. However, if thats not how it works, I can split the series. > > That's for you to work out :) > > one-shot changes are usually not a good idea, there are lots of ways to > prevent this from being required. Sure, I will rework the series. > > good luck! Thank :-) Suzuki
diff --git a/include/linux/device.h b/include/linux/device.h index 52d59d5..68d6e04 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv, struct device *start, void *data, int (*match)(struct device *dev, const void *data)); +/** + * driver_find_device_by_name - device iterator for locating a particular device + * of a specific name. + * @driver: the driver we're iterating + * @start: Device to begin with + * @name: name of the device to match + */ +static inline struct device *driver_find_device_by_name(struct device_driver *drv, + struct device *start, + const char *name) +{ + return driver_find_device(drv, start, (void *)name, device_match_name); +} + +/** + * driver_find_device_by_of_node- device iterator for locating a particular device + * by of_node pointer. + * @driver: the driver we're iterating + * @start: Device to begin with + * @np: of_node pointer to match. + */ +static inline struct device * +driver_find_device_by_of_node(struct device_driver *drv, + struct device *start, + const struct device_node *np) +{ + return driver_find_device(drv, start, (void *)np, device_match_of_node); +} + +/** + * driver_find_device_by_fwnode- device iterator for locating a particular device + * by fwnode pointer. + * @driver: the driver we're iterating + * @start: Device to begin with + * @fwnode: fwnode pointer to match. + */ +static inline struct device * +driver_find_device_by_fwnode(struct device_driver *drv, + struct device *start, + const struct fwnode_handle *fwnode) +{ + return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev);
Add a wrappers to lookup a device by name for a given driver, by various generic properties of a device. This can avoid the proliferation of custom match functions throughout the drivers. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> --- include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.7.4