diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/w1/slaves/w1_therm.c | 21 | ||||
-rw-r--r-- | drivers/w1/w1.h | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 8b5ff33f72cf..1f11a20a8ab9 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/sched.h> | 27 | #include <linux/sched.h> |
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/slab.h> | ||
30 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
31 | 32 | ||
32 | #include "../w1.h" | 33 | #include "../w1.h" |
@@ -58,6 +59,19 @@ MODULE_ALIAS("w1-family-" __stringify(W1_THERM_DS28EA00)); | |||
58 | static int w1_strong_pullup = 1; | 59 | static int w1_strong_pullup = 1; |
59 | module_param_named(strong_pullup, w1_strong_pullup, int, 0); | 60 | module_param_named(strong_pullup, w1_strong_pullup, int, 0); |
60 | 61 | ||
62 | static int w1_therm_add_slave(struct w1_slave *sl) | ||
63 | { | ||
64 | sl->family_data = kzalloc(9, GFP_KERNEL); | ||
65 | if (!sl->family_data) | ||
66 | return -ENOMEM; | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static void w1_therm_remove_slave(struct w1_slave *sl) | ||
71 | { | ||
72 | kfree(sl->family_data); | ||
73 | sl->family_data = NULL; | ||
74 | } | ||
61 | 75 | ||
62 | static ssize_t w1_slave_show(struct device *device, | 76 | static ssize_t w1_slave_show(struct device *device, |
63 | struct device_attribute *attr, char *buf); | 77 | struct device_attribute *attr, char *buf); |
@@ -71,6 +85,8 @@ static struct attribute *w1_therm_attrs[] = { | |||
71 | ATTRIBUTE_GROUPS(w1_therm); | 85 | ATTRIBUTE_GROUPS(w1_therm); |
72 | 86 | ||
73 | static struct w1_family_ops w1_therm_fops = { | 87 | static struct w1_family_ops w1_therm_fops = { |
88 | .add_slave = w1_therm_add_slave, | ||
89 | .remove_slave = w1_therm_remove_slave, | ||
74 | .groups = w1_therm_groups, | 90 | .groups = w1_therm_groups, |
75 | }; | 91 | }; |
76 | 92 | ||
@@ -253,12 +269,13 @@ static ssize_t w1_slave_show(struct device *device, | |||
253 | c -= snprintf(buf + PAGE_SIZE - c, c, ": crc=%02x %s\n", | 269 | c -= snprintf(buf + PAGE_SIZE - c, c, ": crc=%02x %s\n", |
254 | crc, (verdict) ? "YES" : "NO"); | 270 | crc, (verdict) ? "YES" : "NO"); |
255 | if (verdict) | 271 | if (verdict) |
256 | memcpy(sl->rom, rom, sizeof(sl->rom)); | 272 | memcpy(sl->family_data, rom, sizeof(rom)); |
257 | else | 273 | else |
258 | dev_warn(device, "Read failed CRC check\n"); | 274 | dev_warn(device, "Read failed CRC check\n"); |
259 | 275 | ||
260 | for (i = 0; i < 9; ++i) | 276 | for (i = 0; i < 9; ++i) |
261 | c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", sl->rom[i]); | 277 | c -= snprintf(buf + PAGE_SIZE - c, c, "%02x ", |
278 | ((u8 *)sl->family_data)[i]); | ||
262 | 279 | ||
263 | c -= snprintf(buf + PAGE_SIZE - c, c, "t=%d\n", | 280 | c -= snprintf(buf + PAGE_SIZE - c, c, "t=%d\n", |
264 | w1_convert_temp(rom, sl->family->fid)); | 281 | w1_convert_temp(rom, sl->family->fid)); |
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 390a7307fb41..0eb50502f63f 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h | |||
@@ -67,7 +67,6 @@ struct w1_slave | |||
67 | struct list_head w1_slave_entry; | 67 | struct list_head w1_slave_entry; |
68 | struct w1_reg_num reg_num; | 68 | struct w1_reg_num reg_num; |
69 | atomic_t refcnt; | 69 | atomic_t refcnt; |
70 | u8 rom[9]; | ||
71 | int ttl; | 70 | int ttl; |
72 | unsigned long flags; | 71 | unsigned long flags; |
73 | 72 | ||