From: Roel Kluin <12o3l@tiscali.nl>
To: bryan.wu@analog.com
Cc: dmitry.torokhov@gmail.com, linux-input@atrey.karlin.mff.cuni.cz,
linux-joystick@atrey.karlin.mff.cuni.cz,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH try #2] Input/Joystick Driver: add support AD7142 joystick driver
Date: Fri, 12 Oct 2007 11:14:03 +0200 [thread overview]
Message-ID: <470F3ADB.2000704@tiscali.nl> (raw)
In-Reply-To: <1192174727.6247.20.camel@roc-laptop>
Bryan Wu wrote:
> +static int ad7142_i2c_read(struct i2c_client *client, unsigned short offset,
> + unsigned short *data, unsigned int len)
> +{
> + int ret = -1;
> + int i;
> + u8 block_data[32];
> +
> + if (len < 1 && len > 16) {
you want || here
> + printk(KERN_ERR "AD7142: read data length error\n");
> + return ret;
> + }
> +
> + /* Do raw I2C, not smbus compatible */
> + block_data[0] = (offset & 0xFF00) >> 8;
> + block_data[1] = (offset & 0x00FF);
> +
> + ret = i2c_master_send(client, block_data, 2);
> + if (ret < 0) {
> + printk(KERN_ERR "AD7142: I2C read error\n");
> + return ret;
> + }
> +
> + ret = i2c_master_recv(client, block_data, len * 2);
> + if (ret < 0) {
> + printk(KERN_ERR "AD7142: I2C transfer error\n");
> + return ret;
> + }
> +
> + for (i = 0; i < len; i++) {
> + unsigned short temp;
> + temp = block_data[2 * i];
> + temp = (temp << 8) & 0xFF00;
> + *data++ = temp | block_data[2 * i + 1];
> + }
> +
> + return ret;
> +}
next prev parent reply other threads:[~2007-10-12 9:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 7:38 [PATCH try #2] Input/Joystick Driver: add support AD7142 joystick driver Bryan Wu
2007-10-12 7:51 ` Andrey Panin
2007-10-12 9:14 ` Roel Kluin [this message]
2007-10-12 14:49 ` Dmitry Torokhov
2007-10-12 15:39 ` Bryan Wu
2007-10-12 15:50 ` Dmitry Torokhov
2007-10-12 15:59 ` Bryan Wu
2007-10-12 16:14 ` Dmitry Torokhov
2007-10-12 16:41 ` Ahmed S. Darwish
2007-10-12 17:29 ` Dmitry Torokhov
2007-10-12 19:21 ` Ahmed S. Darwish
2007-10-12 20:23 ` Dmitry Torokhov
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=470F3ADB.2000704@tiscali.nl \
--to=12o3l@tiscali.nl \
--cc=akpm@linux-foundation.org \
--cc=bryan.wu@analog.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@atrey.karlin.mff.cuni.cz \
--cc=linux-joystick@atrey.karlin.mff.cuni.cz \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.