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
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 <[email protected]>
---
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
This fixes setting the SET/RESET bit in the REG_CTRL0
register.
Signed-off-by: Daniel Baluta <[email protected]>
---
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
From: Viorel Suman <[email protected]>
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 <[email protected]>
Signed-off-by: Daniel Baluta <[email protected]>
---
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
On 14 July 2015 15:56:54 BST, Daniel Baluta <[email protected]> wrote:
>From: Viorel Suman <[email protected]>
>
>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 <[email protected]>
>Signed-off-by: Daniel Baluta <[email protected]>
>---
> 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.
On Tue, Jul 14, 2015 at 11:04 PM, Jonathan Cameron <[email protected]> wrote:
>
>
> On 14 July 2015 15:56:54 BST, Daniel Baluta <[email protected]> wrote:
>>From: Viorel Suman <[email protected]>
>>
>>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.
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 <[email protected]>
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;
>
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 <[email protected]>
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)
>
On 16/07/15 14:30, Daniel Baluta wrote:
> On Tue, Jul 14, 2015 at 11:04 PM, Jonathan Cameron <[email protected]> wrote:
>>
>>
>> On 14 July 2015 15:56:54 BST, Daniel Baluta <[email protected]> wrote:
>>> From: Viorel Suman <[email protected]>
>>>
>>> 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>