All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Nazarewicz" <m.nazarewicz@samsung.com>
To: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>,
	Andy Isaacson <adi@hexapodia.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-usb <linux-usb@vger.kernel.org>,
	"Wang, Qi" <qi.wang@intel.com>,
	"Wang, Yong Y" <yong.y.wang@intel.com>,
	Andrew <andrew.chih.howe.khor@intel.com>,
	Intel OTC <joel.clark@intel.com>,
	"Foster, Margie" <margie.foster@intel.com>,
	"Ewe, Kok Howg" <kok.howg.ewe@intel.com>
Subject: Re: [PATCH v7] USB device driver of Topcliff PCH
Date: Mon, 08 Nov 2010 12:22:51 +0100	[thread overview]
Message-ID: <op.vlum8dzo7p4s8u@pikus> (raw)
In-Reply-To: <20101103183750.GA23043@hexapodia.org>

> On Mon, Oct 25, 2010 at 07:24:25PM +0900, Toshiharu Okada wrote:
>> +	if (!list_empty(&ep->queue)) {
>> +		dev_dbg(&dev->pdev->dev, "%s: list not empty", __func__);
>> +		ret = -EAGAIN;
>> +	} else if (!halt) {	/* halt or clear halt */
>> +		pch_udc_ep_clear_stall(ep);
>> +		ret = 0;
>> +	} else {
>> +		if (ep->num == PCH_UDC_EP0)
>> +			ep->dev->stall = 1;
>> +		pch_udc_ep_set_stall(ep);
>> +		pch_udc_enable_ep_interrupts(ep->dev,
>> +					     PCH_UDC_EPINT(ep->in, ep->num));
>> +		ret = 0;
>> +	}

On Wed, 03 Nov 2010 19:37:50 +0100, Andy Isaacson <adi@hexapodia.org> wrote:
> I think this would be clearer as
>
> +	if (!list_empty(&ep->queue)) {
> +		dev_dbg(&dev->pdev->dev, "%s: list not empty", __func__);
> +		ret = -EAGAIN;
> +	}
> +	if (halt) {
> +		if (ep->num == PCH_UDC_EP0)
> +			ep->dev->stall = 1;
> +		pch_udc_ep_set_stall(ep);
> +		pch_udc_enable_ep_interrupts(ep->dev,
> +					     PCH_UDC_EPINT(ep->in, ep->num));
> +		ret = 0;
> +	} else {
> +		pch_udc_ep_clear_stall(ep);
> +		ret = 0;
> +	}

This changes the behavior of the construct though.

> because:
> 1. if (!list_empty  is a standalone check, there is no if/else if/else
> connection between list_empty() and halt.

This depends on how you look at it.  The way I see it is that there are three
mutually exclusive cases: the list is not empty, it is a halt, it is not a
halt.  This way, if-else-if-else seems like a good construct to me.

> 2. I prefer if (foo) {} else {} instead of if (!foo) {} else {}, unless
> there is a significant reason to do the negated test.

I agree on that though.

>> +	pr_debug("%s: %s", __func__, usbep->name);
>
> There are probably too many pr_debug() and dev_dbg()s in this driver.
> Please reconsider which ones are appropriate for mainline.

Do we really care?  Just don't define DEBUG...

-- 
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--

  parent reply	other threads:[~2010-11-08 10:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-25 10:24 [PATCH v7] USB device driver of Topcliff PCH Toshiharu Okada
2010-11-03 18:37 ` Andy Isaacson
2010-11-04  8:35   ` Toshiharu Okada
2010-11-08 11:22   ` Michał Nazarewicz [this message]
2010-11-09  4:57     ` Toshiharu Okada
2010-11-10 12:29       ` Michał Nazarewicz
2010-11-11  1:06         ` Toshiharu Okada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=op.vlum8dzo7p4s8u@pikus \
    --to=m.nazarewicz@samsung.com \
    --cc=adi@hexapodia.org \
    --cc=andrew.chih.howe.khor@intel.com \
    --cc=gregkh@suse.de \
    --cc=joel.clark@intel.com \
    --cc=kok.howg.ewe@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=margie.foster@intel.com \
    --cc=qi.wang@intel.com \
    --cc=toshiharu-linux@dsn.okisemi.com \
    --cc=yong.y.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.