diff options
-rw-r--r-- | include/net/bluetooth/hci_core.h | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 33 |
2 files changed, 18 insertions, 17 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index ccb24a4212cd..221d772ded55 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -623,6 +623,8 @@ static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) | |||
623 | #define hci_dev_lock(d) mutex_lock(&d->lock) | 623 | #define hci_dev_lock(d) mutex_lock(&d->lock) |
624 | #define hci_dev_unlock(d) mutex_unlock(&d->lock) | 624 | #define hci_dev_unlock(d) mutex_unlock(&d->lock) |
625 | 625 | ||
626 | #define to_hci_dev(d) container_of(d, struct hci_dev, dev) | ||
627 | |||
626 | struct hci_dev *hci_dev_get(int index); | 628 | struct hci_dev *hci_dev_get(int index); |
627 | struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); | 629 | struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); |
628 | 630 | ||
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index ec03ee2b301e..2a0243add1e4 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -189,19 +189,19 @@ static inline char *host_typetostr(int type) | |||
189 | 189 | ||
190 | static ssize_t show_bus(struct device *dev, struct device_attribute *attr, char *buf) | 190 | static ssize_t show_bus(struct device *dev, struct device_attribute *attr, char *buf) |
191 | { | 191 | { |
192 | struct hci_dev *hdev = dev_get_drvdata(dev); | 192 | struct hci_dev *hdev = to_hci_dev(dev); |
193 | return sprintf(buf, "%s\n", host_bustostr(hdev->bus)); | 193 | return sprintf(buf, "%s\n", host_bustostr(hdev->bus)); |
194 | } | 194 | } |
195 | 195 | ||
196 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) | 196 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) |
197 | { | 197 | { |
198 | struct hci_dev *hdev = dev_get_drvdata(dev); | 198 | struct hci_dev *hdev = to_hci_dev(dev); |
199 | return sprintf(buf, "%s\n", host_typetostr(hdev->dev_type)); | 199 | return sprintf(buf, "%s\n", host_typetostr(hdev->dev_type)); |
200 | } | 200 | } |
201 | 201 | ||
202 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 202 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) |
203 | { | 203 | { |
204 | struct hci_dev *hdev = dev_get_drvdata(dev); | 204 | struct hci_dev *hdev = to_hci_dev(dev); |
205 | char name[HCI_MAX_NAME_LENGTH + 1]; | 205 | char name[HCI_MAX_NAME_LENGTH + 1]; |
206 | int i; | 206 | int i; |
207 | 207 | ||
@@ -214,20 +214,20 @@ static ssize_t show_name(struct device *dev, struct device_attribute *attr, char | |||
214 | 214 | ||
215 | static ssize_t show_class(struct device *dev, struct device_attribute *attr, char *buf) | 215 | static ssize_t show_class(struct device *dev, struct device_attribute *attr, char *buf) |
216 | { | 216 | { |
217 | struct hci_dev *hdev = dev_get_drvdata(dev); | 217 | struct hci_dev *hdev = to_hci_dev(dev); |
218 | return sprintf(buf, "0x%.2x%.2x%.2x\n", | 218 | return sprintf(buf, "0x%.2x%.2x%.2x\n", |
219 | hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]); | 219 | hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]); |
220 | } | 220 | } |
221 | 221 | ||
222 | static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf) | 222 | static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf) |
223 | { | 223 | { |
224 | struct hci_dev *hdev = dev_get_drvdata(dev); | 224 | struct hci_dev *hdev = to_hci_dev(dev); |
225 | return sprintf(buf, "%s\n", batostr(&hdev->bdaddr)); | 225 | return sprintf(buf, "%s\n", batostr(&hdev->bdaddr)); |
226 | } | 226 | } |
227 | 227 | ||
228 | static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf) | 228 | static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf) |
229 | { | 229 | { |
230 | struct hci_dev *hdev = dev_get_drvdata(dev); | 230 | struct hci_dev *hdev = to_hci_dev(dev); |
231 | 231 | ||
232 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | 232 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", |
233 | hdev->features[0], hdev->features[1], | 233 | hdev->features[0], hdev->features[1], |
@@ -238,31 +238,31 @@ static ssize_t show_features(struct device *dev, struct device_attribute *attr, | |||
238 | 238 | ||
239 | static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf) | 239 | static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf) |
240 | { | 240 | { |
241 | struct hci_dev *hdev = dev_get_drvdata(dev); | 241 | struct hci_dev *hdev = to_hci_dev(dev); |
242 | return sprintf(buf, "%d\n", hdev->manufacturer); | 242 | return sprintf(buf, "%d\n", hdev->manufacturer); |
243 | } | 243 | } |
244 | 244 | ||
245 | static ssize_t show_hci_version(struct device *dev, struct device_attribute *attr, char *buf) | 245 | static ssize_t show_hci_version(struct device *dev, struct device_attribute *attr, char *buf) |
246 | { | 246 | { |
247 | struct hci_dev *hdev = dev_get_drvdata(dev); | 247 | struct hci_dev *hdev = to_hci_dev(dev); |
248 | return sprintf(buf, "%d\n", hdev->hci_ver); | 248 | return sprintf(buf, "%d\n", hdev->hci_ver); |
249 | } | 249 | } |
250 | 250 | ||
251 | static ssize_t show_hci_revision(struct device *dev, struct device_attribute *attr, char *buf) | 251 | static ssize_t show_hci_revision(struct device *dev, struct device_attribute *attr, char *buf) |
252 | { | 252 | { |
253 | struct hci_dev *hdev = dev_get_drvdata(dev); | 253 | struct hci_dev *hdev = to_hci_dev(dev); |
254 | return sprintf(buf, "%d\n", hdev->hci_rev); | 254 | return sprintf(buf, "%d\n", hdev->hci_rev); |
255 | } | 255 | } |
256 | 256 | ||
257 | static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf) | 257 | static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf) |
258 | { | 258 | { |
259 | struct hci_dev *hdev = dev_get_drvdata(dev); | 259 | struct hci_dev *hdev = to_hci_dev(dev); |
260 | return sprintf(buf, "%d\n", hdev->idle_timeout); | 260 | return sprintf(buf, "%d\n", hdev->idle_timeout); |
261 | } | 261 | } |
262 | 262 | ||
263 | static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 263 | static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
264 | { | 264 | { |
265 | struct hci_dev *hdev = dev_get_drvdata(dev); | 265 | struct hci_dev *hdev = to_hci_dev(dev); |
266 | unsigned int val; | 266 | unsigned int val; |
267 | int rv; | 267 | int rv; |
268 | 268 | ||
@@ -280,13 +280,13 @@ static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *a | |||
280 | 280 | ||
281 | static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribute *attr, char *buf) | 281 | static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribute *attr, char *buf) |
282 | { | 282 | { |
283 | struct hci_dev *hdev = dev_get_drvdata(dev); | 283 | struct hci_dev *hdev = to_hci_dev(dev); |
284 | return sprintf(buf, "%d\n", hdev->sniff_max_interval); | 284 | return sprintf(buf, "%d\n", hdev->sniff_max_interval); |
285 | } | 285 | } |
286 | 286 | ||
287 | static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 287 | static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
288 | { | 288 | { |
289 | struct hci_dev *hdev = dev_get_drvdata(dev); | 289 | struct hci_dev *hdev = to_hci_dev(dev); |
290 | u16 val; | 290 | u16 val; |
291 | int rv; | 291 | int rv; |
292 | 292 | ||
@@ -304,13 +304,13 @@ static ssize_t store_sniff_max_interval(struct device *dev, struct device_attrib | |||
304 | 304 | ||
305 | static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribute *attr, char *buf) | 305 | static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribute *attr, char *buf) |
306 | { | 306 | { |
307 | struct hci_dev *hdev = dev_get_drvdata(dev); | 307 | struct hci_dev *hdev = to_hci_dev(dev); |
308 | return sprintf(buf, "%d\n", hdev->sniff_min_interval); | 308 | return sprintf(buf, "%d\n", hdev->sniff_min_interval); |
309 | } | 309 | } |
310 | 310 | ||
311 | static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 311 | static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
312 | { | 312 | { |
313 | struct hci_dev *hdev = dev_get_drvdata(dev); | 313 | struct hci_dev *hdev = to_hci_dev(dev); |
314 | u16 val; | 314 | u16 val; |
315 | int rv; | 315 | int rv; |
316 | 316 | ||
@@ -370,7 +370,7 @@ static const struct attribute_group *bt_host_groups[] = { | |||
370 | 370 | ||
371 | static void bt_host_release(struct device *dev) | 371 | static void bt_host_release(struct device *dev) |
372 | { | 372 | { |
373 | void *data = dev_get_drvdata(dev); | 373 | void *data = to_hci_dev(dev); |
374 | kfree(data); | 374 | kfree(data); |
375 | module_put(THIS_MODULE); | 375 | module_put(THIS_MODULE); |
376 | } | 376 | } |
@@ -525,7 +525,6 @@ void hci_init_sysfs(struct hci_dev *hdev) | |||
525 | dev->class = bt_class; | 525 | dev->class = bt_class; |
526 | 526 | ||
527 | __module_get(THIS_MODULE); | 527 | __module_get(THIS_MODULE); |
528 | dev_set_drvdata(dev, hdev); | ||
529 | device_initialize(dev); | 528 | device_initialize(dev); |
530 | } | 529 | } |
531 | 530 | ||