Hi,
i have updated sysfs test patch. i have done changes to write some sysfs attribute which was not available in the original patch. The original patch is
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/gregkh/sysfs-test.patch
My Request:
----------------
please comment on my changes, and suggest me what else i can do on this.
doubt:
--------
i am not able to understand the lines of the original patch, which are commented with "#if 0 ... #endif". it would be great, if anyone can give some explanation on those lines.
patch:
----------
--- linux-2.6.20/drivers/gregkh/gregkh.c.orig 2007-04-24 14:09:12.000000000 +0530
+++ linux-2.6.20/drivers/gregkh/gregkh.c 2007-04-24 14:12:11.000000000 +0530
@@ -121,6 +121,35 @@ static ssize_t void_ptr_show(struct greg
return sprintf(buf, "%p\n", *val);
}
+static ssize_t u32_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->a = temp;
+ dbg("%s val=%d \n", __FUNCTION__, g->a);
+ return count;
+}
+static ssize_t u16_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->b = temp;
+ dbg("%s val=%d \n", __FUNCTION__, g->b);
+ return count;
+}
+static ssize_t u8_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->c = temp;
+ dbg("%s val=%d \n", __FUNCTION__, g->c);
+ return count;
+}
+static ssize_t void_ptr_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->d = (void *)temp;
+ dbg("%s val=%p \n", __FUNCTION__, g->d);
+ return count;
+}
+
#define to_d_greg(obj) container_of(obj, struct d_greg, g)
#if 0
@@ -170,9 +199,10 @@ static void x(struct greg *g)
#define G_RO(_name, _var, _type) \
static struct greg_attribute _name##_attr = { \
- .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \
+ .attr = { .name = __stringify(_name), .mode = 0644, .owner = THIS_MODULE }, \
.offset = offsetof(struct greg, _var), \
.show = _type##_show, \
+ .store = _type##_store, \
}
G_RO(a, a, u32);
+++ linux-2.6.20/drivers/gregkh/gregkh.c 2007-04-24 14:12:11.000000000 +0530
@@ -121,6 +121,35 @@ static ssize_t void_ptr_show(struct greg
return sprintf(buf, "%p\n", *val);
}
+static ssize_t u32_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->a = temp;
+ dbg("%s val=%d \n", __FUNCTION__, g->a);
+ return count;
+}
+static ssize_t u16_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->b = temp;
+ dbg("%s val=%d \n", __FUNCTION__, g->b);
+ return count;
+}
+static ssize_t u8_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->c = temp;
+ dbg("%s val=%d \n", __FUNCTION__, g->c);
+ return count;
+}
+static ssize_t void_ptr_store(struct greg *g, char *buf, size_t count)
+{
+ int temp = simple_strtoul(buf,NULL,10);
+ g->d = (void *)temp;
+ dbg("%s val=%p \n", __FUNCTION__, g->d);
+ return count;
+}
+
#define to_d_greg(obj) container_of(obj, struct d_greg, g)
#if 0
@@ -170,9 +199,10 @@ static void x(struct greg *g)
#define G_RO(_name, _var, _type) \
static struct greg_attribute _name##_attr = { \
- .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \
+ .attr = { .name = __stringify(_name), .mode = 0644, .owner = THIS_MODULE }, \
.offset = offsetof(struct greg, _var), \
.show = _type##_show, \
+ .store = _type##_store, \
}
G_RO(a, a, u32);
thanks
Ashok