From: Amit Kucheria <amit.kucheria@verdurent.com>
To: linux-omap@vger.kernel.org
Subject: Re: [PATCH] [PATCH] twl4030: Add some error checking to twl4030 init
Date: Wed, 3 Jun 2009 11:49:58 +0300 [thread overview]
Message-ID: <20090603084958.GO16000@everest> (raw)
In-Reply-To: <1241611418-19730-1-git-send-email-amit.kucheria@verdurent.com>
Bump..
This patch was acked by David Brownell earlier in the thread.
Regards,
Amit
On Wed, May 06, 2009 at 03:03:38PM +0300, Amit Kucheria wrote:
> Check for return values of i2c read/write operations and size of scripts being
> uploaded to TWL4030
>
> (Removed the unrelated string changes based on David Brownell's comment)
>
> Signed-off-by: Amit Kucheria <amit.kucheria@verdurent.com>
> ---
> drivers/mfd/twl4030-power.c | 52 +++++++++++++++++++++++++++++++-----------
> 1 files changed, 38 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index 9dc493b..8f5d149 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -257,36 +257,40 @@ static int __init config_warmreset_sequence(u8 address)
> return err;
> }
>
> -void twl4030_configure_resource(struct twl4030_resconfig *rconfig)
> +static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
> {
> int rconfig_addr;
> + int err;
> u8 type;
>
> if (rconfig->resource > NUM_OF_RESOURCES) {
> printk(KERN_ERR
> "TWL4030 Resource %d does not exist\n",
> rconfig->resource);
> - return;
> + return -EINVAL;
> }
>
> rconfig_addr = res_config_addrs[rconfig->resource];
>
> /* Set resource group */
> -
> if (rconfig->devgroup >= 0)
> - twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
> + err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
> rconfig->devgroup << 5,
> rconfig_addr + DEVGROUP_OFFSET);
> + if (err < 0) {
> + printk(KERN_ERR
> + "TWL4030 failed to program devgroup");
> + return err;
> + }
>
> /* Set resource types */
> -
> - if (twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER,
> - &type,
> - rconfig_addr + TYPE_OFFSET) < 0) {
> + err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type,
> + rconfig_addr + TYPE_OFFSET);
> + if (err < 0) {
> printk(KERN_ERR
> - "TWL4030 Resource %d type could not read\n",
> - rconfig->resource);
> - return;
> + "TWL4030 Resource %d type could not be read\n",
> + rconfig->resource);
> + return err;
> }
>
> if (rconfig->type >= 0) {
> @@ -299,8 +303,15 @@ void twl4030_configure_resource(struct twl4030_resconfig *rconfig)
> type |= rconfig->type2 << 3;
> }
>
> - twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
> + err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
> type, rconfig_addr + TYPE_OFFSET);
> + if (err < 0) {
> + printk(KERN_ERR
> + "TWL4030 failed to program resource type");
> + return err;
> + }
> +
> + return 0;
>
> }
>
> @@ -309,6 +320,12 @@ static int __init load_triton_script(struct twl4030_script *tscript)
> u8 address = triton_next_free_address;
> int err;
>
> + /* Make sure the script isn't going beyond last valid address */
> + if ((address + tscript->size) > (END_OF_SCRIPT-1)) {
> + printk(KERN_ERR "TWL4030 script too big error\n");
> + return -EINVAL;
> + }
> +
> err = twl4030_write_script(address, tscript->script, tscript->size);
> if (err)
> return err;
> @@ -346,15 +363,22 @@ void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
>
> for (i = 0; i < triton2_scripts->size; i++) {
> err = load_triton_script(triton2_scripts->scripts[i]);
> - if (err)
> + if (err < 0) {
> + printk(KERN_ERR "TWL4030 failed to load scripts");
> break;
> + }
> }
>
> resconfig = triton2_scripts->resource_config;
> if (resconfig) {
> while (resconfig->resource) {
> - twl4030_configure_resource(resconfig);
> + err = twl4030_configure_resource(resconfig);
> resconfig++;
> + if (err < 0) {
> + printk(KERN_ERR
> + "TWL4030 failed to configure resource");
> + break;
> + }
> }
> }
>
> --
> 1.6.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
-------------------------------------------------------------------------
Amit Kucheria, Kernel Developer, Verdurent
-------------------------------------------------------------------------
next prev parent reply other threads:[~2009-06-03 8:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-20 12:49 [PATCH] twl4030: Add some error checking to twl4030 init Amit Kucheria
2009-04-20 20:38 ` Premi, Sanjeev
2009-04-20 21:28 ` Amit Kucheria
2009-04-22 13:11 ` Peter 'p2' De Schrijver
2009-04-23 21:16 ` David Brownell
2009-05-06 12:03 ` [PATCH] " Amit Kucheria
2009-06-03 8:49 ` Amit Kucheria [this message]
2009-06-03 16:53 ` Tony Lindgren
2009-06-03 16:53 ` [APPLIED] " Tony Lindgren
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=20090603084958.GO16000@everest \
--to=amit.kucheria@verdurent.com \
--cc=linux-omap@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox