Re: Using vme_tsi148 device driver from user space

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

 



On Thu, Nov 24, 2011 at 10:53:53AM +0000, Martyn Welch wrote:
> On 23/11/11 15:54, Zvi Vered wrote:
> > Dear Mr. Welch,
> > 
> > I'm using busybox 1.19.3
> > 
> > This is the latest busybox version.
> 
> Hmm, that's interesting.
> 
> It appears that udev converts "!" to "/". In fact, the reverse of this is
> carried out in the kernel (http://lxr.linux.no/#linux+v3.1.2/lib/kobject.c#L228):
> 
> int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
>                                   va_list vargs)
> {
>         const char *old_name = kobj->name;
>         char *s;
> 
>         if (kobj->name && !fmt)
>                 return 0;
> 
>         kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
>         if (!kobj->name)
>                 return -ENOMEM;
> 
>         /* ewww... some of these buggers have '/' in the name ... */
>         while ((s = strchr(kobj->name, '/')))
>                 s[0] = '!';
> 
>         kfree(old_name);
>         return 0;
> }
> 
> This is being triggered because we setup the device names in vme_user like this:
> 
>         for (i = 0; i < VME_DEVS; i++) {
>                 int num;
>                 switch (type[i]) {
>                 case MASTER_MINOR:
>                         sprintf(name, "bus/vme/m%%d");
>                         break;
>                 case CONTROL_MINOR:
>                         sprintf(name, "bus/vme/ctl");
>                         break;
>                 case SLAVE_MINOR:
>                         sprintf(name, "bus/vme/s%%d");
>                         break;
>                 default:
>                         err = -EINVAL;
>                         goto err_sysfs;
>                         break;
>                 }
> 
>                 num = (type[i] == SLAVE_MINOR) ? i - (MASTER_MAX + 1) : i;
>                 image[i].device = device_create(vme_user_sysfs_class, NULL,
>                                         MKDEV(VME_MAJOR, i), NULL, name, num);
>                 if (IS_ERR(image[i].device)) {
>                         printk(KERN_INFO "%s: Error creating sysfs device\n",
>                                 driver_name);
>                         err = PTR_ERR(image[i].device);
>                         goto err_sysfs;
>                 }
>         }
> 
> 
> A quick trawl of the kernel source shows a few places this is done (namely
> char/viotape.c and misc/hpilo.c), though it seems to be rather undocumented,
> the only places I can find this behaviour documented don't seem very
> authoritative.
> 
> Greg, is this the proper way to do this?

Yes, this is the correct way to do this.  Any '!' should be converted to
a '/', and this has been this way since I think the 2.2 kernel days.

> I guess the other question is whether we continue to use these device numbers
> and this device file layout?

Why not, it's up to userspace to create the device nodes properly, if
mudev is broken, please fix it, nothing wrong with the kernel here.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux