linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS
@ 2021-05-07 16:19 Krzysztof Kozlowski
  2021-05-07 16:19 ` [RFT PATCH 2/3] power: supply: max17040: simplify POWER_SUPPLY_PROP_ONLINE Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-07 16:19 UTC (permalink / raw)
  To: Sebastian Reichel, Krzysztof Kozlowski, linux-kernel, linux-pm
  Cc: Iskren Chernev, Jonathan Bakker, Matheus Castello, Marek Szyprowski

The driver was reporting POWER_SUPPLY_PROP_STATUS via platform data
functions.  Without platform data, the max17040_get_status() functions
returns early with POWER_SUPPLY_STATUS_UNKNOWN.  Since there are no
platforms using the driver with platform data (no board files with the
driver), the status property was always unknown.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/power/supply/max17040_battery.c | 32 +++----------------------
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index 1aab868adabf..12854c87df53 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -147,8 +147,6 @@ struct max17040_chip {
 
 	/* battery capacity */
 	int soc;
-	/* State Of Charge */
-	int status;
 	/* Low alert threshold from 32% to 1% of the State of Charge */
 	u32 low_soc_alert;
 	/* some devices return twice the capacity */
@@ -225,24 +223,6 @@ static int max17040_get_online(struct max17040_chip *chip)
 		chip->pdata->battery_online() : 1;
 }
 
-static int max17040_get_status(struct max17040_chip *chip)
-{
-	if (!chip->pdata || !chip->pdata->charger_online
-			|| !chip->pdata->charger_enable)
-		return POWER_SUPPLY_STATUS_UNKNOWN;
-
-	if (max17040_get_soc(chip) > MAX17040_BATTERY_FULL)
-		return POWER_SUPPLY_STATUS_FULL;
-
-	if (chip->pdata->charger_online())
-		if (chip->pdata->charger_enable())
-			return POWER_SUPPLY_STATUS_CHARGING;
-		else
-			return POWER_SUPPLY_STATUS_NOT_CHARGING;
-	else
-		return POWER_SUPPLY_STATUS_DISCHARGING;
-}
-
 static int max17040_get_of_data(struct max17040_chip *chip)
 {
 	struct device *dev = &chip->client->dev;
@@ -283,7 +263,6 @@ static int max17040_get_of_data(struct max17040_chip *chip)
 static void max17040_check_changes(struct max17040_chip *chip)
 {
 	chip->soc = max17040_get_soc(chip);
-	chip->status = max17040_get_status(chip);
 }
 
 static void max17040_queue_work(struct max17040_chip *chip)
@@ -302,17 +281,16 @@ static void max17040_stop_work(void *data)
 static void max17040_work(struct work_struct *work)
 {
 	struct max17040_chip *chip;
-	int last_soc, last_status;
+	int last_soc;
 
 	chip = container_of(work, struct max17040_chip, work.work);
 
-	/* store SOC and status to check changes */
+	/* store SOC to check changes */
 	last_soc = chip->soc;
-	last_status = chip->status;
 	max17040_check_changes(chip);
 
 	/* check changes and send uevent */
-	if (last_soc != chip->soc || last_status != chip->status)
+	if (last_soc != chip->soc)
 		power_supply_changed(chip->battery);
 
 	max17040_queue_work(chip);
@@ -415,9 +393,6 @@ static int max17040_get_property(struct power_supply *psy,
 	struct max17040_chip *chip = power_supply_get_drvdata(psy);
 
 	switch (psp) {
-	case POWER_SUPPLY_PROP_STATUS:
-		val->intval = max17040_get_status(chip);
-		break;
 	case POWER_SUPPLY_PROP_ONLINE:
 		val->intval = max17040_get_online(chip);
 		break;
@@ -444,7 +419,6 @@ static const struct regmap_config max17040_regmap = {
 };
 
 static enum power_supply_property max17040_battery_props[] = {
-	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_ONLINE,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_CAPACITY,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RFT PATCH 2/3] power: supply: max17040: simplify POWER_SUPPLY_PROP_ONLINE
  2021-05-07 16:19 [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS Krzysztof Kozlowski
@ 2021-05-07 16:19 ` Krzysztof Kozlowski
  2021-05-07 16:19 ` [RFT PATCH 3/3] power: supply: max17040: drop unused platform data support Krzysztof Kozlowski
  2021-06-04 12:01 ` [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-07 16:19 UTC (permalink / raw)
  To: Sebastian Reichel, Krzysztof Kozlowski, linux-kernel, linux-pm
  Cc: Iskren Chernev, Jonathan Bakker, Matheus Castello, Marek Szyprowski

The driver was reporting POWER_SUPPLY_PROP_ONLINE via platform data
functions or '1' if no platform data was provided.  Since there are no
platforms using the driver with platform data (no board files with the
driver), the online property can be simplified to always return '1'.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/power/supply/max17040_battery.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index 12854c87df53..d51c3443d732 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -219,8 +219,7 @@ static int max17040_get_version(struct max17040_chip *chip)
 
 static int max17040_get_online(struct max17040_chip *chip)
 {
-	return chip->pdata && chip->pdata->battery_online ?
-		chip->pdata->battery_online() : 1;
+	return 1;
 }
 
 static int max17040_get_of_data(struct max17040_chip *chip)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RFT PATCH 3/3] power: supply: max17040: drop unused platform data support
  2021-05-07 16:19 [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS Krzysztof Kozlowski
  2021-05-07 16:19 ` [RFT PATCH 2/3] power: supply: max17040: simplify POWER_SUPPLY_PROP_ONLINE Krzysztof Kozlowski
@ 2021-05-07 16:19 ` Krzysztof Kozlowski
  2021-06-04 12:01 ` [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-07 16:19 UTC (permalink / raw)
  To: Sebastian Reichel, Krzysztof Kozlowski, linux-kernel, linux-pm
  Cc: Iskren Chernev, Jonathan Bakker, Matheus Castello, Marek Szyprowski

There are no platforms using the driver with platform data (no board
files with the driver), so the dead code can be dropped.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/power/supply/max17040_battery.c |  3 ---
 include/linux/max17040_battery.h        | 16 ----------------
 2 files changed, 19 deletions(-)
 delete mode 100644 include/linux/max17040_battery.h

diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index d51c3443d732..a8ba2c305034 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -16,7 +16,6 @@
 #include <linux/interrupt.h>
 #include <linux/power_supply.h>
 #include <linux/of_device.h>
-#include <linux/max17040_battery.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
@@ -142,7 +141,6 @@ struct max17040_chip {
 	struct regmap			*regmap;
 	struct delayed_work		work;
 	struct power_supply		*battery;
-	struct max17040_platform_data	*pdata;
 	struct chip_data		data;
 
 	/* battery capacity */
@@ -453,7 +451,6 @@ static int max17040_probe(struct i2c_client *client,
 
 	chip->client = client;
 	chip->regmap = devm_regmap_init_i2c(client, &max17040_regmap);
-	chip->pdata = client->dev.platform_data;
 	chip_id = (enum chip_id) id->driver_data;
 	if (client->dev.of_node) {
 		ret = max17040_get_of_data(chip);
diff --git a/include/linux/max17040_battery.h b/include/linux/max17040_battery.h
deleted file mode 100644
index 593602fc9317..000000000000
--- a/include/linux/max17040_battery.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- *  Copyright (C) 2009 Samsung Electronics
- *  Minkyu Kang <mk7.kang@samsung.com>
- */
-
-#ifndef __MAX17040_BATTERY_H_
-#define __MAX17040_BATTERY_H_
-
-struct max17040_platform_data {
-	int (*battery_online)(void);
-	int (*charger_online)(void);
-	int (*charger_enable)(void);
-};
-
-#endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS
  2021-05-07 16:19 [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS Krzysztof Kozlowski
  2021-05-07 16:19 ` [RFT PATCH 2/3] power: supply: max17040: simplify POWER_SUPPLY_PROP_ONLINE Krzysztof Kozlowski
  2021-05-07 16:19 ` [RFT PATCH 3/3] power: supply: max17040: drop unused platform data support Krzysztof Kozlowski
@ 2021-06-04 12:01 ` Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2021-06-04 12:01 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: linux-kernel, linux-pm, Iskren Chernev, Jonathan Bakker,
	Matheus Castello, Marek Szyprowski

[-- Attachment #1: Type: text/plain, Size: 3701 bytes --]

Hi,

On Fri, May 07, 2021 at 12:19:25PM -0400, Krzysztof Kozlowski wrote:
> The driver was reporting POWER_SUPPLY_PROP_STATUS via platform data
> functions.  Without platform data, the max17040_get_status() functions
> returns early with POWER_SUPPLY_STATUS_UNKNOWN.  Since there are no
> platforms using the driver with platform data (no board files with the
> driver), the status property was always unknown.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---

Thanks, I queued the series.

-- Sebastian

>  drivers/power/supply/max17040_battery.c | 32 +++----------------------
>  1 file changed, 3 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
> index 1aab868adabf..12854c87df53 100644
> --- a/drivers/power/supply/max17040_battery.c
> +++ b/drivers/power/supply/max17040_battery.c
> @@ -147,8 +147,6 @@ struct max17040_chip {
>  
>  	/* battery capacity */
>  	int soc;
> -	/* State Of Charge */
> -	int status;
>  	/* Low alert threshold from 32% to 1% of the State of Charge */
>  	u32 low_soc_alert;
>  	/* some devices return twice the capacity */
> @@ -225,24 +223,6 @@ static int max17040_get_online(struct max17040_chip *chip)
>  		chip->pdata->battery_online() : 1;
>  }
>  
> -static int max17040_get_status(struct max17040_chip *chip)
> -{
> -	if (!chip->pdata || !chip->pdata->charger_online
> -			|| !chip->pdata->charger_enable)
> -		return POWER_SUPPLY_STATUS_UNKNOWN;
> -
> -	if (max17040_get_soc(chip) > MAX17040_BATTERY_FULL)
> -		return POWER_SUPPLY_STATUS_FULL;
> -
> -	if (chip->pdata->charger_online())
> -		if (chip->pdata->charger_enable())
> -			return POWER_SUPPLY_STATUS_CHARGING;
> -		else
> -			return POWER_SUPPLY_STATUS_NOT_CHARGING;
> -	else
> -		return POWER_SUPPLY_STATUS_DISCHARGING;
> -}
> -
>  static int max17040_get_of_data(struct max17040_chip *chip)
>  {
>  	struct device *dev = &chip->client->dev;
> @@ -283,7 +263,6 @@ static int max17040_get_of_data(struct max17040_chip *chip)
>  static void max17040_check_changes(struct max17040_chip *chip)
>  {
>  	chip->soc = max17040_get_soc(chip);
> -	chip->status = max17040_get_status(chip);
>  }
>  
>  static void max17040_queue_work(struct max17040_chip *chip)
> @@ -302,17 +281,16 @@ static void max17040_stop_work(void *data)
>  static void max17040_work(struct work_struct *work)
>  {
>  	struct max17040_chip *chip;
> -	int last_soc, last_status;
> +	int last_soc;
>  
>  	chip = container_of(work, struct max17040_chip, work.work);
>  
> -	/* store SOC and status to check changes */
> +	/* store SOC to check changes */
>  	last_soc = chip->soc;
> -	last_status = chip->status;
>  	max17040_check_changes(chip);
>  
>  	/* check changes and send uevent */
> -	if (last_soc != chip->soc || last_status != chip->status)
> +	if (last_soc != chip->soc)
>  		power_supply_changed(chip->battery);
>  
>  	max17040_queue_work(chip);
> @@ -415,9 +393,6 @@ static int max17040_get_property(struct power_supply *psy,
>  	struct max17040_chip *chip = power_supply_get_drvdata(psy);
>  
>  	switch (psp) {
> -	case POWER_SUPPLY_PROP_STATUS:
> -		val->intval = max17040_get_status(chip);
> -		break;
>  	case POWER_SUPPLY_PROP_ONLINE:
>  		val->intval = max17040_get_online(chip);
>  		break;
> @@ -444,7 +419,6 @@ static const struct regmap_config max17040_regmap = {
>  };
>  
>  static enum power_supply_property max17040_battery_props[] = {
> -	POWER_SUPPLY_PROP_STATUS,
>  	POWER_SUPPLY_PROP_ONLINE,
>  	POWER_SUPPLY_PROP_VOLTAGE_NOW,
>  	POWER_SUPPLY_PROP_CAPACITY,
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-04 12:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 16:19 [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS Krzysztof Kozlowski
2021-05-07 16:19 ` [RFT PATCH 2/3] power: supply: max17040: simplify POWER_SUPPLY_PROP_ONLINE Krzysztof Kozlowski
2021-05-07 16:19 ` [RFT PATCH 3/3] power: supply: max17040: drop unused platform data support Krzysztof Kozlowski
2021-06-04 12:01 ` [RFT PATCH 1/3] power: supply: max17040: remove non-working POWER_SUPPLY_PROP_STATUS Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).