summaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-21 15:44:59 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-22 11:05:43 -0700
commit94c9e6d665011a9926c5f6fd349a6c665093e721 (patch)
tree74e0a45de97b3d2d8faac39266944e7d4a285eab /drivers/w1
parent729fb9d33fe239e350a7e33e9f6aec2767086bd4 (diff)
w1: slaves: w1_ds2423: 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/slaves/w1_ds2423.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/w1/slaves/w1_ds2423.c b/drivers/w1/slaves/w1_ds2423.c
index 7f86aec7408..7e41b7d91fb 100644
--- a/drivers/w1/slaves/w1_ds2423.c
+++ b/drivers/w1/slaves/w1_ds2423.c
@@ -40,14 +40,8 @@
#define COUNTER_COUNT 4
#define READ_BYTE_COUNT 42
-static ssize_t w1_counter_read(struct device *device,
- struct device_attribute *attr, char *buf);
-
-static struct device_attribute w1_counter_attr =
- __ATTR(w1_slave, S_IRUGO, w1_counter_read, NULL);
-
-static ssize_t w1_counter_read(struct device *device,
- struct device_attribute *attr, char *out_buf)
+static ssize_t w1_slave_show(struct device *device,
+ struct device_attribute *attr, char *out_buf)
{
struct w1_slave *sl = dev_to_w1_slave(device);
struct w1_master *dev = sl->master;
@@ -128,19 +122,16 @@ static ssize_t w1_counter_read(struct device *device,
return PAGE_SIZE - c;
}
-static int w1_f1d_add_slave(struct w1_slave *sl)
-{
- return device_create_file(&sl->dev, &w1_counter_attr);
-}
+static DEVICE_ATTR_RO(w1_slave);
-static void w1_f1d_remove_slave(struct w1_slave *sl)
-{
- device_remove_file(&sl->dev, &w1_counter_attr);
-}
+static struct attribute *w1_f1d_attrs[] = {
+ &dev_attr_w1_slave.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(w1_f1d);
static struct w1_family_ops w1_f1d_fops = {
- .add_slave = w1_f1d_add_slave,
- .remove_slave = w1_f1d_remove_slave,
+ .groups = w1_f1d_groups,
};
static struct w1_family w1_family_1d = {