Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256821
b: refs/heads/master
c: 4d36e97
h: refs/heads/master
i:
  256819: af8d05e
v: v3
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jul 11, 2011
1 parent 7699a04 commit edc9820
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 672bc4e090c9a2c655c28f8295e981609a1b84ba
refs/heads/master: 4d36e9754f6b71870a476e84f418a864c2ddf77c
19 changes: 19 additions & 0 deletions trunk/drivers/hid/hid-wiimote.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* any later version.
*/

#include <linux/atomic.h>
#include <linux/device.h>
#include <linux/hid.h>
#include <linux/input.h>
Expand All @@ -20,19 +21,34 @@
#define WIIMOTE_NAME "Nintendo Wii Remote"

struct wiimote_data {
atomic_t ready;
struct hid_device *hdev;
struct input_dev *input;
};

static int wiimote_input_event(struct input_dev *dev, unsigned int type,
unsigned int code, int value)
{
struct wiimote_data *wdata = input_get_drvdata(dev);

if (!atomic_read(&wdata->ready))
return -EBUSY;
/* smp_rmb: Make sure wdata->xy is available when wdata->ready is 1 */
smp_rmb();

return 0;
}

static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
u8 *raw_data, int size)
{
struct wiimote_data *wdata = hid_get_drvdata(hdev);

if (!atomic_read(&wdata->ready))
return -EBUSY;
/* smp_rmb: Make sure wdata->xy is available when wdata->ready is 1 */
smp_rmb();

if (size < 1)
return -EINVAL;

Expand Down Expand Up @@ -103,6 +119,9 @@ static int wiimote_hid_probe(struct hid_device *hdev,
goto err_stop;
}

/* smp_wmb: Write wdata->xy first before wdata->ready is set to 1 */
smp_wmb();
atomic_set(&wdata->ready, 1);
hid_info(hdev, "New device registered\n");
return 0;

Expand Down

0 comments on commit edc9820

Please sign in to comment.