diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 18:45:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-22 14:05:44 -0400 |
commit | 0597129cdc464ba3723f340a5a6cbd1e80e78210 (patch) | |
tree | 73c5626d48275bdb51e6ed10c2ba3e426e9f7cea /drivers/w1/slaves | |
parent | 9365261db45ddf1dc0800ce70830928beb0efd78 (diff) |
w1: slaves: w1_ds2760: 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/slaves')
-rw-r--r-- | drivers/w1/slaves/w1_ds2760.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/w1/slaves/w1_ds2760.c b/drivers/w1/slaves/w1_ds2760.c index 93719d25d849..65f90dccd60e 100644 --- a/drivers/w1/slaves/w1_ds2760.c +++ b/drivers/w1/slaves/w1_ds2760.c | |||
@@ -97,21 +97,28 @@ int w1_ds2760_recall_eeprom(struct device *dev, int addr) | |||
97 | return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_RECALL_DATA); | 97 | return w1_ds2760_eeprom_cmd(dev, addr, W1_DS2760_RECALL_DATA); |
98 | } | 98 | } |
99 | 99 | ||
100 | static ssize_t w1_ds2760_read_bin(struct file *filp, struct kobject *kobj, | 100 | static ssize_t w1_slave_read(struct file *filp, struct kobject *kobj, |
101 | struct bin_attribute *bin_attr, | 101 | struct bin_attribute *bin_attr, char *buf, |
102 | char *buf, loff_t off, size_t count) | 102 | loff_t off, size_t count) |
103 | { | 103 | { |
104 | struct device *dev = container_of(kobj, struct device, kobj); | 104 | struct device *dev = container_of(kobj, struct device, kobj); |
105 | return w1_ds2760_read(dev, buf, off, count); | 105 | return w1_ds2760_read(dev, buf, off, count); |
106 | } | 106 | } |
107 | 107 | ||
108 | static struct bin_attribute w1_ds2760_bin_attr = { | 108 | static BIN_ATTR_RO(w1_slave, DS2760_DATA_SIZE); |
109 | .attr = { | 109 | |
110 | .name = "w1_slave", | 110 | static struct bin_attribute *w1_ds2760_bin_attrs[] = { |
111 | .mode = S_IRUGO, | 111 | &bin_attr_w1_slave, |
112 | }, | 112 | NULL, |
113 | .size = DS2760_DATA_SIZE, | 113 | }; |
114 | .read = w1_ds2760_read_bin, | 114 | |
115 | static const struct attribute_group w1_ds2760_group = { | ||
116 | .bin_attrs = w1_ds2760_bin_attrs, | ||
117 | }; | ||
118 | |||
119 | static const struct attribute_group *w1_ds2760_groups[] = { | ||
120 | &w1_ds2760_group, | ||
121 | NULL, | ||
115 | }; | 122 | }; |
116 | 123 | ||
117 | static DEFINE_IDA(bat_ida); | 124 | static DEFINE_IDA(bat_ida); |
@@ -139,16 +146,10 @@ static int w1_ds2760_add_slave(struct w1_slave *sl) | |||
139 | if (ret) | 146 | if (ret) |
140 | goto pdev_add_failed; | 147 | goto pdev_add_failed; |
141 | 148 | ||
142 | ret = sysfs_create_bin_file(&sl->dev.kobj, &w1_ds2760_bin_attr); | ||
143 | if (ret) | ||
144 | goto bin_attr_failed; | ||
145 | |||
146 | dev_set_drvdata(&sl->dev, pdev); | 149 | dev_set_drvdata(&sl->dev, pdev); |
147 | 150 | ||
148 | goto success; | 151 | goto success; |
149 | 152 | ||
150 | bin_attr_failed: | ||
151 | platform_device_del(pdev); | ||
152 | pdev_add_failed: | 153 | pdev_add_failed: |
153 | platform_device_put(pdev); | 154 | platform_device_put(pdev); |
154 | pdev_alloc_failed: | 155 | pdev_alloc_failed: |
@@ -165,12 +166,12 @@ static void w1_ds2760_remove_slave(struct w1_slave *sl) | |||
165 | 166 | ||
166 | platform_device_unregister(pdev); | 167 | platform_device_unregister(pdev); |
167 | ida_simple_remove(&bat_ida, id); | 168 | ida_simple_remove(&bat_ida, id); |
168 | sysfs_remove_bin_file(&sl->dev.kobj, &w1_ds2760_bin_attr); | ||
169 | } | 169 | } |
170 | 170 | ||
171 | static struct w1_family_ops w1_ds2760_fops = { | 171 | static struct w1_family_ops w1_ds2760_fops = { |
172 | .add_slave = w1_ds2760_add_slave, | 172 | .add_slave = w1_ds2760_add_slave, |
173 | .remove_slave = w1_ds2760_remove_slave, | 173 | .remove_slave = w1_ds2760_remove_slave, |
174 | .groups = w1_ds2760_groups, | ||
174 | }; | 175 | }; |
175 | 176 | ||
176 | static struct w1_family w1_ds2760_family = { | 177 | static struct w1_family w1_ds2760_family = { |