diff options
Diffstat (limited to 'drivers/w1/w1_smem.c')
-rw-r--r-- | drivers/w1/w1_smem.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c index a54e425217a0..70d2d469963c 100644 --- a/drivers/w1/w1_smem.c +++ b/drivers/w1/w1_smem.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * w1_smem.c | 2 | * w1_smem.c |
3 | * | 3 | * |
4 | * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 4 | * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the smems of the GNU General Public License as published by | 8 | * it under the smems of the GNU General Public License as published by |
@@ -36,41 +36,25 @@ MODULE_LICENSE("GPL"); | |||
36 | MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); | 36 | MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); |
37 | MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); | 37 | MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); |
38 | 38 | ||
39 | static ssize_t w1_smem_read_name(struct device *, char *); | 39 | static ssize_t w1_smem_read_name(struct device *, struct device_attribute *attr, char *); |
40 | static ssize_t w1_smem_read_val(struct device *, char *); | ||
41 | static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t); | 40 | static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t); |
42 | 41 | ||
43 | static struct w1_family_ops w1_smem_fops = { | 42 | static struct w1_family_ops w1_smem_fops = { |
44 | .rname = &w1_smem_read_name, | 43 | .rname = &w1_smem_read_name, |
45 | .rbin = &w1_smem_read_bin, | 44 | .rbin = &w1_smem_read_bin, |
46 | .rval = &w1_smem_read_val, | ||
47 | .rvalname = "id", | ||
48 | }; | 45 | }; |
49 | 46 | ||
50 | static ssize_t w1_smem_read_name(struct device *dev, char *buf) | 47 | static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf) |
51 | { | 48 | { |
52 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | 49 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); |
53 | 50 | ||
54 | return sprintf(buf, "%s\n", sl->name); | 51 | return sprintf(buf, "%s\n", sl->name); |
55 | } | 52 | } |
56 | 53 | ||
57 | static ssize_t w1_smem_read_val(struct device *dev, char *buf) | ||
58 | { | ||
59 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | ||
60 | int i; | ||
61 | ssize_t count = 0; | ||
62 | |||
63 | for (i = 0; i < 8; ++i) | ||
64 | count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); | ||
65 | count += sprintf(buf + count, "\n"); | ||
66 | |||
67 | return count; | ||
68 | } | ||
69 | |||
70 | static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) | 54 | static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) |
71 | { | 55 | { |
72 | struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), | 56 | struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), |
73 | struct w1_slave, dev); | 57 | struct w1_slave, dev); |
74 | int i; | 58 | int i; |
75 | 59 | ||
76 | atomic_inc(&sl->refcnt); | 60 | atomic_inc(&sl->refcnt); |
@@ -90,7 +74,7 @@ static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, siz | |||
90 | for (i = 0; i < 8; ++i) | 74 | for (i = 0; i < 8; ++i) |
91 | count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); | 75 | count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); |
92 | count += sprintf(buf + count, "\n"); | 76 | count += sprintf(buf + count, "\n"); |
93 | 77 | ||
94 | out: | 78 | out: |
95 | up(&sl->master->mutex); | 79 | up(&sl->master->mutex); |
96 | out_dec: | 80 | out_dec: |
@@ -99,19 +83,37 @@ out_dec: | |||
99 | return count; | 83 | return count; |
100 | } | 84 | } |
101 | 85 | ||
102 | static struct w1_family w1_smem_family = { | 86 | static struct w1_family w1_smem_family_01 = { |
103 | .fid = W1_FAMILY_SMEM, | 87 | .fid = W1_FAMILY_SMEM_01, |
88 | .fops = &w1_smem_fops, | ||
89 | }; | ||
90 | |||
91 | static struct w1_family w1_smem_family_81 = { | ||
92 | .fid = W1_FAMILY_SMEM_81, | ||
104 | .fops = &w1_smem_fops, | 93 | .fops = &w1_smem_fops, |
105 | }; | 94 | }; |
106 | 95 | ||
107 | static int __init w1_smem_init(void) | 96 | static int __init w1_smem_init(void) |
108 | { | 97 | { |
109 | return w1_register_family(&w1_smem_family); | 98 | int err; |
99 | |||
100 | err = w1_register_family(&w1_smem_family_01); | ||
101 | if (err) | ||
102 | return err; | ||
103 | |||
104 | err = w1_register_family(&w1_smem_family_81); | ||
105 | if (err) { | ||
106 | w1_unregister_family(&w1_smem_family_01); | ||
107 | return err; | ||
108 | } | ||
109 | |||
110 | return 0; | ||
110 | } | 111 | } |
111 | 112 | ||
112 | static void __exit w1_smem_fini(void) | 113 | static void __exit w1_smem_fini(void) |
113 | { | 114 | { |
114 | w1_unregister_family(&w1_smem_family); | 115 | w1_unregister_family(&w1_smem_family_01); |
116 | w1_unregister_family(&w1_smem_family_81); | ||
115 | } | 117 | } |
116 | 118 | ||
117 | module_init(w1_smem_init); | 119 | module_init(w1_smem_init); |