aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-24 20:35:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-24 20:35:10 -0500
commit21fbd5809ad126b949206d78e0a0e07ec872ea11 (patch)
treea824045df99fc1f0690095a925cceb50207e332b /drivers/media/rc
parentd9978ec5680059d727b39d6c706777c6973587f2 (diff)
parented72d37a33fdf43dc47787fe220532cdec9da528 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - Some cleanups at V4L2 documentation - new drivers: ts2020 frontend, ov9650 sensor, s5c73m3 sensor, sh-mobile veu mem2mem driver, radio-ma901, davinci_vpfe staging driver - Lots of missing MAINTAINERS entries added - several em28xx driver improvements, including its conversion to videobuf2 - several fixups on drivers to make them to better comply with the API - DVB core: add support for DVBv5 stats, allowing the implementation of statistics for new standards like ISDB - mb86a20s: add statistics to the driver - lots of new board additions, cleanups, and driver improvements. * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (596 commits) [media] media: Add 0x3009 USB PID to ttusb2 driver (fixed diff) [media] rtl28xxu: Add USB IDs for Compro VideoMate U620F [media] em28xx: add usb id for terratec h5 rev. 3 [media] media: rc: gpio-ir-recv: add support for device tree parsing [media] mceusb: move check earlier to make smatch happy [media] radio-si470x doc: add info about v4l2-ctl and sox+alsa [media] staging: media: Remove unnecessary OOM messages [media] sh_vou: Use vou_dev instead of vou_file wherever possible [media] sh_vou: Use video_drvdata() [media] drivers/media/platform/soc_camera/pxa_camera.c: use devm_ functions [media] mt9t112: mt9t111 format set up differs from mt9t112 [media] sh-mobile-ceu-camera: fix SHARPNESS control default Revert "[media] fc0011: Return early, if the frequency is already tuned" [media] cx18/ivtv: fix regression: remove __init from a non-init function [media] em28xx: fix analog streaming with USB bulk transfers [media] stv0900: remove unnecessary null pointer check [media] fc0011: Return early, if the frequency is already tuned [media] fc0011: Add some sanity checks and cleanups [media] fc0011: Fix xin value clamping Revert "[media] [PATH,1/2] mxl5007 move reset to attach" ...
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/ati_remote.c27
-rw-r--r--drivers/media/rc/ene_ir.c28
-rw-r--r--drivers/media/rc/fintek-cir.c24
-rw-r--r--drivers/media/rc/gpio-ir-recv.c55
-rw-r--r--drivers/media/rc/iguanair.c26
-rw-r--r--drivers/media/rc/imon.c4
-rw-r--r--drivers/media/rc/ir-raw.c17
-rw-r--r--drivers/media/rc/ite-cir.c26
-rw-r--r--drivers/media/rc/keymaps/Makefile1
-rw-r--r--drivers/media/rc/keymaps/rc-total-media-in-hand-02.c86
-rw-r--r--drivers/media/rc/mceusb.c37
-rw-r--r--drivers/media/rc/nuvoton-cir.c41
-rw-r--r--drivers/media/rc/rc-core-priv.h16
-rw-r--r--drivers/media/rc/rc-main.c7
-rw-r--r--drivers/media/rc/redrat3.c18
-rw-r--r--drivers/media/rc/ttusbir.c10
-rw-r--r--drivers/media/rc/winbond-cir.c41
17 files changed, 302 insertions, 162 deletions
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 2d6fb26a0170..4d6a63fe6c5e 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -872,11 +872,11 @@ static int ati_remote_probe(struct usb_interface *interface,
872 ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); 872 ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
873 rc_dev = rc_allocate_device(); 873 rc_dev = rc_allocate_device();
874 if (!ati_remote || !rc_dev) 874 if (!ati_remote || !rc_dev)
875 goto fail1; 875 goto exit_free_dev_rdev;
876 876
877 /* Allocate URB buffers, URBs */ 877 /* Allocate URB buffers, URBs */
878 if (ati_remote_alloc_buffers(udev, ati_remote)) 878 if (ati_remote_alloc_buffers(udev, ati_remote))
879 goto fail2; 879 goto exit_free_buffers;
880 880
881 ati_remote->endpoint_in = endpoint_in; 881 ati_remote->endpoint_in = endpoint_in;
882 ati_remote->endpoint_out = endpoint_out; 882 ati_remote->endpoint_out = endpoint_out;
@@ -924,12 +924,12 @@ static int ati_remote_probe(struct usb_interface *interface,
924 /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ 924 /* Device Hardware Initialization - fills in ati_remote->idev from udev. */
925 err = ati_remote_initialize(ati_remote); 925 err = ati_remote_initialize(ati_remote);
926 if (err) 926 if (err)
927 goto fail3; 927 goto exit_kill_urbs;
928 928
929 /* Set up and register rc device */ 929 /* Set up and register rc device */
930 err = rc_register_device(ati_remote->rdev); 930 err = rc_register_device(ati_remote->rdev);
931 if (err) 931 if (err)
932 goto fail3; 932 goto exit_kill_urbs;
933 933
934 /* use our delay for rc_dev */ 934 /* use our delay for rc_dev */
935 ati_remote->rdev->input_dev->rep[REP_DELAY] = repeat_delay; 935 ati_remote->rdev->input_dev->rep[REP_DELAY] = repeat_delay;
@@ -939,7 +939,7 @@ static int ati_remote_probe(struct usb_interface *interface,
939 input_dev = input_allocate_device(); 939 input_dev = input_allocate_device();
940 if (!input_dev) { 940 if (!input_dev) {
941 err = -ENOMEM; 941 err = -ENOMEM;
942 goto fail4; 942 goto exit_unregister_device;
943 } 943 }
944 944
945 ati_remote->idev = input_dev; 945 ati_remote->idev = input_dev;
@@ -947,19 +947,24 @@ static int ati_remote_probe(struct usb_interface *interface,
947 err = input_register_device(input_dev); 947 err = input_register_device(input_dev);
948 948
949 if (err) 949 if (err)
950 goto fail5; 950 goto exit_free_input_device;
951 } 951 }
952 952
953 usb_set_intfdata(interface, ati_remote); 953 usb_set_intfdata(interface, ati_remote);
954 return 0; 954 return 0;
955 955
956 fail5: input_free_device(input_dev); 956 exit_free_input_device:
957 fail4: rc_unregister_device(rc_dev); 957 input_free_device(input_dev);
958 exit_unregister_device:
959 rc_unregister_device(rc_dev);
958 rc_dev = NULL; 960 rc_dev = NULL;
959 fail3: usb_kill_urb(ati_remote->irq_urb); 961 exit_kill_urbs:
962 usb_kill_urb(ati_remote->irq_urb);
960 usb_kill_urb(ati_remote->out_urb); 963 usb_kill_urb(ati_remote->out_urb);
961 fail2: ati_remote_free_buffers(ati_remote); 964 exit_free_buffers:
962 fail1: rc_free_device(rc_dev); 965 ati_remote_free_buffers(ati_remote);
966 exit_free_dev_rdev:
967 rc_free_device(rc_dev);
963 kfree(ati_remote); 968 kfree(ati_remote);
964 return err; 969 return err;
965} 970}
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index cef04786b52f..ee6c984cade2 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1003,7 +1003,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1003 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL); 1003 dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
1004 rdev = rc_allocate_device(); 1004 rdev = rc_allocate_device();
1005 if (!dev || !rdev) 1005 if (!dev || !rdev)
1006 goto failure; 1006 goto exit_free_dev_rdev;
1007 1007
1008 /* validate resources */ 1008 /* validate resources */
1009 error = -ENODEV; 1009 error = -ENODEV;
@@ -1014,10 +1014,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1014 1014
1015 if (!pnp_port_valid(pnp_dev, 0) || 1015 if (!pnp_port_valid(pnp_dev, 0) ||
1016 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) 1016 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE)
1017 goto failure; 1017 goto exit_free_dev_rdev;
1018 1018
1019 if (!pnp_irq_valid(pnp_dev, 0)) 1019 if (!pnp_irq_valid(pnp_dev, 0))
1020 goto failure; 1020 goto exit_free_dev_rdev;
1021 1021
1022 spin_lock_init(&dev->hw_lock); 1022 spin_lock_init(&dev->hw_lock);
1023 1023
@@ -1033,7 +1033,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1033 /* detect hardware version and features */ 1033 /* detect hardware version and features */
1034 error = ene_hw_detect(dev); 1034 error = ene_hw_detect(dev);
1035 if (error) 1035 if (error)
1036 goto failure; 1036 goto exit_free_dev_rdev;
1037 1037
1038 if (!dev->hw_learning_and_tx_capable && txsim) { 1038 if (!dev->hw_learning_and_tx_capable && txsim) {
1039 dev->hw_learning_and_tx_capable = true; 1039 dev->hw_learning_and_tx_capable = true;
@@ -1075,30 +1075,30 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1075 device_set_wakeup_capable(&pnp_dev->dev, true); 1075 device_set_wakeup_capable(&pnp_dev->dev, true);
1076 device_set_wakeup_enable(&pnp_dev->dev, true); 1076 device_set_wakeup_enable(&pnp_dev->dev, true);
1077 1077
1078 error = rc_register_device(rdev);
1079 if (error < 0)
1080 goto exit_free_dev_rdev;
1081
1078 /* claim the resources */ 1082 /* claim the resources */
1079 error = -EBUSY; 1083 error = -EBUSY;
1080 if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { 1084 if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) {
1081 goto failure; 1085 goto exit_unregister_device;
1082 } 1086 }
1083 1087
1084 dev->irq = pnp_irq(pnp_dev, 0); 1088 dev->irq = pnp_irq(pnp_dev, 0);
1085 if (request_irq(dev->irq, ene_isr, 1089 if (request_irq(dev->irq, ene_isr,
1086 IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) { 1090 IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) {
1087 goto failure2; 1091 goto exit_release_hw_io;
1088 } 1092 }
1089 1093
1090 error = rc_register_device(rdev);
1091 if (error < 0)
1092 goto failure3;
1093
1094 pr_notice("driver has been successfully loaded\n"); 1094 pr_notice("driver has been successfully loaded\n");
1095 return 0; 1095 return 0;
1096 1096
1097failure3: 1097exit_release_hw_io:
1098 free_irq(dev->irq, dev);
1099failure2:
1100 release_region(dev->hw_io, ENE_IO_SIZE); 1098 release_region(dev->hw_io, ENE_IO_SIZE);
1101failure: 1099exit_unregister_device:
1100 rc_unregister_device(rdev);
1101exit_free_dev_rdev:
1102 rc_free_device(rdev); 1102 rc_free_device(rdev);
1103 kfree(dev); 1103 kfree(dev);
1104 return error; 1104 return error;
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index 1df410e13688..d6fa441655d2 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -500,18 +500,18 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
500 /* input device for IR remote (and tx) */ 500 /* input device for IR remote (and tx) */
501 rdev = rc_allocate_device(); 501 rdev = rc_allocate_device();
502 if (!rdev) 502 if (!rdev)
503 goto failure; 503 goto exit_free_dev_rdev;
504 504
505 ret = -ENODEV; 505 ret = -ENODEV;
506 /* validate pnp resources */ 506 /* validate pnp resources */
507 if (!pnp_port_valid(pdev, 0)) { 507 if (!pnp_port_valid(pdev, 0)) {
508 dev_err(&pdev->dev, "IR PNP Port not valid!\n"); 508 dev_err(&pdev->dev, "IR PNP Port not valid!\n");
509 goto failure; 509 goto exit_free_dev_rdev;
510 } 510 }
511 511
512 if (!pnp_irq_valid(pdev, 0)) { 512 if (!pnp_irq_valid(pdev, 0)) {
513 dev_err(&pdev->dev, "IR PNP IRQ not valid!\n"); 513 dev_err(&pdev->dev, "IR PNP IRQ not valid!\n");
514 goto failure; 514 goto exit_free_dev_rdev;
515 } 515 }
516 516
517 fintek->cir_addr = pnp_port_start(pdev, 0); 517 fintek->cir_addr = pnp_port_start(pdev, 0);
@@ -528,7 +528,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
528 528
529 ret = fintek_hw_detect(fintek); 529 ret = fintek_hw_detect(fintek);
530 if (ret) 530 if (ret)
531 goto failure; 531 goto exit_free_dev_rdev;
532 532
533 /* Initialize CIR & CIR Wake Logical Devices */ 533 /* Initialize CIR & CIR Wake Logical Devices */
534 fintek_config_mode_enable(fintek); 534 fintek_config_mode_enable(fintek);
@@ -557,33 +557,35 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
557 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */ 557 /* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
558 rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD); 558 rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD);
559 559
560 fintek->rdev = rdev;
561
560 ret = -EBUSY; 562 ret = -EBUSY;
561 /* now claim resources */ 563 /* now claim resources */
562 if (!request_region(fintek->cir_addr, 564 if (!request_region(fintek->cir_addr,
563 fintek->cir_port_len, FINTEK_DRIVER_NAME)) 565 fintek->cir_port_len, FINTEK_DRIVER_NAME))
564 goto failure; 566 goto exit_free_dev_rdev;
565 567
566 if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED, 568 if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED,
567 FINTEK_DRIVER_NAME, (void *)fintek)) 569 FINTEK_DRIVER_NAME, (void *)fintek))
568 goto failure2; 570 goto exit_free_cir_addr;
569 571
570 ret = rc_register_device(rdev); 572 ret = rc_register_device(rdev);
571 if (ret) 573 if (ret)
572 goto failure3; 574 goto exit_free_irq;
573 575
574 device_init_wakeup(&pdev->dev, true); 576 device_init_wakeup(&pdev->dev, true);
575 fintek->rdev = rdev; 577
576 fit_pr(KERN_NOTICE, "driver has been successfully loaded\n"); 578 fit_pr(KERN_NOTICE, "driver has been successfully loaded\n");
577 if (debug) 579 if (debug)
578 cir_dump_regs(fintek); 580 cir_dump_regs(fintek);
579 581
580 return 0; 582 return 0;
581 583
582failure3: 584exit_free_irq:
583 free_irq(fintek->cir_irq, fintek); 585 free_irq(fintek->cir_irq, fintek);
584failure2: 586exit_free_cir_addr:
585 release_region(fintek->cir_addr, fintek->cir_port_len); 587 release_region(fintek->cir_addr, fintek->cir_port_len);
586failure: 588exit_free_dev_rdev:
587 rc_free_device(rdev); 589 rc_free_device(rdev);
588 kfree(fintek); 590 kfree(fintek);
589 591
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index 4f71a7d1f019..8b82ae9bd686 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -16,6 +16,7 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/of_gpio.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/irq.h> 21#include <linux/irq.h>
21#include <media/rc-core.h> 22#include <media/rc-core.h>
@@ -30,6 +31,45 @@ struct gpio_rc_dev {
30 bool active_low; 31 bool active_low;
31}; 32};
32 33
34#ifdef CONFIG_OF
35/*
36 * Translate OpenFirmware node properties into platform_data
37 */
38static int gpio_ir_recv_get_devtree_pdata(struct device *dev,
39 struct gpio_ir_recv_platform_data *pdata)
40{
41 struct device_node *np = dev->of_node;
42 enum of_gpio_flags flags;
43 int gpio;
44
45 gpio = of_get_gpio_flags(np, 0, &flags);
46 if (gpio < 0) {
47 if (gpio != -EPROBE_DEFER)
48 dev_err(dev, "Failed to get gpio flags (%d)\n", gpio);
49 return gpio;
50 }
51
52 pdata->gpio_nr = gpio;
53 pdata->active_low = (flags & OF_GPIO_ACTIVE_LOW);
54 /* probe() takes care of map_name == NULL or allowed_protos == 0 */
55 pdata->map_name = of_get_property(np, "linux,rc-map-name", NULL);
56 pdata->allowed_protos = 0;
57
58 return 0;
59}
60
61static struct of_device_id gpio_ir_recv_of_match[] = {
62 { .compatible = "gpio-ir-receiver", },
63 { },
64};
65MODULE_DEVICE_TABLE(of, gpio_ir_recv_of_match);
66
67#else /* !CONFIG_OF */
68
69#define gpio_ir_recv_get_devtree_pdata(dev, pdata) (-ENOSYS)
70
71#endif
72
33static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id) 73static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
34{ 74{
35 struct gpio_rc_dev *gpio_dev = dev_id; 75 struct gpio_rc_dev *gpio_dev = dev_id;
@@ -66,6 +106,17 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
66 pdev->dev.platform_data; 106 pdev->dev.platform_data;
67 int rc; 107 int rc;
68 108
109 if (pdev->dev.of_node) {
110 struct gpio_ir_recv_platform_data *dtpdata =
111 devm_kzalloc(&pdev->dev, sizeof(*dtpdata), GFP_KERNEL);
112 if (!dtpdata)
113 return -ENOMEM;
114 rc = gpio_ir_recv_get_devtree_pdata(&pdev->dev, dtpdata);
115 if (rc)
116 return rc;
117 pdata = dtpdata;
118 }
119
69 if (!pdata) 120 if (!pdata)
70 return -EINVAL; 121 return -EINVAL;
71 122
@@ -129,12 +180,12 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
129err_request_irq: 180err_request_irq:
130 platform_set_drvdata(pdev, NULL); 181 platform_set_drvdata(pdev, NULL);
131 rc_unregister_device(rcdev); 182 rc_unregister_device(rcdev);
183 rcdev = NULL;
132err_register_rc_device: 184err_register_rc_device:
133err_gpio_direction_input: 185err_gpio_direction_input:
134 gpio_free(pdata->gpio_nr); 186 gpio_free(pdata->gpio_nr);
135err_gpio_request: 187err_gpio_request:
136 rc_free_device(rcdev); 188 rc_free_device(rcdev);
137 rcdev = NULL;
138err_allocate_device: 189err_allocate_device:
139 kfree(gpio_dev); 190 kfree(gpio_dev);
140 return rc; 191 return rc;
@@ -148,7 +199,6 @@ static int gpio_ir_recv_remove(struct platform_device *pdev)
148 platform_set_drvdata(pdev, NULL); 199 platform_set_drvdata(pdev, NULL);
149 rc_unregister_device(gpio_dev->rcdev); 200 rc_unregister_device(gpio_dev->rcdev);
150 gpio_free(gpio_dev->gpio_nr); 201 gpio_free(gpio_dev->gpio_nr);
151 rc_free_device(gpio_dev->rcdev);
152 kfree(gpio_dev); 202 kfree(gpio_dev);
153 return 0; 203 return 0;
154} 204}
@@ -192,6 +242,7 @@ static struct platform_driver gpio_ir_recv_driver = {
192 .driver = { 242 .driver = {
193 .name = GPIO_IR_DRIVER_NAME, 243 .name = GPIO_IR_DRIVER_NAME,
194 .owner = THIS_MODULE, 244 .owner = THIS_MODULE,
245 .of_match_table = of_match_ptr(gpio_ir_recv_of_match),
195#ifdef CONFIG_PM 246#ifdef CONFIG_PM
196 .pm = &gpio_ir_recv_pm_ops, 247 .pm = &gpio_ir_recv_pm_ops,
197#endif 248#endif
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index b99b096d8a8f..a4ab2e6b3f82 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -58,6 +58,7 @@ struct iguanair {
58 char phys[64]; 58 char phys[64];
59}; 59};
60 60
61#define CMD_NOP 0x00
61#define CMD_GET_VERSION 0x01 62#define CMD_GET_VERSION 0x01
62#define CMD_GET_BUFSIZE 0x11 63#define CMD_GET_BUFSIZE 0x11
63#define CMD_GET_FEATURES 0x10 64#define CMD_GET_FEATURES 0x10
@@ -196,6 +197,10 @@ static void iguanair_irq_out(struct urb *urb)
196 197
197 if (urb->status) 198 if (urb->status)
198 dev_dbg(ir->dev, "Error: out urb status = %d\n", urb->status); 199 dev_dbg(ir->dev, "Error: out urb status = %d\n", urb->status);
200
201 /* if we sent an nop packet, do not expect a response */
202 if (urb->status == 0 && ir->packet->header.cmd == CMD_NOP)
203 complete(&ir->completion);
199} 204}
200 205
201static int iguanair_send(struct iguanair *ir, unsigned size) 206static int iguanair_send(struct iguanair *ir, unsigned size)
@@ -219,10 +224,17 @@ static int iguanair_get_features(struct iguanair *ir)
219{ 224{
220 int rc; 225 int rc;
221 226
227 /*
228 * On cold boot, the iguanair initializes on the first packet
229 * received but does not process that packet. Send an empty
230 * packet.
231 */
222 ir->packet->header.start = 0; 232 ir->packet->header.start = 0;
223 ir->packet->header.direction = DIR_OUT; 233 ir->packet->header.direction = DIR_OUT;
224 ir->packet->header.cmd = CMD_GET_VERSION; 234 ir->packet->header.cmd = CMD_NOP;
235 iguanair_send(ir, sizeof(ir->packet->header));
225 236
237 ir->packet->header.cmd = CMD_GET_VERSION;
226 rc = iguanair_send(ir, sizeof(ir->packet->header)); 238 rc = iguanair_send(ir, sizeof(ir->packet->header));
227 if (rc) { 239 if (rc) {
228 dev_info(ir->dev, "failed to get version\n"); 240 dev_info(ir->dev, "failed to get version\n");
@@ -255,19 +267,14 @@ static int iguanair_get_features(struct iguanair *ir)
255 ir->packet->header.cmd = CMD_GET_FEATURES; 267 ir->packet->header.cmd = CMD_GET_FEATURES;
256 268
257 rc = iguanair_send(ir, sizeof(ir->packet->header)); 269 rc = iguanair_send(ir, sizeof(ir->packet->header));
258 if (rc) { 270 if (rc)
259 dev_info(ir->dev, "failed to get features\n"); 271 dev_info(ir->dev, "failed to get features\n");
260 goto out;
261 }
262
263out: 272out:
264 return rc; 273 return rc;
265} 274}
266 275
267static int iguanair_receiver(struct iguanair *ir, bool enable) 276static int iguanair_receiver(struct iguanair *ir, bool enable)
268{ 277{
269 int rc;
270
271 ir->packet->header.start = 0; 278 ir->packet->header.start = 0;
272 ir->packet->header.direction = DIR_OUT; 279 ir->packet->header.direction = DIR_OUT;
273 ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF; 280 ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF;
@@ -275,9 +282,7 @@ static int iguanair_receiver(struct iguanair *ir, bool enable)
275 if (enable) 282 if (enable)
276 ir_raw_event_reset(ir->rc); 283 ir_raw_event_reset(ir->rc);
277 284
278 rc = iguanair_send(ir, sizeof(ir->packet->header)); 285 return iguanair_send(ir, sizeof(ir->packet->header));
279
280 return rc;
281} 286}
282 287
283/* 288/*
@@ -512,6 +517,7 @@ static int iguanair_probe(struct usb_interface *intf,
512 rc->rx_resolution = RX_RESOLUTION; 517 rc->rx_resolution = RX_RESOLUTION;
513 518
514 iguanair_set_tx_carrier(rc, 38000); 519 iguanair_set_tx_carrier(rc, 38000);
520 iguanair_set_tx_mask(rc, 0);
515 521
516 ret = rc_register_device(rc); 522 ret = rc_register_device(rc);
517 if (ret < 0) { 523 if (ret < 0) {
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 78d109b978dd..dec203bb06f6 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1221,7 +1221,7 @@ static u32 imon_panel_key_lookup(u64 code)
1221static bool imon_mouse_event(struct imon_context *ictx, 1221static bool imon_mouse_event(struct imon_context *ictx,
1222 unsigned char *buf, int len) 1222 unsigned char *buf, int len)
1223{ 1223{
1224 char rel_x = 0x00, rel_y = 0x00; 1224 signed char rel_x = 0x00, rel_y = 0x00;
1225 u8 right_shift = 1; 1225 u8 right_shift = 1;
1226 bool mouse_input = true; 1226 bool mouse_input = true;
1227 int dir = 0; 1227 int dir = 0;
@@ -1297,7 +1297,7 @@ static void imon_touch_event(struct imon_context *ictx, unsigned char *buf)
1297static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) 1297static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf)
1298{ 1298{
1299 int dir = 0; 1299 int dir = 0;
1300 char rel_x = 0x00, rel_y = 0x00; 1300 signed char rel_x = 0x00, rel_y = 0x00;
1301 u16 timeout, threshold; 1301 u16 timeout, threshold;
1302 u32 scancode = KEY_RESERVED; 1302 u32 scancode = KEY_RESERVED;
1303 unsigned long flags; 1303 unsigned long flags;
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 97dc8d13b06b..17c94be9f24c 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -31,11 +31,6 @@ static DEFINE_MUTEX(ir_raw_handler_lock);
31static LIST_HEAD(ir_raw_handler_list); 31static LIST_HEAD(ir_raw_handler_list);
32static u64 available_protocols; 32static u64 available_protocols;
33 33
34#ifdef MODULE
35/* Used to load the decoders */
36static struct work_struct wq_load;
37#endif
38
39static int ir_raw_event_thread(void *data) 34static int ir_raw_event_thread(void *data)
40{ 35{
41 struct ir_raw_event ev; 36 struct ir_raw_event ev;
@@ -347,8 +342,7 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
347} 342}
348EXPORT_SYMBOL(ir_raw_handler_unregister); 343EXPORT_SYMBOL(ir_raw_handler_unregister);
349 344
350#ifdef MODULE 345void ir_raw_init(void)
351static void init_decoders(struct work_struct *work)
352{ 346{
353 /* Load the decoder modules */ 347 /* Load the decoder modules */
354 348
@@ -365,12 +359,3 @@ static void init_decoders(struct work_struct *work)
365 it is needed to change the CONFIG_MODULE test at rc-core.h 359 it is needed to change the CONFIG_MODULE test at rc-core.h
366 */ 360 */
367} 361}
368#endif
369
370void ir_raw_init(void)
371{
372#ifdef MODULE
373 INIT_WORK(&wq_load, init_decoders);
374 schedule_work(&wq_load);
375#endif
376}
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 1b8669b6d042..dd8237324c09 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1472,7 +1472,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1472 /* input device for IR remote (and tx) */ 1472 /* input device for IR remote (and tx) */
1473 rdev = rc_allocate_device(); 1473 rdev = rc_allocate_device();
1474 if (!rdev) 1474 if (!rdev)
1475 goto failure; 1475 goto exit_free_dev_rdev;
1476 itdev->rdev = rdev; 1476 itdev->rdev = rdev;
1477 1477
1478 ret = -ENODEV; 1478 ret = -ENODEV;
@@ -1498,12 +1498,12 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1498 if (!pnp_port_valid(pdev, io_rsrc_no) || 1498 if (!pnp_port_valid(pdev, io_rsrc_no) ||
1499 pnp_port_len(pdev, io_rsrc_no) != dev_desc->io_region_size) { 1499 pnp_port_len(pdev, io_rsrc_no) != dev_desc->io_region_size) {
1500 dev_err(&pdev->dev, "IR PNP Port not valid!\n"); 1500 dev_err(&pdev->dev, "IR PNP Port not valid!\n");
1501 goto failure; 1501 goto exit_free_dev_rdev;
1502 } 1502 }
1503 1503
1504 if (!pnp_irq_valid(pdev, 0)) { 1504 if (!pnp_irq_valid(pdev, 0)) {
1505 dev_err(&pdev->dev, "PNP IRQ not valid!\n"); 1505 dev_err(&pdev->dev, "PNP IRQ not valid!\n");
1506 goto failure; 1506 goto exit_free_dev_rdev;
1507 } 1507 }
1508 1508
1509 /* store resource values */ 1509 /* store resource values */
@@ -1591,29 +1591,29 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1591 rdev->driver_name = ITE_DRIVER_NAME; 1591 rdev->driver_name = ITE_DRIVER_NAME;
1592 rdev->map_name = RC_MAP_RC6_MCE; 1592 rdev->map_name = RC_MAP_RC6_MCE;
1593 1593
1594 ret = rc_register_device(rdev);
1595 if (ret)
1596 goto exit_free_dev_rdev;
1597
1594 ret = -EBUSY; 1598 ret = -EBUSY;
1595 /* now claim resources */ 1599 /* now claim resources */
1596 if (!request_region(itdev->cir_addr, 1600 if (!request_region(itdev->cir_addr,
1597 dev_desc->io_region_size, ITE_DRIVER_NAME)) 1601 dev_desc->io_region_size, ITE_DRIVER_NAME))
1598 goto failure; 1602 goto exit_unregister_device;
1599 1603
1600 if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED, 1604 if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED,
1601 ITE_DRIVER_NAME, (void *)itdev)) 1605 ITE_DRIVER_NAME, (void *)itdev))
1602 goto failure2; 1606 goto exit_release_cir_addr;
1603
1604 ret = rc_register_device(rdev);
1605 if (ret)
1606 goto failure3;
1607 1607
1608 ite_pr(KERN_NOTICE, "driver has been successfully loaded\n"); 1608 ite_pr(KERN_NOTICE, "driver has been successfully loaded\n");
1609 1609
1610 return 0; 1610 return 0;
1611 1611
1612failure3: 1612exit_release_cir_addr:
1613 free_irq(itdev->cir_irq, itdev);
1614failure2:
1615 release_region(itdev->cir_addr, itdev->params.io_region_size); 1613 release_region(itdev->cir_addr, itdev->params.io_region_size);
1616failure: 1614exit_unregister_device:
1615 rc_unregister_device(rdev);
1616exit_free_dev_rdev:
1617 rc_free_device(rdev); 1617 rc_free_device(rdev);
1618 kfree(itdev); 1618 kfree(itdev);
1619 1619
diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile
index ab84d66c67c1..778661971aed 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -88,6 +88,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
88 rc-tevii-nec.o \ 88 rc-tevii-nec.o \
89 rc-tivo.o \ 89 rc-tivo.o \
90 rc-total-media-in-hand.o \ 90 rc-total-media-in-hand.o \
91 rc-total-media-in-hand-02.o \
91 rc-trekstor.o \ 92 rc-trekstor.o \
92 rc-tt-1500.o \ 93 rc-tt-1500.o \
93 rc-twinhan1027.o \ 94 rc-twinhan1027.o \
diff --git a/drivers/media/rc/keymaps/rc-total-media-in-hand-02.c b/drivers/media/rc/keymaps/rc-total-media-in-hand-02.c
new file mode 100644
index 000000000000..47270f72ebf0
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-total-media-in-hand-02.c
@@ -0,0 +1,86 @@
1/*
2 * Total Media In Hand_02 remote controller keytable for Mygica X8507
3 *
4 * Copyright (C) 2012 Alfredo J. Delaiti <alfredodelaiti@netscape.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <media/rc-map.h>
22#include <linux/module.h>
23
24
25static struct rc_map_table total_media_in_hand_02[] = {
26 { 0x0000, KEY_0 },
27 { 0x0001, KEY_1 },
28 { 0x0002, KEY_2 },
29 { 0x0003, KEY_3 },
30 { 0x0004, KEY_4 },
31 { 0x0005, KEY_5 },
32 { 0x0006, KEY_6 },
33 { 0x0007, KEY_7 },
34 { 0x0008, KEY_8 },
35 { 0x0009, KEY_9 },
36 { 0x000a, KEY_MUTE },
37 { 0x000b, KEY_STOP }, /* Stop */
38 { 0x000c, KEY_POWER2 }, /* Turn on/off application */
39 { 0x000d, KEY_OK }, /* OK */
40 { 0x000e, KEY_CAMERA }, /* Snapshot */
41 { 0x000f, KEY_ZOOM }, /* Full Screen/Restore */
42 { 0x0010, KEY_RIGHT }, /* Right arrow */
43 { 0x0011, KEY_LEFT }, /* Left arrow */
44 { 0x0012, KEY_CHANNELUP },
45 { 0x0013, KEY_CHANNELDOWN },
46 { 0x0014, KEY_SHUFFLE },
47 { 0x0016, KEY_PAUSE },
48 { 0x0017, KEY_PLAY }, /* Play */
49 { 0x001e, KEY_TIME }, /* Time Shift */
50 { 0x001f, KEY_RECORD },
51 { 0x0020, KEY_UP },
52 { 0x0021, KEY_DOWN },
53 { 0x0025, KEY_POWER }, /* Turn off computer */
54 { 0x0026, KEY_REWIND }, /* FR << */
55 { 0x0027, KEY_FASTFORWARD }, /* FF >> */
56 { 0x0029, KEY_ESC },
57 { 0x002b, KEY_VOLUMEUP },
58 { 0x002c, KEY_VOLUMEDOWN },
59 { 0x002d, KEY_CHANNEL }, /* CH Surfing */
60 { 0x0038, KEY_VIDEO }, /* TV/AV/S-Video/YPbPr */
61};
62
63static struct rc_map_list total_media_in_hand_02_map = {
64 .map = {
65 .scan = total_media_in_hand_02,
66 .size = ARRAY_SIZE(total_media_in_hand_02),
67 .rc_type = RC_TYPE_RC5,
68 .name = RC_MAP_TOTAL_MEDIA_IN_HAND_02,
69 }
70};
71
72static int __init init_rc_map_total_media_in_hand_02(void)
73{
74 return rc_map_register(&total_media_in_hand_02_map);
75}
76
77static void __exit exit_rc_map_total_media_in_hand_02(void)
78{
79 rc_map_unregister(&total_media_in_hand_02_map);
80}
81
82module_init(init_rc_map_total_media_in_hand_02)
83module_exit(exit_rc_map_total_media_in_hand_02)
84
85MODULE_LICENSE("GPL");
86MODULE_AUTHOR(" Alfredo J. Delaiti <alfredodelaiti@netscape.net>");
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 9afb9331217d..5b5b6e6f79e8 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -62,7 +62,6 @@
62#define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */ 62#define MCE_PACKET_SIZE 4 /* Normal length of packet (without header) */
63#define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */ 63#define MCE_IRDATA_HEADER 0x84 /* Actual header format is 0x80 + num_bytes */
64#define MCE_IRDATA_TRAILER 0x80 /* End of IR data */ 64#define MCE_IRDATA_TRAILER 0x80 /* End of IR data */
65#define MCE_TX_HEADER_LENGTH 3 /* # of bytes in the initializing tx header */
66#define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */ 65#define MCE_MAX_CHANNELS 2 /* Two transmitters, hardware dependent? */
67#define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */ 66#define MCE_DEFAULT_TX_MASK 0x03 /* Vals: TX1=0x01, TX2=0x02, ALL=0x03 */
68#define MCE_PULSE_BIT 0x80 /* Pulse bit, MSB set == PULSE else SPACE */ 67#define MCE_PULSE_BIT 0x80 /* Pulse bit, MSB set == PULSE else SPACE */
@@ -291,7 +290,8 @@ static struct usb_device_id mceusb_dev_table[] = {
291 /* Philips/Spinel plus IR transceiver for ASUS */ 290 /* Philips/Spinel plus IR transceiver for ASUS */
292 { USB_DEVICE(VENDOR_PHILIPS, 0x2088) }, 291 { USB_DEVICE(VENDOR_PHILIPS, 0x2088) },
293 /* Philips IR transceiver (Dell branded) */ 292 /* Philips IR transceiver (Dell branded) */
294 { USB_DEVICE(VENDOR_PHILIPS, 0x2093) }, 293 { USB_DEVICE(VENDOR_PHILIPS, 0x2093),
294 .driver_info = MCE_GEN2_TX_INV },
295 /* Realtek MCE IR Receiver and card reader */ 295 /* Realtek MCE IR Receiver and card reader */
296 { USB_DEVICE(VENDOR_REALTEK, 0x0161), 296 { USB_DEVICE(VENDOR_REALTEK, 0x0161),
297 .driver_info = MULTIFUNCTION }, 297 .driver_info = MULTIFUNCTION },
@@ -365,7 +365,8 @@ static struct usb_device_id mceusb_dev_table[] = {
365 /* Formosa Industrial Computing */ 365 /* Formosa Industrial Computing */
366 { USB_DEVICE(VENDOR_FORMOSA, 0xe042) }, 366 { USB_DEVICE(VENDOR_FORMOSA, 0xe042) },
367 /* Fintek eHome Infrared Transceiver (HP branded) */ 367 /* Fintek eHome Infrared Transceiver (HP branded) */
368 { USB_DEVICE(VENDOR_FINTEK, 0x5168) }, 368 { USB_DEVICE(VENDOR_FINTEK, 0x5168),
369 .driver_info = MCE_GEN2_TX_INV },
369 /* Fintek eHome Infrared Transceiver */ 370 /* Fintek eHome Infrared Transceiver */
370 { USB_DEVICE(VENDOR_FINTEK, 0x0602) }, 371 { USB_DEVICE(VENDOR_FINTEK, 0x0602) },
371 /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */ 372 /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */
@@ -788,19 +789,19 @@ static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size)
788static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) 789static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
789{ 790{
790 struct mceusb_dev *ir = dev->priv; 791 struct mceusb_dev *ir = dev->priv;
791 int i, ret = 0; 792 int i, length, ret = 0;
792 int cmdcount = 0; 793 int cmdcount = 0;
793 unsigned char *cmdbuf; /* MCE command buffer */ 794 unsigned char cmdbuf[MCE_CMDBUF_SIZE];
794
795 cmdbuf = kzalloc(sizeof(unsigned) * MCE_CMDBUF_SIZE, GFP_KERNEL);
796 if (!cmdbuf)
797 return -ENOMEM;
798 795
799 /* MCE tx init header */ 796 /* MCE tx init header */
800 cmdbuf[cmdcount++] = MCE_CMD_PORT_IR; 797 cmdbuf[cmdcount++] = MCE_CMD_PORT_IR;
801 cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS; 798 cmdbuf[cmdcount++] = MCE_CMD_SETIRTXPORTS;
802 cmdbuf[cmdcount++] = ir->tx_mask; 799 cmdbuf[cmdcount++] = ir->tx_mask;
803 800
801 /* Send the set TX ports command */
802 mce_async_out(ir, cmdbuf, cmdcount);
803 cmdcount = 0;
804
804 /* Generate mce packet data */ 805 /* Generate mce packet data */
805 for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) { 806 for (i = 0; (i < count) && (cmdcount < MCE_CMDBUF_SIZE); i++) {
806 txbuf[i] = txbuf[i] / MCE_TIME_UNIT; 807 txbuf[i] = txbuf[i] / MCE_TIME_UNIT;
@@ -809,8 +810,7 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
809 810
810 /* Insert mce packet header every 4th entry */ 811 /* Insert mce packet header every 4th entry */
811 if ((cmdcount < MCE_CMDBUF_SIZE) && 812 if ((cmdcount < MCE_CMDBUF_SIZE) &&
812 (cmdcount - MCE_TX_HEADER_LENGTH) % 813 (cmdcount % MCE_CODE_LENGTH) == 0)
813 MCE_CODE_LENGTH == 0)
814 cmdbuf[cmdcount++] = MCE_IRDATA_HEADER; 814 cmdbuf[cmdcount++] = MCE_IRDATA_HEADER;
815 815
816 /* Insert mce packet data */ 816 /* Insert mce packet data */
@@ -828,17 +828,16 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
828 (txbuf[i] -= MCE_MAX_PULSE_LENGTH)); 828 (txbuf[i] -= MCE_MAX_PULSE_LENGTH));
829 } 829 }
830 830
831 /* Fix packet length in last header */
832 cmdbuf[cmdcount - (cmdcount - MCE_TX_HEADER_LENGTH) % MCE_CODE_LENGTH] =
833 MCE_COMMAND_IRDATA + (cmdcount - MCE_TX_HEADER_LENGTH) %
834 MCE_CODE_LENGTH - 1;
835
836 /* Check if we have room for the empty packet at the end */ 831 /* Check if we have room for the empty packet at the end */
837 if (cmdcount >= MCE_CMDBUF_SIZE) { 832 if (cmdcount >= MCE_CMDBUF_SIZE) {
838 ret = -EINVAL; 833 ret = -EINVAL;
839 goto out; 834 goto out;
840 } 835 }
841 836
837 /* Fix packet length in last header */
838 length = cmdcount % MCE_CODE_LENGTH;
839 cmdbuf[cmdcount - length] -= MCE_CODE_LENGTH - length;
840
842 /* All mce commands end with an empty packet (0x80) */ 841 /* All mce commands end with an empty packet (0x80) */
843 cmdbuf[cmdcount++] = MCE_IRDATA_TRAILER; 842 cmdbuf[cmdcount++] = MCE_IRDATA_TRAILER;
844 843
@@ -846,7 +845,6 @@ static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
846 mce_async_out(ir, cmdbuf, cmdcount); 845 mce_async_out(ir, cmdbuf, cmdcount);
847 846
848out: 847out:
849 kfree(cmdbuf);
850 return ret ? ret : count; 848 return ret ? ret : count;
851} 849}
852 850
@@ -1121,16 +1119,13 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
1121 mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); 1119 mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
1122 1120
1123 kfree(data); 1121 kfree(data);
1124}; 1122}
1125 1123
1126static void mceusb_gen2_init(struct mceusb_dev *ir) 1124static void mceusb_gen2_init(struct mceusb_dev *ir)
1127{ 1125{
1128 /* device resume */ 1126 /* device resume */
1129 mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME)); 1127 mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME));
1130 1128
1131 /* get hw/sw revision? */
1132 mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
1133
1134 /* get wake version (protocol, key, address) */ 1129 /* get wake version (protocol, key, address) */
1135 mce_async_out(ir, GET_WAKEVERSION, sizeof(GET_WAKEVERSION)); 1130 mce_async_out(ir, GET_WAKEVERSION, sizeof(GET_WAKEVERSION));
1136 1131
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index b8aa9abb31ff..40125d779049 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -986,25 +986,25 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
986 /* input device for IR remote (and tx) */ 986 /* input device for IR remote (and tx) */
987 rdev = rc_allocate_device(); 987 rdev = rc_allocate_device();
988 if (!rdev) 988 if (!rdev)
989 goto failure; 989 goto exit_free_dev_rdev;
990 990
991 ret = -ENODEV; 991 ret = -ENODEV;
992 /* validate pnp resources */ 992 /* validate pnp resources */
993 if (!pnp_port_valid(pdev, 0) || 993 if (!pnp_port_valid(pdev, 0) ||
994 pnp_port_len(pdev, 0) < CIR_IOREG_LENGTH) { 994 pnp_port_len(pdev, 0) < CIR_IOREG_LENGTH) {
995 dev_err(&pdev->dev, "IR PNP Port not valid!\n"); 995 dev_err(&pdev->dev, "IR PNP Port not valid!\n");
996 goto failure; 996 goto exit_free_dev_rdev;
997 } 997 }
998 998
999 if (!pnp_irq_valid(pdev, 0)) { 999 if (!pnp_irq_valid(pdev, 0)) {
1000 dev_err(&pdev->dev, "PNP IRQ not valid!\n"); 1000 dev_err(&pdev->dev, "PNP IRQ not valid!\n");
1001 goto failure; 1001 goto exit_free_dev_rdev;
1002 } 1002 }
1003 1003
1004 if (!pnp_port_valid(pdev, 1) || 1004 if (!pnp_port_valid(pdev, 1) ||
1005 pnp_port_len(pdev, 1) < CIR_IOREG_LENGTH) { 1005 pnp_port_len(pdev, 1) < CIR_IOREG_LENGTH) {
1006 dev_err(&pdev->dev, "Wake PNP Port not valid!\n"); 1006 dev_err(&pdev->dev, "Wake PNP Port not valid!\n");
1007 goto failure; 1007 goto exit_free_dev_rdev;
1008 } 1008 }
1009 1009
1010 nvt->cir_addr = pnp_port_start(pdev, 0); 1010 nvt->cir_addr = pnp_port_start(pdev, 0);
@@ -1027,7 +1027,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1027 1027
1028 ret = nvt_hw_detect(nvt); 1028 ret = nvt_hw_detect(nvt);
1029 if (ret) 1029 if (ret)
1030 goto failure; 1030 goto exit_free_dev_rdev;
1031 1031
1032 /* Initialize CIR & CIR Wake Logical Devices */ 1032 /* Initialize CIR & CIR Wake Logical Devices */
1033 nvt_efm_enable(nvt); 1033 nvt_efm_enable(nvt);
@@ -1065,31 +1065,32 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1065 /* tx bits */ 1065 /* tx bits */
1066 rdev->tx_resolution = XYZ; 1066 rdev->tx_resolution = XYZ;
1067#endif 1067#endif
1068 nvt->rdev = rdev;
1069
1070 ret = rc_register_device(rdev);
1071 if (ret)
1072 goto exit_free_dev_rdev;
1068 1073
1069 ret = -EBUSY; 1074 ret = -EBUSY;
1070 /* now claim resources */ 1075 /* now claim resources */
1071 if (!request_region(nvt->cir_addr, 1076 if (!request_region(nvt->cir_addr,
1072 CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) 1077 CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
1073 goto failure; 1078 goto exit_unregister_device;
1074 1079
1075 if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED, 1080 if (request_irq(nvt->cir_irq, nvt_cir_isr, IRQF_SHARED,
1076 NVT_DRIVER_NAME, (void *)nvt)) 1081 NVT_DRIVER_NAME, (void *)nvt))
1077 goto failure2; 1082 goto exit_release_cir_addr;
1078 1083
1079 if (!request_region(nvt->cir_wake_addr, 1084 if (!request_region(nvt->cir_wake_addr,
1080 CIR_IOREG_LENGTH, NVT_DRIVER_NAME)) 1085 CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
1081 goto failure3; 1086 goto exit_free_irq;
1082 1087
1083 if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED, 1088 if (request_irq(nvt->cir_wake_irq, nvt_cir_wake_isr, IRQF_SHARED,
1084 NVT_DRIVER_NAME, (void *)nvt)) 1089 NVT_DRIVER_NAME, (void *)nvt))
1085 goto failure4; 1090 goto exit_release_cir_wake_addr;
1086
1087 ret = rc_register_device(rdev);
1088 if (ret)
1089 goto failure5;
1090 1091
1091 device_init_wakeup(&pdev->dev, true); 1092 device_init_wakeup(&pdev->dev, true);
1092 nvt->rdev = rdev; 1093
1093 nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n"); 1094 nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n");
1094 if (debug) { 1095 if (debug) {
1095 cir_dump_regs(nvt); 1096 cir_dump_regs(nvt);
@@ -1098,15 +1099,15 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1098 1099
1099 return 0; 1100 return 0;
1100 1101
1101failure5: 1102exit_release_cir_wake_addr:
1102 free_irq(nvt->cir_wake_irq, nvt);
1103failure4:
1104 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH); 1103 release_region(nvt->cir_wake_addr, CIR_IOREG_LENGTH);
1105failure3: 1104exit_free_irq:
1106 free_irq(nvt->cir_irq, nvt); 1105 free_irq(nvt->cir_irq, nvt);
1107failure2: 1106exit_release_cir_addr:
1108 release_region(nvt->cir_addr, CIR_IOREG_LENGTH); 1107 release_region(nvt->cir_addr, CIR_IOREG_LENGTH);
1109failure: 1108exit_unregister_device:
1109 rc_unregister_device(rdev);
1110exit_free_dev_rdev:
1110 rc_free_device(rdev); 1111 rc_free_device(rdev);
1111 kfree(nvt); 1112 kfree(nvt);
1112 1113
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 96f0a8bb39ea..5d87287ed372 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -165,56 +165,56 @@ void ir_raw_init(void);
165 165
166/* from ir-nec-decoder.c */ 166/* from ir-nec-decoder.c */
167#ifdef CONFIG_IR_NEC_DECODER_MODULE 167#ifdef CONFIG_IR_NEC_DECODER_MODULE
168#define load_nec_decode() request_module("ir-nec-decoder") 168#define load_nec_decode() request_module_nowait("ir-nec-decoder")
169#else 169#else
170static inline void load_nec_decode(void) { } 170static inline void load_nec_decode(void) { }
171#endif 171#endif
172 172
173/* from ir-rc5-decoder.c */ 173/* from ir-rc5-decoder.c */
174#ifdef CONFIG_IR_RC5_DECODER_MODULE 174#ifdef CONFIG_IR_RC5_DECODER_MODULE
175#define load_rc5_decode() request_module("ir-rc5-decoder") 175#define load_rc5_decode() request_module_nowait("ir-rc5-decoder")
176#else 176#else
177static inline void load_rc5_decode(void) { } 177static inline void load_rc5_decode(void) { }
178#endif 178#endif
179 179
180/* from ir-rc6-decoder.c */ 180/* from ir-rc6-decoder.c */
181#ifdef CONFIG_IR_RC6_DECODER_MODULE 181#ifdef CONFIG_IR_RC6_DECODER_MODULE
182#define load_rc6_decode() request_module("ir-rc6-decoder") 182#define load_rc6_decode() request_module_nowait("ir-rc6-decoder")
183#else 183#else
184static inline void load_rc6_decode(void) { } 184static inline void load_rc6_decode(void) { }
185#endif 185#endif
186 186
187/* from ir-jvc-decoder.c */ 187/* from ir-jvc-decoder.c */
188#ifdef CONFIG_IR_JVC_DECODER_MODULE 188#ifdef CONFIG_IR_JVC_DECODER_MODULE
189#define load_jvc_decode() request_module("ir-jvc-decoder") 189#define load_jvc_decode() request_module_nowait("ir-jvc-decoder")
190#else 190#else
191static inline void load_jvc_decode(void) { } 191static inline void load_jvc_decode(void) { }
192#endif 192#endif
193 193
194/* from ir-sony-decoder.c */ 194/* from ir-sony-decoder.c */
195#ifdef CONFIG_IR_SONY_DECODER_MODULE 195#ifdef CONFIG_IR_SONY_DECODER_MODULE
196#define load_sony_decode() request_module("ir-sony-decoder") 196#define load_sony_decode() request_module_nowait("ir-sony-decoder")
197#else 197#else
198static inline void load_sony_decode(void) { } 198static inline void load_sony_decode(void) { }
199#endif 199#endif
200 200
201/* from ir-sanyo-decoder.c */ 201/* from ir-sanyo-decoder.c */
202#ifdef CONFIG_IR_SANYO_DECODER_MODULE 202#ifdef CONFIG_IR_SANYO_DECODER_MODULE
203#define load_sanyo_decode() request_module("ir-sanyo-decoder") 203#define load_sanyo_decode() request_module_nowait("ir-sanyo-decoder")
204#else 204#else
205static inline void load_sanyo_decode(void) { } 205static inline void load_sanyo_decode(void) { }
206#endif 206#endif
207 207
208/* from ir-mce_kbd-decoder.c */ 208/* from ir-mce_kbd-decoder.c */
209#ifdef CONFIG_IR_MCE_KBD_DECODER_MODULE 209#ifdef CONFIG_IR_MCE_KBD_DECODER_MODULE
210#define load_mce_kbd_decode() request_module("ir-mce_kbd-decoder") 210#define load_mce_kbd_decode() request_module_nowait("ir-mce_kbd-decoder")
211#else 211#else
212static inline void load_mce_kbd_decode(void) { } 212static inline void load_mce_kbd_decode(void) { }
213#endif 213#endif
214 214
215/* from ir-lirc-codec.c */ 215/* from ir-lirc-codec.c */
216#ifdef CONFIG_IR_LIRC_CODEC_MODULE 216#ifdef CONFIG_IR_LIRC_CODEC_MODULE
217#define load_lirc_codec() request_module("ir-lirc-codec") 217#define load_lirc_codec() request_module_nowait("ir-lirc-codec")
218#else 218#else
219static inline void load_lirc_codec(void) { } 219static inline void load_lirc_codec(void) { }
220#endif 220#endif
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 601d1ac1c688..759a40a42eaa 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -789,8 +789,10 @@ static ssize_t show_protocols(struct device *device,
789 } else if (dev->raw) { 789 } else if (dev->raw) {
790 enabled = dev->raw->enabled_protocols; 790 enabled = dev->raw->enabled_protocols;
791 allowed = ir_raw_get_allowed_protocols(); 791 allowed = ir_raw_get_allowed_protocols();
792 } else 792 } else {
793 mutex_unlock(&dev->lock);
793 return -ENODEV; 794 return -ENODEV;
795 }
794 796
795 IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n", 797 IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n",
796 (long long)allowed, 798 (long long)allowed,
@@ -890,7 +892,8 @@ static ssize_t store_protocols(struct device *device,
890 892
891 if (i == ARRAY_SIZE(proto_names)) { 893 if (i == ARRAY_SIZE(proto_names)) {
892 IR_dprintk(1, "Unknown protocol: '%s'\n", tmp); 894 IR_dprintk(1, "Unknown protocol: '%s'\n", tmp);
893 return -EINVAL; 895 ret = -EINVAL;
896 goto out;
894 } 897 }
895 898
896 count++; 899 count++;
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 1800326f93e6..1b37fe2779f8 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -195,9 +195,6 @@ struct redrat3_dev {
195 dma_addr_t dma_in; 195 dma_addr_t dma_in;
196 dma_addr_t dma_out; 196 dma_addr_t dma_out;
197 197
198 /* locks this structure */
199 struct mutex lock;
200
201 /* rx signal timeout timer */ 198 /* rx signal timeout timer */
202 struct timer_list rx_timeout; 199 struct timer_list rx_timeout;
203 u32 hw_timeout; 200 u32 hw_timeout;
@@ -922,8 +919,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
922 return -EAGAIN; 919 return -EAGAIN;
923 } 920 }
924 921
925 if (count > (RR3_DRIVER_MAXLENS * 2)) 922 count = min_t(unsigned, count, RR3_MAX_SIG_SIZE - RR3_TX_TRAILER_LEN);
926 return -EINVAL;
927 923
928 /* rr3 will disable rc detector on transmit */ 924 /* rr3 will disable rc detector on transmit */
929 rr3->det_enabled = false; 925 rr3->det_enabled = false;
@@ -936,24 +932,22 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
936 } 932 }
937 933
938 for (i = 0; i < count; i++) { 934 for (i = 0; i < count; i++) {
935 cur_sample_len = redrat3_us_to_len(txbuf[i]);
939 for (lencheck = 0; lencheck < curlencheck; lencheck++) { 936 for (lencheck = 0; lencheck < curlencheck; lencheck++) {
940 cur_sample_len = redrat3_us_to_len(txbuf[i]);
941 if (sample_lens[lencheck] == cur_sample_len) 937 if (sample_lens[lencheck] == cur_sample_len)
942 break; 938 break;
943 } 939 }
944 if (lencheck == curlencheck) { 940 if (lencheck == curlencheck) {
945 cur_sample_len = redrat3_us_to_len(txbuf[i]);
946 rr3_dbg(dev, "txbuf[%d]=%u, pos %d, enc %u\n", 941 rr3_dbg(dev, "txbuf[%d]=%u, pos %d, enc %u\n",
947 i, txbuf[i], curlencheck, cur_sample_len); 942 i, txbuf[i], curlencheck, cur_sample_len);
948 if (curlencheck < 255) { 943 if (curlencheck < RR3_DRIVER_MAXLENS) {
949 /* now convert the value to a proper 944 /* now convert the value to a proper
950 * rr3 value.. */ 945 * rr3 value.. */
951 sample_lens[curlencheck] = cur_sample_len; 946 sample_lens[curlencheck] = cur_sample_len;
952 curlencheck++; 947 curlencheck++;
953 } else { 948 } else {
954 dev_err(dev, "signal too long\n"); 949 count = i - 1;
955 ret = -EINVAL; 950 break;
956 goto out;
957 } 951 }
958 } 952 }
959 } 953 }
@@ -1087,6 +1081,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
1087 rc->tx_ir = redrat3_transmit_ir; 1081 rc->tx_ir = redrat3_transmit_ir;
1088 rc->s_tx_carrier = redrat3_set_tx_carrier; 1082 rc->s_tx_carrier = redrat3_set_tx_carrier;
1089 rc->driver_name = DRIVER_NAME; 1083 rc->driver_name = DRIVER_NAME;
1084 rc->rx_resolution = US_TO_NS(2);
1090 rc->map_name = RC_MAP_HAUPPAUGE; 1085 rc->map_name = RC_MAP_HAUPPAUGE;
1091 1086
1092 ret = rc_register_device(rc); 1087 ret = rc_register_device(rc);
@@ -1202,7 +1197,6 @@ static int redrat3_dev_probe(struct usb_interface *intf,
1202 rr3->bulk_out_buf, ep_out->wMaxPacketSize, 1197 rr3->bulk_out_buf, ep_out->wMaxPacketSize,
1203 (usb_complete_t)redrat3_write_bulk_callback, rr3); 1198 (usb_complete_t)redrat3_write_bulk_callback, rr3);
1204 1199
1205 mutex_init(&rr3->lock);
1206 rr3->udev = udev; 1200 rr3->udev = udev;
1207 1201
1208 redrat3_reset(rr3); 1202 redrat3_reset(rr3);
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index 78be8a914225..cf0d47f57fb2 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -213,19 +213,20 @@ static int ttusbir_probe(struct usb_interface *intf,
213 213
214 /* find the correct alt setting */ 214 /* find the correct alt setting */
215 for (i = 0; i < intf->num_altsetting && altsetting == -1; i++) { 215 for (i = 0; i < intf->num_altsetting && altsetting == -1; i++) {
216 int bulk_out_endp = -1, iso_in_endp = -1; 216 int max_packet, bulk_out_endp = -1, iso_in_endp = -1;
217 217
218 idesc = &intf->altsetting[i].desc; 218 idesc = &intf->altsetting[i].desc;
219 219
220 for (j = 0; j < idesc->bNumEndpoints; j++) { 220 for (j = 0; j < idesc->bNumEndpoints; j++) {
221 desc = &intf->altsetting[i].endpoint[j].desc; 221 desc = &intf->altsetting[i].endpoint[j].desc;
222 max_packet = le16_to_cpu(desc->wMaxPacketSize);
222 if (usb_endpoint_dir_in(desc) && 223 if (usb_endpoint_dir_in(desc) &&
223 usb_endpoint_xfer_isoc(desc) && 224 usb_endpoint_xfer_isoc(desc) &&
224 desc->wMaxPacketSize == 0x10) 225 max_packet == 0x10)
225 iso_in_endp = j; 226 iso_in_endp = j;
226 else if (usb_endpoint_dir_out(desc) && 227 else if (usb_endpoint_dir_out(desc) &&
227 usb_endpoint_xfer_bulk(desc) && 228 usb_endpoint_xfer_bulk(desc) &&
228 desc->wMaxPacketSize == 0x20) 229 max_packet == 0x20)
229 bulk_out_endp = j; 230 bulk_out_endp = j;
230 231
231 if (bulk_out_endp != -1 && iso_in_endp != -1) { 232 if (bulk_out_endp != -1 && iso_in_endp != -1) {
@@ -408,9 +409,8 @@ static int ttusbir_resume(struct usb_interface *intf)
408 struct ttusbir *tt = usb_get_intfdata(intf); 409 struct ttusbir *tt = usb_get_intfdata(intf);
409 int i, rc; 410 int i, rc;
410 411
411 led_classdev_resume(&tt->led);
412 tt->is_led_on = true; 412 tt->is_led_on = true;
413 ttusbir_set_led(tt); 413 led_classdev_resume(&tt->led);
414 414
415 for (i = 0; i < NUM_URBS; i++) { 415 for (i = 0; i < NUM_URBS; i++) {
416 rc = usb_submit_urb(tt->urb[i], GFP_KERNEL); 416 rc = usb_submit_urb(tt->urb[i], GFP_KERNEL);
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 930c61499037..535a18dccbd0 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -154,6 +154,8 @@
154#define WBCIR_CNTR_R 0x02 154#define WBCIR_CNTR_R 0x02
155/* Invert TX */ 155/* Invert TX */
156#define WBCIR_IRTX_INV 0x04 156#define WBCIR_IRTX_INV 0x04
157/* Receiver oversampling */
158#define WBCIR_RX_T_OV 0x40
157 159
158/* Valid banks for the SP3 UART */ 160/* Valid banks for the SP3 UART */
159enum wbcir_bank { 161enum wbcir_bank {
@@ -394,7 +396,8 @@ wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device)
394 if (data->rxstate == WBCIR_RXSTATE_ERROR) 396 if (data->rxstate == WBCIR_RXSTATE_ERROR)
395 continue; 397 continue;
396 398
397 duration = ((irdata & 0x7F) + 1) * 2; 399 duration = ((irdata & 0x7F) + 1) *
400 (data->carrier_report_enabled ? 2 : 10);
398 rawir.pulse = irdata & 0x80 ? false : true; 401 rawir.pulse = irdata & 0x80 ? false : true;
399 rawir.duration = US_TO_NS(duration); 402 rawir.duration = US_TO_NS(duration);
400 403
@@ -550,6 +553,17 @@ wbcir_set_carrier_report(struct rc_dev *dev, int enable)
550 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL, 553 wbcir_set_bits(data->ebase + WBCIR_REG_ECEIR_CCTL,
551 WBCIR_CNTR_EN, WBCIR_CNTR_EN | WBCIR_CNTR_R); 554 WBCIR_CNTR_EN, WBCIR_CNTR_EN | WBCIR_CNTR_R);
552 555
556 /* Set a higher sampling resolution if carrier reports are enabled */
557 wbcir_select_bank(data, WBCIR_BANK_2);
558 data->dev->rx_resolution = US_TO_NS(enable ? 2 : 10);
559 outb(enable ? 0x03 : 0x0f, data->sbase + WBCIR_REG_SP3_BGDL);
560 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
561
562 /* Enable oversampling if carrier reports are enabled */
563 wbcir_select_bank(data, WBCIR_BANK_7);
564 wbcir_set_bits(data->sbase + WBCIR_REG_SP3_RCCFG,
565 enable ? WBCIR_RX_T_OV : 0, WBCIR_RX_T_OV);
566
553 data->carrier_report_enabled = enable; 567 data->carrier_report_enabled = enable;
554 spin_unlock_irqrestore(&data->spinlock, flags); 568 spin_unlock_irqrestore(&data->spinlock, flags);
555 569
@@ -931,8 +945,8 @@ wbcir_init_hw(struct wbcir_data *data)
931 /* prescaler 1.0, tx/rx fifo lvl 16 */ 945 /* prescaler 1.0, tx/rx fifo lvl 16 */
932 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2); 946 outb(0x30, data->sbase + WBCIR_REG_SP3_EXCR2);
933 947
934 /* Set baud divisor to sample every 2 ns */ 948 /* Set baud divisor to sample every 10 us */
935 outb(0x03, data->sbase + WBCIR_REG_SP3_BGDL); 949 outb(0x0f, data->sbase + WBCIR_REG_SP3_BGDL);
936 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH); 950 outb(0x00, data->sbase + WBCIR_REG_SP3_BGDH);
937 951
938 /* Set CEIR mode */ 952 /* Set CEIR mode */
@@ -941,12 +955,9 @@ wbcir_init_hw(struct wbcir_data *data)
941 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */ 955 inb(data->sbase + WBCIR_REG_SP3_LSR); /* Clear LSR */
942 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */ 956 inb(data->sbase + WBCIR_REG_SP3_MSR); /* Clear MSR */
943 957
944 /* 958 /* Disable RX demod, enable run-length enc/dec, set freq span */
945 * Disable RX demod, enable run-length enc/dec, set freq span and
946 * enable over-sampling
947 */
948 wbcir_select_bank(data, WBCIR_BANK_7); 959 wbcir_select_bank(data, WBCIR_BANK_7);
949 outb(0xd0, data->sbase + WBCIR_REG_SP3_RCCFG); 960 outb(0x90, data->sbase + WBCIR_REG_SP3_RCCFG);
950 961
951 /* Disable timer */ 962 /* Disable timer */
952 wbcir_select_bank(data, WBCIR_BANK_4); 963 wbcir_select_bank(data, WBCIR_BANK_4);
@@ -1093,11 +1104,15 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1093 data->dev->rx_resolution = US_TO_NS(2); 1104 data->dev->rx_resolution = US_TO_NS(2);
1094 data->dev->allowed_protos = RC_BIT_ALL; 1105 data->dev->allowed_protos = RC_BIT_ALL;
1095 1106
1107 err = rc_register_device(data->dev);
1108 if (err)
1109 goto exit_free_rc;
1110
1096 if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) { 1111 if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) {
1097 dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", 1112 dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
1098 data->wbase, data->wbase + WAKEUP_IOMEM_LEN - 1); 1113 data->wbase, data->wbase + WAKEUP_IOMEM_LEN - 1);
1099 err = -EBUSY; 1114 err = -EBUSY;
1100 goto exit_free_rc; 1115 goto exit_unregister_device;
1101 } 1116 }
1102 1117
1103 if (!request_region(data->ebase, EHFUNC_IOMEM_LEN, DRVNAME)) { 1118 if (!request_region(data->ebase, EHFUNC_IOMEM_LEN, DRVNAME)) {
@@ -1122,24 +1137,20 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1122 goto exit_release_sbase; 1137 goto exit_release_sbase;
1123 } 1138 }
1124 1139
1125 err = rc_register_device(data->dev);
1126 if (err)
1127 goto exit_free_irq;
1128
1129 device_init_wakeup(&device->dev, 1); 1140 device_init_wakeup(&device->dev, 1);
1130 1141
1131 wbcir_init_hw(data); 1142 wbcir_init_hw(data);
1132 1143
1133 return 0; 1144 return 0;
1134 1145
1135exit_free_irq:
1136 free_irq(data->irq, device);
1137exit_release_sbase: 1146exit_release_sbase:
1138 release_region(data->sbase, SP_IOMEM_LEN); 1147 release_region(data->sbase, SP_IOMEM_LEN);
1139exit_release_ebase: 1148exit_release_ebase:
1140 release_region(data->ebase, EHFUNC_IOMEM_LEN); 1149 release_region(data->ebase, EHFUNC_IOMEM_LEN);
1141exit_release_wbase: 1150exit_release_wbase:
1142 release_region(data->wbase, WAKEUP_IOMEM_LEN); 1151 release_region(data->wbase, WAKEUP_IOMEM_LEN);
1152exit_unregister_device:
1153 rc_unregister_device(data->dev);
1143exit_free_rc: 1154exit_free_rc:
1144 rc_free_device(data->dev); 1155 rc_free_device(data->dev);
1145exit_unregister_led: 1156exit_unregister_led: