diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/w1/w1.c | 22 | ||||
-rw-r--r-- | drivers/w1/w1.h | 15 | ||||
-rw-r--r-- | drivers/w1/w1_smem.c | 6 | ||||
-rw-r--r-- | drivers/w1/w1_therm.c | 6 |
4 files changed, 29 insertions, 20 deletions
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index b2fe0f7b0b7c..39888af6d33d 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
@@ -89,15 +89,13 @@ static int w1_master_remove(struct device *dev) | |||
89 | 89 | ||
90 | static void w1_master_release(struct device *dev) | 90 | static void w1_master_release(struct device *dev) |
91 | { | 91 | { |
92 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 92 | struct w1_master *md = dev_to_w1_master(dev); |
93 | |||
94 | complete(&md->dev_released); | 93 | complete(&md->dev_released); |
95 | } | 94 | } |
96 | 95 | ||
97 | static void w1_slave_release(struct device *dev) | 96 | static void w1_slave_release(struct device *dev) |
98 | { | 97 | { |
99 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | 98 | struct w1_slave *sl = dev_to_w1_slave(dev); |
100 | |||
101 | complete(&sl->dev_released); | 99 | complete(&sl->dev_released); |
102 | } | 100 | } |
103 | 101 | ||
@@ -162,7 +160,7 @@ struct device w1_slave_device = { | |||
162 | 160 | ||
163 | static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf) | 161 | static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf) |
164 | { | 162 | { |
165 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 163 | struct w1_master *md = dev_to_w1_master(dev); |
166 | ssize_t count; | 164 | ssize_t count; |
167 | 165 | ||
168 | if (down_interruptible (&md->mutex)) | 166 | if (down_interruptible (&md->mutex)) |
@@ -179,7 +177,7 @@ static ssize_t w1_master_attribute_store_search(struct device * dev, | |||
179 | struct device_attribute *attr, | 177 | struct device_attribute *attr, |
180 | const char * buf, size_t count) | 178 | const char * buf, size_t count) |
181 | { | 179 | { |
182 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 180 | struct w1_master *md = dev_to_w1_master(dev); |
183 | 181 | ||
184 | if (down_interruptible (&md->mutex)) | 182 | if (down_interruptible (&md->mutex)) |
185 | return -EBUSY; | 183 | return -EBUSY; |
@@ -195,7 +193,7 @@ static ssize_t w1_master_attribute_show_search(struct device *dev, | |||
195 | struct device_attribute *attr, | 193 | struct device_attribute *attr, |
196 | char *buf) | 194 | char *buf) |
197 | { | 195 | { |
198 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 196 | struct w1_master *md = dev_to_w1_master(dev); |
199 | ssize_t count; | 197 | ssize_t count; |
200 | 198 | ||
201 | if (down_interruptible (&md->mutex)) | 199 | if (down_interruptible (&md->mutex)) |
@@ -210,7 +208,7 @@ static ssize_t w1_master_attribute_show_search(struct device *dev, | |||
210 | 208 | ||
211 | static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf) | 209 | static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf) |
212 | { | 210 | { |
213 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 211 | struct w1_master *md = dev_to_w1_master(dev); |
214 | ssize_t count; | 212 | ssize_t count; |
215 | 213 | ||
216 | if (down_interruptible(&md->mutex)) | 214 | if (down_interruptible(&md->mutex)) |
@@ -231,7 +229,7 @@ static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct devic | |||
231 | 229 | ||
232 | static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute *attr, char *buf) | 230 | static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute *attr, char *buf) |
233 | { | 231 | { |
234 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 232 | struct w1_master *md = dev_to_w1_master(dev); |
235 | ssize_t count; | 233 | ssize_t count; |
236 | 234 | ||
237 | if (down_interruptible(&md->mutex)) | 235 | if (down_interruptible(&md->mutex)) |
@@ -245,7 +243,7 @@ static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, stru | |||
245 | 243 | ||
246 | static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct device_attribute *attr, char *buf) | 244 | static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct device_attribute *attr, char *buf) |
247 | { | 245 | { |
248 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 246 | struct w1_master *md = dev_to_w1_master(dev); |
249 | ssize_t count; | 247 | ssize_t count; |
250 | 248 | ||
251 | if (down_interruptible(&md->mutex)) | 249 | if (down_interruptible(&md->mutex)) |
@@ -259,7 +257,7 @@ static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct devi | |||
259 | 257 | ||
260 | static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct device_attribute *attr, char *buf) | 258 | static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct device_attribute *attr, char *buf) |
261 | { | 259 | { |
262 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 260 | struct w1_master *md = dev_to_w1_master(dev); |
263 | ssize_t count; | 261 | ssize_t count; |
264 | 262 | ||
265 | if (down_interruptible(&md->mutex)) | 263 | if (down_interruptible(&md->mutex)) |
@@ -273,7 +271,7 @@ static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct d | |||
273 | 271 | ||
274 | static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf) | 272 | static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf) |
275 | { | 273 | { |
276 | struct w1_master *md = container_of(dev, struct w1_master, dev); | 274 | struct w1_master *md = dev_to_w1_master(dev); |
277 | int c = PAGE_SIZE; | 275 | int c = PAGE_SIZE; |
278 | 276 | ||
279 | if (down_interruptible(&md->mutex)) | 277 | if (down_interruptible(&md->mutex)) |
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 4f0a986e33e3..f8308266d8d6 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h | |||
@@ -191,6 +191,21 @@ struct w1_master | |||
191 | int w1_create_master_attributes(struct w1_master *); | 191 | int w1_create_master_attributes(struct w1_master *); |
192 | void w1_search(struct w1_master *dev, w1_slave_found_callback cb); | 192 | void w1_search(struct w1_master *dev, w1_slave_found_callback cb); |
193 | 193 | ||
194 | static inline struct w1_slave* dev_to_w1_slave(struct device *dev) | ||
195 | { | ||
196 | return container_of(dev, struct w1_slave, dev); | ||
197 | } | ||
198 | |||
199 | static inline struct w1_slave* kobj_to_w1_slave(struct kobject *kobj) | ||
200 | { | ||
201 | return dev_to_w1_slave(container_of(kobj, struct device, kobj)); | ||
202 | } | ||
203 | |||
204 | static inline struct w1_master* dev_to_w1_master(struct device *dev) | ||
205 | { | ||
206 | return container_of(dev, struct w1_master, dev); | ||
207 | } | ||
208 | |||
194 | #endif /* __KERNEL__ */ | 209 | #endif /* __KERNEL__ */ |
195 | 210 | ||
196 | #endif /* __W1_H */ | 211 | #endif /* __W1_H */ |
diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c index 70d2d469963c..2b6580c7e953 100644 --- a/drivers/w1/w1_smem.c +++ b/drivers/w1/w1_smem.c | |||
@@ -46,15 +46,13 @@ static struct w1_family_ops w1_smem_fops = { | |||
46 | 46 | ||
47 | static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf) | 47 | static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf) |
48 | { | 48 | { |
49 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | 49 | struct w1_slave *sl = dev_to_w1_slave(dev); |
50 | |||
51 | return sprintf(buf, "%s\n", sl->name); | 50 | return sprintf(buf, "%s\n", sl->name); |
52 | } | 51 | } |
53 | 52 | ||
54 | static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) | 53 | static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) |
55 | { | 54 | { |
56 | struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), | 55 | struct w1_slave *sl = kobj_to_w1_slave(kobj); |
57 | struct w1_slave, dev); | ||
58 | int i; | 56 | int i; |
59 | 57 | ||
60 | atomic_inc(&sl->refcnt); | 58 | atomic_inc(&sl->refcnt); |
diff --git a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c index 165526c9360a..2259f3d851ff 100644 --- a/drivers/w1/w1_therm.c +++ b/drivers/w1/w1_therm.c | |||
@@ -92,8 +92,7 @@ static struct w1_therm_family_converter w1_therm_families[] = { | |||
92 | 92 | ||
93 | static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *attr, char *buf) | 93 | static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *attr, char *buf) |
94 | { | 94 | { |
95 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | 95 | struct w1_slave *sl = dev_to_w1_slave(dev); |
96 | |||
97 | return sprintf(buf, "%s\n", sl->name); | 96 | return sprintf(buf, "%s\n", sl->name); |
98 | } | 97 | } |
99 | 98 | ||
@@ -148,8 +147,7 @@ static int w1_therm_check_rom(u8 rom[9]) | |||
148 | 147 | ||
149 | static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) | 148 | static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) |
150 | { | 149 | { |
151 | struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), | 150 | struct w1_slave *sl = kobj_to_w1_slave(kobj); |
152 | struct w1_slave, dev); | ||
153 | struct w1_master *dev = sl->master; | 151 | struct w1_master *dev = sl->master; |
154 | u8 rom[9], crc, verdict; | 152 | u8 rom[9], crc, verdict; |
155 | int i, max_trying = 10; | 153 | int i, max_trying = 10; |