From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Jon Hunter <jon-hunter@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
Tero Kristo <t-kristo@ti.com>
Subject: Re: [PATCH v2 09/11] mfd: twl-core: Collect global variables behind one private structure (global)
Date: Sat, 9 Feb 2013 06:50:49 +0100 [thread overview]
Message-ID: <5115E3B9.6090100@ti.com> (raw)
In-Reply-To: <51154A7A.2010709@ti.com>
On 02/08/2013 07:56 PM, Jon Hunter wrote:
>> /**
>> * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
>> * @mod_no: module number
>> @@ -322,16 +323,17 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
>> pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
>> return -EPERM;
>> }
>> - if (unlikely(!inuse)) {
>> + if (unlikely(!twl_priv->ready)) {
>
> This is causing the kernel to panic on all my omap2 boards when booting linux-next
> because twl_priv is not initialised yet.
Good catch.
I just wonder from where the twl_* call is coming on OMAP2. AFAIK the twl code
is for OMAP3/4, for OMAP2 Menelaus is the one which is used.
I'm currently working on to remove all those twl_* calls from random places in
the kernel so we will only access twl via the MFD stack.
>
>> pr_err("%s: not initialized\n", DRIVER_NAME);
>> return -EPERM;
>> }
>>
>> - sid = twl_map[mod_no].sid;
>> - twl = &twl_modules[sid];
>> + sid = twl_priv->twl_map[mod_no].sid;
>> + twl = &twl_priv->twl_modules[sid];
>>
>> - ret = regmap_bulk_write(twl->regmap, twl_map[mod_no].base + reg,
>> - value, num_bytes);
>> + ret = regmap_bulk_write(twl->regmap,
>> + twl_priv->twl_map[mod_no].base + reg, value,
>> + num_bytes);
>>
>> if (ret)
>> pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n",
>> @@ -360,16 +362,17 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
>> pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
>> return -EPERM;
>> }
>> - if (unlikely(!inuse)) {
>> + if (unlikely(!twl_priv->ready)) {
>
> Same problem here.
>
> Here is a fix ...
>
> From 141fcbbdee6bdc14d5a444ff20fad6b3440215dc Mon Sep 17 00:00:00 2001
> From: Jon Hunter <jon-hunter@ti.com>
> Date: Fri, 8 Feb 2013 12:42:20 -0600
> Subject: [PATCH] ARM: OMAP2+: Fix kernel panic on boot
>
> Commit 8a6aaa3 (mfd: twl-core: Collect global variables behind one
> private structure (global)) removed the variable "inuse" that is used
> to determine if the device has been initialised and now use the
> twl_priv structure instead. This is causing the kernel to panic on all
> OMAP2+ devices, because we try to access the twl_priv->ready member
> before checking if twl_priv is initialised. Fix this and move this test
> to the beginning of the twl_i2c_read/write function because
> twl_get_last_module() also uses the twl_priv structure.
>
> Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> drivers/mfd/twl-core.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 557f9ee..89ab4d9 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -316,12 +316,12 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
> int sid;
> struct twl_client *twl;
>
> - if (unlikely(mod_no >= twl_get_last_module())) {
> - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> + if (unlikely(!twl_priv || !twl_priv->ready)) {
> + pr_err("%s: not initialized\n", DRIVER_NAME);
> return -EPERM;
> }
> - if (unlikely(!twl_priv->ready)) {
> - pr_err("%s: not initialized\n", DRIVER_NAME);
> + if (unlikely(mod_no >= twl_get_last_module())) {
> + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> return -EPERM;
> }
>
> @@ -355,12 +355,12 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
> int sid;
> struct twl_client *twl;
>
> - if (unlikely(mod_no >= twl_get_last_module())) {
> - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> + if (unlikely(!twl_priv || !twl_priv->ready)) {
> + pr_err("%s: not initialized\n", DRIVER_NAME);
> return -EPERM;
> }
> - if (unlikely(!twl_priv->ready)) {
> - pr_err("%s: not initialized\n", DRIVER_NAME);
> + if (unlikely(mod_no >= twl_get_last_module())) {
> + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> return -EPERM;
> }
>
>
--
Péter
WARNING: multiple messages have this Message-ID (diff)
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Jon Hunter <jon-hunter@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
<linux-kernel@vger.kernel.org>, <linux-omap@vger.kernel.org>,
Tero Kristo <t-kristo@ti.com>
Subject: Re: [PATCH v2 09/11] mfd: twl-core: Collect global variables behind one private structure (global)
Date: Sat, 9 Feb 2013 06:50:49 +0100 [thread overview]
Message-ID: <5115E3B9.6090100@ti.com> (raw)
In-Reply-To: <51154A7A.2010709@ti.com>
On 02/08/2013 07:56 PM, Jon Hunter wrote:
>> /**
>> * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
>> * @mod_no: module number
>> @@ -322,16 +323,17 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
>> pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
>> return -EPERM;
>> }
>> - if (unlikely(!inuse)) {
>> + if (unlikely(!twl_priv->ready)) {
>
> This is causing the kernel to panic on all my omap2 boards when booting linux-next
> because twl_priv is not initialised yet.
Good catch.
I just wonder from where the twl_* call is coming on OMAP2. AFAIK the twl code
is for OMAP3/4, for OMAP2 Menelaus is the one which is used.
I'm currently working on to remove all those twl_* calls from random places in
the kernel so we will only access twl via the MFD stack.
>
>> pr_err("%s: not initialized\n", DRIVER_NAME);
>> return -EPERM;
>> }
>>
>> - sid = twl_map[mod_no].sid;
>> - twl = &twl_modules[sid];
>> + sid = twl_priv->twl_map[mod_no].sid;
>> + twl = &twl_priv->twl_modules[sid];
>>
>> - ret = regmap_bulk_write(twl->regmap, twl_map[mod_no].base + reg,
>> - value, num_bytes);
>> + ret = regmap_bulk_write(twl->regmap,
>> + twl_priv->twl_map[mod_no].base + reg, value,
>> + num_bytes);
>>
>> if (ret)
>> pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n",
>> @@ -360,16 +362,17 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
>> pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
>> return -EPERM;
>> }
>> - if (unlikely(!inuse)) {
>> + if (unlikely(!twl_priv->ready)) {
>
> Same problem here.
>
> Here is a fix ...
>
> From 141fcbbdee6bdc14d5a444ff20fad6b3440215dc Mon Sep 17 00:00:00 2001
> From: Jon Hunter <jon-hunter@ti.com>
> Date: Fri, 8 Feb 2013 12:42:20 -0600
> Subject: [PATCH] ARM: OMAP2+: Fix kernel panic on boot
>
> Commit 8a6aaa3 (mfd: twl-core: Collect global variables behind one
> private structure (global)) removed the variable "inuse" that is used
> to determine if the device has been initialised and now use the
> twl_priv structure instead. This is causing the kernel to panic on all
> OMAP2+ devices, because we try to access the twl_priv->ready member
> before checking if twl_priv is initialised. Fix this and move this test
> to the beginning of the twl_i2c_read/write function because
> twl_get_last_module() also uses the twl_priv structure.
>
> Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> drivers/mfd/twl-core.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 557f9ee..89ab4d9 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -316,12 +316,12 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
> int sid;
> struct twl_client *twl;
>
> - if (unlikely(mod_no >= twl_get_last_module())) {
> - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> + if (unlikely(!twl_priv || !twl_priv->ready)) {
> + pr_err("%s: not initialized\n", DRIVER_NAME);
> return -EPERM;
> }
> - if (unlikely(!twl_priv->ready)) {
> - pr_err("%s: not initialized\n", DRIVER_NAME);
> + if (unlikely(mod_no >= twl_get_last_module())) {
> + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> return -EPERM;
> }
>
> @@ -355,12 +355,12 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
> int sid;
> struct twl_client *twl;
>
> - if (unlikely(mod_no >= twl_get_last_module())) {
> - pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> + if (unlikely(!twl_priv || !twl_priv->ready)) {
> + pr_err("%s: not initialized\n", DRIVER_NAME);
> return -EPERM;
> }
> - if (unlikely(!twl_priv->ready)) {
> - pr_err("%s: not initialized\n", DRIVER_NAME);
> + if (unlikely(mod_no >= twl_get_last_module())) {
> + pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> return -EPERM;
> }
>
>
--
Péter
next prev parent reply other threads:[~2013-02-09 5:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 13:53 [PATCH v2 00/11] MFD: twl-core: Cleanup part 2 for 3.9 Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 01/11] ARM: OMAP: zoom-display: Remove the use of TWL4030_MODULE_PWM1 Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 02/11] mfd: twl-core: Clean up module id lookup and definitions Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 03/11] mfd: twl-core: No need to check for invalid subchip ID Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 04/11] mfd: twl-core: Use the lookup table to find the correct subchip for the modules Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 05/11] mfd: twl-core: Allocate twl_modules dynamically Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 06/11] mfd: twl-core: Do not try to call legacy mfd add_children() when booted with DT Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 07/11] mfd: twl-core: Do not create dummy pdata " Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 08/11] mfd: twl-core: Move 'inuse' check early at probe time Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 09/11] mfd: twl-core: Collect global variables behind one private structure (global) Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-02-08 18:56 ` Jon Hunter
2013-02-08 18:56 ` Jon Hunter
2013-02-09 5:50 ` Peter Ujfalusi [this message]
2013-02-09 5:50 ` Peter Ujfalusi
2013-02-11 20:22 ` Jon Hunter
2013-02-11 20:22 ` Jon Hunter
2013-02-12 7:26 ` Peter Ujfalusi
2013-02-12 7:26 ` Peter Ujfalusi
2013-02-12 16:15 ` Jon Hunter
2013-02-12 16:15 ` Jon Hunter
2013-02-13 13:59 ` Peter Ujfalusi
2013-02-13 13:59 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 10/11] mfd: twl-core: Remove no longer valid comment regarding to write buffer size Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-01-16 13:53 ` [PATCH v2 11/11] mfd: twl-core: Move twl_i2c_read/write_u8 to header as inline function Peter Ujfalusi
2013-01-16 13:53 ` Peter Ujfalusi
2013-02-03 17:01 ` [PATCH v2 00/11] MFD: twl-core: Cleanup part 2 for 3.9 Samuel Ortiz
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=5115E3B9.6090100@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=jon-hunter@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=sameo@linux.intel.com \
--cc=t-kristo@ti.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.