lkml.org 
[lkml]   [2012]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: RFC: remove usb_device pointer from usb_skeleton.c
    On Fri, 8 Jun 2012, Stefani Seibold wrote:

    > Hi,
    >
    > what do you think about this solution for removing the usb_device
    > pointer from the struct usb_skel in the usb_skeleton driver?

    There's nothing wrong with keeping the pointer there. Why do you want
    to remove it?

    > @@ -73,9 +73,12 @@ static struct usb_driver skel_driver;
    > static void skel_delete(struct kref *kref)
    > {
    > struct usb_skel *dev = to_skel_dev(kref);
    > + struct usb_interface *interface = dev->interface;
    > + struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface));
    >
    > usb_free_urb(dev->bulk_in_urb);
    > - usb_put_dev(dev->udev);
    > + usb_put_dev(udev);

    On the other hand, this usb_put_dev call is useless. Why do you want
    to keep it?

    > + usb_put_intf(interface);

    If you get rid of the usb_put_dev then this call is also useless.

    > kfree(dev->bulk_in_buffer);
    > kfree(dev);
    > }
    > @@ -128,7 +131,7 @@ static int skel_release(struct inode *inode, struct file *file)
    >
    > /* allow the device to be autosuspended */
    > mutex_lock(&dev->io_mutex);
    > - if (dev->interface)
    > + if (dev->connected)

    There's nothing really wrong with adding a "disconnected" flag. But
    setting dev->interface to NULL works just as well, in my opinion. It's
    a matter of taste.

    Alan Stern



    \
     
     \ /
      Last update: 2012-06-08 16:21    [W:2.936 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site