diff options
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
-rw-r--r-- | drivers/i2c/i2c-dev.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index c3ccdea3d180..80b47e8ce030 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -102,8 +102,8 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev) | |||
102 | kfree(i2c_dev); | 102 | kfree(i2c_dev); |
103 | } | 103 | } |
104 | 104 | ||
105 | static ssize_t show_adapter_name(struct device *dev, | 105 | static ssize_t name_show(struct device *dev, |
106 | struct device_attribute *attr, char *buf) | 106 | struct device_attribute *attr, char *buf) |
107 | { | 107 | { |
108 | struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt)); | 108 | struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt)); |
109 | 109 | ||
@@ -111,7 +111,13 @@ static ssize_t show_adapter_name(struct device *dev, | |||
111 | return -ENODEV; | 111 | return -ENODEV; |
112 | return sprintf(buf, "%s\n", i2c_dev->adap->name); | 112 | return sprintf(buf, "%s\n", i2c_dev->adap->name); |
113 | } | 113 | } |
114 | static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); | 114 | static DEVICE_ATTR_RO(name); |
115 | |||
116 | static struct attribute *i2c_attrs[] = { | ||
117 | &dev_attr_name.attr, | ||
118 | NULL, | ||
119 | }; | ||
120 | ATTRIBUTE_GROUPS(i2c); | ||
115 | 121 | ||
116 | /* ------------------------------------------------------------------------- */ | 122 | /* ------------------------------------------------------------------------- */ |
117 | 123 | ||
@@ -562,15 +568,10 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy) | |||
562 | res = PTR_ERR(i2c_dev->dev); | 568 | res = PTR_ERR(i2c_dev->dev); |
563 | goto error; | 569 | goto error; |
564 | } | 570 | } |
565 | res = device_create_file(i2c_dev->dev, &dev_attr_name); | ||
566 | if (res) | ||
567 | goto error_destroy; | ||
568 | 571 | ||
569 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", | 572 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", |
570 | adap->name, adap->nr); | 573 | adap->name, adap->nr); |
571 | return 0; | 574 | return 0; |
572 | error_destroy: | ||
573 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | ||
574 | error: | 575 | error: |
575 | return_i2c_dev(i2c_dev); | 576 | return_i2c_dev(i2c_dev); |
576 | return res; | 577 | return res; |
@@ -589,7 +590,6 @@ static int i2cdev_detach_adapter(struct device *dev, void *dummy) | |||
589 | if (!i2c_dev) /* attach_adapter must have failed */ | 590 | if (!i2c_dev) /* attach_adapter must have failed */ |
590 | return 0; | 591 | return 0; |
591 | 592 | ||
592 | device_remove_file(i2c_dev->dev, &dev_attr_name); | ||
593 | return_i2c_dev(i2c_dev); | 593 | return_i2c_dev(i2c_dev); |
594 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 594 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
595 | 595 | ||
@@ -637,6 +637,7 @@ static int __init i2c_dev_init(void) | |||
637 | res = PTR_ERR(i2c_dev_class); | 637 | res = PTR_ERR(i2c_dev_class); |
638 | goto out_unreg_chrdev; | 638 | goto out_unreg_chrdev; |
639 | } | 639 | } |
640 | i2c_dev_class->dev_groups = i2c_groups; | ||
640 | 641 | ||
641 | /* Keep track of adapters which will be added or removed later */ | 642 | /* Keep track of adapters which will be added or removed later */ |
642 | res = bus_register_notifier(&i2c_bus_type, &i2cdev_notifier); | 643 | res = bus_register_notifier(&i2c_bus_type, &i2cdev_notifier); |