diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-07-03 16:46:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-01 17:51:59 -0500 |
commit | ac11d0601bbe73c92e31b393eeb1225593788d4c (patch) | |
tree | 01e425a71270dad5d9e2a40ebd165c83fac81b7a /drivers/i2c/i2c-dev.c | |
parent | 38ca6c34d385f143027ff40dd271c61adcc9b23c (diff) |
I2C: convert i2c-dev to use struct device instead of struct class_device
As class_device is going away eventually...
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
-rw-r--r-- | drivers/i2c/i2c-dev.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 3f869033ed70..94a4e9a3013c 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -42,7 +42,7 @@ static struct i2c_driver i2cdev_driver; | |||
42 | struct i2c_dev { | 42 | struct i2c_dev { |
43 | struct list_head list; | 43 | struct list_head list; |
44 | struct i2c_adapter *adap; | 44 | struct i2c_adapter *adap; |
45 | struct class_device *class_dev; | 45 | struct device *dev; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #define I2C_MINORS 256 | 48 | #define I2C_MINORS 256 |
@@ -92,15 +92,16 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev) | |||
92 | spin_unlock(&i2c_dev_list_lock); | 92 | spin_unlock(&i2c_dev_list_lock); |
93 | } | 93 | } |
94 | 94 | ||
95 | static ssize_t show_adapter_name(struct class_device *class_dev, char *buf) | 95 | static ssize_t show_adapter_name(struct device *dev, |
96 | struct device_attribute *attr, char *buf) | ||
96 | { | 97 | { |
97 | struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(class_dev->devt)); | 98 | struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt)); |
98 | 99 | ||
99 | if (!i2c_dev) | 100 | if (!i2c_dev) |
100 | return -ENODEV; | 101 | return -ENODEV; |
101 | return sprintf(buf, "%s\n", i2c_dev->adap->name); | 102 | return sprintf(buf, "%s\n", i2c_dev->adap->name); |
102 | } | 103 | } |
103 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); | 104 | static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); |
104 | 105 | ||
105 | static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, | 106 | static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, |
106 | loff_t *offset) | 107 | loff_t *offset) |
@@ -413,15 +414,14 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
413 | return PTR_ERR(i2c_dev); | 414 | return PTR_ERR(i2c_dev); |
414 | 415 | ||
415 | /* register this i2c device with the driver core */ | 416 | /* register this i2c device with the driver core */ |
416 | i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL, | 417 | i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, |
417 | MKDEV(I2C_MAJOR, adap->nr), | 418 | MKDEV(I2C_MAJOR, adap->nr), |
418 | &adap->dev, "i2c-%d", | 419 | "i2c-%d", adap->nr); |
419 | adap->nr); | 420 | if (!i2c_dev->dev) { |
420 | if (!i2c_dev->class_dev) { | ||
421 | res = -ENODEV; | 421 | res = -ENODEV; |
422 | goto error; | 422 | goto error; |
423 | } | 423 | } |
424 | res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name); | 424 | res = device_create_file(i2c_dev->dev, &dev_attr_name); |
425 | if (res) | 425 | if (res) |
426 | goto error_destroy; | 426 | goto error_destroy; |
427 | 427 | ||
@@ -429,7 +429,7 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
429 | adap->name, adap->nr); | 429 | adap->name, adap->nr); |
430 | return 0; | 430 | return 0; |
431 | error_destroy: | 431 | error_destroy: |
432 | class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 432 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
433 | error: | 433 | error: |
434 | return_i2c_dev(i2c_dev); | 434 | return_i2c_dev(i2c_dev); |
435 | kfree(i2c_dev); | 435 | kfree(i2c_dev); |
@@ -444,9 +444,9 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
444 | if (!i2c_dev) /* attach_adapter must have failed */ | 444 | if (!i2c_dev) /* attach_adapter must have failed */ |
445 | return 0; | 445 | return 0; |
446 | 446 | ||
447 | class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name); | 447 | device_remove_file(i2c_dev->dev, &dev_attr_name); |
448 | return_i2c_dev(i2c_dev); | 448 | return_i2c_dev(i2c_dev); |
449 | class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 449 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
450 | kfree(i2c_dev); | 450 | kfree(i2c_dev); |
451 | 451 | ||
452 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); | 452 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); |