problem to retrieve usb_serial object from usb_serial_port object

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

 



Hello,

I try to communicate with a cp210x-device on my usb bus. I create a sysfs
object with some simple lines of code like the next one ...

    static ssize_t cp210x_show_x(struct device *dev, struct device_attribute *attr, char *buf)
    {
        struct usb_serial_port *port = to_usb_serial_port(dev);

        if(!port) {
            printk("no port\n");
            goto exit;
        }

        if(!port->serial) {
            printk("no serial\n");
            goto exit;
        }

        struct cp210x_serial_private *spriv = usb_get_serial_data(port->serial);
        printk("%s:%s:%d num_ports:0x%08x\n", __FILE__, __func__, __LINE__, port->serial->num_ports);

    exit:
        return 0;
    }
    static DEVICE_ATTR(x, S_IRUGO, cp210x_show_x, NULL);

    static int create_sysfs_attrs(struct usb_serial *serial)
    {
        return device_create_file(&serial->dev->dev, &dev_attr_x);
    } 

I have the problem that port->serial is everytime NULL.

Some digging in usb-serial.c shows me that the port->serial is set on plugin of
my device through the usb_serial_probe-function.

Is this a bug or should I recive the usb_serial object with other mehods? What
methods should I use?

This Problem occurs on 3.9-rc7 and 3.13-rc3.

Thanks for some hints,
Silvio

-- 
-- S. Fricke ---------------------------------------- silvio@xxxxxxxxxxxx --
   Diplom-Informatiker (FH)
   Linux-Entwicklung             JABBER: silvio@xxxxxxxxxxxxxxxxxxxxxxxxx   
----------------------------------------------------------------------------
--
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