aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-08-11 05:34:53 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-12 12:49:44 -0400
commitcfc1b2a06f87f562da2ffb9f8d1ae4203d9bfbfa (patch)
treec256562f8ca82abfc1a80a19b7b7caaaefdee34b /drivers/media
parent820ddfa6ca87fc12bf202907b77f635df2098e66 (diff)
[media] radio-shark*: Call cancel_work_sync from disconnect rather then release
This removes the need for shark_led_work to take the v4l2 lock. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/radio/radio-shark.c13
-rw-r--r--drivers/media/radio/radio-shark2.c12
2 files changed, 4 insertions, 21 deletions
diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
index e35b8d938a30..1d76afa9e1b7 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -181,14 +181,6 @@ static void shark_led_work(struct work_struct *work)
181 container_of(work, struct shark_device, led_work); 181 container_of(work, struct shark_device, led_work);
182 int i, res, brightness, actual_len; 182 int i, res, brightness, actual_len;
183 183
184 /*
185 * We use the v4l2_dev lock and registered bit to ensure the device
186 * does not get unplugged and unreffed while we're running.
187 */
188 mutex_lock(&shark->tea.mutex);
189 if (!video_is_registered(&shark->tea.vd))
190 goto leave;
191
192 for (i = 0; i < 3; i++) { 184 for (i = 0; i < 3; i++) {
193 if (!test_and_clear_bit(i, &shark->brightness_new)) 185 if (!test_and_clear_bit(i, &shark->brightness_new))
194 continue; 186 continue;
@@ -208,8 +200,6 @@ static void shark_led_work(struct work_struct *work)
208 v4l2_err(&shark->v4l2_dev, "set LED %s error: %d\n", 200 v4l2_err(&shark->v4l2_dev, "set LED %s error: %d\n",
209 shark->led_names[i], res); 201 shark->led_names[i], res);
210 } 202 }
211leave:
212 mutex_unlock(&shark->tea.mutex);
213} 203}
214 204
215static void shark_led_set_blue(struct led_classdev *led_cdev, 205static void shark_led_set_blue(struct led_classdev *led_cdev,
@@ -259,6 +249,8 @@ static void usb_shark_disconnect(struct usb_interface *intf)
259 for (i = 0; i < NO_LEDS; i++) 249 for (i = 0; i < NO_LEDS; i++)
260 led_classdev_unregister(&shark->leds[i]); 250 led_classdev_unregister(&shark->leds[i]);
261 251
252 cancel_work_sync(&shark->led_work);
253
262 v4l2_device_put(&shark->v4l2_dev); 254 v4l2_device_put(&shark->v4l2_dev);
263} 255}
264 256
@@ -266,7 +258,6 @@ static void usb_shark_release(struct v4l2_device *v4l2_dev)
266{ 258{
267 struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev); 259 struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev);
268 260
269 cancel_work_sync(&shark->led_work);
270 v4l2_device_unregister(&shark->v4l2_dev); 261 v4l2_device_unregister(&shark->v4l2_dev);
271 kfree(shark->transfer_buffer); 262 kfree(shark->transfer_buffer);
272 kfree(shark); 263 kfree(shark);
diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
index fc0289d5da4e..217483ca1b18 100644
--- a/drivers/media/radio/radio-shark2.c
+++ b/drivers/media/radio/radio-shark2.c
@@ -166,13 +166,6 @@ static void shark_led_work(struct work_struct *work)
166 struct shark_device *shark = 166 struct shark_device *shark =
167 container_of(work, struct shark_device, led_work); 167 container_of(work, struct shark_device, led_work);
168 int i, res, brightness, actual_len; 168 int i, res, brightness, actual_len;
169 /*
170 * We use the v4l2_dev lock and registered bit to ensure the device
171 * does not get unplugged and unreffed while we're running.
172 */
173 mutex_lock(&shark->tea.mutex);
174 if (!video_is_registered(&shark->tea.vd))
175 goto leave;
176 169
177 for (i = 0; i < 2; i++) { 170 for (i = 0; i < 2; i++) {
178 if (!test_and_clear_bit(i, &shark->brightness_new)) 171 if (!test_and_clear_bit(i, &shark->brightness_new))
@@ -191,8 +184,6 @@ static void shark_led_work(struct work_struct *work)
191 v4l2_err(&shark->v4l2_dev, "set LED %s error: %d\n", 184 v4l2_err(&shark->v4l2_dev, "set LED %s error: %d\n",
192 shark->led_names[i], res); 185 shark->led_names[i], res);
193 } 186 }
194leave:
195 mutex_unlock(&shark->tea.mutex);
196} 187}
197 188
198static void shark_led_set_blue(struct led_classdev *led_cdev, 189static void shark_led_set_blue(struct led_classdev *led_cdev,
@@ -231,6 +222,8 @@ static void usb_shark_disconnect(struct usb_interface *intf)
231 for (i = 0; i < NO_LEDS; i++) 222 for (i = 0; i < NO_LEDS; i++)
232 led_classdev_unregister(&shark->leds[i]); 223 led_classdev_unregister(&shark->leds[i]);
233 224
225 cancel_work_sync(&shark->led_work);
226
234 v4l2_device_put(&shark->v4l2_dev); 227 v4l2_device_put(&shark->v4l2_dev);
235} 228}
236 229
@@ -238,7 +231,6 @@ static void usb_shark_release(struct v4l2_device *v4l2_dev)
238{ 231{
239 struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev); 232 struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev);
240 233
241 cancel_work_sync(&shark->led_work);
242 v4l2_device_unregister(&shark->v4l2_dev); 234 v4l2_device_unregister(&shark->v4l2_dev);
243 kfree(shark->transfer_buffer); 235 kfree(shark->transfer_buffer);
244 kfree(shark); 236 kfree(shark);