Skip to contentSkip to conversation

Add a private_data pointer to struct device_attribute

PATCH Timur Tabi 2 participants 2 messages Nov 17, 2007 Driver core

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

A private data pointer in struct device_attribute allows the 'show' and 'store' functions to access instance data. This handy in situations where the driver_data and platform_data pointers of 'struct device' are already used for other purposes.

---

Greg, can you tell me if you think this patch is a good idea? It doesn't appear to do any harm, and I'm working on an ALSA driver that could benefit for this patch. I think 2.6.25 would be a good target.

 include/linux/device.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/device.h +1 -0
index 2e15822..10708ee 100644
@@ -344,6 +344,7 @@ struct device_attribute {
 			char *buf);
 	ssize_t (*store)(struct device *dev, struct device_attribute *attr,
 			 const char *buf, size_t count);
+	void *private_data;
 };
 
 #define DEVICE_ATTR(_name,_mode,_show,_store) \
Signature · 1 line
1.5.2.4
#1 lore raw
Quoted 11 lines · Timur Tabi

A private data pointer in struct device_attribute allows the 'show' and 'store' functions to access instance data. This handy in situations where the driver_data and platform_data pointers of 'struct device' are already used for other purposes.

---

Greg, can you tell me if you think this patch is a good idea? It doesn't appear to do any harm, and I'm working on an ALSA driver that could benefit for this patch. I think 2.6.25 would be a good target.

Huh? Why is this needed? Can you give me a usage case for it? Why would you just not use the pointer to the attribute itself to identify it? All device specific information should be stored in the struct device structure, as that is what describes the device, not the attribute.

confused,

greg k-h