Re: [PATCH 09/12] omap3: pm: TWL5030 version checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Fri, Feb 18, 2011 at 7:08 PM, Lesly A M <leslyam@xxxxxx> wrote:
> Added api to get the TWL5030 Si version from the IDCODE register.
> It is used for enabling the workaround for TWL errata 27.
>
> Signed-off-by: Lesly A M <leslyam@xxxxxx>
> Cc: Nishanth Menon <nm@xxxxxx>
> Cc: David Derrick <dderrick@xxxxxx>
> Cc: Samuel Ortiz <sameo@xxxxxxxxxxxxxxx>
> ---
> Âdrivers/mfd/twl-core.c Â| Â 50 +++++++++++++++++++++++++++++++++++++++++++++++
> Âinclude/linux/i2c/twl.h | Â 10 +++++++++
> Â2 files changed, 60 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index a35fa7d..211c2cc 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -487,6 +487,56 @@ EXPORT_SYMBOL(twl_i2c_read_u8);
>
> Â/*----------------------------------------------------------------------*/
>
> +/**
> + * twl_read_idcode_register - api to read the IDCODE register.
> + * @value: returns 32 bit IDCODE register value.
> + *
> + * Unlocks the IDCODE register and read the 32 bit value.
> + */
> +int twl_read_idcode_register(u32 *value)
> +{
> + Â Â Â int err = 0;

No need to initialize 'ret'.

> +
> + Â Â Â err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, TWL_EEPROM_R_UNLOCK,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â R_UNLOCK_TEST_REG);
> + Â Â Â if (err)
> + Â Â Â Â Â Â Â pr_err("TWL4030 Unable to unlock IDCODE registers\n");
> +
> + Â Â Â err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(value),
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0x0, 4);

Variable 'err' is being overwritten here.

> + Â Â Â if (err)
> + Â Â Â Â Â Â Â pr_err("TWL4030: unable to read IDCODE-%d\n", err);
> +
> + Â Â Â err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, 0x0, R_UNLOCK_TEST_REG);

Here again.

> + Â Â Â if (err)
> + Â Â Â Â Â Â Â pr_err("TWL4030 Unable to relock IDCODE registers\n");
> +
> + Â Â Â return err;

And then you're returning 'err'. Unless you care only about the last
'err' assignment, something is wrong here, isn't it? :)

> +}
> +
> +/**
> + * twl5030_get_si_ver - api to get TWL5030 Si version.
> + * @value: returns Si version from IDCODE.
> + *
> + * Api to get the TWL5030 Si version from IDCODE value.
> + */
> +int twl5030_get_si_ver(u32 *value)
> +{
> + Â Â Â int ret = 0;

No need to initialize 'ret'.

> + Â Â Â static u32 twl_idcode;
> +
> + Â Â Â if (twl_idcode == 0)
> + Â Â Â Â Â Â Â ret = twl_read_idcode_register(&twl_idcode);
> + Â Â Â if (ret)
> + Â Â Â Â Â Â Â pr_err("TWL4030 Unable to check Si version\n");

Shouldn't you return error here?

> +
> + Â Â Â if (TWL_SIL_TYPE(twl_idcode) == TWL_SIL_5030)
> + Â Â Â Â Â Â Â *value = TWL_SIL_REV(twl_idcode);

Otherwise, what happens here if twl_read_idcode_register() fails?

> +
> + Â Â Â return ret;

return 0 if the code reaches this point.

Br,

David Cohen

> +}
> +EXPORT_SYMBOL(twl5030_get_si_ver);
> +
> Âstatic struct device *
> Âadd_numbered_child(unsigned chip, const char *name, int num,
> Â Â Â Â Â Â Â Âvoid *pdata, unsigned pdata_len,
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index f4bd475..5d3f2bf 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -150,7 +150,15 @@
> Â#define MMC_PU Â Â Â Â Â Â Â Â Â Â Â Â (0x1 << 3)
> Â#define MMC_PD Â Â Â Â Â Â Â Â Â Â Â Â (0x1 << 2)
>
> +#define R_UNLOCK_TEST_REG Â Â Â0x12
> +#define TWL_EEPROM_R_UNLOCK Â Â0x49
>
> +#define TWL_SIL_TYPE(rev) Â Â Â((rev) & 0x00FFFFFF)
> +#define TWL_SIL_REV(rev) Â Â Â ((rev) >> 24)
> +#define TWL_SIL_5030 Â Â Â Â Â 0x09002F
> +#define TWL5030_REV_1_0 Â Â Â Â Â Â Â Â0x00
> +#define TWL5030_REV_1_1 Â Â Â Â Â Â Â Â0x10
> +#define TWL5030_REV_1_2 Â Â Â Â Â Â Â Â0x30
>
> Â#define TWL4030_CLASS_ID Â Â Â Â Â Â Â 0x4030
> Â#define TWL6030_CLASS_ID Â Â Â Â Â Â Â 0x6030
> @@ -180,6 +188,8 @@ int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
> Âint twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
> Âint twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
>
> +int twl5030_get_si_ver(u32 *value);
> +
> Âint twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
> Âint twl6030_interrupt_mask(u8 bit_mask, u8 offset);
>
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux