diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-20 08:23:04 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-12-10 06:04:52 -0500 |
commit | b07b4783fb30dee8c542fc76ed8993108d46d6aa (patch) | |
tree | 0e57cc5887511b31e964299820a7adf37e6e45ae /drivers/media/dvb/dvb-usb/dvb-usb-remote.c | |
parent | ff67c614e23bf5a3c16968e2c42ab442121c4beb (diff) |
V4L/DVB (4854): Handle errors from input_register_device()
Also sprinkled some input_sync() throughout the code.
Acked-by: Ricardo Cerqueira <v4l@cerqueira.org>
Acked-by: Oliver Endriss <o.endriss@gmx.de>
Acked-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dvb-usb-remote.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-remote.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c index 794e4471561c..19ff5978bc91 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c | |||
@@ -90,7 +90,9 @@ schedule: | |||
90 | 90 | ||
91 | int dvb_usb_remote_init(struct dvb_usb_device *d) | 91 | int dvb_usb_remote_init(struct dvb_usb_device *d) |
92 | { | 92 | { |
93 | struct input_dev *input_dev; | ||
93 | int i; | 94 | int i; |
95 | int err; | ||
94 | 96 | ||
95 | if (d->props.rc_key_map == NULL || | 97 | if (d->props.rc_key_map == NULL || |
96 | d->props.rc_query == NULL || | 98 | d->props.rc_query == NULL || |
@@ -100,23 +102,24 @@ int dvb_usb_remote_init(struct dvb_usb_device *d) | |||
100 | usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); | 102 | usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); |
101 | strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys)); | 103 | strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys)); |
102 | 104 | ||
103 | d->rc_input_dev = input_allocate_device(); | 105 | input_dev = input_allocate_device(); |
104 | if (!d->rc_input_dev) | 106 | if (!input_dev) |
105 | return -ENOMEM; | 107 | return -ENOMEM; |
106 | 108 | ||
107 | d->rc_input_dev->evbit[0] = BIT(EV_KEY); | 109 | input_dev->evbit[0] = BIT(EV_KEY); |
108 | d->rc_input_dev->keycodesize = sizeof(unsigned char); | 110 | input_dev->keycodesize = sizeof(unsigned char); |
109 | d->rc_input_dev->keycodemax = KEY_MAX; | 111 | input_dev->keycodemax = KEY_MAX; |
110 | d->rc_input_dev->name = "IR-receiver inside an USB DVB receiver"; | 112 | input_dev->name = "IR-receiver inside an USB DVB receiver"; |
111 | d->rc_input_dev->phys = d->rc_phys; | 113 | input_dev->phys = d->rc_phys; |
112 | usb_to_input_id(d->udev, &d->rc_input_dev->id); | 114 | usb_to_input_id(d->udev, &input_dev->id); |
113 | d->rc_input_dev->cdev.dev = &d->udev->dev; | 115 | input_dev->cdev.dev = &d->udev->dev; |
114 | 116 | ||
115 | /* set the bits for the keys */ | 117 | /* set the bits for the keys */ |
116 | deb_rc("key map size: %d\n", d->props.rc_key_map_size); | 118 | deb_rc("key map size: %d\n", d->props.rc_key_map_size); |
117 | for (i = 0; i < d->props.rc_key_map_size; i++) { | 119 | for (i = 0; i < d->props.rc_key_map_size; i++) { |
118 | deb_rc("setting bit for event %d item %d\n",d->props.rc_key_map[i].event, i); | 120 | deb_rc("setting bit for event %d item %d\n", |
119 | set_bit(d->props.rc_key_map[i].event, d->rc_input_dev->keybit); | 121 | d->props.rc_key_map[i].event, i); |
122 | set_bit(d->props.rc_key_map[i].event, input_dev->keybit); | ||
120 | } | 123 | } |
121 | 124 | ||
122 | /* Start the remote-control polling. */ | 125 | /* Start the remote-control polling. */ |
@@ -124,10 +127,16 @@ int dvb_usb_remote_init(struct dvb_usb_device *d) | |||
124 | d->props.rc_interval = 100; /* default */ | 127 | d->props.rc_interval = 100; /* default */ |
125 | 128 | ||
126 | /* setting these two values to non-zero, we have to manage key repeats */ | 129 | /* setting these two values to non-zero, we have to manage key repeats */ |
127 | d->rc_input_dev->rep[REP_PERIOD] = d->props.rc_interval; | 130 | input_dev->rep[REP_PERIOD] = d->props.rc_interval; |
128 | d->rc_input_dev->rep[REP_DELAY] = d->props.rc_interval + 150; | 131 | input_dev->rep[REP_DELAY] = d->props.rc_interval + 150; |
129 | 132 | ||
130 | input_register_device(d->rc_input_dev); | 133 | err = input_register_device(input_dev); |
134 | if (err) { | ||
135 | input_free_device(input_dev); | ||
136 | return err; | ||
137 | } | ||
138 | |||
139 | d->rc_input_dev = input_dev; | ||
131 | 140 | ||
132 | INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control); | 141 | INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control); |
133 | 142 | ||