Skip to content

Commit cfc1b2a

Browse files
jwrdegoedeMauro Carvalho Chehab
authored andcommitted
[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 <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 820ddfa commit cfc1b2a

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

drivers/media/radio/radio-shark.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,6 @@ static void shark_led_work(struct work_struct *work)
181181
container_of(work, struct shark_device, led_work);
182182
int i, res, brightness, actual_len;
183183

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-
192184
for (i = 0; i < 3; i++) {
193185
if (!test_and_clear_bit(i, &shark->brightness_new))
194186
continue;
@@ -208,8 +200,6 @@ static void shark_led_work(struct work_struct *work)
208200
v4l2_err(&shark->v4l2_dev, "set LED %s error: %d\n",
209201
shark->led_names[i], res);
210202
}
211-
leave:
212-
mutex_unlock(&shark->tea.mutex);
213203
}
214204

215205
static void shark_led_set_blue(struct led_classdev *led_cdev,
@@ -259,14 +249,15 @@ static void usb_shark_disconnect(struct usb_interface *intf)
259249
for (i = 0; i < NO_LEDS; i++)
260250
led_classdev_unregister(&shark->leds[i]);
261251

252+
cancel_work_sync(&shark->led_work);
253+
262254
v4l2_device_put(&shark->v4l2_dev);
263255
}
264256

265257
static void usb_shark_release(struct v4l2_device *v4l2_dev)
266258
{
267259
struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev);
268260

269-
cancel_work_sync(&shark->led_work);
270261
v4l2_device_unregister(&shark->v4l2_dev);
271262
kfree(shark->transfer_buffer);
272263
kfree(shark);

drivers/media/radio/radio-shark2.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,6 @@ static void shark_led_work(struct work_struct *work)
166166
struct shark_device *shark =
167167
container_of(work, struct shark_device, led_work);
168168
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;
176169

177170
for (i = 0; i < 2; i++) {
178171
if (!test_and_clear_bit(i, &shark->brightness_new))
@@ -191,8 +184,6 @@ static void shark_led_work(struct work_struct *work)
191184
v4l2_err(&shark->v4l2_dev, "set LED %s error: %d\n",
192185
shark->led_names[i], res);
193186
}
194-
leave:
195-
mutex_unlock(&shark->tea.mutex);
196187
}
197188

198189
static void shark_led_set_blue(struct led_classdev *led_cdev,
@@ -231,14 +222,15 @@ static void usb_shark_disconnect(struct usb_interface *intf)
231222
for (i = 0; i < NO_LEDS; i++)
232223
led_classdev_unregister(&shark->leds[i]);
233224

225+
cancel_work_sync(&shark->led_work);
226+
234227
v4l2_device_put(&shark->v4l2_dev);
235228
}
236229

237230
static void usb_shark_release(struct v4l2_device *v4l2_dev)
238231
{
239232
struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev);
240233

241-
cancel_work_sync(&shark->led_work);
242234
v4l2_device_unregister(&shark->v4l2_dev);
243235
kfree(shark->transfer_buffer);
244236
kfree(shark);

0 commit comments

Comments
 (0)