Commit 5f945489 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: do not register statically allocated devices

Do not register statically allocated input devices to prevent
OOPS when attaching input interfaces since it requires class
device to be properly initialized.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 438c9da5
...@@ -377,7 +377,7 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int ...@@ -377,7 +377,7 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
list_for_each_entry(dev, &input_dev_list, node) { list_for_each_entry(dev, &input_dev_list, node) {
path = dev->dynalloc ? kobject_get_path(&dev->cdev.kobj, GFP_KERNEL) : NULL; path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
...@@ -741,15 +741,21 @@ static void input_register_classdevice(struct input_dev *dev) ...@@ -741,15 +741,21 @@ static void input_register_classdevice(struct input_dev *dev)
sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group); sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
} }
void input_register_device(struct input_dev *dev) int input_register_device(struct input_dev *dev)
{ {
struct input_handle *handle; struct input_handle *handle;
struct input_handler *handler; struct input_handler *handler;
struct input_device_id *id; struct input_device_id *id;
set_bit(EV_SYN, dev->evbit); if (!dev->dynalloc) {
printk(KERN_WARNING "input: device %s is statically allocated, will not register\n"
"Please convert to input_allocate_device() or contact dtor_core@ameritech.net\n",
dev->name ? dev->name : "<Unknown>");
return -EINVAL;
}
init_MUTEX(&dev->sem); init_MUTEX(&dev->sem);
set_bit(EV_SYN, dev->evbit);
/* /*
* If delay and period are pre-set by the driver, then autorepeating * If delay and period are pre-set by the driver, then autorepeating
...@@ -767,8 +773,7 @@ void input_register_device(struct input_dev *dev) ...@@ -767,8 +773,7 @@ void input_register_device(struct input_dev *dev)
INIT_LIST_HEAD(&dev->h_list); INIT_LIST_HEAD(&dev->h_list);
list_add_tail(&dev->node, &input_dev_list); list_add_tail(&dev->node, &input_dev_list);
if (dev->dynalloc) input_register_classdevice(dev);
input_register_classdevice(dev);
list_for_each_entry(handler, &input_handler_list, node) list_for_each_entry(handler, &input_handler_list, node)
if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
...@@ -776,8 +781,9 @@ void input_register_device(struct input_dev *dev) ...@@ -776,8 +781,9 @@ void input_register_device(struct input_dev *dev)
if ((handle = handler->connect(handler, dev, id))) if ((handle = handler->connect(handler, dev, id)))
input_link_handle(handle); input_link_handle(handle);
input_wakeup_procfs_readers(); input_wakeup_procfs_readers();
return 0;
} }
void input_unregister_device(struct input_dev *dev) void input_unregister_device(struct input_dev *dev)
...@@ -797,11 +803,9 @@ void input_unregister_device(struct input_dev *dev) ...@@ -797,11 +803,9 @@ void input_unregister_device(struct input_dev *dev)
list_del_init(&dev->node); list_del_init(&dev->node);
if (dev->dynalloc) { sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); class_device_unregister(&dev->cdev);
class_device_unregister(&dev->cdev);
}
input_wakeup_procfs_readers(); input_wakeup_procfs_readers();
} }
......
...@@ -1007,7 +1007,7 @@ static inline void input_put_device(struct input_dev *dev) ...@@ -1007,7 +1007,7 @@ static inline void input_put_device(struct input_dev *dev)
class_device_put(&dev->cdev); class_device_put(&dev->cdev);
} }
void input_register_device(struct input_dev *); int input_register_device(struct input_dev *);
void input_unregister_device(struct input_dev *); void input_unregister_device(struct input_dev *);
void input_register_handler(struct input_handler *); void input_register_handler(struct input_handler *);
......
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