Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1273291

RE: [PATCH 1/8] staging: comedi: rearrange comedi_write() code

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Hartley Sweeten <HartleyS@visionengravers.com>
Newsgroups linux.kernel
Subject RE: [PATCH 1/8] staging: comedi: rearrange comedi_write() code
Date Thu, 19 Nov 2015 18:10:01 +0100
Message-ID <qwASB-3Lk-3@gated-at.bofh.it> (permalink)
References <qwfbs-6aN-7@gated-at.bofh.it> <qwfbt-6aN-21@gated-at.bofh.it>
X-Original-To Ian Abbott <abbotti@mev.co.uk>, "driverdev-devel@linuxdriverproject.org" <driverdev-devel@linuxdriverproject.org>
Thread-Topic [PATCH 1/8] staging: comedi: rearrange comedi_write() code
Thread-Index AQHRIipMqxemfcxLk0WhZvtpDpPtW56jk2mg
Accept-Language en-US
Content-Language en-US
Authentication-Results spf=none (sender IP is ) smtp.mailfrom=HartleyS@visionengravers.com;
X-Originating-IP [184.183.19.121]
X-Microsoft-Exchange-Diagnostics 1;BN3PR0101MB1058;5:jZt655/fYDpbSS4TDkXjtIUp1usxZSIGghwpFgQ2AmRT5nwhBFBu9iKE02XDmfEpBHamvsMpPAf3xCVaEWVMedrP21ZWBQ7RIWX4pOhQDMmA1bbdLTdOUWiXcUfkOSjbxU4geI2fGqXn/OOUcLbiZQ==;24:3eJbrLpMpkgUnNcUPMlDI87OBnMJP7OpvKoraREZ9SxAf2UpSujoLLln/XhWIgVk0tF1gSiOFUgvdlciOdtgk9L0qyEGfjdHGCutA/HNqls=;20:jfNpttOQ6mTDWmFqoQyEBRTTOuHRGGMSOxeA/hba+uEv2LIgJRNBAZYrV7HerQiNKxJOJe0w5PRwjl1dZ6dRNw==
X-Microsoft-Antispam UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0101MB1058;
X-Microsoft-Antispam-Prvs <BN3PR0101MB1058A28E1845CBAF4D72EC59D01B0@BN3PR0101MB1058.prod.exchangelabs.com>
X-Exchange-Antispam-Report-Test UriScan:;
X-Exchange-Antispam-Report-Cfa-Test BCL:0;PCL:0;RULEID:(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001);SRVR:BN3PR0101MB1058;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0101MB1058;
X-Forefront-Prvs 07658B8EA3
X-Forefront-Antispam-Report SFV:NSPM;SFS:(10019020)(6009001)(377454003)(189002)(199003)(24454002)(10400500002)(50986999)(105586002)(54356999)(5008740100001)(74316001)(87936001)(19580405001)(19580395003)(106356001)(586003)(77096005)(66066001)(92566002)(2950100001)(86362001)(81156007)(80792005)(11100500001)(2900100001)(5004730100002)(5002640100001)(97736004)(122556002)(106116001)(3846002)(40100003)(76176999)(33656002)(102836003)(5001960100002)(189998001)(5001920100001)(2501003)(5003600100002)(101416001)(5001770100001)(6116002)(5007970100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0101MB1058;H:BN3PR0101MB1057.prod.exchangelabs.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en;
Received-Spf None (protection.outlook.com: visionengravers.com does not designate permitted sender hosts)
Spamdiagnosticoutput 1:23
Spamdiagnosticmetadata NSPM
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding 8BIT
MIME-Version 1.0
X-Originatororg visionengravers.com
X-Ms-Exchange-Crosstenant-Originalarrivaltime 19 Nov 2015 17:03:05.1463 (UTC)
X-Ms-Exchange-Crosstenant-Fromentityheader Hosted
X-Ms-Exchange-Crosstenant-ID d698601f-af92-4269-8099-fd6f11636477
X-Ms-Exchange-Transport-Crosstenantheadersstamped BN3PR0101MB1058
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 40
Organization linux.* mail to news gateway
X-Original-Cc Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
X-Original-Date Thu, 19 Nov 2015 17:03:05 +0000
X-Original-Message-ID <BN3PR0101MB1057365D27515C535A1384E4D01B0@BN3PR0101MB1057.prod.exchangelabs.com>
X-Original-References <1447869311-21955-1-git-send-email-abbotti@mev.co.uk> <1447869311-21955-2-git-send-email-abbotti@mev.co.uk>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1273291

Show key headers only | View raw


On Wednesday, November 18, 2015 10:55 AM, Ian Abbott wrote:
> Rearrange the code in `comedi_write()` to reduce the amount of
> indentation.  The code never reiterates the `while` loop once `count`
> has become non-zero, so we can check that in the `while` condition to
> save an indentation level.  (Note that `nbytes` has been checked to be
> non-zero before entering the loop, so we can remove that check.)  Move
> the code that makes the subdevice "become non-busy" outside the `while`
> loop, using a new flag variable `become_nonbusy` to decide whether it
> needs to be done.  This simplifies the wait queue handling so there is a
> single place where the task is removed from the wait queue, and we can
> remove the `on_wait_queue` flag variable.
>
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
>  drivers/staging/comedi/comedi_fops.c | 71 +++++++++++++++---------------------
>  1 file changed, 30 insertions(+), 41 deletions(-)

Ian,

Minor nit-pick...

[snip]

> -out:
> -	if (on_wait_queue)
> -		remove_wait_queue(&async->wait_head, &wait);
> +	remove_wait_queue(&async->wait_head, &wait);
>  	set_current_state(TASK_RUNNING);
> +	if (become_nonbusy && count == 0) {

It looks like 'count' will always be 0 here.

Regards
Hartley

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/8] staging: comedi: some comedi_write() changes Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 19:00 +0100
  [PATCH 1/8] staging: comedi: rearrange comedi_write() code Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 19:00 +0100
    RE: [PATCH 1/8] staging: comedi: rearrange comedi_write() code Hartley Sweeten <HartleyS@visionengravers.com> - 2015-11-19 18:10 +0100
  [PATCH 5/8] staging: comedi: allow buffer wraparound in comedi_write() Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 19:00 +0100
  [PATCH 8/8] staging: comedi: check for more errors for zero-length write Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 19:00 +0100
  [PATCH 4/8] staging: comedi: avoid bad truncation of a size_t in comedi_write() Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 19:00 +0100
  [PATCH 6/8] staging: comedi: return error on "write" if no command set up Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 19:00 +0100
  [PATCH 7/8] staging: comedi: simplify returned errors for comedi_write() Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 19:00 +0100
  RE: [PATCH 0/8] staging: comedi: some comedi_write() changes Hartley Sweeten <HartleyS@visionengravers.com> - 2015-11-19 18:40 +0100

csiph-web