Skip to content

Commit d9d2401

Browse files
dtorJiri Kosina
authored andcommitted
greybus: hid: remove custom locking from gb_hid_open/close
Now that HID core enforces serialization of transport driver open/close calls we can remove custom locking from greybus hid driver. Signed-off-by: Dmitry Torokhov <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Viresh Kumar <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent e399396 commit d9d2401

File tree

1 file changed

+14
-29
lines changed
  • drivers/staging/greybus

1 file changed

+14
-29
lines changed

drivers/staging/greybus/hid.c

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ struct gb_hid {
3232
char *inbuf;
3333
};
3434

35-
static DEFINE_MUTEX(gb_hid_open_mutex);
36-
3735
/* Routines to get controller's information over greybus */
3836

3937
/* Operations performed on greybus */
@@ -346,41 +344,28 @@ static void gb_hid_stop(struct hid_device *hid)
346344
static int gb_hid_open(struct hid_device *hid)
347345
{
348346
struct gb_hid *ghid = hid->driver_data;
349-
int ret = 0;
350-
351-
mutex_lock(&gb_hid_open_mutex);
352-
if (!hid->open++) {
353-
ret = gb_hid_set_power(ghid, GB_HID_TYPE_PWR_ON);
354-
if (ret < 0)
355-
hid->open--;
356-
else
357-
set_bit(GB_HID_STARTED, &ghid->flags);
358-
}
359-
mutex_unlock(&gb_hid_open_mutex);
347+
int ret;
360348

361-
return ret;
349+
ret = gb_hid_set_power(ghid, GB_HID_TYPE_PWR_ON);
350+
if (ret < 0)
351+
return ret;
352+
353+
set_bit(GB_HID_STARTED, &ghid->flags);
354+
return 0;
362355
}
363356

364357
static void gb_hid_close(struct hid_device *hid)
365358
{
366359
struct gb_hid *ghid = hid->driver_data;
367360
int ret;
368361

369-
/*
370-
* Protecting hid->open to make sure we don't restart data acquistion
371-
* due to a resumption we no longer care about..
372-
*/
373-
mutex_lock(&gb_hid_open_mutex);
374-
if (!--hid->open) {
375-
clear_bit(GB_HID_STARTED, &ghid->flags);
376-
377-
/* Save some power */
378-
ret = gb_hid_set_power(ghid, GB_HID_TYPE_PWR_OFF);
379-
if (ret)
380-
dev_err(&ghid->connection->bundle->dev,
381-
"failed to power off (%d)\n", ret);
382-
}
383-
mutex_unlock(&gb_hid_open_mutex);
362+
clear_bit(GB_HID_STARTED, &ghid->flags);
363+
364+
/* Save some power */
365+
ret = gb_hid_set_power(ghid, GB_HID_TYPE_PWR_OFF);
366+
if (ret)
367+
dev_err(&ghid->connection->bundle->dev,
368+
"failed to power off (%d)\n", ret);
384369
}
385370

386371
static int gb_hid_power(struct hid_device *hid, int lvl)

0 commit comments

Comments
 (0)