diff mbox

[v2,01/11] power: supplies: bq275xx: rename BQ27500 allow for deprecation in future.

Message ID 1482451507-37676-2-git-send-email-chris@lapa.com.au (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

chris@lapa.com.au Dec. 23, 2016, 12:04 a.m. UTC
From: Chris Lapa <chris@lapa.com.au>

The BQ275XX definition exists only to satisfy backwards compatibility.

tested: yes

Signed-off-by: Chris Lapa <chris@lapa.com.au>
---
 drivers/power/supply/bq27xxx_battery.c     | 8 ++++----
 drivers/power/supply/bq27xxx_battery_i2c.c | 6 +++---
 include/linux/power/bq27xxx_battery.h      | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

Comments

Sebastian Reichel Jan. 5, 2017, 11:59 p.m. UTC | #1
Hi Chris,

On Fri, Dec 23, 2016 at 11:04:57AM +1100, Chris Lapa wrote:
> From: Chris Lapa <chris@lapa.com.au>
> 
> The BQ275XX definition exists only to satisfy backwards compatibility.
> 
> tested: yes
> 
> Signed-off-by: Chris Lapa <chris@lapa.com.au>
>
> [...]
>
>  static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
>  {
> -	if (di->chip == BQ27500 || di->chip == BQ27541 || di->chip == BQ27545)
> +	if (di->chip == BQ275XX || di->chip == BQ27541 || di->chip == BQ27545)
>  		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
>  	if (di->chip == BQ27530 || di->chip == BQ27421)
>  		return flags & BQ27XXX_FLAG_OT;

This is really getting out of hands in this patchset. Please
add a patch at the beginning of the patchset, which converts
this construct into the following:

switch (di->chip) {
case A:
case B:
case C:
case D:
    return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
case E:
case F:
    return flags & BQ27XXX_FLAG_OT;
default:
    return false;
}

-- Sebastian
chris@lapa.com.au Jan. 6, 2017, 12:29 a.m. UTC | #2
On 6/1/17 10:59 am, Sebastian Reichel wrote:
> Hi Chris,
>
> On Fri, Dec 23, 2016 at 11:04:57AM +1100, Chris Lapa wrote:
>> From: Chris Lapa <chris@lapa.com.au>
>>
>> The BQ275XX definition exists only to satisfy backwards compatibility.
>>
>> tested: yes
>>
>> Signed-off-by: Chris Lapa <chris@lapa.com.au>
>>
>> [...]
>>
>>  static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
>>  {
>> -	if (di->chip == BQ27500 || di->chip == BQ27541 || di->chip == BQ27545)
>> +	if (di->chip == BQ275XX || di->chip == BQ27541 || di->chip == BQ27545)
>>  		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
>>  	if (di->chip == BQ27530 || di->chip == BQ27421)
>>  		return flags & BQ27XXX_FLAG_OT;
>
> This is really getting out of hands in this patchset. Please
> add a patch at the beginning of the patchset, which converts
> this construct into the following:
>
> switch (di->chip) {
> case A:
> case B:
> case C:
> case D:
>     return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
> case E:
> case F:
>     return flags & BQ27XXX_FLAG_OT;
> default:
>     return false;
> }
>
> -- Sebastian
>

I was advised to move these tests into a function which I've done in the 
10th patch. I have no issue with changing it to a switch statement, but 
should I drop the bq27xxx_has_multiple_overtemp_flags() function I added?
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sebastian Reichel Jan. 6, 2017, 5:36 p.m. UTC | #3
Hi,

On Fri, Jan 06, 2017 at 11:29:19AM +1100, Chris Lapa wrote:
> On 6/1/17 10:59 am, Sebastian Reichel wrote:
> > Hi Chris,
> > 
> > On Fri, Dec 23, 2016 at 11:04:57AM +1100, Chris Lapa wrote:
> > > From: Chris Lapa <chris@lapa.com.au>
> > > 
> > > The BQ275XX definition exists only to satisfy backwards compatibility.
> > > 
> > > tested: yes
> > > 
> > > Signed-off-by: Chris Lapa <chris@lapa.com.au>
> > > 
> > > [...]
> > > 
> > >  static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
> > >  {
> > > -	if (di->chip == BQ27500 || di->chip == BQ27541 || di->chip == BQ27545)
> > > +	if (di->chip == BQ275XX || di->chip == BQ27541 || di->chip == BQ27545)
> > >  		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
> > >  	if (di->chip == BQ27530 || di->chip == BQ27421)
> > >  		return flags & BQ27XXX_FLAG_OT;
> > 
> > This is really getting out of hands in this patchset. Please
> > add a patch at the beginning of the patchset, which converts
> > this construct into the following:
> > 
> > switch (di->chip) {
> > case A:
> > case B:
> > case C:
> > case D:
> >     return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
> > case E:
> > case F:
> >     return flags & BQ27XXX_FLAG_OT;
> > default:
> >     return false;
> > }
> > 
> > -- Sebastian
> > 
> 
> I was advised to move these tests into a function which I've done in the
> 10th patch. I have no issue with changing it to a switch statement, but
> should I drop the bq27xxx_has_multiple_overtemp_flags() function I added?

I'm fine with or without the extra function. But please introduce
the switch at the beginning of the patchseries, since it also eases
patch-reviewing.

-- Sebastian
diff mbox

Patch

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 3b0dbc6..312f668 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -145,7 +145,7 @@  static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
 		[BQ27XXX_REG_DCAP] = 0x76,
 		[BQ27XXX_REG_AP] = INVALID_REG_ADDR,
 	},
-	[BQ27500] = {
+	[BQ275XX] = {
 		[BQ27XXX_REG_CTRL] = 0x00,
 		[BQ27XXX_REG_TEMP] = 0x06,
 		[BQ27XXX_REG_INT_TEMP] = 0x28,
@@ -284,7 +284,7 @@  static enum power_supply_property bq27010_battery_props[] = {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
-static enum power_supply_property bq27500_battery_props[] = {
+static enum power_supply_property bq275xx_battery_props[] = {
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
@@ -384,7 +384,7 @@  static struct {
 } bq27xxx_battery_props[] = {
 	BQ27XXX_PROP(BQ27000, bq27000_battery_props),
 	BQ27XXX_PROP(BQ27010, bq27010_battery_props),
-	BQ27XXX_PROP(BQ27500, bq27500_battery_props),
+	BQ27XXX_PROP(BQ275XX, bq275xx_battery_props),
 	BQ27XXX_PROP(BQ27530, bq27530_battery_props),
 	BQ27XXX_PROP(BQ27541, bq27541_battery_props),
 	BQ27XXX_PROP(BQ27545, bq27545_battery_props),
@@ -635,7 +635,7 @@  static int bq27xxx_battery_read_pwr_avg(struct bq27xxx_device_info *di)
  */
 static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
 {
-	if (di->chip == BQ27500 || di->chip == BQ27541 || di->chip == BQ27545)
+	if (di->chip == BQ275XX || di->chip == BQ27541 || di->chip == BQ27545)
 		return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
 	if (di->chip == BQ27530 || di->chip == BQ27421)
 		return flags & BQ27XXX_FLAG_OT;
diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c
index 85d4ea2..762d96e 100644
--- a/drivers/power/supply/bq27xxx_battery_i2c.c
+++ b/drivers/power/supply/bq27xxx_battery_i2c.c
@@ -148,9 +148,9 @@  static int bq27xxx_battery_i2c_remove(struct i2c_client *client)
 static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
 	{ "bq27200", BQ27000 },
 	{ "bq27210", BQ27010 },
-	{ "bq27500", BQ27500 },
-	{ "bq27510", BQ27500 },
-	{ "bq27520", BQ27500 },
+	{ "bq27500", BQ275XX },
+	{ "bq27510", BQ275XX },
+	{ "bq27520", BQ275XX },
 	{ "bq27530", BQ27530 },
 	{ "bq27531", BQ27530 },
 	{ "bq27541", BQ27541 },
diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
index e30deb0..c452b94 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -4,7 +4,7 @@ 
 enum bq27xxx_chip {
 	BQ27000 = 1, /* bq27000, bq27200 */
 	BQ27010, /* bq27010, bq27210 */
-	BQ27500, /* bq27500, bq27510, bq27520 */
+	BQ275XX, /* bq27500, bq27510, bq27520 deprecated alias */
 	BQ27530, /* bq27530, bq27531 */
 	BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
 	BQ27545, /* bq27545 */