On Tue, Aug 29, 2006 at 10:53:31PM -0300, Luiz Fernando N. Capitulino wrote:
> 
>  Hi Sam,
> 
> |   Sorry for not doing this SubmittingPatches-compliantly the first time,
> | I hope I got everything all right this time.
> 
>  I think you did, but I can't resist to make some minor comments. :)
> 
> | +static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
> | +                    const char *buf, size_t count)
> | +{
> | +   struct usb_interface *intf = to_usb_interface(dev);
> | +   struct trancevibrator *tv = usb_get_intfdata(intf);
> | +   int temp, retval;
> | +
> | +   temp = simple_strtoul(buf, NULL, 10);
> | +   if (temp > 255)
> | +           temp = 255;
> | +   else if (temp < 0)
> | +           temp = 0;
> | +   tv->speed = temp;
> | +
> | +   dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed);
> | +
> | +   /* Set speed */
> | +   retval = usb_control_msg(tv->udev, usb_sndctrlpipe(tv->udev, 0),
> | +                            0x01, /* vendor request: set speed */
> | +                            USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
> | +                            tv->speed, /* speed value */
> | +                            0, NULL, 0, USB_CTRL_GET_TIMEOUT);
> | +   if (retval)
> | +           dev_dbg(&tv->udev->dev, "retval = %d\n", retval);
> 
>  Isn't it good to report an error here?

Oops, forgot to make this fix, will go do that...

> 
> | +   return count;
> | +}
> | +
> | +static DEVICE_ATTR(speed, S_IWUGO | S_IRUGO, show_speed, set_speed);
> | +
> | +static int tv_probe(struct usb_interface *interface,
> | +               const struct usb_device_id *id)
> | +{
> | +   struct usb_device *udev = interface_to_usbdev(interface);
> | +   struct trancevibrator *dev = NULL;
> | +   int retval = -ENOMEM;
> 
>  You don't need to initialize 'dev', and you can drop 'retval' and return
> -ENOMEM directly in the error label.

I made that fix.

> | +
> | +   dev = kzalloc(sizeof(struct trancevibrator), GFP_KERNEL);
> | +   if (dev == NULL) {
> | +           dev_err(&interface->dev, "Out of memory\n");
> | +           goto error;
> | +   }
> | +
> | +   dev->udev = usb_get_dev(udev);
> | +   usb_set_intfdata (interface, dev);
> | +   device_create_file(&interface->dev, &dev_attr_speed);
> 
>  Shouldn't the probe fail if device_create_file() fail?

I also made that fix.

thanks,

greg k-h

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to