From: Oliver Neukum <oneukum@suse.de>
To: Tatsunosuke Tobita <junkpainting@gmail.com>
Cc: linux-input@vger.kernel.org,
Tatsunosuke Tobita <tobita.tatsunosuke@wacom.co.jp>
Subject: Re: [PATCH] input:Adding support for Wacom Stylus with I2c interface
Date: Tue, 4 Oct 2011 09:53:04 +0200 [thread overview]
Message-ID: <201110040953.04734.oneukum@suse.de> (raw)
In-Reply-To: <1317714263-9851-1-git-send-email-tobita.tatsunosuke@wacom.co.jp>
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
next prev parent reply other threads:[~2011-10-04 7:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-04 7:44 [PATCH] input:Adding support for Wacom Stylus with I2c interface Tatsunosuke Tobita
2011-10-04 7:53 ` Oliver Neukum [this message]
[not found] ` <4e8abadb.680f440a.2b3a.7fbbSMTPIN_ADDED@mx.google.com>
2011-10-04 16:23 ` Chris Bagwell
2011-10-05 7:10 ` Dmitry Torokhov
[not found] ` <4e8ee2bf.a808440a.3441.ffffc8e5SMTPIN_ADDED@mx.google.com>
2011-10-07 16:48 ` Dmitry Torokhov
-- strict thread matches above, loose matches on Subject: below --
2011-10-03 8:27 [PATCH] Input:Adding support for Wacom Stylus with I2C interface Tatsunosuke Tobita
2011-10-03 20:16 ` Chris Bagwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201110040953.04734.oneukum@suse.de \
--to=oneukum@suse.de \
--cc=junkpainting@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=tobita.tatsunosuke@wacom.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).