I\'m creating a character device. I found two way to initialize char device
cdev_alloc
and
cdev_init
Acc
According to LDD3 for using cdev_init cdev should be initialized and shouldn't be NULL, so either use struct cdev dev as suggested by kripanand or if using struct cdev *dev then allocate dev memory using kzalloc, if using kmalloc memset would be required. This is wat cdev_alloc does.
I've now replaced cdev_alloc in my code as
//vcar->dev=cdev_alloc;
vcar->dev=kzalloc(sizeof(struct cdev),GFP_KERNEL);