linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: accel: mxc6255: Fix chip-id check
@ 2016-09-11 16:29 Hans de Goede
  2016-09-12 19:19 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2016-09-11 16:29 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: linux-iio, Hans de Goede

The initial commit adding support for the mxc6225 assumed the
mxc6225 has a chip-id of 0xe5 based on testing on a single Allwinner
A23 tablet with a mxc6225. Testing on a bunch of other Allwinner
tablets have shown that the chip-id for the mxc6225 is not constant.

A datasheet for the MXC6255 which I've found online says that bits
7 and 6 of the chip-id register are undefined (for the mxc6255), testing
on 5 different tablets with a mxc6225 has found the following ids:
0x25, 0x45, 0x65, 0x85, 0xe5. So it seems that for the mxc6225 bits
7, 6 and 5 of the chip-id register are undefined.

This commit adjusts the chip-id check so that the mxc6255 driver
properly recognizes the mxc6225 in all these tablets.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/mxc6255.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c
index 50343a7..0abad69 100644
--- a/drivers/iio/accel/mxc6255.c
+++ b/drivers/iio/accel/mxc6255.c
@@ -26,7 +26,6 @@
 #define MXC6255_REG_YOUT		0x01
 #define MXC6255_REG_CHIP_ID		0x08
 
-#define MXC6225_CHIP_ID			0xe5
 #define MXC6255_CHIP_ID			0x05
 
 /*
@@ -155,11 +154,7 @@ static int mxc6255_probe(struct i2c_client *client,
 		return ret;
 	}
 
-	switch (chip_id) {
-	case MXC6225_CHIP_ID:
-	case MXC6255_CHIP_ID:
-		break;
-	default:
+	if ((chip_id & 0x1f) != MXC6255_CHIP_ID) {
 		dev_err(&client->dev, "Invalid chip id %x\n", chip_id);
 		return -ENODEV;
 	}
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: accel: mxc6255: Fix chip-id check
  2016-09-11 16:29 [PATCH] iio: accel: mxc6255: Fix chip-id check Hans de Goede
@ 2016-09-12 19:19 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2016-09-12 19:19 UTC (permalink / raw)
  To: Hans de Goede, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: linux-iio

On 11/09/16 17:29, Hans de Goede wrote:
> The initial commit adding support for the mxc6225 assumed the
> mxc6225 has a chip-id of 0xe5 based on testing on a single Allwinner
> A23 tablet with a mxc6225. Testing on a bunch of other Allwinner
> tablets have shown that the chip-id for the mxc6225 is not constant.
> 
> A datasheet for the MXC6255 which I've found online says that bits
> 7 and 6 of the chip-id register are undefined (for the mxc6255), testing
> on 5 different tablets with a mxc6225 has found the following ids:
> 0x25, 0x45, 0x65, 0x85, 0xe5. So it seems that for the mxc6225 bits
> 7, 6 and 5 of the chip-id register are undefined.
> 
> This commit adjusts the chip-id check so that the mxc6255 driver
> properly recognizes the mxc6225 in all these tablets.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
As this is trivial I'll slip it in late for the pull request I'm
just doing.

Applied to the togreg branch of iio.git.

Thanks,

Jonathan
> ---
>  drivers/iio/accel/mxc6255.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c
> index 50343a7..0abad69 100644
> --- a/drivers/iio/accel/mxc6255.c
> +++ b/drivers/iio/accel/mxc6255.c
> @@ -26,7 +26,6 @@
>  #define MXC6255_REG_YOUT		0x01
>  #define MXC6255_REG_CHIP_ID		0x08
>  
> -#define MXC6225_CHIP_ID			0xe5
>  #define MXC6255_CHIP_ID			0x05
>  
>  /*
> @@ -155,11 +154,7 @@ static int mxc6255_probe(struct i2c_client *client,
>  		return ret;
>  	}
>  
> -	switch (chip_id) {
> -	case MXC6225_CHIP_ID:
> -	case MXC6255_CHIP_ID:
> -		break;
> -	default:
> +	if ((chip_id & 0x1f) != MXC6255_CHIP_ID) {
>  		dev_err(&client->dev, "Invalid chip id %x\n", chip_id);
>  		return -ENODEV;
>  	}
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-12 19:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-11 16:29 [PATCH] iio: accel: mxc6255: Fix chip-id check Hans de Goede
2016-09-12 19:19 ` Jonathan Cameron

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).