LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] IIO: struct iio_dev_attr should be defined as static.
@ 2010-04-02  2:55 sonic zhang
  2010-04-06  3:21 ` Sonic Zhang
  2010-04-06 11:30 ` Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: sonic zhang @ 2010-04-02  2:55 UTC (permalink / raw
  To: Jonathan Cameron; +Cc: Linux Kernel, linux-iio


Otherwise link errors "multiple definition of `iio_dev_attr_mode'"
are reported when compile multiple different iio drivers with the
same attribute name.

Signed-off-by: Sonic Zhang <sonic.adi@gmail.com>
---
 drivers/staging/iio/sysfs.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h
index e501e13..39d207e 100644
--- a/drivers/staging/iio/sysfs.h
+++ b/drivers/staging/iio/sysfs.h
@@ -95,16 +95,16 @@ struct iio_const_attr {
 			.val2 = _val2 }
 
 #define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr)	\
-	struct iio_dev_attr iio_dev_attr_##_name		\
+	static struct iio_dev_attr iio_dev_attr_##_name		\
 	= IIO_ATTR(_name, _mode, _show, _store, _addr)
 
 
 #define IIO_DEVICE_ATTR_2(_name, _mode, _show, _store, _addr, _val2)	\
-	struct iio_dev_attr iio_dev_attr_##_name			\
+	static struct iio_dev_attr iio_dev_attr_##_name			\
 	= IIO_ATTR_2(_name, _mode, _show, _store, _addr, _val2)
 
 #define IIO_CONST_ATTR(_name, _string)					\
-	struct iio_const_attr iio_const_attr_##_name			\
+	static struct iio_const_attr iio_const_attr_##_name			\
 	= { .string = _string,						\
 	    .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
 
-- 
1.6.0




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

* Re: [PATCH] IIO: struct iio_dev_attr should be defined as static.
  2010-04-02  2:55 [PATCH] IIO: struct iio_dev_attr should be defined as static sonic zhang
@ 2010-04-06  3:21 ` Sonic Zhang
  2010-04-06 11:30 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Sonic Zhang @ 2010-04-06  3:21 UTC (permalink / raw
  To: Jonathan Cameron; +Cc: Linux Kernel, linux-iio

Hi Jonathan,

Any comments?

Sonic

On Fri, Apr 2, 2010 at 10:55 AM, sonic zhang <sonic.adi@gmail.com> wrote:
>
> Otherwise link errors "multiple definition of `iio_dev_attr_mode'"
> are reported when compile multiple different iio drivers with the
> same attribute name.
>
> Signed-off-by: Sonic Zhang <sonic.adi@gmail.com>
> ---
>  drivers/staging/iio/sysfs.h |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h
> index e501e13..39d207e 100644
> --- a/drivers/staging/iio/sysfs.h
> +++ b/drivers/staging/iio/sysfs.h
> @@ -95,16 +95,16 @@ struct iio_const_attr {
>                        .val2 = _val2 }
>
>  #define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr)    \
> -       struct iio_dev_attr iio_dev_attr_##_name                \
> +       static struct iio_dev_attr iio_dev_attr_##_name         \
>        = IIO_ATTR(_name, _mode, _show, _store, _addr)
>
>
>  #define IIO_DEVICE_ATTR_2(_name, _mode, _show, _store, _addr, _val2)   \
> -       struct iio_dev_attr iio_dev_attr_##_name                        \
> +       static struct iio_dev_attr iio_dev_attr_##_name                 \
>        = IIO_ATTR_2(_name, _mode, _show, _store, _addr, _val2)
>
>  #define IIO_CONST_ATTR(_name, _string)                                 \
> -       struct iio_const_attr iio_const_attr_##_name                    \
> +       static struct iio_const_attr iio_const_attr_##_name                     \
>        = { .string = _string,                                          \
>            .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
>
> --
> 1.6.0
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

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

* Re: [PATCH] IIO: struct iio_dev_attr should be defined as static.
  2010-04-02  2:55 [PATCH] IIO: struct iio_dev_attr should be defined as static sonic zhang
  2010-04-06  3:21 ` Sonic Zhang
@ 2010-04-06 11:30 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2010-04-06 11:30 UTC (permalink / raw
  To: sonic zhang; +Cc: Linux Kernel, linux-iio

On 04/02/10 03:55, sonic zhang wrote:
> 
> Otherwise link errors "multiple definition of `iio_dev_attr_mode'"
> are reported when compile multiple different iio drivers with the
> same attribute name.

Hi Sonic,

Sorry for slow response had long weekend away from all computers!

NAK.  The right place to do this is in the call of the macro, not
in the macro itself. See the many examples in hwmon....

So 

static IIO_DEVICE_ATTR(accel_x, .... etc

This makes it explicit in the drivers.

There were a few calls that were missing this in the mainline driver
set but I think they are all fixed in patches that have gone to Greg
for merging. (Michael Hennerich's patch - the second one in the thread
[PATCH] IIO:sysfs.h: Use static declaration.
The first was as per your patch).

iirc there are a few exceptions where the static is in the header
due to the macro defining a pair of static structures.  Not sure if
there is a cleaner way to handle that.

Thanks,

Jonathan


> 
> Signed-off-by: Sonic Zhang <sonic.adi@gmail.com>
> ---
>  drivers/staging/iio/sysfs.h |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h
> index e501e13..39d207e 100644
> --- a/drivers/staging/iio/sysfs.h
> +++ b/drivers/staging/iio/sysfs.h
> @@ -95,16 +95,16 @@ struct iio_const_attr {
>  			.val2 = _val2 }
>  
>  #define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr)	\
> -	struct iio_dev_attr iio_dev_attr_##_name		\
> +	static struct iio_dev_attr iio_dev_attr_##_name		\
>  	= IIO_ATTR(_name, _mode, _show, _store, _addr)
>  
>  
>  #define IIO_DEVICE_ATTR_2(_name, _mode, _show, _store, _addr, _val2)	\
> -	struct iio_dev_attr iio_dev_attr_##_name			\
> +	static struct iio_dev_attr iio_dev_attr_##_name			\
>  	= IIO_ATTR_2(_name, _mode, _show, _store, _addr, _val2)
>  
>  #define IIO_CONST_ATTR(_name, _string)					\
> -	struct iio_const_attr iio_const_attr_##_name			\
> +	static struct iio_const_attr iio_const_attr_##_name			\
>  	= { .string = _string,						\
>  	    .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
>  


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

end of thread, other threads:[~2010-04-06 11:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-02  2:55 [PATCH] IIO: struct iio_dev_attr should be defined as static sonic zhang
2010-04-06  3:21 ` Sonic Zhang
2010-04-06 11:30 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).