aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/w1.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index b1b21df835f5..04e7de4b266a 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -103,35 +103,20 @@ static ssize_t w1_slave_read_name(struct device *dev, struct device_attribute *a
103 return sprintf(buf, "%s\n", sl->name); 103 return sprintf(buf, "%s\n", sl->name);
104} 104}
105 105
106static ssize_t w1_slave_read_id(struct kobject *kobj, 106static ssize_t w1_slave_read_id(struct device *dev,
107 struct bin_attribute *bin_attr, 107 struct device_attribute *attr, char *buf)
108 char *buf, loff_t off, size_t count)
109{ 108{
110 struct w1_slave *sl = kobj_to_w1_slave(kobj); 109 struct w1_slave *sl = dev_to_w1_slave(dev);
111 110 ssize_t count = sizeof(sl->reg_num);
112 if (off > 8) {
113 count = 0;
114 } else {
115 if (off + count > 8)
116 count = 8 - off;
117
118 memcpy(buf, (u8 *)&sl->reg_num, count);
119 }
120 111
112 memcpy(buf, (u8 *)&sl->reg_num, count);
121 return count; 113 return count;
122} 114}
123 115
124static struct device_attribute w1_slave_attr_name = 116static struct device_attribute w1_slave_attr_name =
125 __ATTR(name, S_IRUGO, w1_slave_read_name, NULL); 117 __ATTR(name, S_IRUGO, w1_slave_read_name, NULL);
126 118static struct device_attribute w1_slave_attr_id =
127static struct bin_attribute w1_slave_attr_bin_id = { 119 __ATTR(id, S_IRUGO, w1_slave_read_id, NULL);
128 .attr = {
129 .name = "id",
130 .mode = S_IRUGO,
131 },
132 .size = 8,
133 .read = w1_slave_read_id,
134};
135 120
136/* Default family */ 121/* Default family */
137 122
@@ -650,7 +635,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
650 } 635 }
651 636
652 /* Create "id" entry */ 637 /* Create "id" entry */
653 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); 638 err = device_create_file(&sl->dev, &w1_slave_attr_id);
654 if (err < 0) { 639 if (err < 0) {
655 dev_err(&sl->dev, 640 dev_err(&sl->dev,
656 "sysfs file creation for [%s] failed. err=%d\n", 641 "sysfs file creation for [%s] failed. err=%d\n",
@@ -672,7 +657,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
672 return 0; 657 return 0;
673 658
674out_rem2: 659out_rem2:
675 sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); 660 device_remove_file(&sl->dev, &w1_slave_attr_id);
676out_rem1: 661out_rem1:
677 device_remove_file(&sl->dev, &w1_slave_attr_name); 662 device_remove_file(&sl->dev, &w1_slave_attr_name);
678out_unreg: 663out_unreg:
@@ -754,7 +739,7 @@ void w1_slave_detach(struct w1_slave *sl)
754 msg.type = W1_SLAVE_REMOVE; 739 msg.type = W1_SLAVE_REMOVE;
755 w1_netlink_send(sl->master, &msg); 740 w1_netlink_send(sl->master, &msg);
756 741
757 sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id); 742 device_remove_file(&sl->dev, &w1_slave_attr_id);
758 device_remove_file(&sl->dev, &w1_slave_attr_name); 743 device_remove_file(&sl->dev, &w1_slave_attr_name);
759 device_unregister(&sl->dev); 744 device_unregister(&sl->dev);
760 745