]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/hid/hid-core.c
HID: use kobj_to_dev()
[mirror_ubuntu-zesty-kernel.git] / drivers / hid / hid-core.c
index c6f7a694f67a189daaae4be80645fb8773bfd2d5..e847fb7f5d5d6ecaab52e30f1ef84ba775a3f884 100644 (file)
@@ -625,7 +625,7 @@ static void hid_close_report(struct hid_device *device)
 
 static void hid_device_release(struct device *dev)
 {
-       struct hid_device *hid = container_of(dev, struct hid_device, dev);
+       struct hid_device *hid = to_hid_device(dev);
 
        hid_close_report(hid);
        kfree(hid->dev_rdesc);
@@ -1571,8 +1571,8 @@ read_report_descriptor(struct file *filp, struct kobject *kobj,
                struct bin_attribute *attr,
                char *buf, loff_t off, size_t count)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
-       struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+       struct device *dev = kobj_to_dev(kobj);
+       struct hid_device *hdev = to_hid_device(dev);
 
        if (off >= hdev->rsize)
                return 0;
@@ -1589,7 +1589,7 @@ static ssize_t
 show_country(struct device *dev, struct device_attribute *attr,
                char *buf)
 {
-       struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+       struct hid_device *hdev = to_hid_device(dev);
 
        return sprintf(buf, "%02x\n", hdev->country & 0xff);
 }
@@ -1902,6 +1902,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_WHEEL) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) },
@@ -2076,7 +2077,7 @@ struct hid_dynid {
 static ssize_t store_new_id(struct device_driver *drv, const char *buf,
                size_t count)
 {
-       struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
+       struct hid_driver *hdrv = to_hid_driver(drv);
        struct hid_dynid *dynid;
        __u32 bus, vendor, product;
        unsigned long driver_data = 0;
@@ -2138,17 +2139,16 @@ static const struct hid_device_id *hid_match_device(struct hid_device *hdev,
 
 static int hid_bus_match(struct device *dev, struct device_driver *drv)
 {
-       struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
-       struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+       struct hid_driver *hdrv = to_hid_driver(drv);
+       struct hid_device *hdev = to_hid_device(dev);
 
        return hid_match_device(hdev, hdrv) != NULL;
 }
 
 static int hid_device_probe(struct device *dev)
 {
-       struct hid_driver *hdrv = container_of(dev->driver,
-                       struct hid_driver, driver);
-       struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+       struct hid_driver *hdrv = to_hid_driver(dev->driver);
+       struct hid_device *hdev = to_hid_device(dev);
        const struct hid_device_id *id;
        int ret = 0;
 
@@ -2190,7 +2190,7 @@ unlock_driver_lock:
 
 static int hid_device_remove(struct device *dev)
 {
-       struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+       struct hid_device *hdev = to_hid_device(dev);
        struct hid_driver *hdrv;
        int ret = 0;
 
@@ -2240,7 +2240,7 @@ ATTRIBUTE_GROUPS(hid_dev);
 
 static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
-       struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+       struct hid_device *hdev = to_hid_device(dev);   
 
        if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
                        hdev->bus, hdev->vendor, hdev->product))