linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] MMC35240 magneto fixes
@ 2015-07-14 14:56 Daniel Baluta
  2015-07-14 14:56 ` [PATCH 1/3] iio: magnetometer: mmc35240: Fix crash in pm suspend Daniel Baluta
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Daniel Baluta @ 2015-07-14 14:56 UTC (permalink / raw)
  To: jic23
  Cc: daniel.baluta, viorel.suman, knaack.h, lars, pmeerw, linux-iio,
	linux-kernel

Found while testing with a compass Android app.

Jonathan, this is a follow up of the first patch in this series,
initially sent for review before merged window was closed:
See: https://lkml.org/lkml/2015/6/21/68

Daniel Baluta (2):
  iio: magnetometer: mmc35240: Fix crash in pm suspend
  iio: magnetometer: mmc35240: Fix SET/RESET mask

Viorel Suman (1):
  iio: magnetometer: mmc35240: fix SET/RESET sequence

 drivers/iio/magnetometer/mmc35240.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

-- 
1.9.1


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

* [PATCH 1/3] iio: magnetometer: mmc35240: Fix crash in pm suspend
  2015-07-14 14:56 [PATCH 0/3] MMC35240 magneto fixes Daniel Baluta
@ 2015-07-14 14:56 ` Daniel Baluta
  2015-07-19 10:49   ` Jonathan Cameron
  2015-07-14 14:56 ` [PATCH 2/3] iio: magnetometer: mmc35240: Fix SET/RESET mask Daniel Baluta
  2015-07-14 14:56 ` [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence Daniel Baluta
  2 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2015-07-14 14:56 UTC (permalink / raw)
  To: jic23
  Cc: daniel.baluta, viorel.suman, knaack.h, lars, pmeerw, linux-iio,
	linux-kernel

We must set i2c client private data at probe in order to
correctly retrieve it in pm suspend/resume, preventing
the following crash:

[ 321.790582] PM: Syncing filesystems ... done.
[ 322.364440] PM: Preparing system for mem sleep
[ 322.400047] PM: Entering mem sleep
[ 322.462178] BUG: unable to handle kernel NULL pointer dereference at 0000036c
[ 322.469119] IP: [<80e0b3d2>] mmc35240_suspend+0x12/0x30
[ 322.474291] *pdpt = 000000002fd6f001 *pde = 0000000000000000
[ 322.479967] Oops: 0000 1 PREEMPT SMP
[ 322.496516] task: a86d0df0 ti: a8766000 task.ti: a8766000
[ 322.570744] Call Trace:
[ 322.573217] [<80c0d2d1>] pm_generic_suspend+0x21/0x30
[ 322.578284] [<80d042ab>] i2c_device_pm_suspend+0x1b/0x30

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
---
 drivers/iio/magnetometer/mmc35240.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index 7a2ea71..e89b059 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -496,6 +496,7 @@ static int mmc35240_probe(struct i2c_client *client,
 	}
 
 	data = iio_priv(indio_dev);
+	i2c_set_clientdata(client, indio_dev);
 	data->client = client;
 	data->regmap = regmap;
 	data->res = MMC35240_16_BITS_SLOW;
-- 
1.9.1


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

* [PATCH 2/3] iio: magnetometer: mmc35240: Fix SET/RESET mask
  2015-07-14 14:56 [PATCH 0/3] MMC35240 magneto fixes Daniel Baluta
  2015-07-14 14:56 ` [PATCH 1/3] iio: magnetometer: mmc35240: Fix crash in pm suspend Daniel Baluta
@ 2015-07-14 14:56 ` Daniel Baluta
  2015-07-19 10:54   ` Jonathan Cameron
  2015-07-14 14:56 ` [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence Daniel Baluta
  2 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2015-07-14 14:56 UTC (permalink / raw)
  To: jic23
  Cc: daniel.baluta, viorel.suman, knaack.h, lars, pmeerw, linux-iio,
	linux-kernel

This fixes setting the SET/RESET bit in the REG_CTRL0
register.

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
---
 drivers/iio/magnetometer/mmc35240.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index e89b059..f4d7495 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -195,8 +195,8 @@ static int mmc35240_hw_set(struct mmc35240_data *data, bool set)
 		coil_bit = MMC35240_CTRL0_RESET_BIT;
 
 	return regmap_update_bits(data->regmap, MMC35240_REG_CTRL0,
-				  MMC35240_CTRL0_REFILL_BIT,
-				  coil_bit);
+				  coil_bit, coil_bit);
+
 }
 
 static int mmc35240_init(struct mmc35240_data *data)
-- 
1.9.1


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

* [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence
  2015-07-14 14:56 [PATCH 0/3] MMC35240 magneto fixes Daniel Baluta
  2015-07-14 14:56 ` [PATCH 1/3] iio: magnetometer: mmc35240: Fix crash in pm suspend Daniel Baluta
  2015-07-14 14:56 ` [PATCH 2/3] iio: magnetometer: mmc35240: Fix SET/RESET mask Daniel Baluta
@ 2015-07-14 14:56 ` Daniel Baluta
  2015-07-14 20:04   ` Jonathan Cameron
  2 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2015-07-14 14:56 UTC (permalink / raw)
  To: jic23
  Cc: daniel.baluta, viorel.suman, knaack.h, lars, pmeerw, linux-iio,
	linux-kernel

From: Viorel Suman <viorel.suman@intel.com>

The RESET operation invoked in the last instance will align
in the natural way all 3 axis and the chip top view.

Signed-off-by: Viorel Suman <viorel.suman@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
---
 drivers/iio/magnetometer/mmc35240.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index f4d7495..a53efd2 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -215,14 +215,15 @@ static int mmc35240_init(struct mmc35240_data *data)
 
 	/*
 	 * make sure we restore sensor characteristics, by doing
-	 * a RESET/SET sequence
+	 * a SET/RESET sequence, the axis polarity being naturally
+	 * aligned after RESET
 	 */
-	ret = mmc35240_hw_set(data, false);
+	ret = mmc35240_hw_set(data, true);
 	if (ret < 0)
 		return ret;
 	usleep_range(MMC53240_WAIT_SET_RESET, MMC53240_WAIT_SET_RESET + 1);
 
-	ret = mmc35240_hw_set(data, true);
+	ret = mmc35240_hw_set(data, false);
 	if (ret < 0)
 		return ret;
 
-- 
1.9.1


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

* Re: [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence
  2015-07-14 14:56 ` [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence Daniel Baluta
@ 2015-07-14 20:04   ` Jonathan Cameron
  2015-07-16 13:30     ` Daniel Baluta
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2015-07-14 20:04 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: viorel.suman, knaack.h, lars, pmeerw, linux-iio, linux-kernel



On 14 July 2015 15:56:54 BST, Daniel Baluta <daniel.baluta@intel.com> wrote:
>From: Viorel Suman <viorel.suman@intel.com>
>
>The RESET operation invoked in the last instance will align
>in the natural way all 3 axis and the chip top view.
What is the result of the bug?
Just trying to assess urgency of the patch!
>
>Signed-off-by: Viorel Suman <viorel.suman@intel.com>
>Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>---
> drivers/iio/magnetometer/mmc35240.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/iio/magnetometer/mmc35240.c
>b/drivers/iio/magnetometer/mmc35240.c
>index f4d7495..a53efd2 100644
>--- a/drivers/iio/magnetometer/mmc35240.c
>+++ b/drivers/iio/magnetometer/mmc35240.c
>@@ -215,14 +215,15 @@ static int mmc35240_init(struct mmc35240_data
>*data)
> 
> 	/*
> 	 * make sure we restore sensor characteristics, by doing
>-	 * a RESET/SET sequence
>+	 * a SET/RESET sequence, the axis polarity being naturally
>+	 * aligned after RESET
> 	 */
>-	ret = mmc35240_hw_set(data, false);
>+	ret = mmc35240_hw_set(data, true);
> 	if (ret < 0)
> 		return ret;
> 	usleep_range(MMC53240_WAIT_SET_RESET, MMC53240_WAIT_SET_RESET + 1);
> 
>-	ret = mmc35240_hw_set(data, true);
>+	ret = mmc35240_hw_set(data, false);
> 	if (ret < 0)
> 		return ret;
> 

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

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

* Re: [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence
  2015-07-14 20:04   ` Jonathan Cameron
@ 2015-07-16 13:30     ` Daniel Baluta
  2015-07-19 10:55       ` Jonathan Cameron
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2015-07-16 13:30 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Daniel Baluta, viorel.suman, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Linux Kernel Mailing List

On Tue, Jul 14, 2015 at 11:04 PM, Jonathan Cameron <jic23@kernel.org> wrote:
>
>
> On 14 July 2015 15:56:54 BST, Daniel Baluta <daniel.baluta@intel.com> wrote:
>>From: Viorel Suman <viorel.suman@intel.com>
>>
>>The RESET operation invoked in the last instance will align
>>in the natural way all 3 axis and the chip top view.
> What is the result of the bug?
> Just trying to assess urgency of the patch!

Compass app shows North and South switched. This can be corrected
from mounting matrix though.

Daniel.

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

* Re: [PATCH 1/3] iio: magnetometer: mmc35240: Fix crash in pm suspend
  2015-07-14 14:56 ` [PATCH 1/3] iio: magnetometer: mmc35240: Fix crash in pm suspend Daniel Baluta
@ 2015-07-19 10:49   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2015-07-19 10:49 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: viorel.suman, knaack.h, lars, pmeerw, linux-iio, linux-kernel

On 14/07/15 15:56, Daniel Baluta wrote:
> We must set i2c client private data at probe in order to
> correctly retrieve it in pm suspend/resume, preventing
> the following crash:
> 
> [ 321.790582] PM: Syncing filesystems ... done.
> [ 322.364440] PM: Preparing system for mem sleep
> [ 322.400047] PM: Entering mem sleep
> [ 322.462178] BUG: unable to handle kernel NULL pointer dereference at 0000036c
> [ 322.469119] IP: [<80e0b3d2>] mmc35240_suspend+0x12/0x30
> [ 322.474291] *pdpt = 000000002fd6f001 *pde = 0000000000000000
> [ 322.479967] Oops: 0000 1 PREEMPT SMP
> [ 322.496516] task: a86d0df0 ti: a8766000 task.ti: a8766000
> [ 322.570744] Call Trace:
> [ 322.573217] [<80c0d2d1>] pm_generic_suspend+0x21/0x30
> [ 322.578284] [<80d042ab>] i2c_device_pm_suspend+0x1b/0x30
> 
> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Applied to the fixes-togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/magnetometer/mmc35240.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
> index 7a2ea71..e89b059 100644
> --- a/drivers/iio/magnetometer/mmc35240.c
> +++ b/drivers/iio/magnetometer/mmc35240.c
> @@ -496,6 +496,7 @@ static int mmc35240_probe(struct i2c_client *client,
>  	}
>  
>  	data = iio_priv(indio_dev);
> +	i2c_set_clientdata(client, indio_dev);
>  	data->client = client;
>  	data->regmap = regmap;
>  	data->res = MMC35240_16_BITS_SLOW;
> 


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

* Re: [PATCH 2/3] iio: magnetometer: mmc35240: Fix SET/RESET mask
  2015-07-14 14:56 ` [PATCH 2/3] iio: magnetometer: mmc35240: Fix SET/RESET mask Daniel Baluta
@ 2015-07-19 10:54   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2015-07-19 10:54 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: viorel.suman, knaack.h, lars, pmeerw, linux-iio, linux-kernel

On 14/07/15 15:56, Daniel Baluta wrote:
> This fixes setting the SET/RESET bit in the REG_CTRL0
> register.
> 
> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Applied to the fixes-togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/magnetometer/mmc35240.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
> index e89b059..f4d7495 100644
> --- a/drivers/iio/magnetometer/mmc35240.c
> +++ b/drivers/iio/magnetometer/mmc35240.c
> @@ -195,8 +195,8 @@ static int mmc35240_hw_set(struct mmc35240_data *data, bool set)
>  		coil_bit = MMC35240_CTRL0_RESET_BIT;
>  
>  	return regmap_update_bits(data->regmap, MMC35240_REG_CTRL0,
> -				  MMC35240_CTRL0_REFILL_BIT,
> -				  coil_bit);
> +				  coil_bit, coil_bit);
> +
>  }
>  
>  static int mmc35240_init(struct mmc35240_data *data)
> 


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

* Re: [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence
  2015-07-16 13:30     ` Daniel Baluta
@ 2015-07-19 10:55       ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2015-07-19 10:55 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: viorel.suman, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald,
	linux-iio, Linux Kernel Mailing List

On 16/07/15 14:30, Daniel Baluta wrote:
> On Tue, Jul 14, 2015 at 11:04 PM, Jonathan Cameron <jic23@kernel.org> wrote:
>>
>>
>> On 14 July 2015 15:56:54 BST, Daniel Baluta <daniel.baluta@intel.com> wrote:
>>> From: Viorel Suman <viorel.suman@intel.com>
>>>
>>> The RESET operation invoked in the last instance will align
>>> in the natural way all 3 axis and the chip top view.
>> What is the result of the bug?
>> Just trying to assess urgency of the patch!
> 
> Compass app shows North and South switched. This can be corrected
> from mounting matrix though.
> 
Applied.
> Daniel.
> --
> 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] 9+ messages in thread

end of thread, other threads:[~2015-07-19 10:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 14:56 [PATCH 0/3] MMC35240 magneto fixes Daniel Baluta
2015-07-14 14:56 ` [PATCH 1/3] iio: magnetometer: mmc35240: Fix crash in pm suspend Daniel Baluta
2015-07-19 10:49   ` Jonathan Cameron
2015-07-14 14:56 ` [PATCH 2/3] iio: magnetometer: mmc35240: Fix SET/RESET mask Daniel Baluta
2015-07-19 10:54   ` Jonathan Cameron
2015-07-14 14:56 ` [PATCH 3/3] iio: magnetometer: mmc35240: fix SET/RESET sequence Daniel Baluta
2015-07-14 20:04   ` Jonathan Cameron
2015-07-16 13:30     ` Daniel Baluta
2015-07-19 10:55       ` 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).