sysfs for gadget driver

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

 



Hello.  I'm writing a gadget driver for an existing system running on
a 2.6.10 kernel on a TI Davinici 6446 chip (ARM).  Due to time
constraints and for risk reduction, upgrading this to the latest
kernel is not an option as much as I would want to.

The USB portion of the driver is working, but I'm having trouble
exposing attributes via sysfs.  It doesn't appear as if there are any
usb or gadget entries under /sysfs/bus.  (Note: This hardware does not
have a USB host port, only peripheral USB hardware.)  When I create a
DRIVER_ATTR struct and call driver_create_file() after calling
usb_gadget_register_driver(), the kernel panics with a segmentation
fault in the function sysfs_create_file().  Turning on all the kernel
hacking stuff in the kernel config, I see that it is failing on two
bug checks before it panics.

In my init function, I have the following:

rc = usb_gadget_register_driver (&myusb_driver);
if (rc == 0) {
    driver_create_file(&myusb_driver.driver, &driver_attr_myattr);

In the function driver_create_file() in drivers/base/drivers.c, it
calls the following:

if (get_driver(drv)) {
    error = sysfs_create_file(&drv->kobj, &attr->attr);

In get_driver(), it attempts to get and increment the kref for the
kobject.  This throws an error because it appears that the kref was
never initialized. (refcount->counter == 0)

Then in sysfs_create_file() in fs/sysfs/file.c, the first line is:

BUG_ON(!kobj || !kobj->dentry || !attr);

This throws the second error because it appears as if kobj->dentry is
not valid.  I'm assuming the Oops that happens later is caused by this
value being dereferenced.

Therefore, something in the device_driver struct that is embedded in
the usb_gadget_driver struct is not being initialized properly.  So my
question is, what am I missing in order to initialize the gadget sysfs
interface?  Or is this not implemented in 2.6.10?  If not, is it
implemented in the latest kernel (2.6.35)?  Is there another method of
opening communication with the gadget driver from userspace without
updating the kernel?

Thanks,
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux