2020-02-11 09:08:32

by Baolin Wang

[permalink] [raw]
Subject: [PATCH] power: supply: Allow charger manager can be built as a module

Allow charger manager can be built as a module like other charger
drivers.

Signed-off-by: Baolin Wang <[email protected]>
---
drivers/power/supply/Kconfig | 2 +-
include/linux/power/charger-manager.h | 7 +------
2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index 9a5591a..195bc04 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -480,7 +480,7 @@ config CHARGER_GPIO
called gpio-charger.

config CHARGER_MANAGER
- bool "Battery charger manager for multiple chargers"
+ tristate "Battery charger manager for multiple chargers"
depends on REGULATOR
select EXTCON
help
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
index ad19e68..40493b2 100644
--- a/include/linux/power/charger-manager.h
+++ b/include/linux/power/charger-manager.h
@@ -248,11 +248,6 @@ struct charger_manager {
u64 charging_end_time;
};

-#ifdef CONFIG_CHARGER_MANAGER
extern void cm_notify_event(struct power_supply *psy,
- enum cm_event_types type, char *msg);
-#else
-static inline void cm_notify_event(struct power_supply *psy,
- enum cm_event_types type, char *msg) { }
-#endif
+ enum cm_event_types type, char *msg);
#endif /* _CHARGER_MANAGER_H */
--
1.7.9.5


2020-02-27 16:06:56

by Orson Zhai

[permalink] [raw]
Subject: Re: [PATCH] power: supply: Allow charger manager can be built as a module

Hi Sebastian and other guys here,

On Tue, Feb 11, 2020 at 4:51 PM Baolin Wang <[email protected]> wrote:
>
> Allow charger manager can be built as a module like other charger
> drivers.
>
What do you think about this patch?
We want to set charger-manager as module in our project for new Android devices.

-Orson

> Signed-off-by: Baolin Wang <[email protected]>
> ---
> drivers/power/supply/Kconfig | 2 +-
> include/linux/power/charger-manager.h | 7 +------
> 2 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
> index 9a5591a..195bc04 100644
> --- a/drivers/power/supply/Kconfig
> +++ b/drivers/power/supply/Kconfig
> @@ -480,7 +480,7 @@ config CHARGER_GPIO
> called gpio-charger.
>
> config CHARGER_MANAGER
> - bool "Battery charger manager for multiple chargers"
> + tristate "Battery charger manager for multiple chargers"
> depends on REGULATOR
> select EXTCON
> help
> diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
> index ad19e68..40493b2 100644
> --- a/include/linux/power/charger-manager.h
> +++ b/include/linux/power/charger-manager.h
> @@ -248,11 +248,6 @@ struct charger_manager {
> u64 charging_end_time;
> };
>
> -#ifdef CONFIG_CHARGER_MANAGER
> extern void cm_notify_event(struct power_supply *psy,
> - enum cm_event_types type, char *msg);
> -#else
> -static inline void cm_notify_event(struct power_supply *psy,
> - enum cm_event_types type, char *msg) { }
> -#endif
> + enum cm_event_types type, char *msg);
> #endif /* _CHARGER_MANAGER_H */
> --
> 1.7.9.5
>

2020-02-28 02:56:24

by Saravana Kannan

[permalink] [raw]
Subject: Re: [PATCH] power: supply: Allow charger manager can be built as a module

On Thu, Feb 27, 2020 at 8:06 AM Orson Zhai <[email protected]> wrote:
>
> Hi Sebastian and other guys here,
>
> On Tue, Feb 11, 2020 at 4:51 PM Baolin Wang <[email protected]> wrote:
> >
> > Allow charger manager can be built as a module like other charger
> > drivers.
> >
> What do you think about this patch?
> We want to set charger-manager as module in our project for new Android devices.
>
> -Orson
>
> > Signed-off-by: Baolin Wang <[email protected]>
> > ---
> > drivers/power/supply/Kconfig | 2 +-
> > include/linux/power/charger-manager.h | 7 +------
> > 2 files changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
> > index 9a5591a..195bc04 100644
> > --- a/drivers/power/supply/Kconfig
> > +++ b/drivers/power/supply/Kconfig
> > @@ -480,7 +480,7 @@ config CHARGER_GPIO
> > called gpio-charger.
> >
> > config CHARGER_MANAGER
> > - bool "Battery charger manager for multiple chargers"
> > + tristate "Battery charger manager for multiple chargers"
> > depends on REGULATOR
> > select EXTCON
> > help
> > diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
> > index ad19e68..40493b2 100644
> > --- a/include/linux/power/charger-manager.h
> > +++ b/include/linux/power/charger-manager.h
> > @@ -248,11 +248,6 @@ struct charger_manager {
> > u64 charging_end_time;
> > };
> >
> > -#ifdef CONFIG_CHARGER_MANAGER
> > extern void cm_notify_event(struct power_supply *psy,
> > - enum cm_event_types type, char *msg);
> > -#else
> > -static inline void cm_notify_event(struct power_supply *psy,
> > - enum cm_event_types type, char *msg) { }
> > -#endif
> > + enum cm_event_types type, char *msg);
> > #endif /* _CHARGER_MANAGER_H */

You are breaking the kernel if CONFIG_CHARGER_MANAGER is disabled. Why
not simple change the #ifdef to
#if IS_ENABLED(CONFIG_CHARGER_MANAGER)
?

-Saravana

2020-02-28 05:39:04

by Baolin Wang

[permalink] [raw]
Subject: Re: [PATCH] power: supply: Allow charger manager can be built as a module

On Fri, Feb 28, 2020 at 10:54 AM Saravana Kannan <[email protected]> wrote:
>
> On Thu, Feb 27, 2020 at 8:06 AM Orson Zhai <[email protected]> wrote:
> >
> > Hi Sebastian and other guys here,
> >
> > On Tue, Feb 11, 2020 at 4:51 PM Baolin Wang <[email protected]> wrote:
> > >
> > > Allow charger manager can be built as a module like other charger
> > > drivers.
> > >
> > What do you think about this patch?
> > We want to set charger-manager as module in our project for new Android devices.
> >
> > -Orson
> >
> > > Signed-off-by: Baolin Wang <[email protected]>
> > > ---
> > > drivers/power/supply/Kconfig | 2 +-
> > > include/linux/power/charger-manager.h | 7 +------
> > > 2 files changed, 2 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
> > > index 9a5591a..195bc04 100644
> > > --- a/drivers/power/supply/Kconfig
> > > +++ b/drivers/power/supply/Kconfig
> > > @@ -480,7 +480,7 @@ config CHARGER_GPIO
> > > called gpio-charger.
> > >
> > > config CHARGER_MANAGER
> > > - bool "Battery charger manager for multiple chargers"
> > > + tristate "Battery charger manager for multiple chargers"
> > > depends on REGULATOR
> > > select EXTCON
> > > help
> > > diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
> > > index ad19e68..40493b2 100644
> > > --- a/include/linux/power/charger-manager.h
> > > +++ b/include/linux/power/charger-manager.h
> > > @@ -248,11 +248,6 @@ struct charger_manager {
> > > u64 charging_end_time;
> > > };
> > >
> > > -#ifdef CONFIG_CHARGER_MANAGER
> > > extern void cm_notify_event(struct power_supply *psy,
> > > - enum cm_event_types type, char *msg);
> > > -#else
> > > -static inline void cm_notify_event(struct power_supply *psy,
> > > - enum cm_event_types type, char *msg) { }
> > > -#endif
> > > + enum cm_event_types type, char *msg);
> > > #endif /* _CHARGER_MANAGER_H */
>
> You are breaking the kernel if CONFIG_CHARGER_MANAGER is disabled. Why

No, now no users in mainline have called cm_notify_event() function,
and if some charger drivers want to use the charger manager, they
should select CHARGER_MANAGER, like:
config CHARGER_SC2731
tristate "Spreadtrum SC2731 charger driver"
depends on MFD_SC27XX_PMIC || COMPILE_TEST
select CHARGER_MANAGER

> not simple change the #ifdef to
> #if IS_ENABLED(CONFIG_CHARGER_MANAGER)
> ?

Yes, this also can work, and either way is okay for me. Sebastian,
what do you prefer? Thanks.