mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
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 <dmitry.torokhov@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
aaac082dac
commit
85ae911331
1 changed files with 9 additions and 23 deletions
|
@ -743,18 +743,12 @@ static int i2c_hid_open(struct hid_device *hid)
|
||||||
struct i2c_hid *ihid = i2c_get_clientdata(client);
|
struct i2c_hid *ihid = i2c_get_clientdata(client);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&i2c_hid_open_mut);
|
|
||||||
if (!hid->open++) {
|
|
||||||
ret = pm_runtime_get_sync(&client->dev);
|
ret = pm_runtime_get_sync(&client->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
hid->open--;
|
return ret;
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
set_bit(I2C_HID_STARTED, &ihid->flags);
|
set_bit(I2C_HID_STARTED, &ihid->flags);
|
||||||
}
|
return 0;
|
||||||
done:
|
|
||||||
mutex_unlock(&i2c_hid_open_mut);
|
|
||||||
return ret < 0 ? ret : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void i2c_hid_close(struct hid_device *hid)
|
static void i2c_hid_close(struct hid_device *hid)
|
||||||
|
@ -762,19 +756,11 @@ static void i2c_hid_close(struct hid_device *hid)
|
||||||
struct i2c_client *client = hid->driver_data;
|
struct i2c_client *client = hid->driver_data;
|
||||||
struct i2c_hid *ihid = i2c_get_clientdata(client);
|
struct i2c_hid *ihid = i2c_get_clientdata(client);
|
||||||
|
|
||||||
/* protecting hid->open to make sure we don't restart
|
|
||||||
* data acquistion due to a resumption we no longer
|
|
||||||
* care about
|
|
||||||
*/
|
|
||||||
mutex_lock(&i2c_hid_open_mut);
|
|
||||||
if (!--hid->open) {
|
|
||||||
clear_bit(I2C_HID_STARTED, &ihid->flags);
|
clear_bit(I2C_HID_STARTED, &ihid->flags);
|
||||||
|
|
||||||
/* Save some power */
|
/* Save some power */
|
||||||
pm_runtime_put(&client->dev);
|
pm_runtime_put(&client->dev);
|
||||||
}
|
}
|
||||||
mutex_unlock(&i2c_hid_open_mut);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int i2c_hid_power(struct hid_device *hid, int lvl)
|
static int i2c_hid_power(struct hid_device *hid, int lvl)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue