Thread (5 messages) flat view 5 messages, 2 authors, 2012-05-14

Re: [PATCH] input: Add MELFAS mms114 touchscreen driver

From: Henrik Rydberg <hidden>
Date: 2012-05-14 06:50:51

quoted
quoted
+struct mms114_data {
+	struct i2c_client	*client;
+	struct input_dev	*input_dev;
+	struct mutex		mutex;
Other similar drivers seem to get by with the input mutex.
This is the mutex for i2c synchronization, not for input.
Yes, but you have disable_irq()/enable_irq() for that.
quoted
quoted
+static int __mms114_read_reg(struct mms114_data *data, unsigned int reg,
+			     unsigned int len, u8 *val)
+{
+	struct i2c_client *client = data->client;
+	struct i2c_msg xfer;
+	u8 buf = reg&  0xff;
+	int ret;
+
+	if (reg == MMS114_MODE_CONTROL) {
+		dev_err(&client->dev, "No support to read mode control reg\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&data->mutex);
Looks like this mutex is malplaced. The function is called both from
interrupt context and from user-driven context.
This driver uses threaded irq, it is not interrupt context.
Interrupt-driven context, I meant to say. Technically, your code
works, but the pattern is unusual. The serialization is needed to
remove the race between a call initiated by the interrupt and a call
initiated by the user, coming in through suspend/resume. The standard
pattern for the latter is to turn interrupts off and wait for
interrupt completion, which you already do, then continue
execution. The effect is the same, without the mutex.
quoted
quoted
+	touchdata->strength = buf[5];
Does not seem to be used anywhere.
It seems to be used for pressure.
It is assigned a variable, but it is not reported to userland.
quoted
quoted
+static int mms114_suspend(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct mms114_data *data = i2c_get_clientdata(client);
+	struct mms114_touchdata *touchdata = data->touchdata;
+	int id;
+	int ret;
+
It would seem the mutex should be here instead.
Any reasons? I did not feel the mutex needs here.
Oh well, as long as suspend/resume is the only user intervention, and
because those are already serialized, then maybe so. Something to
revisit in the next patch version, I presume.

Thanks,
Henrik
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help