Re: [PATCH v5 5/5] Add ioctls to enable and disable local controls on an instrument
From: Dave Penkler
Date: Wed Nov 25 2015 - 04:13:24 EST
On Sun, Nov 22, 2015 at 12:36:53PM +0200, Andy Shevchenko wrote:
> On Sun, Nov 22, 2015 at 10:51 AM, Dave Penkler <dpenkler@xxxxxxxxx> wrote:
> > On Wed, Nov 18, 2015 at 11:41:30AM +0200, Andy Shevchenko wrote:
> >> On Wed, Nov 18, 2015 at 10:38 AM, Dave Penkler <dpenkler@xxxxxxxxx> wrote:
>
>
> >> > + if (rv < 0) {
> >> > + dev_err(dev, "simple usb_control_msg failed %d\n", rv);
> >> > + goto exit;
> >> > + } else if (rv != 1) {
> >> > + dev_warn(dev, "simple usb_control_msg returned %d\n", rv);
> >>
> >> Actually here what king of results could be? 0? 2+? In all cases of
> >> error you have to provide an error code.
> >>
> >
> > We seem to be going round in circles here, last time you suggested to
> > propagate the return value.
>
> You didn't pay much attention to where I put my comment. You have few
> branches depending on return value
>
> 1) negative, apparently an error code, should be propagated if nothing
> specific to framework;
> 2) zero, what does it means?
Zero bytes transferred -> error
> 3) one, seems the expected result when success, so, error code should be 0;
Which it is when we drop through
> 4) two, three, ??? non-negative numbers,see 2).
>
> For my understanding 2) and 4) have to return what you initially had -EIO.
>
> > The non-negative return is the number of bytes
> > transferred which should be 1 unless there is some usb implementation
> > flakiness happening. So I will go back to returning -EIO.
>
> Yes, in *this* branch.
>
OK so now I have the same as in v4 again:
if (rv < 0) {
dev_err(dev, "simple usb_control_msg failed %d\n", rv);
goto exit;
} else if (rv != 1) {
dev_warn(dev, "simple usb_control_msg returned %d\n", rv);
rv = -EIO;
goto exit;
}
> >
> >> > + goto exit;
> >> > + }
> >> > +
> >> > + if (buffer[0] != USBTMC_STATUS_SUCCESS) {
> >> > + dev_err(dev, "simple control status returned %x\n", buffer[0]);
> >> > + rv = -EIO;
> >> > + goto exit;
> >> > + }
> >> > + rv = 0;
> >> > +
> >> > + exit:
> >> > + kfree(buffer);
> >> > + return rv;
> >> > +}
>
> --
> With Best Regards,
> Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/