From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752698AbbCPDIf (ORCPT ); Sun, 15 Mar 2015 23:08:35 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:33339 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751430AbbCPDId (ORCPT ); Sun, 15 Mar 2015 23:08:33 -0400 Message-ID: <5506492D.70001@gmail.com> Date: Mon, 16 Mar 2015 11:08:29 +0800 From: Peter Hung User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Johan Hovold CC: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, tom_tsai@fintek.com.tw, peter_hong@fintek.com.tw, Peter Hung Subject: Re: [PATCH V8 04/10] USB: f81232: implement read IIR/MSR with endpoint References: <1424944936-7117-1-git-send-email-hpeter+linux_kernel@gmail.com> <1424944936-7117-5-git-send-email-hpeter+linux_kernel@gmail.com> <20150314120231.GD9442@localhost> In-Reply-To: <20150314120231.GD9442@localhost> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Johan Hovold 於 2015/3/14 下午 08:02 寫道: > On Thu, Feb 26, 2015 at 06:02:10PM +0800, Peter Hung wrote: >> + if (status != sizeof(*val)) { >> + dev_err(&port->dev, "%s failed status: %d\n", __func__, status); >> + >> + if (status == 0) >> + status = -EIO; >> + else >> + status = usb_translate_errors(status); > > Could you rewrite this as > > if (status < 0) > status = usb_translate_errors(status); > else > status = 0; In my definition the return value of set/getregister(), 0 is success, negative values are errors. The function usb_control_msg() return value is success transmited/received byte. It's maybe return 0. I want to treat 0 with error(-EIO). But if pass 0 to usb_translate_errors(), It will return 0 back. So I need especially handle with status == 0. I'll keep this sections. Thanks for review -- With Best Regards, Peter Hung