Thread (3 messages) flat view 3 messages, 3 authors, 2011-10-05

Re: [PATCH] input:Adding support for Wacom Stylus with I2c interface

From: Oliver Neukum <hidden>
Date: 2011-10-04 07:52:56

Am Dienstag, 4. Oktober 2011, 09:44:23 schrieb Tatsunosuke Tobita:

Hi,
+static int wacom_i2c_probe(struct i2c_client *client,
+                          const struct i2c_device_id *id)
+{
+       struct wacom_i2c *wac_i2c;
+       int i, ret;
+       i = ret = 0;
+
+       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+               goto err2;
+
+       wac_i2c = kzalloc(sizeof(struct wacom_i2c), GFP_KERNEL);
+       wac_i2c->wac_feature = wacom_feature_EMR;
potentially following the NULL pointer
+
+       mutex_init(&wac_i2c->lock);
+
+       wac_i2c->dev = input_allocate_device();
+       if (wac_i2c == NULL || wac_i2c->dev == NULL)
+               goto fail;
You must test before you use
+       wacom_i2c_set_input_values(client, wac_i2c, wac_i2c->dev);
+
+       wac_i2c->client = client;
+
+       INIT_WORK(&wac_i2c->workq, wacom_i2c_workqueue);
+
+       ret = wacom_send_query(wac_i2c);
+       if (ret < 0)
+               goto err1;
+
+       wac_i2c->dev->id.version = wac_i2c->wac_feature.fw_version;
+       input_set_abs_params(wac_i2c->dev, ABS_X, 0,
+                            wac_i2c->wac_feature.x_max, 0, 0);
+       input_set_abs_params(wac_i2c->dev, ABS_Y, 0,
+                            wac_i2c->wac_feature.y_max, 0, 0);
+       input_set_abs_params(wac_i2c->dev, ABS_PRESSURE, 0,
+                            wac_i2c->wac_feature.pressure_max, 0, 0);
+       input_set_drvdata(wac_i2c->dev, wac_i2c);
+
+       i2c_set_clientdata(client, wac_i2c);
+       if (input_register_device(wac_i2c->dev))
+               goto err1;
+
+       hrtimer_init(&wac_i2c->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+       wac_i2c->timer.function = wacom_i2c_timer;
+       hrtimer_start(&wac_i2c->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
I think you want to initialize this before you register the input device to prevent
a race condition.
+       printk(KERN_INFO "WACOM_I2C_DIGITIZER: initialized and started \n");
+
+       return 0;
+
+ err2:
+       printk(KERN_ERR "wacom_i2c:No I2C functionality found\n");
+       return -ENODEV;
+
+ err1:
+       printk(KERN_ERR "wacom_i2c:err1 occured(num:%d)\n", ret);
+       input_free_device(wac_i2c->dev);
+       wac_i2c->dev = NULL;
+       return -EIO;
+
+ fail:
+       printk(KERN_ERR "wacom_i2c:fail occured\n");
+       return -ENOMEM;
+}
+
	Regards
		Oliver
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help