Strategies for accessing driver data from file operations!?

Daniel Hilst Selli danielhilst at gmail.com
Mon Aug 25 14:34:45 EDT 2014


On 08/13/2014 06:40 PM, Greg KH wrote:
> On Wed, Aug 13, 2014 at 09:46:51AM -0300, Daniel Hilst Selli wrote:
>> One last question, supposing I need to create multiple /dev nodes, do I need to
>> allocate one struct cdev for each major:minor pair (cdev_alloc(), cdev_init(), cdev_add())?
>
> No, you can allocate multiple minor numbers with a single set of cdev
> calls.  But watch out, you also need to create a 'struct device' for
> _each_ minor number you are actually using if you want the device nodes
> to show up in /dev automatically.
>
> Yeah, it's a pain, sorry, but this way you can allocate a whole range of
> major:minor pairs but don't actually expose them to userspace until you
> really need them (i.e. the hardware is present in the system.)  This
> keeps /dev looking like only the devices that are present in the system,
> not the "old" way of "every possible device that could ever be possibly
> present".
>
> Hope this helps,
>
> greg k-h
>

It help-me alot Greg, thanks.. At last I know I'm doing in the right way :)

Cheers,



More information about the Kernelnewbies mailing list