aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/hci_sysfs.c')
-rw-r--r--net/bluetooth/hci_sysfs.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 521095614235..bc154298979a 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -33,19 +33,19 @@ static inline char *link_typetostr(int type)
33 33
34static ssize_t show_link_type(struct device *dev, struct device_attribute *attr, char *buf) 34static ssize_t show_link_type(struct device *dev, struct device_attribute *attr, char *buf)
35{ 35{
36 struct hci_conn *conn = dev_get_drvdata(dev); 36 struct hci_conn *conn = to_hci_conn(dev);
37 return sprintf(buf, "%s\n", link_typetostr(conn->type)); 37 return sprintf(buf, "%s\n", link_typetostr(conn->type));
38} 38}
39 39
40static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf) 40static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf)
41{ 41{
42 struct hci_conn *conn = dev_get_drvdata(dev); 42 struct hci_conn *conn = to_hci_conn(dev);
43 return sprintf(buf, "%s\n", batostr(&conn->dst)); 43 return sprintf(buf, "%s\n", batostr(&conn->dst));
44} 44}
45 45
46static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf) 46static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf)
47{ 47{
48 struct hci_conn *conn = dev_get_drvdata(dev); 48 struct hci_conn *conn = to_hci_conn(dev);
49 49
50 return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", 50 return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
51 conn->features[0], conn->features[1], 51 conn->features[0], conn->features[1],
@@ -79,8 +79,8 @@ static const struct attribute_group *bt_link_groups[] = {
79 79
80static void bt_link_release(struct device *dev) 80static void bt_link_release(struct device *dev)
81{ 81{
82 void *data = dev_get_drvdata(dev); 82 struct hci_conn *conn = to_hci_conn(dev);
83 kfree(data); 83 kfree(conn);
84} 84}
85 85
86static struct device_type bt_link = { 86static struct device_type bt_link = {
@@ -120,8 +120,6 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
120 120
121 dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle); 121 dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
122 122
123 dev_set_drvdata(&conn->dev, conn);
124
125 if (device_add(&conn->dev) < 0) { 123 if (device_add(&conn->dev) < 0) {
126 BT_ERR("Failed to register connection device"); 124 BT_ERR("Failed to register connection device");
127 return; 125 return;
@@ -189,19 +187,19 @@ static inline char *host_typetostr(int type)
189 187
190static ssize_t show_bus(struct device *dev, struct device_attribute *attr, char *buf) 188static ssize_t show_bus(struct device *dev, struct device_attribute *attr, char *buf)
191{ 189{
192 struct hci_dev *hdev = dev_get_drvdata(dev); 190 struct hci_dev *hdev = to_hci_dev(dev);
193 return sprintf(buf, "%s\n", host_bustostr(hdev->bus)); 191 return sprintf(buf, "%s\n", host_bustostr(hdev->bus));
194} 192}
195 193
196static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) 194static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf)
197{ 195{
198 struct hci_dev *hdev = dev_get_drvdata(dev); 196 struct hci_dev *hdev = to_hci_dev(dev);
199 return sprintf(buf, "%s\n", host_typetostr(hdev->dev_type)); 197 return sprintf(buf, "%s\n", host_typetostr(hdev->dev_type));
200} 198}
201 199
202static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) 200static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
203{ 201{
204 struct hci_dev *hdev = dev_get_drvdata(dev); 202 struct hci_dev *hdev = to_hci_dev(dev);
205 char name[HCI_MAX_NAME_LENGTH + 1]; 203 char name[HCI_MAX_NAME_LENGTH + 1];
206 int i; 204 int i;
207 205
@@ -214,20 +212,20 @@ static ssize_t show_name(struct device *dev, struct device_attribute *attr, char
214 212
215static ssize_t show_class(struct device *dev, struct device_attribute *attr, char *buf) 213static ssize_t show_class(struct device *dev, struct device_attribute *attr, char *buf)
216{ 214{
217 struct hci_dev *hdev = dev_get_drvdata(dev); 215 struct hci_dev *hdev = to_hci_dev(dev);
218 return sprintf(buf, "0x%.2x%.2x%.2x\n", 216 return sprintf(buf, "0x%.2x%.2x%.2x\n",
219 hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]); 217 hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]);
220} 218}
221 219
222static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf) 220static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf)
223{ 221{
224 struct hci_dev *hdev = dev_get_drvdata(dev); 222 struct hci_dev *hdev = to_hci_dev(dev);
225 return sprintf(buf, "%s\n", batostr(&hdev->bdaddr)); 223 return sprintf(buf, "%s\n", batostr(&hdev->bdaddr));
226} 224}
227 225
228static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf) 226static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf)
229{ 227{
230 struct hci_dev *hdev = dev_get_drvdata(dev); 228 struct hci_dev *hdev = to_hci_dev(dev);
231 229
232 return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", 230 return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
233 hdev->features[0], hdev->features[1], 231 hdev->features[0], hdev->features[1],
@@ -238,31 +236,31 @@ static ssize_t show_features(struct device *dev, struct device_attribute *attr,
238 236
239static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf) 237static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf)
240{ 238{
241 struct hci_dev *hdev = dev_get_drvdata(dev); 239 struct hci_dev *hdev = to_hci_dev(dev);
242 return sprintf(buf, "%d\n", hdev->manufacturer); 240 return sprintf(buf, "%d\n", hdev->manufacturer);
243} 241}
244 242
245static ssize_t show_hci_version(struct device *dev, struct device_attribute *attr, char *buf) 243static ssize_t show_hci_version(struct device *dev, struct device_attribute *attr, char *buf)
246{ 244{
247 struct hci_dev *hdev = dev_get_drvdata(dev); 245 struct hci_dev *hdev = to_hci_dev(dev);
248 return sprintf(buf, "%d\n", hdev->hci_ver); 246 return sprintf(buf, "%d\n", hdev->hci_ver);
249} 247}
250 248
251static ssize_t show_hci_revision(struct device *dev, struct device_attribute *attr, char *buf) 249static ssize_t show_hci_revision(struct device *dev, struct device_attribute *attr, char *buf)
252{ 250{
253 struct hci_dev *hdev = dev_get_drvdata(dev); 251 struct hci_dev *hdev = to_hci_dev(dev);
254 return sprintf(buf, "%d\n", hdev->hci_rev); 252 return sprintf(buf, "%d\n", hdev->hci_rev);
255} 253}
256 254
257static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf) 255static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf)
258{ 256{
259 struct hci_dev *hdev = dev_get_drvdata(dev); 257 struct hci_dev *hdev = to_hci_dev(dev);
260 return sprintf(buf, "%d\n", hdev->idle_timeout); 258 return sprintf(buf, "%d\n", hdev->idle_timeout);
261} 259}
262 260
263static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 261static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
264{ 262{
265 struct hci_dev *hdev = dev_get_drvdata(dev); 263 struct hci_dev *hdev = to_hci_dev(dev);
266 unsigned int val; 264 unsigned int val;
267 int rv; 265 int rv;
268 266
@@ -280,13 +278,13 @@ static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *a
280 278
281static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribute *attr, char *buf) 279static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribute *attr, char *buf)
282{ 280{
283 struct hci_dev *hdev = dev_get_drvdata(dev); 281 struct hci_dev *hdev = to_hci_dev(dev);
284 return sprintf(buf, "%d\n", hdev->sniff_max_interval); 282 return sprintf(buf, "%d\n", hdev->sniff_max_interval);
285} 283}
286 284
287static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 285static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
288{ 286{
289 struct hci_dev *hdev = dev_get_drvdata(dev); 287 struct hci_dev *hdev = to_hci_dev(dev);
290 u16 val; 288 u16 val;
291 int rv; 289 int rv;
292 290
@@ -304,13 +302,13 @@ static ssize_t store_sniff_max_interval(struct device *dev, struct device_attrib
304 302
305static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribute *attr, char *buf) 303static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribute *attr, char *buf)
306{ 304{
307 struct hci_dev *hdev = dev_get_drvdata(dev); 305 struct hci_dev *hdev = to_hci_dev(dev);
308 return sprintf(buf, "%d\n", hdev->sniff_min_interval); 306 return sprintf(buf, "%d\n", hdev->sniff_min_interval);
309} 307}
310 308
311static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 309static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
312{ 310{
313 struct hci_dev *hdev = dev_get_drvdata(dev); 311 struct hci_dev *hdev = to_hci_dev(dev);
314 u16 val; 312 u16 val;
315 int rv; 313 int rv;
316 314
@@ -370,8 +368,9 @@ static const struct attribute_group *bt_host_groups[] = {
370 368
371static void bt_host_release(struct device *dev) 369static void bt_host_release(struct device *dev)
372{ 370{
373 void *data = dev_get_drvdata(dev); 371 struct hci_dev *hdev = to_hci_dev(dev);
374 kfree(data); 372 kfree(hdev);
373 module_put(THIS_MODULE);
375} 374}
376 375
377static struct device_type bt_host = { 376static struct device_type bt_host = {
@@ -383,12 +382,12 @@ static struct device_type bt_host = {
383static int inquiry_cache_show(struct seq_file *f, void *p) 382static int inquiry_cache_show(struct seq_file *f, void *p)
384{ 383{
385 struct hci_dev *hdev = f->private; 384 struct hci_dev *hdev = f->private;
386 struct inquiry_cache *cache = &hdev->inq_cache; 385 struct discovery_state *cache = &hdev->discovery;
387 struct inquiry_entry *e; 386 struct inquiry_entry *e;
388 387
389 hci_dev_lock(hdev); 388 hci_dev_lock(hdev);
390 389
391 for (e = cache->list; e; e = e->next) { 390 list_for_each_entry(e, &cache->all, all) {
392 struct inquiry_data *data = &e->data; 391 struct inquiry_data *data = &e->data;
393 seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", 392 seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
394 batostr(&data->bdaddr), 393 batostr(&data->bdaddr),
@@ -523,7 +522,7 @@ void hci_init_sysfs(struct hci_dev *hdev)
523 dev->type = &bt_host; 522 dev->type = &bt_host;
524 dev->class = bt_class; 523 dev->class = bt_class;
525 524
526 dev_set_drvdata(dev, hdev); 525 __module_get(THIS_MODULE);
527 device_initialize(dev); 526 device_initialize(dev);
528} 527}
529 528