On Tue, 2014-01-14 at 14:54 +0100, Silvio F. wrote:
> 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);
>     } 

You are creating a sysfs entry for struct device associated with a
struct usb_serial. Yet you convert this to struct usb_serial_port.

struct usb_serial {
        struct usb_device               *dev;
        struct usb_serial_driver        *type;
        struct usb_interface            *interface;
        unsigned char                   disconnected:1;
        unsigned char                   suspending:1;
        unsigned char                   attached:1;
        unsigned char                   minors_reserved:1;
        unsigned char                   num_ports;
        unsigned char                   num_port_pointers;
        char                            num_interrupt_in;
        char                            num_interrupt_out;
        char                            num_bulk_in;
        char                            num_bulk_out;
        struct usb_serial_port          *port[MAX_NUM_PORTS];
        struct kref                     kref;
        struct mutex                    disc_mutex;
        void                            *private;
};

This structure points to multiple instances of struct usb_serial_port.
This cannot work.

        Regards
                Oliver


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

Reply via email to