From: 'Greg KH' <greg@kroah.com>
To: ckim@etri.re.kr
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: can't find device_create funtion in a driver containing cdev (habanalabs)
Date: Thu, 29 Apr 2021 09:29:38 +0200 [thread overview]
Message-ID: <YIpgYvZ8uvEZpHSZ@kroah.com> (raw)
In-Reply-To: <018201d73c92$7153fb60$53fbf220$@etri.re.kr>
On Thu, Apr 29, 2021 at 09:56:09AM +0900, ckim@etri.re.kr wrote:
> Hi, Greg KH,
>
> To me cdev_device_add seems to be calling only cdev_add(below).
> In this case since dev->devt already holds dev_t value ("hl%d"), it just
> sets cdev_set_parent and cdev_add.
>
> int cdev_device_add(struct cdev *cdev, struct device *dev)
> {
> int rc = 0;
>
> if (dev->devt) {
> cdev_set_parent(cdev, &dev->kobj);
>
> rc = cdev_add(cdev, dev->devt, 1);
> if (rc)
> return rc;
> }
>
> rc = device_add(dev);
Right here is the line you are looking for.
device_create() is a wrapper around a call to device_initialize() and
device_add(). To use cdev_device_add() you have to have already called
device_initialize() which the habannalabs code already did.
Only on device_add() is the device really "added" to the driver core,
and the uevents are sent out and lots of other stuff happens.
device_create() wraps a lot of housekeeping logic up into a simpler call
if your driver doesn't need that level of flexibility, but there is no
requirement to call only it at all.
Hope this helps,
greg k-h
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
prev parent reply other threads:[~2021-04-29 7:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 13:46 can't find device_create funtion in a driver containing cdev (habanalabs) ckim
2021-04-28 18:32 ` Greg KH
2021-04-29 0:56 ` ckim
2021-04-29 7:29 ` 'Greg KH' [this message]
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=YIpgYvZ8uvEZpHSZ@kroah.com \
--to=greg@kroah.com \
--cc=ckim@etri.re.kr \
--cc=kernelnewbies@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.