Re: LDD3 scull code doubt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/9/07, pradeep singh <2500.pradeep@xxxxxxxxx> wrote:
Hi All,

The scull code which is a sample char driver has some code snippets in
the 3rd chapter.
Under section 3.4.1 Device Registration in scull we have following
code snippet -

   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);
  }

My doubt is
  though we have used cdev_init(&dev->cdev, &scull_fops) to initiaize
the fops structure for our embedded cdev, why are we again setting the
dev->cdev.ops explicity again using
   dev->cdev.ops = &scull_fops;

Its redundant  IMHO.



Isn't cdev_init() supposed to do the initialisation?
What am i missing here?

Thank you
~psr

--
play the game

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




--
Anubhav Rakshit

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux