}
 EXPORT_SYMBOL_GPL(device_create_with_groups);
 
-static int __match_devt(struct device *dev, const void *data)
-{
-       const dev_t *devt = data;
-
-       return dev->devt == *devt;
-}
-
 /**
  * device_destroy - removes a device that was created with device_create()
  * @class: pointer to the struct class that this device was registered with
 {
        struct device *dev;
 
-       dev = class_find_device(class, NULL, &devt, __match_devt);
+       dev = class_find_device_by_devt(class, devt);
        if (dev) {
                put_device(dev);
                device_unregister(dev);
        return dev_fwnode(dev) == fwnode;
 }
 EXPORT_SYMBOL_GPL(device_match_fwnode);
+
+int device_match_devt(struct device *dev, const void *pdevt)
+{
+       return dev->devt == *(dev_t *)pdevt;
+}
+EXPORT_SYMBOL_GPL(device_match_devt);
 
        return 0;
 }
 
-static int match_devt(struct device *dev, const void *data)
-{
-       dev_t devt = (dev_t)(unsigned long)(void *)data;
-       return dev->devt == devt;
-}
-
 static int intel_th_output_open(struct inode *inode, struct file *file)
 {
        const struct file_operations *fops;
        struct device *dev;
        int err;
 
-       dev = bus_find_device(&intel_th_bus, NULL,
-                             (void *)(unsigned long)inode->i_rdev,
-                             match_devt);
+       dev = bus_find_device_by_devt(&intel_th_bus, inode->i_rdev);
        if (!dev || !dev->driver)
                return -ENODEV;
 
 
 }
 static DEVICE_ATTR_RO(dev_state);
 
-static int match_devt(struct device *dev, const void *data)
-{
-       const dev_t *devt = data;
-
-       return dev->devt == *devt;
-}
-
 /**
  * dev_set_devstate: set to new device state and notify sysfs file.
  *
 
        dev->dev_state = state;
 
-       clsdev = class_find_device(mei_class, NULL, &dev->cdev.dev, match_devt);
+       clsdev = class_find_device_by_devt(mei_class, dev->cdev.dev);
        if (clsdev) {
                sysfs_notify(&clsdev->kobj, NULL, "dev_state");
                put_device(clsdev);
 
 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
  */
 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;
 }
 
 
 EXPORT_SYMBOL(do_SAK);
 
-static int dev_match_devt(struct device *dev, const void *data)
-{
-       const dev_t *devt = data;
-       return dev->devt == *devt;
-}
-
 /* Must put_device() after it's unused! */
 static struct device *tty_get_device(struct tty_struct *tty)
 {
        dev_t devt = tty_devnum(tty);
-       return class_find_device(tty_class, NULL, &devt, dev_match_devt);
+       return class_find_device_by_devt(tty_class, devt);
 }
 
 
 
        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);
 
 int device_match_name(struct device *dev, const void *name);
 int device_match_of_node(struct device *dev, const void *np);
 int device_match_fwnode(struct device *dev, const void *fwnode);
+int device_match_devt(struct device *dev, const void *pdevt);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
                     int (*fn)(struct device *dev, void *data));
        return bus_find_device(bus, NULL, fwnode, device_match_fwnode);
 }
 
+/**
+ * bus_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @bus: bus type
+ * @devt: device type of the device to match.
+ */
+static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
+                                                    dev_t devt)
+{
+       return bus_find_device(bus, NULL, &devt, device_match_devt);
+}
+
 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
                                        struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
        return driver_find_device(drv, NULL, fwnode, device_match_fwnode);
 }
 
+/**
+ * driver_find_device_by_devt- device iterator for locating a particular device
+ * by devt.
+ * @driver: the driver we're iterating
+ * @devt: devt pointer to match.
+ */
+static inline struct device *driver_find_device_by_devt(struct device_driver *drv,
+                                                       dev_t devt)
+{
+       return driver_find_device(drv, NULL, &devt, device_match_devt);
+}
+
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
 int driver_deferred_probe_check_state_continue(struct device *dev);
        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
+ * @devt: device type of the device to match.
+ */
+static inline struct device *class_find_device_by_devt(struct class *class,
+                                                      dev_t devt)
+{
+       return class_find_device(class, NULL, &devt, device_match_devt);
+}
+
 struct class_attribute {
        struct attribute attr;
        ssize_t (*show)(struct class *class, struct class_attribute *attr,