drivers: Introduce device lookup variants by name
Add a helper to match the device name for device lookup. Also reuse this generic exported helper for the existing bus_find_device_by_name(). and add similar variants for driver/class. Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexander Aring <alex.aring@gmail.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Dan Murphy <dmurphy@ti.com> Cc: Harald Freudenberger <freude@linux.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com> Cc: Lee Jones <lee.jones@linaro.org> 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: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Peter Oberparleiter <oberpar@linux.ibm.com> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Stefan Schmidt <stefan@datenfreihafen.org> 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> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20190723221838.12024-2-suzuki.poulose@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
5f9e832c13
commit
6cda08a20d
@@ -133,12 +133,6 @@ struct zcdn_device {
|
||||
static int zcdn_create(const char *name);
|
||||
static int zcdn_destroy(const char *name);
|
||||
|
||||
/* helper function, matches the name for find_zcdndev_by_name() */
|
||||
static int __match_zcdn_name(struct device *dev, const void *data)
|
||||
{
|
||||
return strcmp(dev_name(dev), (const char *)data) == 0;
|
||||
}
|
||||
|
||||
/* helper function, matches the devt value for find_zcdndev_by_devt() */
|
||||
static int __match_zcdn_devt(struct device *dev, const void *data)
|
||||
{
|
||||
@@ -152,10 +146,7 @@ static int __match_zcdn_devt(struct device *dev, const void *data)
|
||||
*/
|
||||
static inline struct zcdn_device *find_zcdndev_by_name(const char *name)
|
||||
{
|
||||
struct device *dev =
|
||||
class_find_device(zcrypt_class, NULL,
|
||||
(void *) name,
|
||||
__match_zcdn_name);
|
||||
struct device *dev = class_find_device_by_name(zcrypt_class, name);
|
||||
|
||||
return dev ? to_zcdn_dev(dev) : NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user