All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [patch] refactor SENSORS_DEV_ATTR: was pc87360
@ 2005-07-28 14:52 Jim Cromie
  0 siblings, 0 replies; only message in thread
From: Jim Cromie @ 2005-07-28 14:52 UTC (permalink / raw)
  To: lm-sensors

Jean Delvare wrote:

>Hi Jim,
>
>On 2005-07-28, Jim Cromie wrote:
>  
>
>>attached is a patch which:
>>
>>1. adds an __ATTR_N macro to device.h,
>>which takes an extra _index arg, and initializes device_attibute's new
>>.index member.
>>    
>>
>
>This seems to be duplicating the SENSOR_DEVICE_ATTR macro as defined in
>include/linux/hwmon-sysfs.h.
>
>  
>
its almost the same - and was heavily inspired by it.
The difference is that __ATTR_N is a smaller building block,
it has only the RHS of the initialization, it does not have the
variable declaration or the assignment/initialization itself.

So attached patch refactors SENSOR_DEV_ATTR
into a declaration and an initialization expression,
allowing latter to be used in array initializations.


-------------- next part --------------
diff -ruN -X exclude-diffs ../linux-2.6.13-rc3-mm1/include/linux/hwmon-sysfs.h linux/include/linux/hwmon-sysfs.h
--- ../linux-2.6.13-rc3-mm1/include/linux/hwmon-sysfs.h	2005-07-18 12:36:48.000000000 -0600
+++ linux/include/linux/hwmon-sysfs.h	2005-07-28 06:38:08.000000000 -0600
@@ -27,10 +27,13 @@
 #define to_sensor_dev_attr(_dev_attr) \
 	container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
 
-#define SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index)	\
-struct sensor_device_attribute sensor_dev_attr_##_name = {	\
-	.dev_attr =	__ATTR(_name,_mode,_show,_store),	\
-	.index =	_index,					\
+#define __SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index)	\
+	{ .dev_attr =	__ATTR(_name,_mode,_show,_store),	\
+	  .index =	_index,					\
 }
 
+#define SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index)	\
+struct sensor_device_attribute sensor_dev_attr_##_name		\
+	= __SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index)
+
 #endif /* _LINUX_HWMON_SYSFS_H */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-07-28 14:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-28 14:52 [lm-sensors] [patch] refactor SENSORS_DEV_ATTR: was pc87360 Jim Cromie

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.