Skip to content

Commit 9584051

Browse files
batcheusre
authored andcommitted
power: supply: charger-manager: Remove cm_notify_event function
cm_notify_event() was introduced to get an event associated with the battery status externally (ie in board files), but no one ever used it. Moreover it makes charger manager driver more complicated. Drop the function and all data related to it to simplify the driver. Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 033dea1 commit 9584051

2 files changed

Lines changed: 16 additions & 200 deletions

File tree

‎drivers/power/supply/charger-manager.c‎

Lines changed: 10 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -434,25 +434,18 @@ static int try_charger_restart(struct charger_manager *cm)
434434

435435
/**
436436
* fullbatt_vchk - Check voltage drop some times after "FULL" event.
437-
* @work: the work_struct appointing the function
438437
*
439-
* If a user has designated "fullbatt_vchkdrop_ms/uV" values with
438+
* If a user has designated "fullbatt_vchkdrop_uV" values with
440439
* charger_desc, Charger Manager checks voltage drop after the battery
441440
* "FULL" event. It checks whether the voltage has dropped more than
442441
* fullbatt_vchkdrop_uV by calling this function after fullbatt_vchkrop_ms.
443442
*/
444-
static void fullbatt_vchk(struct work_struct *work)
443+
static void fullbatt_vchk(struct charger_manager *cm)
445444
{
446-
struct delayed_work *dwork = to_delayed_work(work);
447-
struct charger_manager *cm = container_of(dwork,
448-
struct charger_manager, fullbatt_vchk_work);
449445
struct charger_desc *desc = cm->desc;
450446
int batt_uV, err, diff;
451447

452-
/* remove the appointment for fullbatt_vchk */
453-
cm->fullbatt_vchk_jiffies_at = 0;
454-
455-
if (!desc->fullbatt_vchkdrop_uV || !desc->fullbatt_vchkdrop_ms)
448+
if (!desc->fullbatt_vchkdrop_uV)
456449
return;
457450

458451
err = get_batt_uV(cm, &batt_uV);
@@ -588,9 +581,11 @@ static int cm_check_thermal_status(struct charger_manager *cm)
588581
}
589582

590583
if (temp > upper_limit)
591-
ret = CM_EVENT_BATT_OVERHEAT;
584+
ret = CM_BATT_OVERHEAT;
592585
else if (temp < lower_limit)
593-
ret = CM_EVENT_BATT_COLD;
586+
ret = CM_BATT_COLD;
587+
else
588+
ret = CM_BATT_OK;
594589

595590
return ret;
596591
}
@@ -635,7 +630,7 @@ static bool _cm_monitor(struct charger_manager *cm)
635630
*/
636631
} else if (!cm->emergency_stop && is_ext_pwr_online(cm) &&
637632
!cm->charger_enabled) {
638-
fullbatt_vchk(&cm->fullbatt_vchk_work.work);
633+
fullbatt_vchk(cm);
639634

640635
/*
641636
* Check whether fully charged state to protect overcharge
@@ -648,7 +643,7 @@ static bool _cm_monitor(struct charger_manager *cm)
648643

649644
try_charger_enable(cm, false);
650645

651-
fullbatt_vchk(&cm->fullbatt_vchk_work.work);
646+
fullbatt_vchk(cm);
652647
} else {
653648
cm->emergency_stop = 0;
654649
if (is_ext_pwr_online(cm)) {
@@ -750,66 +745,6 @@ static void cm_monitor_poller(struct work_struct *work)
750745
schedule_work(&setup_polling);
751746
}
752747

753-
/**
754-
* fullbatt_handler - Event handler for CM_EVENT_BATT_FULL
755-
* @cm: the Charger Manager representing the battery.
756-
*/
757-
static void fullbatt_handler(struct charger_manager *cm)
758-
{
759-
struct charger_desc *desc = cm->desc;
760-
761-
if (!desc->fullbatt_vchkdrop_uV || !desc->fullbatt_vchkdrop_ms)
762-
goto out;
763-
764-
if (cm_suspended)
765-
device_set_wakeup_capable(cm->dev, true);
766-
767-
mod_delayed_work(cm_wq, &cm->fullbatt_vchk_work,
768-
msecs_to_jiffies(desc->fullbatt_vchkdrop_ms));
769-
cm->fullbatt_vchk_jiffies_at = jiffies + msecs_to_jiffies(
770-
desc->fullbatt_vchkdrop_ms);
771-
772-
if (cm->fullbatt_vchk_jiffies_at == 0)
773-
cm->fullbatt_vchk_jiffies_at = 1;
774-
775-
out:
776-
dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged\n");
777-
power_supply_changed(cm->charger_psy);
778-
}
779-
780-
/**
781-
* battout_handler - Event handler for CM_EVENT_BATT_OUT
782-
* @cm: the Charger Manager representing the battery.
783-
*/
784-
static void battout_handler(struct charger_manager *cm)
785-
{
786-
if (cm_suspended)
787-
device_set_wakeup_capable(cm->dev, true);
788-
789-
if (!is_batt_present(cm)) {
790-
dev_emerg(cm->dev, "Battery Pulled Out!\n");
791-
power_supply_changed(cm->charger_psy);
792-
} else {
793-
power_supply_changed(cm->charger_psy);
794-
}
795-
}
796-
797-
/**
798-
* misc_event_handler - Handler for other events
799-
* @cm: the Charger Manager representing the battery.
800-
* @type: the Charger Manager representing the battery.
801-
*/
802-
static void misc_event_handler(struct charger_manager *cm,
803-
enum cm_event_types type)
804-
{
805-
if (cm_suspended)
806-
device_set_wakeup_capable(cm->dev, true);
807-
808-
if (is_polling_required(cm) && cm->desc->polling_interval_ms)
809-
schedule_work(&setup_polling);
810-
power_supply_changed(cm->charger_psy);
811-
}
812-
813748
static int charger_get_property(struct power_supply *psy,
814749
enum power_supply_property psp,
815750
union power_supply_propval *val)
@@ -1000,21 +935,6 @@ static bool cm_setup_timer(void)
1000935

1001936
mutex_lock(&cm_list_mtx);
1002937
list_for_each_entry(cm, &cm_list, entry) {
1003-
unsigned int fbchk_ms = 0;
1004-
1005-
/* fullbatt_vchk is required. setup timer for that */
1006-
if (cm->fullbatt_vchk_jiffies_at) {
1007-
fbchk_ms = jiffies_to_msecs(cm->fullbatt_vchk_jiffies_at
1008-
- jiffies);
1009-
if (time_is_before_eq_jiffies(
1010-
cm->fullbatt_vchk_jiffies_at) ||
1011-
msecs_to_jiffies(fbchk_ms) < CM_JIFFIES_SMALL) {
1012-
fullbatt_vchk(&cm->fullbatt_vchk_work.work);
1013-
fbchk_ms = 0;
1014-
}
1015-
}
1016-
CM_MIN_VALID(wakeup_ms, fbchk_ms);
1017-
1018938
/* Skip if polling is not required for this CM */
1019939
if (!is_polling_required(cm) && !cm->emergency_stop)
1020940
continue;
@@ -1422,8 +1342,6 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
14221342
of_property_read_u32(np, "cm-poll-interval",
14231343
&desc->polling_interval_ms);
14241344

1425-
of_property_read_u32(np, "cm-fullbatt-vchkdrop-ms",
1426-
&desc->fullbatt_vchkdrop_ms);
14271345
of_property_read_u32(np, "cm-fullbatt-vchkdrop-volt",
14281346
&desc->fullbatt_vchkdrop_uV);
14291347
of_property_read_u32(np, "cm-fullbatt-voltage", &desc->fullbatt_uV);
@@ -1585,9 +1503,8 @@ static int charger_manager_probe(struct platform_device *pdev)
15851503
if (desc->fullbatt_uV == 0) {
15861504
dev_info(&pdev->dev, "Ignoring full-battery voltage threshold as it is not supplied\n");
15871505
}
1588-
if (!desc->fullbatt_vchkdrop_ms || !desc->fullbatt_vchkdrop_uV) {
1506+
if (!desc->fullbatt_vchkdrop_uV) {
15891507
dev_info(&pdev->dev, "Disabling full-battery voltage drop checking mechanism as it is not supplied\n");
1590-
desc->fullbatt_vchkdrop_ms = 0;
15911508
desc->fullbatt_vchkdrop_uV = 0;
15921509
}
15931510
if (desc->fullbatt_soc == 0) {
@@ -1693,8 +1610,6 @@ static int charger_manager_probe(struct platform_device *pdev)
16931610
cm->charger_psy_desc.properties = properties;
16941611
cm->charger_psy_desc.num_properties = num_properties;
16951612

1696-
INIT_DELAYED_WORK(&cm->fullbatt_vchk_work, fullbatt_vchk);
1697-
16981613
/* Register sysfs entry for charger(regulator) */
16991614
ret = charger_manager_prepare_sysfs(cm);
17001615
if (ret < 0) {
@@ -1834,8 +1749,6 @@ static bool cm_need_to_awake(void)
18341749

18351750
static int cm_suspend_prepare(struct device *dev)
18361751
{
1837-
struct charger_manager *cm = dev_get_drvdata(dev);
1838-
18391752
if (cm_need_to_awake())
18401753
return -EBUSY;
18411754

@@ -1847,7 +1760,6 @@ static int cm_suspend_prepare(struct device *dev)
18471760
if (cm_timer_set) {
18481761
cancel_work_sync(&setup_polling);
18491762
cancel_delayed_work_sync(&cm_monitor_work);
1850-
cancel_delayed_work(&cm->fullbatt_vchk_work);
18511763
}
18521764

18531765
return 0;
@@ -1872,31 +1784,6 @@ static void cm_suspend_complete(struct device *dev)
18721784

18731785
_cm_monitor(cm);
18741786

1875-
/* Re-enqueue delayed work (fullbatt_vchk_work) */
1876-
if (cm->fullbatt_vchk_jiffies_at) {
1877-
unsigned long delay = 0;
1878-
unsigned long now = jiffies + CM_JIFFIES_SMALL;
1879-
1880-
if (time_after_eq(now, cm->fullbatt_vchk_jiffies_at)) {
1881-
delay = (unsigned long)((long)now
1882-
- (long)(cm->fullbatt_vchk_jiffies_at));
1883-
delay = jiffies_to_msecs(delay);
1884-
} else {
1885-
delay = 0;
1886-
}
1887-
1888-
/*
1889-
* Account for cm_suspend_duration_ms with assuming that
1890-
* timer stops in suspend.
1891-
*/
1892-
if (delay > cm_suspend_duration_ms)
1893-
delay -= cm_suspend_duration_ms;
1894-
else
1895-
delay = 0;
1896-
1897-
queue_delayed_work(cm_wq, &cm->fullbatt_vchk_work,
1898-
msecs_to_jiffies(delay));
1899-
}
19001787
device_set_wakeup_capable(cm->dev, false);
19011788
}
19021789

@@ -1938,56 +1825,6 @@ static void __exit charger_manager_cleanup(void)
19381825
}
19391826
module_exit(charger_manager_cleanup);
19401827

1941-
/**
1942-
* cm_notify_event - charger driver notify Charger Manager of charger event
1943-
* @psy: pointer to instance of charger's power_supply
1944-
* @type: type of charger event
1945-
* @msg: optional message passed to uevent_notify function
1946-
*/
1947-
void cm_notify_event(struct power_supply *psy, enum cm_event_types type,
1948-
char *msg)
1949-
{
1950-
struct charger_manager *cm;
1951-
bool found_power_supply = false;
1952-
1953-
if (psy == NULL)
1954-
return;
1955-
1956-
mutex_lock(&cm_list_mtx);
1957-
list_for_each_entry(cm, &cm_list, entry) {
1958-
if (match_string(cm->desc->psy_charger_stat, -1,
1959-
psy->desc->name) >= 0) {
1960-
found_power_supply = true;
1961-
break;
1962-
}
1963-
}
1964-
mutex_unlock(&cm_list_mtx);
1965-
1966-
if (!found_power_supply)
1967-
return;
1968-
1969-
switch (type) {
1970-
case CM_EVENT_BATT_FULL:
1971-
fullbatt_handler(cm);
1972-
break;
1973-
case CM_EVENT_BATT_OUT:
1974-
battout_handler(cm);
1975-
break;
1976-
case CM_EVENT_BATT_IN:
1977-
case CM_EVENT_EXT_PWR_IN_OUT ... CM_EVENT_CHG_START_STOP:
1978-
misc_event_handler(cm, type);
1979-
break;
1980-
case CM_EVENT_UNKNOWN:
1981-
case CM_EVENT_OTHERS:
1982-
power_supply_changed(cm->charger_psy);
1983-
break;
1984-
default:
1985-
dev_err(cm->dev, "%s: type not specified\n", __func__);
1986-
break;
1987-
}
1988-
}
1989-
EXPORT_SYMBOL_GPL(cm_notify_event);
1990-
19911828
MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
19921829
MODULE_DESCRIPTION("Charger Manager");
19931830
MODULE_LICENSE("GPL");

‎include/linux/power/charger-manager.h‎

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,10 @@ enum polling_modes {
3131
CM_POLL_CHARGING_ONLY,
3232
};
3333

34-
enum cm_event_types {
35-
CM_EVENT_UNKNOWN = 0,
36-
CM_EVENT_BATT_FULL,
37-
CM_EVENT_BATT_IN,
38-
CM_EVENT_BATT_OUT,
39-
CM_EVENT_BATT_OVERHEAT,
40-
CM_EVENT_BATT_COLD,
41-
CM_EVENT_EXT_PWR_IN_OUT,
42-
CM_EVENT_CHG_START_STOP,
43-
CM_EVENT_OTHERS,
34+
enum cm_batt_temp {
35+
CM_BATT_OK = 0,
36+
CM_BATT_OVERHEAT,
37+
CM_BATT_COLD,
4438
};
4539

4640
/**
@@ -131,11 +125,10 @@ struct charger_regulator {
131125
* @psy_name: the name of power-supply-class for charger manager
132126
* @polling_mode:
133127
* Determine which polling mode will be used
134-
* @fullbatt_vchkdrop_ms:
135128
* @fullbatt_vchkdrop_uV:
136129
* Check voltage drop after the battery is fully charged.
137-
* If it has dropped more than fullbatt_vchkdrop_uV after
138-
* fullbatt_vchkdrop_ms, CM will restart charging.
130+
* If it has dropped more than fullbatt_vchkdrop_uV
131+
* CM will restart charging.
139132
* @fullbatt_uV: voltage in microvolt
140133
* If VBATT >= fullbatt_uV, it is assumed to be full.
141134
* @fullbatt_soc: state of Charge in %
@@ -172,7 +165,6 @@ struct charger_desc {
172165
enum polling_modes polling_mode;
173166
unsigned int polling_interval_ms;
174167

175-
unsigned int fullbatt_vchkdrop_ms;
176168
unsigned int fullbatt_vchkdrop_uV;
177169
unsigned int fullbatt_uV;
178170
unsigned int fullbatt_soc;
@@ -211,9 +203,6 @@ struct charger_desc {
211203
* @charger_stat: array of power_supply for chargers
212204
* @tzd_batt : thermal zone device for battery
213205
* @charger_enabled: the state of charger
214-
* @fullbatt_vchk_jiffies_at:
215-
* jiffies at the time full battery check will occur.
216-
* @fullbatt_vchk_work: work queue for full battery check
217206
* @emergency_stop:
218207
* When setting true, stop charging
219208
* @psy_name_buf: the name of power-supply-class for charger manager
@@ -235,9 +224,6 @@ struct charger_manager {
235224
#endif
236225
bool charger_enabled;
237226

238-
unsigned long fullbatt_vchk_jiffies_at;
239-
struct delayed_work fullbatt_vchk_work;
240-
241227
int emergency_stop;
242228

243229
char psy_name_buf[PSY_NAME_MAX + 1];
@@ -248,11 +234,4 @@ struct charger_manager {
248234
u64 charging_end_time;
249235
};
250236

251-
#if IS_ENABLED(CONFIG_CHARGER_MANAGER)
252-
extern void cm_notify_event(struct power_supply *psy,
253-
enum cm_event_types type, char *msg);
254-
#else
255-
static inline void cm_notify_event(struct power_supply *psy,
256-
enum cm_event_types type, char *msg) { }
257-
#endif
258237
#endif /* _CHARGER_MANAGER_H */

0 commit comments

Comments
 (0)