Commit 5012aada authored by Stefan Achatz's avatar Stefan Achatz Committed by Jiri Kosina

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: default avatarStefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent c97415a7
This diff is collapsed.
This diff is collapsed.
...@@ -67,7 +67,6 @@ struct roccat_reader { ...@@ -67,7 +67,6 @@ struct roccat_reader {
}; };
static int roccat_major; static int roccat_major;
static struct class *roccat_class;
static struct cdev roccat_cdev; static struct cdev roccat_cdev;
static struct roccat_device *devices[ROCCAT_MAX_DEVICES]; static struct roccat_device *devices[ROCCAT_MAX_DEVICES];
...@@ -289,12 +288,14 @@ EXPORT_SYMBOL_GPL(roccat_report_event); ...@@ -289,12 +288,14 @@ EXPORT_SYMBOL_GPL(roccat_report_event);
/* /*
* roccat_connect() - create a char device for special event output * roccat_connect() - create a char device for special event output
* @class: the class thats used to create the device. Meant to hold device
* specific sysfs attributes.
* @hid: the hid device the char device should be connected to. * @hid: the hid device the char device should be connected to.
* *
* Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on
* success, a negative error code on failure. * success, a negative error code on failure.
*/ */
int roccat_connect(struct hid_device *hid) int roccat_connect(struct class *klass, struct hid_device *hid)
{ {
unsigned int minor; unsigned int minor;
struct roccat_device *device; struct roccat_device *device;
...@@ -320,7 +321,7 @@ int roccat_connect(struct hid_device *hid) ...@@ -320,7 +321,7 @@ int roccat_connect(struct hid_device *hid)
return -EINVAL; return -EINVAL;
} }
device->dev = device_create(roccat_class, &hid->dev, device->dev = device_create(klass, &hid->dev,
MKDEV(roccat_major, minor), NULL, MKDEV(roccat_major, minor), NULL,
"%s%s%d", "roccat", hid->driver->name, minor); "%s%s%d", "roccat", hid->driver->name, minor);
...@@ -361,7 +362,7 @@ void roccat_disconnect(int minor) ...@@ -361,7 +362,7 @@ void roccat_disconnect(int minor)
device->exist = 0; /* TODO exist maybe not needed */ device->exist = 0; /* TODO exist maybe not needed */
device_destroy(roccat_class, MKDEV(roccat_major, minor)); device_destroy(device->dev->class, MKDEV(roccat_major, minor));
if (device->open) { if (device->open) {
hid_hw_close(device->hid); hid_hw_close(device->hid);
...@@ -396,13 +397,6 @@ static int __init roccat_init(void) ...@@ -396,13 +397,6 @@ static int __init roccat_init(void)
return retval; return retval;
} }
roccat_class = class_create(THIS_MODULE, "roccat");
if (IS_ERR(roccat_class)) {
retval = PTR_ERR(roccat_class);
unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES);
return retval;
}
cdev_init(&roccat_cdev, &roccat_ops); cdev_init(&roccat_cdev, &roccat_ops);
cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES); cdev_add(&roccat_cdev, dev_id, ROCCAT_MAX_DEVICES);
...@@ -414,7 +408,6 @@ static void __exit roccat_exit(void) ...@@ -414,7 +408,6 @@ static void __exit roccat_exit(void)
dev_t dev_id = MKDEV(roccat_major, 0); dev_t dev_id = MKDEV(roccat_major, 0);
cdev_del(&roccat_cdev); cdev_del(&roccat_cdev);
class_destroy(roccat_class);
unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES);
} }
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
#include <linux/types.h> #include <linux/types.h>
#if defined(CONFIG_HID_ROCCAT) || defined(CONFIG_HID_ROCCAT_MODULE) #if defined(CONFIG_HID_ROCCAT) || defined(CONFIG_HID_ROCCAT_MODULE)
int roccat_connect(struct hid_device *hid); int roccat_connect(struct class *klass, struct hid_device *hid);
void roccat_disconnect(int minor); void roccat_disconnect(int minor);
int roccat_report_event(int minor, u8 const *data, int len); int roccat_report_event(int minor, u8 const *data, int len);
#else #else
static inline int roccat_connect(struct hid_device *hid) { return -1; } static inline int roccat_connect(struct class *klass,
struct hid_device *hid) { return -1; }
static inline void roccat_disconnect(int minor) {} static inline void roccat_disconnect(int minor) {}
static inline int roccat_report_event(int minor, u8 const *data, int len) static inline int roccat_report_event(int minor, u8 const *data, int len)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment