Using vme_tsi148 device driver from user space

Martyn Welch martyn.welch at ge.com
Thu Nov 24 10:53:53 UTC 2011


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?

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

Those entries in the Documentation/devices.txt file pre-date git. Last time I
checked the code at vmelinux.org was very out of date, I have a feeling it
is/was usable with 2.2 and 2.4 kernels (the site is currently off line). The
vme_user module doesn't use the same IOCTLs as that driver (and I don't think
the approach taken in that driver would every have been suitable to mainline).
How about just using simpler names such as "vme_m0"? The vme_user module only
currently supports one vme bridge and the device numbers would need to be
massaged to properly support more bridges / newer chips with more images
(windows) anyway.

Do we keep that entry in Documentation/devices.txt, especially since vme_user
doesn't use the same interface as the driver at vmelinux.org? What if
vmelinux.org has gone away?

Martyn

> 
> Thanks,
> Zvika.
> 
> ----- Original Message ----- From: "Martyn Welch" <martyn.welch at ge.com>
> To: "Zvi Vered" <veredz72 at gmail.com>
> Cc: <devel at linuxdriverproject.org>
> Sent: Wednesday, November 23, 2011 11:37
> Subject: Re: Using vme_tsi148 device driver from user space
> 
> 
>> Please keep your responses on list...
>>
>> On 22/11/11 18:17, Zvi Vered wrote:
>>> Dear Mr. Welch,
>>>
>>> I tried the following sequence:
>>>
>>> 1. insmod vme.ko
>>> 2. insmod vme_tsi148.ko
>>> 3. insmod vme_user.ko bus=0
>>> 4. mdev -s
>>>
>>> Upon completion I got the following files in /dev:
>>>
>>> bus!vme!m0
>>> bus!vme!m1
>>> bus!vme!m2
>>> bus!vme!m3
>>> bus!vme!s0
>>> bus!vme!s1
>>> bus!vme!s2
>>> bus!vme!s3
>>>
>>> The file names are strange (the '!' character).
>>>
>>> According to the documentation the files should be: bus/vme/m0 ... bus/vme/s4
>>> But bus,vme folders are not created.
>>>
>>> Can you help ?
>>>
>>
>> Just tried it here:
>>
>> # modprobe vme_user bus=0
>> vme_user: module is from the staging directory, the quality is unknown, you
>> have been warned.
>> VME User Space Access Driver
>> # cd /dev/bus
>> # ls
>> usb  vme
>> # cd vme
>> # ls -la
>> total 0
>> drwxr-xr-x 2 root root    220 Nov 23 09:22 .
>> drwxr-xr-x 4 root root     80 Nov 23 09:22 ..
>> crw-rw---- 1 root root 221, 8 Nov 23 09:22 ctl
>> crw-rw---- 1 root root 221, 0 Nov 23 09:22 m0
>> crw-rw---- 1 root root 221, 1 Nov 23 09:22 m1
>> crw-rw---- 1 root root 221, 2 Nov 23 09:22 m2
>> crw-rw---- 1 root root 221, 3 Nov 23 09:22 m3
>> crw-rw---- 1 root root 221, 4 Nov 23 09:22 s0
>> crw-rw---- 1 root root 221, 5 Nov 23 09:22 s1
>> crw-rw---- 1 root root 221, 6 Nov 23 09:22 s2
>> crw-rw---- 1 root root 221, 7 Nov 23 09:22 s3
>> #
>>
>> Our user space uses udev, that seems to be creating the directory structure
>> correctly. It appears that the version of mdev you are using isn't. Which
>> version of busybox are you using? It appears from the busybox website that
>> support for the "!" syntax was added to mdev in busybox 1.17.0.
>>
>> Martyn
>>
>>> Thanks,
>>> Zvika.
>>>

-- 
Martyn Welch (Lead Software Engineer)  | Registered in England and Wales
GE Intelligent Platforms               | (3828642) at 100 Barbirolli Square
T +44(0)1327322748                     | Manchester, M2 3AB
E martyn.welch at ge.com                  | VAT:GB 927559189



More information about the devel mailing list