aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/rc-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/rc/rc-main.c')
-rw-r--r--drivers/media/rc/rc-main.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 759a40a42eaa..1cf382a0b277 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -715,14 +715,14 @@ static void ir_close(struct input_dev *idev)
715} 715}
716 716
717/* class for /sys/class/rc */ 717/* class for /sys/class/rc */
718static char *ir_devnode(struct device *dev, umode_t *mode) 718static char *rc_devnode(struct device *dev, umode_t *mode)
719{ 719{
720 return kasprintf(GFP_KERNEL, "rc/%s", dev_name(dev)); 720 return kasprintf(GFP_KERNEL, "rc/%s", dev_name(dev));
721} 721}
722 722
723static struct class ir_input_class = { 723static struct class rc_class = {
724 .name = "rc", 724 .name = "rc",
725 .devnode = ir_devnode, 725 .devnode = rc_devnode,
726}; 726};
727 727
728/* 728/*
@@ -783,13 +783,12 @@ static ssize_t show_protocols(struct device *device,
783 783
784 mutex_lock(&dev->lock); 784 mutex_lock(&dev->lock);
785 785
786 if (dev->driver_type == RC_DRIVER_SCANCODE) { 786 enabled = dev->enabled_protocols;
787 enabled = dev->rc_map.rc_type; 787 if (dev->driver_type == RC_DRIVER_SCANCODE)
788 allowed = dev->allowed_protos; 788 allowed = dev->allowed_protos;
789 } else if (dev->raw) { 789 else if (dev->raw)
790 enabled = dev->raw->enabled_protocols;
791 allowed = ir_raw_get_allowed_protocols(); 790 allowed = ir_raw_get_allowed_protocols();
792 } else { 791 else {
793 mutex_unlock(&dev->lock); 792 mutex_unlock(&dev->lock);
794 return -ENODEV; 793 return -ENODEV;
795 } 794 }
@@ -847,7 +846,6 @@ static ssize_t store_protocols(struct device *device,
847 u64 type; 846 u64 type;
848 u64 mask; 847 u64 mask;
849 int rc, i, count = 0; 848 int rc, i, count = 0;
850 unsigned long flags;
851 ssize_t ret; 849 ssize_t ret;
852 850
853 /* Device is being removed */ 851 /* Device is being removed */
@@ -856,15 +854,12 @@ static ssize_t store_protocols(struct device *device,
856 854
857 mutex_lock(&dev->lock); 855 mutex_lock(&dev->lock);
858 856
859 if (dev->driver_type == RC_DRIVER_SCANCODE) 857 if (dev->driver_type != RC_DRIVER_SCANCODE && !dev->raw) {
860 type = dev->rc_map.rc_type;
861 else if (dev->raw)
862 type = dev->raw->enabled_protocols;
863 else {
864 IR_dprintk(1, "Protocol switching not supported\n"); 858 IR_dprintk(1, "Protocol switching not supported\n");
865 ret = -EINVAL; 859 ret = -EINVAL;
866 goto out; 860 goto out;
867 } 861 }
862 type = dev->enabled_protocols;
868 863
869 while ((tmp = strsep((char **) &data, " \n")) != NULL) { 864 while ((tmp = strsep((char **) &data, " \n")) != NULL) {
870 if (!*tmp) 865 if (!*tmp)
@@ -922,14 +917,7 @@ static ssize_t store_protocols(struct device *device,
922 } 917 }
923 } 918 }
924 919
925 if (dev->driver_type == RC_DRIVER_SCANCODE) { 920 dev->enabled_protocols = type;
926 spin_lock_irqsave(&dev->rc_map.lock, flags);
927 dev->rc_map.rc_type = type;
928 spin_unlock_irqrestore(&dev->rc_map.lock, flags);
929 } else {
930 dev->raw->enabled_protocols = type;
931 }
932
933 IR_dprintk(1, "Current protocol(s): 0x%llx\n", 921 IR_dprintk(1, "Current protocol(s): 0x%llx\n",
934 (long long)type); 922 (long long)type);
935 923
@@ -1016,7 +1004,7 @@ struct rc_dev *rc_allocate_device(void)
1016 setup_timer(&dev->timer_keyup, ir_timer_keyup, (unsigned long)dev); 1004 setup_timer(&dev->timer_keyup, ir_timer_keyup, (unsigned long)dev);
1017 1005
1018 dev->dev.type = &rc_dev_type; 1006 dev->dev.type = &rc_dev_type;
1019 dev->dev.class = &ir_input_class; 1007 dev->dev.class = &rc_class;
1020 device_initialize(&dev->dev); 1008 device_initialize(&dev->dev);
1021 1009
1022 __module_get(THIS_MODULE); 1010 __module_get(THIS_MODULE);
@@ -1068,9 +1056,8 @@ int rc_register_device(struct rc_dev *dev)
1068 /* 1056 /*
1069 * Take the lock here, as the device sysfs node will appear 1057 * Take the lock here, as the device sysfs node will appear
1070 * when device_add() is called, which may trigger an ir-keytable udev 1058 * when device_add() is called, which may trigger an ir-keytable udev
1071 * rule, which will in turn call show_protocols and access either 1059 * rule, which will in turn call show_protocols and access
1072 * dev->rc_map.rc_type or dev->raw->enabled_protocols before it has 1060 * dev->enabled_protocols before it has been initialized.
1073 * been initialized.
1074 */ 1061 */
1075 mutex_lock(&dev->lock); 1062 mutex_lock(&dev->lock);
1076 1063
@@ -1132,6 +1119,7 @@ int rc_register_device(struct rc_dev *dev)
1132 rc = dev->change_protocol(dev, &rc_type); 1119 rc = dev->change_protocol(dev, &rc_type);
1133 if (rc < 0) 1120 if (rc < 0)
1134 goto out_raw; 1121 goto out_raw;
1122 dev->enabled_protocols = rc_type;
1135 } 1123 }
1136 1124
1137 mutex_unlock(&dev->lock); 1125 mutex_unlock(&dev->lock);
@@ -1190,7 +1178,7 @@ EXPORT_SYMBOL_GPL(rc_unregister_device);
1190 1178
1191static int __init rc_core_init(void) 1179static int __init rc_core_init(void)
1192{ 1180{
1193 int rc = class_register(&ir_input_class); 1181 int rc = class_register(&rc_class);
1194 if (rc) { 1182 if (rc) {
1195 printk(KERN_ERR "rc_core: unable to register rc class\n"); 1183 printk(KERN_ERR "rc_core: unable to register rc class\n");
1196 return rc; 1184 return rc;
@@ -1203,11 +1191,11 @@ static int __init rc_core_init(void)
1203 1191
1204static void __exit rc_core_exit(void) 1192static void __exit rc_core_exit(void)
1205{ 1193{
1206 class_unregister(&ir_input_class); 1194 class_unregister(&rc_class);
1207 rc_map_unregister(&empty_map); 1195 rc_map_unregister(&empty_map);
1208} 1196}
1209 1197
1210module_init(rc_core_init); 1198subsys_initcall(rc_core_init);
1211module_exit(rc_core_exit); 1199module_exit(rc_core_exit);
1212 1200
1213int rc_core_debug; /* ir_debug level (0,1,2) */ 1201int rc_core_debug; /* ir_debug level (0,1,2) */