All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal: Constify 'type' argument for the registration routine
@ 2012-06-18  4:50 Anton Vorontsov
  2012-06-18  6:19 ` Jean Delvare
  2012-06-20  0:11 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Anton Vorontsov @ 2012-06-18  4:50 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Len Brown, Jean Delvare, linux-kernel

thermal_zone_device_register() does not modify 'type' argument, so
it is safe to declare it as const. Otherwise, if we pass a const
string, we are getting the ugly warning:

  CC      drivers/power/power_supply_core.o
drivers/power/power_supply_core.c: In function 'psy_register_thermal':
drivers/power/power_supply_core.c:204:6: warning: passing argument 1 of ‘thermal_zone_device_register’ discards 'const' qualifier from pointer target type [enabled by default]
include/linux/thermal.h:140:29: note: expected 'char *' but argument is of type 'const char *'

Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
---
 drivers/thermal/thermal_sys.c |    2 +-
 include/linux/thermal.h       |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 022bacb..3bf68c9 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1106,7 +1106,7 @@ EXPORT_SYMBOL(thermal_zone_device_update);
  * longer needed. The passive cooling formula uses tc1 and tc2 as described in
  * section 11.1.5.1 of the ACPI specification 3.0.
  */
-struct thermal_zone_device *thermal_zone_device_register(char *type,
+struct thermal_zone_device *thermal_zone_device_register(const char *type,
 	int trips, void *devdata,
 	const struct thermal_zone_device_ops *ops,
 	int tc1, int tc2, int passive_delay, int polling_delay)
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 796f1ff..ef75757 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -137,7 +137,8 @@ enum {
 };
 #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)
 
-struct thermal_zone_device *thermal_zone_device_register(char *, int, void *,
+struct thermal_zone_device *
+thermal_zone_device_register(const char *, int, void *,
 		const struct thermal_zone_device_ops *, int tc1, int tc2,
 		int passive_freq, int polling_freq);
 void thermal_zone_device_unregister(struct thermal_zone_device *);
-- 
1.7.10.4


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

* Re: [PATCH] thermal: Constify 'type' argument for the registration routine
  2012-06-18  4:50 [PATCH] thermal: Constify 'type' argument for the registration routine Anton Vorontsov
@ 2012-06-18  6:19 ` Jean Delvare
  2012-06-20  0:11 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2012-06-18  6:19 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Andrew Morton, Len Brown, linux-kernel

On Sun, 17 Jun 2012 21:50:37 -0700, Anton Vorontsov wrote:
> thermal_zone_device_register() does not modify 'type' argument, so
> it is safe to declare it as const. Otherwise, if we pass a const
> string, we are getting the ugly warning:
> 
>   CC      drivers/power/power_supply_core.o
> drivers/power/power_supply_core.c: In function 'psy_register_thermal':
> drivers/power/power_supply_core.c:204:6: warning: passing argument 1 of ‘thermal_zone_device_register’ discards 'const' qualifier from pointer target type [enabled by default]
> include/linux/thermal.h:140:29: note: expected 'char *' but argument is of type 'const char *'
> 
> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
> ---
>  drivers/thermal/thermal_sys.c |    2 +-
>  include/linux/thermal.h       |    3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 022bacb..3bf68c9 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -1106,7 +1106,7 @@ EXPORT_SYMBOL(thermal_zone_device_update);
>   * longer needed. The passive cooling formula uses tc1 and tc2 as described in
>   * section 11.1.5.1 of the ACPI specification 3.0.
>   */
> -struct thermal_zone_device *thermal_zone_device_register(char *type,
> +struct thermal_zone_device *thermal_zone_device_register(const char *type,
>  	int trips, void *devdata,
>  	const struct thermal_zone_device_ops *ops,
>  	int tc1, int tc2, int passive_delay, int polling_delay)
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 796f1ff..ef75757 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -137,7 +137,8 @@ enum {
>  };
>  #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)
>  
> -struct thermal_zone_device *thermal_zone_device_register(char *, int, void *,
> +struct thermal_zone_device *
> +thermal_zone_device_register(const char *, int, void *,
>  		const struct thermal_zone_device_ops *, int tc1, int tc2,
>  		int passive_freq, int polling_freq);
>  void thermal_zone_device_unregister(struct thermal_zone_device *);

Acked-by: Jean Delvare <khali@linux-fr.org>

-- 
Jean Delvare

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

* Re: [PATCH] thermal: Constify 'type' argument for the registration routine
  2012-06-18  4:50 [PATCH] thermal: Constify 'type' argument for the registration routine Anton Vorontsov
  2012-06-18  6:19 ` Jean Delvare
@ 2012-06-20  0:11 ` Andrew Morton
  2012-06-20  1:25   ` Anton Vorontsov
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2012-06-20  0:11 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Len Brown, Jean Delvare, linux-kernel

On Sun, 17 Jun 2012 21:50:37 -0700
Anton Vorontsov <anton.vorontsov@linaro.org> wrote:

> thermal_zone_device_register() does not modify 'type' argument, so
> it is safe to declare it as const. Otherwise, if we pass a const
> string, we are getting the ugly warning:
> 
> ...
>

For some reason I can't apply this.  I typed it in again and it seems
to work OK.  I'll assume that someone else will merge it into
whatever-tree-broke.

> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -137,7 +137,8 @@ enum {
>  };
>  #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)
>  
> -struct thermal_zone_device *thermal_zone_device_register(char *, int, void *,
> +struct thermal_zone_device *
> +thermal_zone_device_register(const char *, int, void *,
>  		const struct thermal_zone_device_ops *, int tc1, int tc2,
>  		int passive_freq, int polling_freq);
>  void thermal_zone_device_unregister(struct thermal_zone_device *);

Personally, I prefer it when the arguments are named in the declaration
- if you ever have reason to *read* the thing, the lack of names is
quite maddening.  Particularly when the function has 72 arguments.

But naming some of them and not others is just daft.

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

* Re: [PATCH] thermal: Constify 'type' argument for the registration routine
  2012-06-20  0:11 ` Andrew Morton
@ 2012-06-20  1:25   ` Anton Vorontsov
  0 siblings, 0 replies; 4+ messages in thread
From: Anton Vorontsov @ 2012-06-20  1:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Len Brown, Jean Delvare, linux-kernel

On Tue, Jun 19, 2012 at 05:11:28PM -0700, Andrew Morton wrote:
> On Sun, 17 Jun 2012 21:50:37 -0700
> Anton Vorontsov <anton.vorontsov@linaro.org> wrote:
> 
> > thermal_zone_device_register() does not modify 'type' argument, so
> > it is safe to declare it as const. Otherwise, if we pass a const
> > string, we are getting the ugly warning:
> > 
> > ...
> >
> 
> For some reason I can't apply this.

The reason is the same patch in ACPI tree that "broke" battery tree;
we're just touching the same lines of code and that causes some pain.

> I typed it in again and it seems
> to work OK.  I'll assume that someone else will merge it into
> whatever-tree-broke.

Len, will you merge this patch? Or should I take it into battery
tree? (If I'm taking it, then Stephen will have to resolve some
conflicts upon next -next tree generation.)

> > +struct thermal_zone_device *
> > +thermal_zone_device_register(const char *, int, void *,
> >  		const struct thermal_zone_device_ops *, int tc1, int tc2,
> >  		int passive_freq, int polling_freq);
> >  void thermal_zone_device_unregister(struct thermal_zone_device *);
> 
> Personally, I prefer it when the arguments are named in the declaration
> - if you ever have reason to *read* the thing, the lack of names is
> quite maddening.  Particularly when the function has 72 arguments.

:-)

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

end of thread, other threads:[~2012-06-20  1:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-18  4:50 [PATCH] thermal: Constify 'type' argument for the registration routine Anton Vorontsov
2012-06-18  6:19 ` Jean Delvare
2012-06-20  0:11 ` Andrew Morton
2012-06-20  1:25   ` Anton Vorontsov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.