From: Suzuki K Poulose <suzuki.poulose@arm.com> To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alessandro Zummo <a.zummo@towertech.it>, Alexander Aring <alex.aring@gmail.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Andrew Lunn <andrew@lunn.ch>, Arnd Bergmann <arnd@arndb.de>, Dan Murphy <dmurphy@ti.com>, "David S. Miller" <davem@davemloft.net>, Florian Fainelli <f.fainelli@gmail.com>, Harald Freudenberger <freude@linux.ibm.com>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Heiko Carstens <heiko.carstens@de.ibm.com>, Heiner Kallweit <hkallweit1@gmail.com>, Jacek Anaszewski <jacek.anaszewski@gmail.com>, Jiri Slaby <jslaby@suse.com>, Liam Girdwood <lgirdwood@gmail.com>, linux-leds@vger.kernel.org, linux-rtc@vger Subject: [PATCH 10/13] drivers: Introduce variants of class_find_device() Date: Wed, 5 Jun 2019 16:13:47 +0100 [thread overview] Message-ID: <1559747630-28065-11-git-send-email-suzuki.poulose@arm.com> (raw) In-Reply-To: <1559747630-28065-1-git-send-email-suzuki.poulose@arm.com> Now that we have generic helpers to match various generic device attributes, provide wrappers to the class_find_device() to lookup devices by individual properties. The new wrappers except the lookup by devt, drops the "start" device pointer as none of the existing users need it and the attributes are usually unique. The idea is to stop the proliferation of custom match functions to do generic attribute matching. So now we have : class_find_device_by_name class_find_device_by_of_node class_find_device_by_fwnode class_find_device_by_devt Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexander Aring <alex.aring@gmail.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Dan Murphy <dmurphy@ti.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Harald Freudenberger <freude@linux.ibm.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Heiner Kallweit <hkallweit1@gmail.com> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com> Cc: Jiri Slaby <jslaby@suse.com> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: linux-leds@vger.kernel.org Cc: linux-rtc@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: linux-wpan@vger.kernel.org Cc: Mark Brown <broonie@kernel.org> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Peter Rosin <peda@axentia.se> Cc: Stefan Schmidt <stefan@datenfreihafen.org> Cc: Tomas Winkler <tomas.winkler@intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> --- include/linux/device.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 8c8727b..4396edc 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -474,6 +474,57 @@ extern struct device *class_find_device(struct class *class, struct device *start, const void *data, int (*match)(struct device *, const void *)); +/** + * class_find_device_by_name - device iterator for locating a particular device + * of a specific name. + * @class: class type + * @name: name of the device to match + */ +static inline struct device *class_find_device_by_name(struct class *class, + const char *name) +{ + return class_find_device(class, NULL, name, device_match_name); +} + +/** + * class_find_device_by_of_node : device iterator for locating a particular device + * matching the of_node. + * @class: class type + * @np: of_node of the device to match. + */ +static inline struct device * +class_find_device_by_of_node(struct class *class, const struct device_node *np) +{ + return class_find_device(class, NULL, np, device_match_of_node); +} + +/** + * class_find_device_by_fwnode : device iterator for locating a particular device + * matching the fwnode. + * @class: class type + * @fwnode: fwnode of the device to match. + */ +static inline struct device * +class_find_device_by_fwnode(struct class *class, + const struct fwnode_handle *fwnode) +{ + return class_find_device(class, NULL, fwnode, device_match_fwnode); +} + +/** + * class_find_device_by_devt : device iterator for locating a particular device + * matching the device type. + * @class: class type + * @start: device to start search from + * @devt: device type of the device to match. + */ +static inline struct device *class_find_device_by_devt(struct class *class, + struct device *start, + dev_t devt) +{ + return class_find_device(class, start, &devt, device_match_devt); +} + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr, -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Suzuki K Poulose <suzuki.poulose@arm.com> To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alessandro Zummo <a.zummo@towertech.it>, Alexander Aring <alex.aring@gmail.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Andrew Lunn <andrew@lunn.ch>, Arnd Bergmann <arnd@arndb.de>, Dan Murphy <dmurphy@ti.com>, "David S. Miller" <davem@davemloft.net>, Florian Fainelli <f.fainelli@gmail.com>, Harald Freudenberger <freude@linux.ibm.com>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Heiko Carstens <heiko.carstens@de.ibm.com>, Heiner Kallweit <hkallweit1@gmail.com>, Jacek Anaszewski <jacek.anaszewski@gmail.com>, Jiri Slaby <jslaby@suse.com>, Liam Girdwood <lgirdwood@gmail.com>, linux-leds@vger.kernel.org, linux-rtc@vger.kernel.org, linux-usb@vger.kernel.org, linux-wpan@vger.kernel.org, Mark Brown <broonie@kernel.org>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Pavel Machek <pavel@ucw.cz>, Peter Rosin <peda@axentia.se>, Stefan Schmidt <stefan@datenfreihafen.org>, Tomas Winkler <tomas.winkler@intel.com>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Subject: [PATCH 10/13] drivers: Introduce variants of class_find_device() Date: Wed, 5 Jun 2019 16:13:47 +0100 [thread overview] Message-ID: <1559747630-28065-11-git-send-email-suzuki.poulose@arm.com> (raw) In-Reply-To: <1559747630-28065-1-git-send-email-suzuki.poulose@arm.com> Now that we have generic helpers to match various generic device attributes, provide wrappers to the class_find_device() to lookup devices by individual properties. The new wrappers except the lookup by devt, drops the "start" device pointer as none of the existing users need it and the attributes are usually unique. The idea is to stop the proliferation of custom match functions to do generic attribute matching. So now we have : class_find_device_by_name class_find_device_by_of_node class_find_device_by_fwnode class_find_device_by_devt Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexander Aring <alex.aring@gmail.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Dan Murphy <dmurphy@ti.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Harald Freudenberger <freude@linux.ibm.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Heiner Kallweit <hkallweit1@gmail.com> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com> Cc: Jiri Slaby <jslaby@suse.com> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: linux-leds@vger.kernel.org Cc: linux-rtc@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: linux-wpan@vger.kernel.org Cc: Mark Brown <broonie@kernel.org> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Peter Rosin <peda@axentia.se> Cc: Stefan Schmidt <stefan@datenfreihafen.org> Cc: Tomas Winkler <tomas.winkler@intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> --- include/linux/device.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 8c8727b..4396edc 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -474,6 +474,57 @@ extern struct device *class_find_device(struct class *class, struct device *start, const void *data, int (*match)(struct device *, const void *)); +/** + * class_find_device_by_name - device iterator for locating a particular device + * of a specific name. + * @class: class type + * @name: name of the device to match + */ +static inline struct device *class_find_device_by_name(struct class *class, + const char *name) +{ + return class_find_device(class, NULL, name, device_match_name); +} + +/** + * class_find_device_by_of_node : device iterator for locating a particular device + * matching the of_node. + * @class: class type + * @np: of_node of the device to match. + */ +static inline struct device * +class_find_device_by_of_node(struct class *class, const struct device_node *np) +{ + return class_find_device(class, NULL, np, device_match_of_node); +} + +/** + * class_find_device_by_fwnode : device iterator for locating a particular device + * matching the fwnode. + * @class: class type + * @fwnode: fwnode of the device to match. + */ +static inline struct device * +class_find_device_by_fwnode(struct class *class, + const struct fwnode_handle *fwnode) +{ + return class_find_device(class, NULL, fwnode, device_match_fwnode); +} + +/** + * class_find_device_by_devt : device iterator for locating a particular device + * matching the device type. + * @class: class type + * @start: device to start search from + * @devt: device type of the device to match. + */ +static inline struct device *class_find_device_by_devt(struct class *class, + struct device *start, + dev_t devt) +{ + return class_find_device(class, start, &devt, device_match_devt); +} + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr, -- 2.7.4
next prev parent reply other threads:[~2019-06-05 15:13 UTC|newest] Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-06-05 15:13 [PATCH 00/13] drivers: Introduce generic device lookup helpers Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 01/13] acpi: utils: Cleanup acpi_dev_match_cb Suzuki K Poulose 2019-06-06 9:14 ` Rafael J. Wysocki 2019-06-06 9:21 ` Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose 2019-06-05 15:48 ` Corey Minyard 2019-06-05 15:51 ` Kershner, David A 2019-06-05 18:18 ` Mark Brown 2019-06-06 8:56 ` Rafael J. Wysocki 2019-06-06 9:01 ` Srinivas Kandagatla 2019-06-05 15:13 ` [PATCH 03/13] driver_find_device: Unify the match function with class_find_device() Suzuki K Poulose 2019-06-12 9:32 ` Lee Jones 2019-06-12 9:36 ` Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 04/13] drivers: Add generic helper to match by of_node Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 05/13] drivers: Add generic helper to match by fwnode Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 06/13] drivers: Add generic helper to match by devt Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose 2019-06-06 9:17 ` Rafael J. Wysocki 2019-06-06 9:28 ` Suzuki K Poulose 2019-06-06 9:57 ` Rafael J. Wysocki 2019-06-12 9:43 ` Suzuki K Poulose 2019-06-12 22:07 ` Rafael J. Wysocki 2019-06-05 15:13 ` [PATCH 08/13] drivers: Add generic helper to match by name Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 09/13] drivers: Add generic helper to match any device Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose [this message] 2019-06-05 15:13 ` [PATCH 10/13] drivers: Introduce variants of class_find_device() Suzuki K Poulose 2019-06-05 16:14 ` Greg KH 2019-06-05 16:14 ` Greg KH 2019-06-05 18:13 ` Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 11/13] drivers: Introduce variants for bus_find_device() Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose 2019-06-05 15:13 ` Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 12/13] drivers: Introduce variants of driver_find_device() Suzuki K Poulose 2019-06-05 15:13 ` [PATCH 13/13] platform: Add platform_find_device_by_driver() helper Suzuki K Poulose
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1559747630-28065-11-git-send-email-suzuki.poulose@arm.com \ --to=suzuki.poulose@arm.com \ --cc=a.zummo@towertech.it \ --cc=alex.aring@gmail.com \ --cc=alexander.shishkin@linux.intel.com \ --cc=alexandre.belloni@bootlin.com \ --cc=andrew@lunn.ch \ --cc=arnd@arndb.de \ --cc=davem@davemloft.net \ --cc=dmurphy@ti.com \ --cc=f.fainelli@gmail.com \ --cc=freude@linux.ibm.com \ --cc=gregkh@linuxfoundation.org \ --cc=heikki.krogerus@linux.intel.com \ --cc=heiko.carstens@de.ibm.com \ --cc=hkallweit1@gmail.com \ --cc=jacek.anaszewski@gmail.com \ --cc=jslaby@suse.com \ --cc=lgirdwood@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-leds@vger.kernel.org \ --cc=linux-rtc@vger \ --cc=rafael@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.