Results 1 to 2 of 2
Hi there...
I try to build additional device attributes in my module so they will appear in sysfs. But I can't build them and i can't find how to do ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-15-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 2
Device Attributes in sysfs
Hi there...
I try to build additional device attributes in my module so they will appear in sysfs. But I can't build them and i can't find how to do it!?
Plz help...the atributes are "name", "pid", "pgdir"...
My source-code is:
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/fs.h>
MODULE_DESCRIPTION("My kernel module");
MODULE_LICENSE("GPL");
static char *name;
module_param(name, charp, 0644);
struct class *bs_class;
struct device *bs_device;
static int bs_Major;
//static int device_open(struct inode *, struct file *);
//static int device_release(struct inode *, struct file *);
//static ssize_t device_read(struct file *, char *, size_t, loff_t *);
//static ssize_t device_write(struct file *, const char *, size_t, loff_t *);
static struct file_operations fops = {
// .read = device_read,
// .write = device_write,
// .open = device_open,
// .release = device_release
};
static int bs1_init_module(void)
{
printk("<0>Module BS1 init\n" );
bs_Major = register_chrdev(0,"bs-device", &fops);
if (bs_Major<0) {
printk(KERN_WARNING "Kann keine Major-Nummer bekommen!");
return bs_Major;
}
bs_class = class_create(THIS_MODULE,"bs-class");
bs_device = device_create(bs_class,NULL,MKDEV(bs_Major,0),"bs-device");
// DEVICE_ATTR(name,0644,show_debug, NULL);
return 0;
}
static void bs1_exit_module(void)
{
printk("<0>Module BS1 exit\n" );
class_destroy(bs_class);
device_destroy(bs_class,MKDEV(bs_Major,0));
unregister_chrdev(bs_Major,"bs-device");
}
module_init(bs1_init_module);
module_exit(bs1_exit_module);
- 08-09-2010 #2Just Joined!
- Join Date
- May 2010
- Posts
- 2
device attribute functions call
Hi,
I am facing one problem with device attribute functions.
I am using below macro for registering
static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, xmd_boot_modem_state_show,
xmd_boot_modem_state_store);
and
status = device_create_file(&pdev->dev, &dev_attr_state);
here in my code xmd_boot_modem_state_store() is not getting called.
Just i wanted to know what makes these functions gets called.
Kindly help me in this regard.


Reply With Quote
