diff options
author | Stefan Achatz <erazor_de@users.sourceforge.net> | 2010-11-26 14:57:33 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-01-07 19:11:00 -0500 |
commit | 5012aada506cb8b570e46579077c0ec5b82ebd5d (patch) | |
tree | cf2d49567af63b16f7cdbef80ae5662938bd539c /drivers/hid/hid-roccat.c | |
parent | c97415a72521071c235e0879f9a600014afd87b1 (diff) |
HID: roccat: use class for char device for sysfs attribute creation
Adding sysfs attributes to an already created device raises no userland
notification. Now the device drivers associate the devices attributes
with a class and use this for roccat event char device creation.
Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-roccat.c')
-rw-r--r-- | drivers/hid/hid-roccat.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c index 4bc7a93dc1f5..a14c579ea781 100644 --- a/drivers/hid/hid-roccat.c +++ b/drivers/hid/hid-roccat.c | |||
@@ -67,7 +67,6 @@ struct roccat_reader { | |||
67 | }; | 67 | }; |
68 | 68 | ||
69 | static int roccat_major; | 69 | static int roccat_major; |
70 | static struct class *roccat_class; | ||
71 | static struct cdev roccat_cdev; | 70 | static struct cdev roccat_cdev; |
72 | 71 | ||
73 | static struct roccat_device *devices[ROCCAT_MAX_DEVICES]; | 72 | static struct roccat_device *devices[ROCCAT_MAX_DEVICES]; |
@@ -289,12 +288,14 @@ EXPORT_SYMBOL_GPL(roccat_report_event); | |||
289 | 288 | ||
290 | /* | 289 | /* |
291 | * roccat_connect() - create a char device for special event output | 290 | * roccat_connect() - create a char device for special event output |
291 | * @class: the class thats used to create the device. Meant to hold device | ||
292 | * specific sysfs attributes. | ||
292 | * @hid: the hid device the char device should be connected to. | 293 | * @hid: the hid device the char device should be connected to. |
293 | * | 294 | * |
294 | * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on | 295 | * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on |
295 | * success, a negative error code on failure. | 296 | * success, a negative error code on failure. |
296 | */ | 297 | */ |
297 | int roccat_connect(struct hid_device *hid) | 298 | int roccat_connect(struct class *klass, struct hid_device *hid) |
298 | { | 299 | { |
299 | unsigned int minor; | 300 | unsigned int minor; |
300 | struct roccat_device *device; | 301 | struct roccat_device *device; |
@@ -320,7 +321,7 @@ int roccat_connect(struct hid_device *hid) | |||
320 | return -EINVAL; | 321 | return -EINVAL; |
321 | } | 322 | } |
322 | 323 | ||
323 | device->dev = device_create(roccat_class, &hid->dev, | 324 | device->dev = device_create(klass, &hid->dev, |
324 | MKDEV(roccat_major, minor), NULL, | 325 | MKDEV(roccat_major, minor), NULL, |
325 | "%s%s%d", "roccat", hid->driver->name, minor); | 326 | "%s%s%d", "roccat", hid->driver->name, minor); |
326 | 327 | ||
@@ -361,7 +362,7 @@ void roccat_disconnect(int minor) | |||
361 | 362 | ||
362 | device->exist = 0; /* TODO exist maybe not needed */ | 363 | device->exist = 0; /* TODO exist maybe not needed */ |
363 | 364 | ||
364 | device_destroy(roccat_class, MKDEV(roccat_major, minor)); | 365 | device_destroy(device->dev->class, MKDEV(roccat_major, minor)); |
365 | 366 | ||
366 | if (device->open) { | 367 | if (device->open) { |
367 | hid_hw_close(device->hid); | 368 | hid_hw_close(device->hid); |
@@ -396,13 +397,6 @@ static int __init roccat_init(void) | |||
396 | return retval; | 397 | return retval; |
397 | } | 398 | } |
398 | 399 | ||
399 | roccat_class = class_create(THIS_MODULE, "roccat"); | ||
400 | if (IS_ERR(roccat_class)) { | ||
401 | retval = PTR_ERR(roccat_class); | ||
402 | unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); | ||
403 | return retval; | ||
404 | } | ||
405 | |||
406 | cdev_init(&roccat_cdev, &roccat_ops); | 400 | cdev_init(&roccat_cdev, &roccat_ops); |
407 | cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES); | 401 | cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES); |
408 | 402 | ||
@@ -414,7 +408,6 @@ static void __exit roccat_exit(void) | |||
414 | dev_t dev_id = MKDEV(roccat_major, 0); | 408 | dev_t dev_id = MKDEV(roccat_major, 0); |
415 | 409 | ||
416 | cdev_del(&roccat_cdev); | 410 | cdev_del(&roccat_cdev); |
417 | class_destroy(roccat_class); | ||
418 | unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); | 411 | unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); |
419 | } | 412 | } |
420 | 413 | ||