Hello <br><br>Thank you anish for the reply, the code is I pasted below.<br>[code-starts]<br><br>#include <linux/init.h><br>#include <linux/module.h><br>#include <linux/kernel.h><br>#include <linux/fs.h><br>
#include <linux/device.h><br>#include <linux/sysdev.h><br>#include <linux/major.h><br>#include <asm/uaccess.h><br>#include <linux/slab.h><br>#include <linux/cdev.h><br>#include <linux/kdev_t.h><br>
<br>static char *gvar = "BeHonest";<br>// Store and Show functions......<br> static ssize_t attr1_store(struct class *cls, struct class_attribute *attr, const char *buf, size_t count);<br> static ssize_t attr1_show(struct class *cls, struct class_attribute *attr, char *buf);<br>
<br>static struct class_attribute pwm_class_attrs[] = {<br> __ATTR(attr1, S_IRUGO | S_IWUSR , attr1_show, attr1_store), <br> __ATTR_NULL<br>};<br><br>static struct class pwm_class =<br>{<br> .name = "dev_jes",<br>
.owner = THIS_MODULE,<br> .class_attrs = pwm_class_attrs<br>};<br><br><br>static int hello_init(void)<br>{<br> class_register(&pwm_class);<br> printk("In hello_init function \n");<br><br> return 0;<br>
}<br><br>static ssize_t attr1_show(struct class *cls, struct class_attribute *attr, char *buf)<br>{<br><br> printk("In attr1_show function\n");<br> return sprintf(buf, "%s\n", gvar);<br>}<br><br>
static ssize_t attr1_store(struct class *cls, struct class_attribute *attr, const char *buf, size_t count)<br>{<br> printk("the string is : %s\n",buf);<br> printk("In attr1_store function\n");<br>
return 1;<br> //return sprintf(gvar, "%s\n", buf); --- If I put this line I am getting ERROR :( <br>}<br><br><br>static void hello_exit(void)<br>{<br> class_unregister(&pwm_class);<br>
printk("In hello_exit function \n");<br>}<br><br>module_init(hello_init);<br>module_exit(hello_exit);<br><br>MODULE_LICENSE("GPL");<br>MODULE_AUTHOR("Jeshwanth");<br>MODULE_DESCRIPTION("Learning sysfs");<br>
<br>[code-ends]<br><br>echo "jeshu" > /sys/class/dev_jes/attr1<br><br>And If I pass the command to atttribute I got result below in dmesg.<br><br>[ 3435.613057] the string is : jeshu<br>[ 3435.613061] <br>[ 3435.613066] In attr1_store function<br>
[ 3435.613072] the string is : eshu<br>[ 3435.613074] <br>[ 3435.613078] In attr1_store function<br>[ 3435.613083] the string is : shu<br>[ 3435.613085] <br>[ 3435.613088] In attr1_store function<br>[ 3435.613093] the string is : hu<br>
[ 3435.613095] <br>[ 3435.613098] In attr1_store function<br>[ 3435.613103] the string is : u<br>[ 3435.613105] <br>[ 3435.613108] In attr1_store function<br>[ 3435.613113] the string is : <br>[ 3435.613115] <br>[ 3435.613118] In attr1_store function<br>
<br><br>So please help me how to read the attribute in store function.. Thanks :)<br><br><br><div class="gmail_quote">On Tue, Jun 19, 2012 at 4:02 PM, anish singh <span dir="ltr"><<a href="mailto:anish198519851985@gmail.com" target="_blank">anish198519851985@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Jun 19, 2012 at 3:14 PM, jeshwanth Kumar N K<br>
<<a href="mailto:jeshkumar555@gmail.com">jeshkumar555@gmail.com</a>> wrote:<br>
> Hello all<br>
><br>
> I am new to sysfs interface ans I read about in mochel's documentation. And<br>
> doing some experiements on it. Let's come to Tue problem, in my module I<br>
> have a global variable type char* myglobal and it s static, I am putting<br>
> that value in my one and only class attribute using show function. But for<br>
> the same if I a user put some value in to the using echo or something, the<br>
> attribute value is not changing. And one more thing s after I passed the<br>
> value to the attribute my system not shutting down :( . Please help me how<br>
> to read values.<br>
</div>Why don't you post your code?As that will really help and moreover as<br>
this is your code<br>
you won't be breakign any law set by your company.<br>
<div class="im">><br>
> // in store function I am doing this:<br>
> Myglobal = bus;<br>
><br>
> Sent from my HTC<br>
><br>
><br>
><br>
><br>
</div>> _______________________________________________<br>
> Kernelnewbies mailing list<br>
> <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
><br>
</blockquote></div><br><br clear="all"><br>-- <br>Regards<br>Jeshwanth Kumar N K<br>+91-7411483498<br><br>