Hi,
I'm writing a simple module implementing a character device, having the "Linux Device Drivers 3rd edition" as a template.
To register your device, one should use cdev_init() and cdev_add() functions.
When I open my device and check lsmod, the "Used by" count is incremented by 2. Why is that?
According to "the manual", one should initialize the owner member .owner to THIS_MODULE like:
Code:
static void scull_setup_cdev(struct scull_dev *dev, int index)
{
int err, devno = MKDEV(scull_major, scull_minor + index);
cdev_init(&dev->cdev, &scull_fops);
dev->cdev.owner = THIS_MODULE;
dev->cdev.ops = &scull_fops;
err = cdev_add (&dev->cdev, devno, 1);
/* Fail gracefully if need be */
if (err)
printk(KERN_NOTICE "Error %d adding scull%d", err, index);
}
I tried to remove this .owner member initialization and then use count is incremented by one again.
What am I missing here?
/MK