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
@@ -942,17 +942,11 @@ error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int match_devt(struct device *dev, const void *data)
|
||||
{
|
||||
return dev->devt == (dev_t)(unsigned long)(void *)data;
|
||||
}
|
||||
|
||||
static struct usb_device *usbdev_lookup_by_devt(dev_t devt)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
dev = bus_find_device(&usb_bus_type, NULL,
|
||||
(void *) (unsigned long) devt, match_devt);
|
||||
dev = bus_find_device_by_devt(&usb_bus_type, devt);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
return to_usb_device(dev);
|
||||
|
||||
Reference in New Issue
Block a user