From: john@jjdev.com (John de la Garza)
To: kernelnewbies@lists.kernelnewbies.org
Subject: cdev_init and struct file_operations
Date: Tue, 26 Aug 2014 20:48:41 -0400 [thread overview]
Message-ID: <20140827004839.GA4431@vega.jjdev.com> (raw)
In the book Linux Device Drivers a struct cdev is setup like this:
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;
...
the code for cdev_init does this:
void cdev_init(struct cdev *cdev, const struct file_operations *fops)
{
memset(cdev, 0, sizeof *cdev);
INIT_LIST_HEAD(&cdev->list);
kobject_init(&cdev->kobj, &ktype_cdev_default);
cdev->ops = fops;
}
Why does the code from ldd3 set dev->cdev.ops = &scull_fops again?
Doesn't cdev_init already do that?
next reply other threads:[~2014-08-27 0:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 0:48 John de la Garza [this message]
2014-08-27 1:18 ` cdev_init and struct file_operations Valdis.Kletnieks at vt.edu
2014-08-27 14:35 ` John de la Garza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140827004839.GA4431@vega.jjdev.com \
--to=john@jjdev.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.