lkml.org 
[lkml]   [2011]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Allow setting of number of raw devices as a module parameter
On Tue 03-05-11 12:55:06, Arnd Bergmann wrote:
> On Monday 02 May 2011, Jan Kara wrote:
> > >
> > > The character device layer uses kobj_lookup internally when opening
> > > the device. When you are inside the driver, you can access it through
> > > file->f_path.dentry->d_inode->i_cdev, from where you go to your own data
> > > structure using container_of.
> >
> > OK, but if I don't have the inode of the character device (like in
> > RAW_GETBIND case)?
>
> Oh, good point. That doesn't work as easily then. You'd have to use kobj_lookup,
> but you can only do that from fs/char_dev.c because otherwise the cdev_map
> is not visible.
>
> So you could in theory add a cdev_lookup() function to fs/char_dev.c, but I'm
> not sure if that is a good idea if the only user is raw.c. It's probably
> not any cleaner than the approach you were suggesting.
>
> Another idea would be to make the array dynamically sized, using some version
> of realloc (which doesn't exist for vmalloc today), or to use a more complex
> data structure for the lookup, like idr or radix_tree.
Yes, but in that case, I find vmalloc() the smaller pain given how obscure
the driver is. Alan seems to have agreed as well so if you don't object
Greg can merge the patch as is (modulo the changelog improvement from Greg)...

Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR


\
 
 \ /
  Last update: 2011-05-03 19:07    [W:0.068 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site