* [PATCH 1/3] power: supply: core: Remove unused power_supply_set_battery_charged
2025-03-07 23:02 [PATCH 0/3] power: supply: set_charged deadcode linux
@ 2025-03-07 23:02 ` linux
2025-03-07 23:02 ` [PATCH 2/3] power: supply: ds2760: Remove unused ds2760_battery_set_charged linux
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: linux @ 2025-03-07 23:02 UTC (permalink / raw)
To: sre, linux-pm; +Cc: linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
power_supply_set_battery_charged() has been unused since 2019's
commit 0f884f8a090e ("ARM: pxa: remove raumfeld board files and
defconfig")
Remove it.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
drivers/power/supply/power_supply_core.c | 13 -------------
include/linux/power_supply.h | 1 -
2 files changed, 14 deletions(-)
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 76c340b38015..47e0fea84917 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -449,19 +449,6 @@ int power_supply_get_property_from_supplier(struct power_supply *psy,
}
EXPORT_SYMBOL_GPL(power_supply_get_property_from_supplier);
-int power_supply_set_battery_charged(struct power_supply *psy)
-{
- if (atomic_read(&psy->use_cnt) >= 0 &&
- psy->desc->type == POWER_SUPPLY_TYPE_BATTERY &&
- psy->desc->set_charged) {
- psy->desc->set_charged(psy);
- return 0;
- }
-
- return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(power_supply_set_battery_charged);
-
static int power_supply_match_device_by_name(struct device *dev, const void *data)
{
const char *name = data;
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 6ed53b292162..5afc5946eb03 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -852,7 +852,6 @@ extern int power_supply_am_i_supplied(struct power_supply *psy);
int power_supply_get_property_from_supplier(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val);
-extern int power_supply_set_battery_charged(struct power_supply *psy);
static inline bool
power_supply_supports_maintenance_charging(struct power_supply_battery_info *info)
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] power: supply: ds2760: Remove unused ds2760_battery_set_charged
2025-03-07 23:02 [PATCH 0/3] power: supply: set_charged deadcode linux
2025-03-07 23:02 ` [PATCH 1/3] power: supply: core: Remove unused power_supply_set_battery_charged linux
@ 2025-03-07 23:02 ` linux
2025-03-07 23:02 ` [PATCH 3/3] power: supply: Remove unused set_charged method linux
2025-03-08 0:14 ` [PATCH 0/3] power: supply: set_charged deadcode Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: linux @ 2025-03-07 23:02 UTC (permalink / raw)
To: sre, linux-pm; +Cc: linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
With power_supply_set_battery_charged() deleted in the previous
patch, there's no one left to call the set_charged method.
The only implemented is in ds2760, unwire it and delete the
associated functions and data.
(Arguably it might be time to delete ds2760 since I don't
think there are any users left)
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
drivers/power/supply/ds2760_battery.c | 49 ---------------------------
1 file changed, 49 deletions(-)
diff --git a/drivers/power/supply/ds2760_battery.c b/drivers/power/supply/ds2760_battery.c
index 83bdec5a2bda..a7f7d4c3f1ee 100644
--- a/drivers/power/supply/ds2760_battery.c
+++ b/drivers/power/supply/ds2760_battery.c
@@ -112,7 +112,6 @@ struct ds2760_device_info {
struct power_supply_desc bat_desc;
struct workqueue_struct *monitor_wqueue;
struct delayed_work monitor_work;
- struct delayed_work set_charged_work;
struct notifier_block pm_notifier;
};
@@ -489,50 +488,6 @@ static void ds2760_battery_external_power_changed(struct power_supply *psy)
}
-static void ds2760_battery_set_charged_work(struct work_struct *work)
-{
- char bias;
- struct ds2760_device_info *di = container_of(work,
- struct ds2760_device_info, set_charged_work.work);
-
- dev_dbg(di->dev, "%s\n", __func__);
-
- ds2760_battery_read_status(di);
-
- /* When we get notified by external circuitry that the battery is
- * considered fully charged now, we know that there is no current
- * flow any more. However, the ds2760's internal current meter is
- * too inaccurate to rely on - spec say something ~15% failure.
- * Hence, we use the current offset bias register to compensate
- * that error.
- */
-
- if (!power_supply_am_i_supplied(di->bat))
- return;
-
- bias = (signed char) di->current_raw +
- (signed char) di->raw[DS2760_CURRENT_OFFSET_BIAS];
-
- dev_dbg(di->dev, "%s: bias = %d\n", __func__, bias);
-
- w1_ds2760_write(di->dev, &bias, DS2760_CURRENT_OFFSET_BIAS, 1);
- w1_ds2760_store_eeprom(di->dev, DS2760_EEPROM_BLOCK1);
- w1_ds2760_recall_eeprom(di->dev, DS2760_EEPROM_BLOCK1);
-
- /* Write to the di->raw[] buffer directly - the CURRENT_OFFSET_BIAS
- * value won't be read back by ds2760_battery_read_status() */
- di->raw[DS2760_CURRENT_OFFSET_BIAS] = bias;
-}
-
-static void ds2760_battery_set_charged(struct power_supply *psy)
-{
- struct ds2760_device_info *di = power_supply_get_drvdata(psy);
-
- /* postpone the actual work by 20 secs. This is for debouncing GPIO
- * signals and to let the current value settle. See AN4188. */
- mod_delayed_work(di->monitor_wqueue, &di->set_charged_work, HZ * 20);
-}
-
static int ds2760_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -692,7 +647,6 @@ static int w1_ds2760_add_slave(struct w1_slave *sl)
di->bat_desc.set_property = ds2760_battery_set_property;
di->bat_desc.property_is_writeable =
ds2760_battery_property_is_writeable;
- di->bat_desc.set_charged = ds2760_battery_set_charged;
di->bat_desc.external_power_changed =
ds2760_battery_external_power_changed;
@@ -747,8 +701,6 @@ static int w1_ds2760_add_slave(struct w1_slave *sl)
}
INIT_DELAYED_WORK(&di->monitor_work, ds2760_battery_work);
- INIT_DELAYED_WORK(&di->set_charged_work,
- ds2760_battery_set_charged_work);
di->monitor_wqueue = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
if (!di->monitor_wqueue) {
retval = -ESRCH;
@@ -774,7 +726,6 @@ static void w1_ds2760_remove_slave(struct w1_slave *sl)
unregister_pm_notifier(&di->pm_notifier);
cancel_delayed_work_sync(&di->monitor_work);
- cancel_delayed_work_sync(&di->set_charged_work);
destroy_workqueue(di->monitor_wqueue);
}
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 0/3] power: supply: set_charged deadcode
2025-03-07 23:02 [PATCH 0/3] power: supply: set_charged deadcode linux
` (2 preceding siblings ...)
2025-03-07 23:02 ` [PATCH 3/3] power: supply: Remove unused set_charged method linux
@ 2025-03-08 0:14 ` Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2025-03-08 0:14 UTC (permalink / raw)
To: sre, linux-pm, linux; +Cc: linux-kernel
On Fri, 07 Mar 2025 23:02:22 +0000, linux@treblig.org wrote:
> From: "Dr. David Alan Gilbert" <linux@treblig.org>
>
> Hi,
> This series removes power_supply_set_battery_charged()
> which hasn't been called for a while, and then goes to clean up
> the set_charged() method which it was the only caller of.
> The only setter of it was the ds2760, which I'm not too sure
> is used any more, but I've left the device in.
>
> [...]
Applied, thanks!
[1/3] power: supply: core: Remove unused power_supply_set_battery_charged
commit: 46723e2839a543859a754b0e6b6f88fa71038b09
[2/3] power: supply: ds2760: Remove unused ds2760_battery_set_charged
commit: 172b7d79f79629300e7a6d16bc7e743b11e5ff2c
[3/3] power: supply: Remove unused set_charged method
commit: 68b6cf4020726a8be4fa4462e12b16c7fcf8487d
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread