drivers: Introduce device lookup variants by device type
Add a helper to match a device by its type and provide wrappers for {bus/class/driver}_find_device() APIs. Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Harald Freudenberger <freude@linux.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: linux-usb@vger.kernel.org Cc: Oliver Neukum <oneukum@suse.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Tomas Winkler <tomas.winkler@intel.com> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Ulf Hansson <ulf.hansson@linaro.org> Cc: Joe Perches <joe@perches.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20190723221838.12024-5-suzuki.poulose@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
67843bbaf3
commit
4495dfdd61
@@ -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 devt value for find_zcdndev_by_devt() */
|
||||
static int __match_zcdn_devt(struct device *dev, const void *data)
|
||||
{
|
||||
return dev->devt == *((dev_t *) data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find zcdn device by name.
|
||||
* Returns reference to the zcdn device which needs to be released
|
||||
@@ -158,10 +152,7 @@ static inline struct zcdn_device *find_zcdndev_by_name(const char *name)
|
||||
*/
|
||||
static inline struct zcdn_device *find_zcdndev_by_devt(dev_t devt)
|
||||
{
|
||||
struct device *dev =
|
||||
class_find_device(zcrypt_class, NULL,
|
||||
(void *) &devt,
|
||||
__match_zcdn_devt);
|
||||
struct device *dev = class_find_device_by_devt(zcrypt_class, devt);
|
||||
|
||||
return dev ? to_zcdn_dev(dev) : NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user