linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fixed segfault in Invensens MPU driver
@ 2014-04-25 10:18 Atilla Filiz
  2014-04-26 10:18 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Atilla Filiz @ 2014-04-25 10:18 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, linux-kernel


Hello

I found the Invensense MPU6050 driver is not Device-Tree compatible, so I
fixed it. I willl appreciate if you CC your comments to myself.

Regards
Atilla

>From 69995b31f67727e3b9605c494beaeeefd1aa1cd4 Mon Sep 17 00:00:00 2001
From: Atilla Filiz <atilla.filiz@essensium.com>
Date: Fri, 11 Apr 2014 16:51:23 +0200
Subject: [PATCH] Fixed segfault in Invensens MPU driver

The driver used to segfault when the kernel boots
vith device tree

Signed-off-by: Atilla Filiz <atilla.filiz@essensium.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 37ca05b..3c2ef2e 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -660,6 +660,7 @@ static int inv_mpu_probe(struct i2c_client *client,
 {
 	struct inv_mpu6050_state *st;
 	struct iio_dev *indio_dev;
+	struct inv_mpu6050_platform_data *pdata;
 	int result;

 	if (!i2c_check_functionality(client->adapter,
@@ -675,8 +676,10 @@ static int inv_mpu_probe(struct i2c_client *client,
 	}
 	st = iio_priv(indio_dev);
 	st->client = client;
-	st->plat_data = *(struct inv_mpu6050_platform_data
-				*)dev_get_platdata(&client->dev);
+	pdata = (struct inv_mpu6050_platform_data
+			*)dev_get_platdata(&client->dev);
+	if (pdata)
+		st->plat_data = *pdata;
 	/* power is turned on inside check chip type*/
 	result = inv_check_and_setup_chip(st, id);
 	if (result)
--
1.8.1.2

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

* Re: [PATCH] Fixed segfault in Invensens MPU driver
  2014-04-25 10:18 [PATCH] Fixed segfault in Invensens MPU driver Atilla Filiz
@ 2014-04-26 10:18 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2014-04-26 10:18 UTC (permalink / raw)
  To: Atilla Filiz, jic23; +Cc: linux-iio, linux-kernel

On 25/04/14 11:18, Atilla Filiz wrote:
>
> Hello
>
> I found the Invensense MPU6050 driver is not Device-Tree compatible, so I
> fixed it. I willl appreciate if you CC your comments to myself.
>
> Regards
> Atilla
Hi Atilla,

Please send patches 'bare'.  If you want to add comments then they
go below the --- as then git am will ignore them.  If the comments are more
involved (or apply to a set of patches) then add a cover letter.  That way
you save me (or whoever else) 30 seconds of editing the patch before applying
it!
>
>  From 69995b31f67727e3b9605c494beaeeefd1aa1cd4 Mon Sep 17 00:00:00 2001
> From: Atilla Filiz <atilla.filiz@essensium.com>
> Date: Fri, 11 Apr 2014 16:51:23 +0200
> Subject: [PATCH] Fixed segfault in Invensens MPU driver
Please match the naming convention used in the area of the kernel to which
the patch is being applied.
>
> The driver used to segfault when the kernel boots
> vith device tree
>
> Signed-off-by: Atilla Filiz <atilla.filiz@essensium.com>
Applied with some edits to the patch description to the fixes-togreg branch of
iio.git.  I'll send this on to Greg fairly shortly.  I've also marked it for
stable so that we get this fix out to slightly older kernels.

Good find, thanks.

Jonathan
> ---
>   drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 37ca05b..3c2ef2e 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -660,6 +660,7 @@ static int inv_mpu_probe(struct i2c_client *client,
>   {
>   	struct inv_mpu6050_state *st;
>   	struct iio_dev *indio_dev;
> +	struct inv_mpu6050_platform_data *pdata;
>   	int result;
>
>   	if (!i2c_check_functionality(client->adapter,
> @@ -675,8 +676,10 @@ static int inv_mpu_probe(struct i2c_client *client,
>   	}
>   	st = iio_priv(indio_dev);
>   	st->client = client;
> -	st->plat_data = *(struct inv_mpu6050_platform_data
> -				*)dev_get_platdata(&client->dev);
> +	pdata = (struct inv_mpu6050_platform_data
> +			*)dev_get_platdata(&client->dev);
> +	if (pdata)
> +		st->plat_data = *pdata;
>   	/* power is turned on inside check chip type*/
>   	result = inv_check_and_setup_chip(st, id);
>   	if (result)
> --
> 1.8.1.2
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

end of thread, other threads:[~2014-04-26 10:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-25 10:18 [PATCH] Fixed segfault in Invensens MPU driver Atilla Filiz
2014-04-26 10:18 ` 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).