misc: eeprom: use kobj_to_dev()
authorGeliang Tang <geliangtang@163.com>
Wed, 13 Jan 2016 15:30:11 +0000 (23:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Feb 2016 07:01:45 +0000 (23:01 -0800)
Use kobj_to_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/eeprom/at24.c
drivers/misc/eeprom/at25.c
drivers/misc/eeprom/eeprom.c
drivers/misc/eeprom/eeprom_93xx46.c

index 5d7c0900fa1b129c8bf103d3eddd03cbd92fe80d..d105c25644000bf6f1409cf7c8cfadb7b61aafb4 100644 (file)
@@ -289,7 +289,7 @@ static ssize_t at24_bin_read(struct file *filp, struct kobject *kobj,
 {
        struct at24_data *at24;
 
-       at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
+       at24 = dev_get_drvdata(kobj_to_dev(kobj));
        return at24_read(at24, buf, off, count);
 }
 
@@ -420,7 +420,7 @@ static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj,
 {
        struct at24_data *at24;
 
-       at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
+       at24 = dev_get_drvdata(kobj_to_dev(kobj));
        return at24_write(at24, buf, off, count);
 }
 
index f850ef556bcc48d598f11537fffa6fe351b7eef9..3e9e5a28acaa2f6331570639ec53a0e36ffb29b4 100644 (file)
@@ -139,7 +139,7 @@ at25_bin_read(struct file *filp, struct kobject *kobj,
        struct device           *dev;
        struct at25_data        *at25;
 
-       dev = container_of(kobj, struct device, kobj);
+       dev = kobj_to_dev(kobj);
        at25 = dev_get_drvdata(dev);
 
        return at25_ee_read(at25, buf, off, count);
@@ -273,7 +273,7 @@ at25_bin_write(struct file *filp, struct kobject *kobj,
        struct device           *dev;
        struct at25_data        *at25;
 
-       dev = container_of(kobj, struct device, kobj);
+       dev = kobj_to_dev(kobj);
        at25 = dev_get_drvdata(dev);
 
        return at25_ee_write(at25, buf, off, count);
index 7342fd637031335a21ed4779442ca69eb39fb045..3d1d55157e5f3b605bb4695c797eb12a6987bfff 100644 (file)
@@ -84,7 +84,7 @@ static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
                           struct bin_attribute *bin_attr,
                           char *buf, loff_t off, size_t count)
 {
-       struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
+       struct i2c_client *client = to_i2c_client(kobj_to_dev(kobj));
        struct eeprom_data *data = i2c_get_clientdata(client);
        u8 slice;
 
index ff63f05edc763cac7bb8aefef565e20e1463a82b..473aa0a2eaf61fe2743c821be88cbb8baaaab1ce 100644 (file)
@@ -45,7 +45,7 @@ eeprom_93xx46_bin_read(struct file *filp, struct kobject *kobj,
        int bits, ret;
        u16 cmd_addr;
 
-       dev = container_of(kobj, struct device, kobj);
+       dev = kobj_to_dev(kobj);
        edev = dev_get_drvdata(dev);
 
        cmd_addr = OP_READ << edev->addrlen;
@@ -190,7 +190,7 @@ eeprom_93xx46_bin_write(struct file *filp, struct kobject *kobj,
        struct device *dev;
        int i, ret, step = 1;
 
-       dev = container_of(kobj, struct device, kobj);
+       dev = kobj_to_dev(kobj);
        edev = dev_get_drvdata(dev);
 
        /* only write even number of bytes on 16-bit devices */