diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 18:45:05 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-22 14:05:44 -0400 |
commit | eefafb79a4489b7eeb1853621f95139e3f7cb94c (patch) | |
tree | a638213c4837550e0541be269c80c39b2514e508 /drivers/w1 | |
parent | 0597129cdc464ba3723f340a5a6cbd1e80e78210 (diff) |
w1: slaves: w1_ds2781: convert to use w1_family_ops.groups
This moves the sysfs file creation/removal to the w1 core by using the
.groups field, saving code in the slave driver.
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Cc: Alexander Stein <alexander.stein@informatik.tu-chemnitz.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/slaves/w1_ds2781.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/w1/slaves/w1_ds2781.c b/drivers/w1/slaves/w1_ds2781.c index 1aba8e41ad46..1eb98fb1688d 100644 --- a/drivers/w1/slaves/w1_ds2781.c +++ b/drivers/w1/slaves/w1_ds2781.c | |||
@@ -87,22 +87,28 @@ int w1_ds2781_eeprom_cmd(struct device *dev, int addr, int cmd) | |||
87 | } | 87 | } |
88 | EXPORT_SYMBOL(w1_ds2781_eeprom_cmd); | 88 | EXPORT_SYMBOL(w1_ds2781_eeprom_cmd); |
89 | 89 | ||
90 | static ssize_t w1_ds2781_read_bin(struct file *filp, | 90 | static ssize_t w1_slave_read(struct file *filp, struct kobject *kobj, |
91 | struct kobject *kobj, | 91 | struct bin_attribute *bin_attr, char *buf, |
92 | struct bin_attribute *bin_attr, | 92 | loff_t off, size_t count) |
93 | char *buf, loff_t off, size_t count) | ||
94 | { | 93 | { |
95 | struct device *dev = container_of(kobj, struct device, kobj); | 94 | struct device *dev = container_of(kobj, struct device, kobj); |
96 | return w1_ds2781_io(dev, buf, off, count, 0); | 95 | return w1_ds2781_io(dev, buf, off, count, 0); |
97 | } | 96 | } |
98 | 97 | ||
99 | static struct bin_attribute w1_ds2781_bin_attr = { | 98 | static BIN_ATTR_RO(w1_slave, DS2781_DATA_SIZE); |
100 | .attr = { | 99 | |
101 | .name = "w1_slave", | 100 | static struct bin_attribute *w1_ds2781_bin_attrs[] = { |
102 | .mode = S_IRUGO, | 101 | &bin_attr_w1_slave, |
103 | }, | 102 | NULL, |
104 | .size = DS2781_DATA_SIZE, | 103 | }; |
105 | .read = w1_ds2781_read_bin, | 104 | |
105 | static const struct attribute_group w1_ds2781_group = { | ||
106 | .bin_attrs = w1_ds2781_bin_attrs, | ||
107 | }; | ||
108 | |||
109 | static const struct attribute_group *w1_ds2781_groups[] = { | ||
110 | &w1_ds2781_group, | ||
111 | NULL, | ||
106 | }; | 112 | }; |
107 | 113 | ||
108 | static DEFINE_IDA(bat_ida); | 114 | static DEFINE_IDA(bat_ida); |
@@ -130,16 +136,10 @@ static int w1_ds2781_add_slave(struct w1_slave *sl) | |||
130 | if (ret) | 136 | if (ret) |
131 | goto pdev_add_failed; | 137 | goto pdev_add_failed; |
132 | 138 | ||
133 | ret = sysfs_create_bin_file(&sl->dev.kobj, &w1_ds2781_bin_attr); | ||
134 | if (ret) | ||
135 | goto bin_attr_failed; | ||
136 | |||
137 | dev_set_drvdata(&sl->dev, pdev); | 139 | dev_set_drvdata(&sl->dev, pdev); |
138 | 140 | ||
139 | return 0; | 141 | return 0; |
140 | 142 | ||
141 | bin_attr_failed: | ||
142 | platform_device_del(pdev); | ||
143 | pdev_add_failed: | 143 | pdev_add_failed: |
144 | platform_device_put(pdev); | 144 | platform_device_put(pdev); |
145 | pdev_alloc_failed: | 145 | pdev_alloc_failed: |
@@ -155,12 +155,12 @@ static void w1_ds2781_remove_slave(struct w1_slave *sl) | |||
155 | 155 | ||
156 | platform_device_unregister(pdev); | 156 | platform_device_unregister(pdev); |
157 | ida_simple_remove(&bat_ida, id); | 157 | ida_simple_remove(&bat_ida, id); |
158 | sysfs_remove_bin_file(&sl->dev.kobj, &w1_ds2781_bin_attr); | ||
159 | } | 158 | } |
160 | 159 | ||
161 | static struct w1_family_ops w1_ds2781_fops = { | 160 | static struct w1_family_ops w1_ds2781_fops = { |
162 | .add_slave = w1_ds2781_add_slave, | 161 | .add_slave = w1_ds2781_add_slave, |
163 | .remove_slave = w1_ds2781_remove_slave, | 162 | .remove_slave = w1_ds2781_remove_slave, |
163 | .groups = w1_ds2781_groups, | ||
164 | }; | 164 | }; |
165 | 165 | ||
166 | static struct w1_family w1_ds2781_family = { | 166 | static struct w1_family w1_ds2781_family = { |