From: "Éric Piel" <Eric.Piel@tremplin-utc.net>
To: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Cc: git@vger.kernel.org, Pavel Machek <pavel@suse.cz>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCHv2] lis3lv02d: support both one- and two-byte sensors
Date: Wed, 11 Feb 2009 00:46:24 +0100 [thread overview]
Message-ID: <499211D0.3090705@tremplin-utc.net> (raw)
In-Reply-To: <1234309249-13672-1-git-send-email-giuseppe.bilotta@gmail.com>
Giuseppe Bilotta schreef:
> Sensors responding with 0x3B to WHO_AM_I only have one data register per
> direction, thus returning a signed byte from the position which is
> occupied by the MSB in sensors responding with 0x3A.
>
> We support both kind of sensors by checking for the sensor type on init
> and defining appropriate data-access routines and sensor limits (for the
> joystick) depending on what we find.
>
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
> ---
>
> This is the other version of the patch, and it changes access to use the
> base address from the 8-bit, so the 16-bit routine is changed to access
> the PREVIOUS byte for the LSB.
>
> Choose whichever of the patches is deemed more correct 8-)
>
> Note that both patches are based off Linus tree, so I don't know how
> they cope with Pavel's "don't touch too much on init" one. I'll try to
> work out a patch on top of that too.
Yes, great, and this one looks even better than v1 :-)
However I'm not sure about the conversion between s8 and s16:
> +static s16 lis3lv02d_read_8(acpi_handle handle, int reg)
> +{
> + u8 lo;
> + adev.read(handle, reg, &lo);
> + return *((s8*)(&lo));
> +}
Does it really extend the sign to 16 bits? I would have written it this way:
+static s16 lis3lv02d_read_8(acpi_handle handle, int reg)
+{
+ s8 lo;
+ adev.read(handle, reg, &lo);
+ return (s16)lo;
+}
Doesn't it work better?
Eric
next prev parent reply other threads:[~2009-02-10 23:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-10 23:40 [PATCHv2] lis3lv02d: support both one- and two-byte sensors Giuseppe Bilotta
2009-02-10 23:46 ` Éric Piel [this message]
2009-02-10 23:51 ` Giuseppe Bilotta
2009-02-10 23:54 ` Éric Piel
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=499211D0.3090705@tremplin-utc.net \
--to=eric.piel@tremplin-utc.net \
--cc=git@vger.kernel.org \
--cc=giuseppe.bilotta@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
/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).