aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/slaves/w1_therm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/w1/slaves/w1_therm.c')
-rw-r--r--drivers/w1/slaves/w1_therm.c21
1 files changed, 19 insertions, 2 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));
58static int w1_strong_pullup = 1; 59static int w1_strong_pullup = 1;
59module_param_named(strong_pullup, w1_strong_pullup, int, 0); 60module_param_named(strong_pullup, w1_strong_pullup, int, 0);
60 61
62static 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
70static void w1_therm_remove_slave(struct w1_slave *sl)
71{
72 kfree(sl->family_data);
73 sl->family_data = NULL;
74}
61 75
62static ssize_t w1_slave_show(struct device *device, 76static 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[] = {
71ATTRIBUTE_GROUPS(w1_therm); 85ATTRIBUTE_GROUPS(w1_therm);
72 86
73static struct w1_family_ops w1_therm_fops = { 87static 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));