Re: [PATCHv3] bq27x00_battery: Add support for BQ27425 chip

From: Lars-Peter Clausen
Date: Mon Jul 02 2012 - 11:59:59 EST


On 06/30/2012 06:56 PM, Saranya Gopal wrote:
> This patch adds support for BQ27425 (TI) chip. This chip is same as
> BQ27500 with few registers removed and register address map changed.
> The data sheet for this chip is publicly available at
> http://www.ti.com/product/bq27425-g1
>
> Changes since v2:
> Remove register address definitions of bq27425 and
> use register address offset instead.
> Add a small helper function to decide if the chip version
> is higher than bq27200 to make it less noisy
> to add another chip with similar register layout.
>
> Signed-off-by: Saranya Gopal <saranya.gopal@xxxxxxxxx>

Looks good to me.

Reviewed-by: Lars-Peter Clausen <lars@xxxxxxxxxx>

Two minor suggestions though:

>[...]
>
> #include <linux/module.h>
> @@ -67,6 +68,10 @@
> #define BQ27500_FLAG_SOC1 BIT(2) /* State-of-Charge threshold 1 */
> #define BQ27500_FLAG_FC BIT(9)
>
> +/* bq27425 register addresses are same as bq27x00 addresses minus 4 */
> +#define BQ27425_REG_OFFSET 0x04
> +#define BQ27425_REG_SOC 0x1C
> +

I'd have added the offset to REG_SOC here, ...

> @@ -150,6 +183,9 @@ static int bq27x00_battery_read_rsoc(struct
bq27x00_device_info *di)
>
> if (di->chip == BQ27500)
> rsoc = bq27x00_read(di, BQ27500_REG_SOC, false);
> + else if (di->chip == BQ27425)
> + rsoc = bq27x00_read(di, BQ27425_REG_SOC+BQ27425_REG_OFFSET,
> + false);

... instead of here.

> /*
> + * Higher versions of the chip like BQ27425 and BQ27500
> + * differ from BQ27000 and BQ27200 in calculation of certain
> + * parameters. Hence we need to check for the chip type.
> + */
> +static bool is_chip_version_higher(struct bq27x00_device_info *di)

Maybe a prefix for the function is not such a bad idea, e.g. bq27xxx_...

> +{
> + if (di->chip == BQ27425 || di->chip == BQ27500)
> + return true;
> + return false;
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/