mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] thermal: Introduce dummy functions when thermal is not defined
@ 2015-02-14  1:28 Nishanth Menon
  2015-02-24 18:38 ` Eduardo Valentin
  0 siblings, 1 reply; 2+ messages in thread
From: Nishanth Menon @ 2015-02-14  1:28 UTC (permalink / raw)
  To: Eduardo Valentin, Zhang Rui
  Cc: linux-kernel, linux-pm, Guenter Roeck, Nishanth Menon

When CONFIG_THERMAL is not enabled, it is better to introduce
equivalent dummy functions in the exported header than to
introduce #ifdeffery in drivers using the function.

This will prevent issues such as that reported in:
http://www.spinics.net/lists/linux-next/msg31573.html

While at it switch over to IS_ENABLED for thermal macros
to allow for thermal framework to be built as framework
and relevant APIs be usable by relevant drivers as a result.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Nishanth Menon <nm@ti.com>
---

based on next-20150213 tag.

Note: there are a few "CHECK: Alignment should match open parenthesis"
checkpatch warnings which I ignored since these are pure dummy
functions anyways.

 include/linux/thermal.h |   56 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 54 insertions(+), 2 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e307efab..5eac316490ea 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -314,6 +314,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 }
 
 #endif
+
+#if IS_ENABLED(CONFIG_THERMAL)
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
 		const struct thermal_zone_params *, int, int);
@@ -340,8 +342,58 @@ struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
 void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
-
-#ifdef CONFIG_NET
+#else
+static inline struct thermal_zone_device *thermal_zone_device_register(
+	const char *type, int trips, int mask, void *devdata,
+	struct thermal_zone_device_ops *ops,
+	const struct thermal_zone_params *tzp,
+	int passive_delay, int polling_delay)
+{ return ERR_PTR(-ENODEV); }
+static inline void thermal_zone_device_unregister(
+	struct thermal_zone_device *tz)
+{ }
+static inline int thermal_zone_bind_cooling_device(
+	struct thermal_zone_device *tz, int trip,
+	struct thermal_cooling_device *cdev,
+	unsigned long upper, unsigned long lower)
+{ return -ENODEV; }
+static inline int thermal_zone_unbind_cooling_device(
+	struct thermal_zone_device *tz, int trip,
+	struct thermal_cooling_device *cdev)
+{ return -ENODEV; }
+static inline void thermal_zone_device_update(struct thermal_zone_device *tz)
+{ }
+static inline struct thermal_cooling_device *
+thermal_cooling_device_register(char *type, void *devdata,
+	const struct thermal_cooling_device_ops *ops)
+{ return ERR_PTR(-ENODEV); }
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+	char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
+{ return ERR_PTR(-ENODEV); }
+static inline void thermal_cooling_device_unregister(
+	struct thermal_cooling_device *cdev)
+{ }
+static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
+		const char *name)
+{ return ERR_PTR(-ENODEV); }
+static inline int thermal_zone_get_temp(
+		struct thermal_zone_device *tz, unsigned long *temp)
+{ return -ENODEV; }
+static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
+{ return -ENODEV; }
+static inline struct thermal_instance *
+get_thermal_instance(struct thermal_zone_device *tz,
+	struct thermal_cooling_device *cdev, int trip)
+{ return ERR_PTR(-ENODEV); }
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{ }
+static inline void thermal_notify_framework(struct thermal_zone_device *tz,
+	int trip)
+{ }
+#endif /* CONFIG_THERMAL */
+
+#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL)
 extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
 						enum events event);
 #else
-- 
1.7.9.5


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

* Re: [PATCH] thermal: Introduce dummy functions when thermal is not defined
  2015-02-14  1:28 [PATCH] thermal: Introduce dummy functions when thermal is not defined Nishanth Menon
@ 2015-02-24 18:38 ` Eduardo Valentin
  0 siblings, 0 replies; 2+ messages in thread
From: Eduardo Valentin @ 2015-02-24 18:38 UTC (permalink / raw)
  To: Nishanth Menon; +Cc: Zhang Rui, linux-kernel, linux-pm, Guenter Roeck

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

Rui,



On Fri, Feb 13, 2015 at 07:28:02PM -0600, Nishanth Menon wrote:
> When CONFIG_THERMAL is not enabled, it is better to introduce
> equivalent dummy functions in the exported header than to
> introduce #ifdeffery in drivers using the function.
> 
> This will prevent issues such as that reported in:
> http://www.spinics.net/lists/linux-next/msg31573.html
> 
> While at it switch over to IS_ENABLED for thermal macros
> to allow for thermal framework to be built as framework
> and relevant APIs be usable by relevant drivers as a result.
> 
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Nishanth Menon <nm@ti.com>

I am collecting this one and queuing in my -fixes branch.

> ---
> 
> based on next-20150213 tag.
> 
> Note: there are a few "CHECK: Alignment should match open parenthesis"
> checkpatch warnings which I ignored since these are pure dummy
> functions anyways.
> 
>  include/linux/thermal.h |   56 +++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 54 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index fc52e307efab..5eac316490ea 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -314,6 +314,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  }
>  
>  #endif
> +
> +#if IS_ENABLED(CONFIG_THERMAL)
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>  		void *, struct thermal_zone_device_ops *,
>  		const struct thermal_zone_params *, int, int);
> @@ -340,8 +342,58 @@ struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
>  void thermal_cdev_update(struct thermal_cooling_device *);
>  void thermal_notify_framework(struct thermal_zone_device *, int);
> -
> -#ifdef CONFIG_NET
> +#else
> +static inline struct thermal_zone_device *thermal_zone_device_register(
> +	const char *type, int trips, int mask, void *devdata,
> +	struct thermal_zone_device_ops *ops,
> +	const struct thermal_zone_params *tzp,
> +	int passive_delay, int polling_delay)
> +{ return ERR_PTR(-ENODEV); }
> +static inline void thermal_zone_device_unregister(
> +	struct thermal_zone_device *tz)
> +{ }
> +static inline int thermal_zone_bind_cooling_device(
> +	struct thermal_zone_device *tz, int trip,
> +	struct thermal_cooling_device *cdev,
> +	unsigned long upper, unsigned long lower)
> +{ return -ENODEV; }
> +static inline int thermal_zone_unbind_cooling_device(
> +	struct thermal_zone_device *tz, int trip,
> +	struct thermal_cooling_device *cdev)
> +{ return -ENODEV; }
> +static inline void thermal_zone_device_update(struct thermal_zone_device *tz)
> +{ }
> +static inline struct thermal_cooling_device *
> +thermal_cooling_device_register(char *type, void *devdata,
> +	const struct thermal_cooling_device_ops *ops)
> +{ return ERR_PTR(-ENODEV); }
> +static inline struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +	char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
> +{ return ERR_PTR(-ENODEV); }
> +static inline void thermal_cooling_device_unregister(
> +	struct thermal_cooling_device *cdev)
> +{ }
> +static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
> +		const char *name)
> +{ return ERR_PTR(-ENODEV); }
> +static inline int thermal_zone_get_temp(
> +		struct thermal_zone_device *tz, unsigned long *temp)
> +{ return -ENODEV; }
> +static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
> +{ return -ENODEV; }
> +static inline struct thermal_instance *
> +get_thermal_instance(struct thermal_zone_device *tz,
> +	struct thermal_cooling_device *cdev, int trip)
> +{ return ERR_PTR(-ENODEV); }
> +static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> +{ }
> +static inline void thermal_notify_framework(struct thermal_zone_device *tz,
> +	int trip)
> +{ }
> +#endif /* CONFIG_THERMAL */
> +
> +#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL)
>  extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
>  						enum events event);
>  #else
> -- 
> 1.7.9.5
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2015-02-24 18:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-14  1:28 [PATCH] thermal: Introduce dummy functions when thermal is not defined Nishanth Menon
2015-02-24 18:38 ` Eduardo Valentin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®