Skip to content

Commit 85ae911

Browse files
dtorJiri Kosina
authored andcommitted
HID: i2c-hid: remove custom locking from i2c_hid_open/close
Now that HID core enforces serialization of transport driver open/close calls we can remove custom locking from i2c-hid driver. Signed-off-by: Dmitry Torokhov <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent aaac082 commit 85ae911

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

drivers/hid/i2c-hid/i2c-hid.c

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -743,37 +743,23 @@ static int i2c_hid_open(struct hid_device *hid)
743743
struct i2c_hid *ihid = i2c_get_clientdata(client);
744744
int ret = 0;
745745

746-
mutex_lock(&i2c_hid_open_mut);
747-
if (!hid->open++) {
748-
ret = pm_runtime_get_sync(&client->dev);
749-
if (ret < 0) {
750-
hid->open--;
751-
goto done;
752-
}
753-
set_bit(I2C_HID_STARTED, &ihid->flags);
754-
}
755-
done:
756-
mutex_unlock(&i2c_hid_open_mut);
757-
return ret < 0 ? ret : 0;
746+
ret = pm_runtime_get_sync(&client->dev);
747+
if (ret < 0)
748+
return ret;
749+
750+
set_bit(I2C_HID_STARTED, &ihid->flags);
751+
return 0;
758752
}
759753

760754
static void i2c_hid_close(struct hid_device *hid)
761755
{
762756
struct i2c_client *client = hid->driver_data;
763757
struct i2c_hid *ihid = i2c_get_clientdata(client);
764758

765-
/* protecting hid->open to make sure we don't restart
766-
* data acquistion due to a resumption we no longer
767-
* care about
768-
*/
769-
mutex_lock(&i2c_hid_open_mut);
770-
if (!--hid->open) {
771-
clear_bit(I2C_HID_STARTED, &ihid->flags);
759+
clear_bit(I2C_HID_STARTED, &ihid->flags);
772760

773-
/* Save some power */
774-
pm_runtime_put(&client->dev);
775-
}
776-
mutex_unlock(&i2c_hid_open_mut);
761+
/* Save some power */
762+
pm_runtime_put(&client->dev);
777763
}
778764

779765
static int i2c_hid_power(struct hid_device *hid, int lvl)

0 commit comments

Comments
 (0)