Skip to content

Commit 2682b89

Browse files
author
Jiri Kosina
committed
Merge branch 'for-4.14/driver-lock-removal' into for-linus
- Arnd pointed out that driver_lock semaphore is superfluous, as driver core already provides all the necessary concurency protection. Removal patch from Binoy Jayan
2 parents aaf4f13 + 6f68f0a commit 2682b89

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

drivers/hid/hid-core.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,11 +2488,9 @@ static int hid_device_probe(struct device *dev)
24882488
const struct hid_device_id *id;
24892489
int ret = 0;
24902490

2491-
if (down_interruptible(&hdev->driver_lock))
2492-
return -EINTR;
24932491
if (down_interruptible(&hdev->driver_input_lock)) {
24942492
ret = -EINTR;
2495-
goto unlock_driver_lock;
2493+
goto end;
24962494
}
24972495
hdev->io_started = false;
24982496

@@ -2519,8 +2517,7 @@ static int hid_device_probe(struct device *dev)
25192517
unlock:
25202518
if (!hdev->io_started)
25212519
up(&hdev->driver_input_lock);
2522-
unlock_driver_lock:
2523-
up(&hdev->driver_lock);
2520+
end:
25242521
return ret;
25252522
}
25262523

@@ -2530,11 +2527,9 @@ static int hid_device_remove(struct device *dev)
25302527
struct hid_driver *hdrv;
25312528
int ret = 0;
25322529

2533-
if (down_interruptible(&hdev->driver_lock))
2534-
return -EINTR;
25352530
if (down_interruptible(&hdev->driver_input_lock)) {
25362531
ret = -EINTR;
2537-
goto unlock_driver_lock;
2532+
goto end;
25382533
}
25392534
hdev->io_started = false;
25402535

@@ -2550,8 +2545,7 @@ static int hid_device_remove(struct device *dev)
25502545

25512546
if (!hdev->io_started)
25522547
up(&hdev->driver_input_lock);
2553-
unlock_driver_lock:
2554-
up(&hdev->driver_lock);
2548+
end:
25552549
return ret;
25562550
}
25572551

@@ -3009,7 +3003,6 @@ struct hid_device *hid_allocate_device(void)
30093003
init_waitqueue_head(&hdev->debug_wait);
30103004
INIT_LIST_HEAD(&hdev->debug_list);
30113005
spin_lock_init(&hdev->debug_list_lock);
3012-
sema_init(&hdev->driver_lock, 1);
30133006
sema_init(&hdev->driver_input_lock, 1);
30143007
mutex_init(&hdev->ll_open_lock);
30153008

include/linux/hid.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ struct hid_device { /* device report descriptor */
526526
struct hid_report_enum report_enum[HID_REPORT_TYPES];
527527
struct work_struct led_work; /* delayed LED worker */
528528

529-
struct semaphore driver_lock; /* protects the current driver, except during input */
530529
struct semaphore driver_input_lock; /* protects the current driver */
531530
struct device dev; /* device */
532531
struct hid_driver *driver;
@@ -553,7 +552,7 @@ struct hid_device { /* device report descriptor */
553552
unsigned int status; /* see STAT flags above */
554553
unsigned claimed; /* Claimed by hidinput, hiddev? */
555554
unsigned quirks; /* Various quirks the device can pull on us */
556-
bool io_started; /* Protected by driver_lock. If IO has started */
555+
bool io_started; /* If IO has started */
557556

558557
struct list_head inputs; /* The list of inputs */
559558
void *hiddev; /* The hiddev structure */

0 commit comments

Comments
 (0)