Commit 2682b892 authored by Jiri Kosina's avatar Jiri Kosina

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
parents aaf4f13c 6f68f0ac
...@@ -2488,11 +2488,9 @@ static int hid_device_probe(struct device *dev) ...@@ -2488,11 +2488,9 @@ static int hid_device_probe(struct device *dev)
const struct hid_device_id *id; const struct hid_device_id *id;
int ret = 0; int ret = 0;
if (down_interruptible(&hdev->driver_lock))
return -EINTR;
if (down_interruptible(&hdev->driver_input_lock)) { if (down_interruptible(&hdev->driver_input_lock)) {
ret = -EINTR; ret = -EINTR;
goto unlock_driver_lock; goto end;
} }
hdev->io_started = false; hdev->io_started = false;
...@@ -2519,8 +2517,7 @@ static int hid_device_probe(struct device *dev) ...@@ -2519,8 +2517,7 @@ static int hid_device_probe(struct device *dev)
unlock: unlock:
if (!hdev->io_started) if (!hdev->io_started)
up(&hdev->driver_input_lock); up(&hdev->driver_input_lock);
unlock_driver_lock: end:
up(&hdev->driver_lock);
return ret; return ret;
} }
...@@ -2530,11 +2527,9 @@ static int hid_device_remove(struct device *dev) ...@@ -2530,11 +2527,9 @@ static int hid_device_remove(struct device *dev)
struct hid_driver *hdrv; struct hid_driver *hdrv;
int ret = 0; int ret = 0;
if (down_interruptible(&hdev->driver_lock))
return -EINTR;
if (down_interruptible(&hdev->driver_input_lock)) { if (down_interruptible(&hdev->driver_input_lock)) {
ret = -EINTR; ret = -EINTR;
goto unlock_driver_lock; goto end;
} }
hdev->io_started = false; hdev->io_started = false;
...@@ -2550,8 +2545,7 @@ static int hid_device_remove(struct device *dev) ...@@ -2550,8 +2545,7 @@ static int hid_device_remove(struct device *dev)
if (!hdev->io_started) if (!hdev->io_started)
up(&hdev->driver_input_lock); up(&hdev->driver_input_lock);
unlock_driver_lock: end:
up(&hdev->driver_lock);
return ret; return ret;
} }
...@@ -3009,7 +3003,6 @@ struct hid_device *hid_allocate_device(void) ...@@ -3009,7 +3003,6 @@ struct hid_device *hid_allocate_device(void)
init_waitqueue_head(&hdev->debug_wait); init_waitqueue_head(&hdev->debug_wait);
INIT_LIST_HEAD(&hdev->debug_list); INIT_LIST_HEAD(&hdev->debug_list);
spin_lock_init(&hdev->debug_list_lock); spin_lock_init(&hdev->debug_list_lock);
sema_init(&hdev->driver_lock, 1);
sema_init(&hdev->driver_input_lock, 1); sema_init(&hdev->driver_input_lock, 1);
mutex_init(&hdev->ll_open_lock); mutex_init(&hdev->ll_open_lock);
......
...@@ -526,7 +526,6 @@ struct hid_device { /* device report descriptor */ ...@@ -526,7 +526,6 @@ struct hid_device { /* device report descriptor */
struct hid_report_enum report_enum[HID_REPORT_TYPES]; struct hid_report_enum report_enum[HID_REPORT_TYPES];
struct work_struct led_work; /* delayed LED worker */ struct work_struct led_work; /* delayed LED worker */
struct semaphore driver_lock; /* protects the current driver, except during input */
struct semaphore driver_input_lock; /* protects the current driver */ struct semaphore driver_input_lock; /* protects the current driver */
struct device dev; /* device */ struct device dev; /* device */
struct hid_driver *driver; struct hid_driver *driver;
...@@ -553,7 +552,7 @@ struct hid_device { /* device report descriptor */ ...@@ -553,7 +552,7 @@ struct hid_device { /* device report descriptor */
unsigned int status; /* see STAT flags above */ unsigned int status; /* see STAT flags above */
unsigned claimed; /* Claimed by hidinput, hiddev? */ unsigned claimed; /* Claimed by hidinput, hiddev? */
unsigned quirks; /* Various quirks the device can pull on us */ unsigned quirks; /* Various quirks the device can pull on us */
bool io_started; /* Protected by driver_lock. If IO has started */ bool io_started; /* If IO has started */
struct list_head inputs; /* The list of inputs */ struct list_head inputs; /* The list of inputs */
void *hiddev; /* The hiddev structure */ void *hiddev; /* The hiddev structure */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment