diff mbox series

[7/7] hwmon/drivers/core: Simplify complex dependency

Message ID 20190402161256.11044-7-daniel.lezcano@linaro.org
State Accepted
Commit f37353320ee9905ef7aaba4c67eae85496bee950
Headers show
Series [1/7] thermal/drivers/core: Remove the module Kconfig's option | expand

Commit Message

Daniel Lezcano April 2, 2019, 4:12 p.m. UTC
As the thermal framework does not longer compile as a module, we can
simplify this condition below:

 if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
       (!defined(CONFIG_THERMAL_HWMON) || \
        !(defined(MODULE) && IS_MODULE(CONFIG_THERMAL)))

 if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
       (!defined(CONFIG_THERMAL_HWMON) || \
        !(defined(MODULE) && 0))

=> (whatever && 0) = 0

 if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
       (!defined(CONFIG_THERMAL_HWMON) || !(0))

 if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
       (!defined(CONFIG_THERMAL_HWMON) || 1)

=> (whatever || 1) = 1

 if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
       (1)

=> (whatever && 1) = whatever

 if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF)

CONFIG_THERMAL can not be a module anymore, then:

 if defined(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF)

And CONFIG_THERMAL_OF already depends on CONFIG_THERMAL, so:

 if defined(CONFIG_THERMAL_OF)

Thus,

 ifdef CONFIG_THERMAL_OF

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

---
 drivers/hwmon/hwmon.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

-- 
2.17.1

Comments

Guenter Roeck April 2, 2019, 6:23 p.m. UTC | #1
On Tue, Apr 02, 2019 at 06:12:50PM +0200, Daniel Lezcano wrote:
> As the thermal framework does not longer compile as a module, we can

> simplify this condition below:

> 

>  if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \

>        (!defined(CONFIG_THERMAL_HWMON) || \

>         !(defined(MODULE) && IS_MODULE(CONFIG_THERMAL)))

> 

>  if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \

>        (!defined(CONFIG_THERMAL_HWMON) || \

>         !(defined(MODULE) && 0))

> 

> => (whatever && 0) = 0

> 

>  if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \

>        (!defined(CONFIG_THERMAL_HWMON) || !(0))

> 

>  if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \

>        (!defined(CONFIG_THERMAL_HWMON) || 1)

> 

> => (whatever || 1) = 1

> 

>  if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \

>        (1)

> 

> => (whatever && 1) = whatever

> 

>  if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF)

> 

> CONFIG_THERMAL can not be a module anymore, then:

> 

>  if defined(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF)

> 

> And CONFIG_THERMAL_OF already depends on CONFIG_THERMAL, so:

> 

>  if defined(CONFIG_THERMAL_OF)

> 

> Thus,

> 

>  ifdef CONFIG_THERMAL_OF

> 

> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>


Acked-by: Guenter Roeck <linux@roeck-us.net>


... assuming this will be pushed with the series. Otherwise please
let me know.

Thanks,
Guenter

> ---

>  drivers/hwmon/hwmon.c | 4 +---

>  1 file changed, 1 insertion(+), 3 deletions(-)

> 

> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c

> index c22dc1e07911..6f76f2484db0 100644

> --- a/drivers/hwmon/hwmon.c

> +++ b/drivers/hwmon/hwmon.c

> @@ -118,9 +118,7 @@ static DEFINE_IDA(hwmon_ida);

>   * The complex conditional is necessary to avoid a cyclic dependency

>   * between hwmon and thermal_sys modules.

>   */

> -#if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \

> -	(!defined(CONFIG_THERMAL_HWMON) || \

> -	 !(defined(MODULE) && IS_MODULE(CONFIG_THERMAL)))

> +#ifdef CONFIG_THERMAL_OF

>  static int hwmon_thermal_get_temp(void *data, int *temp)

>  {

>  	struct hwmon_thermal_data *tdata = data;

> -- 

> 2.17.1

>
diff mbox series

Patch

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index c22dc1e07911..6f76f2484db0 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -118,9 +118,7 @@  static DEFINE_IDA(hwmon_ida);
  * The complex conditional is necessary to avoid a cyclic dependency
  * between hwmon and thermal_sys modules.
  */
-#if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
-	(!defined(CONFIG_THERMAL_HWMON) || \
-	 !(defined(MODULE) && IS_MODULE(CONFIG_THERMAL)))
+#ifdef CONFIG_THERMAL_OF
 static int hwmon_thermal_get_temp(void *data, int *temp)
 {
 	struct hwmon_thermal_data *tdata = data;