Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp535138ybx; Wed, 6 Nov 2019 04:39:49 -0800 (PST) X-Google-Smtp-Source: APXvYqynSSaUD3pKcy80BNLwkkI6Acy8f1zhn0E1c/rxtUPH4Go8fW3Xt11+AA+SgGw9KAw1bjzj X-Received: by 2002:a17:906:80c1:: with SMTP id a1mr35194471ejx.37.1573043989647; Wed, 06 Nov 2019 04:39:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573043989; cv=none; d=google.com; s=arc-20160816; b=Or5jftMoQneiXcu0HJJABrCT9O4MQiRoEt0Tdg52QrOCa+k7cw8Ol19ZY/BuvMdpt6 NtNKHzfQkJLs0qNMQSRhJ7bCx2hWpUxp7ppKSZjSN1DmV7PvK3+Y5j7zErevtUzGbQ1H n6znhtYqbUMjbSWGq8B+5EkESZHmJvlZG6qHbmBZnuIIpI5siMKMEfpX7tYXrcPxRIyH f8NV1dmZ5LXiIwQBMWyWj6HiYD0lLcEZdh+fLdpVoaIUYSGXRxUMq6WVLG1iww3jKiv7 Ma5SHNyOaznb8X59iZ9+Rm+p7CdUDr5yi26hC9Sste3CmBGj6Bw8jVQtEDyXpLoZS1DR Ap2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=UICFSnf/Q0mqFlP3f0Qejag6EmjSHl2tMUqDxMyFEec=; b=Su895ouP69/JwGTDwQJoq9UpmCKPwo0hFrOJZAVxhmn8mjTPF5aw4YSvGsddPB+jZi 2NE5Ul5pF4RAGU+Sqlq/s6xQpUgj3YRIokUjaE77mVrwtGdjJgBYSzoXgpUeOIjNIEtf u2KSzj0Md7iLVcmmsMfktQn+mHD2ivJvBBmvsHFXvhq/twI3tesnxPY2IK76UfaPgDjW /xM7rLnKpWUPDFlOoRHjUTbGN2u3/jnZLSM74YE210fs94OrCfJRqE4mfAZx4vipt8C6 0JhHJRrZD48T790uQE1mX1phrpxXBxs8yPUWJbH1nqN3QZFel/eCfv1NqrRQ9YLeuYkX mE/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si11854485edu.250.2019.11.06.04.39.24; Wed, 06 Nov 2019 04:39:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730233AbfKFMil (ORCPT + 99 others); Wed, 6 Nov 2019 07:38:41 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:37353 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727741AbfKFMil (ORCPT ); Wed, 6 Nov 2019 07:38:41 -0500 Received: by mail-ot1-f67.google.com with SMTP id d5so8641168otp.4; Wed, 06 Nov 2019 04:38:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UICFSnf/Q0mqFlP3f0Qejag6EmjSHl2tMUqDxMyFEec=; b=GIS15WkmJsIlA0vgTCWf32aUt24Bx/qMYIF4vQUDVWof6PjKlFJ9MGzbeRqaeKyVV6 Bdh7nxZz0t00m5/kWhCUYKEHuuynxrckPwZkxnRAyla948cXoM62mTh7XCAyvd6nQCYM XoyA0axQX+XQBzMRxz4gBphpUA1Pn40fRhpWoov+RXkPmIchij6UFG+9ROX5G0LwS9VU nG50Y+jltLroDOhtVCQGsO1RpdidOvByXcW089wtFlw25BbEAK+T7qRGND06gDlam2Yd sBMpqVobOtTGIFsYKAlgSOJsQcvqFqG+l6cR5sOK+xxBdWA6EtwxGHvmiVbpEu22Bg8Z NVQQ== X-Gm-Message-State: APjAAAXhSWaEaOcFnfiM4V/6ZRJO2569DykQYK61b9o7CyztSj7/V3oO p+ly8FT3LOkrlD6CnYWjzeMGsEYGb3nk4O2Nt04= X-Received: by 2002:a9d:73cd:: with SMTP id m13mr1666991otk.145.1573043920420; Wed, 06 Nov 2019 04:38:40 -0800 (PST) MIME-Version: 1.0 References: <0a1fe4365ef599adde42396f0bb735c8623f679c.1572945757.git.matti.vaittinen@fi.rohmeurope.com> <20191106053446.GD5290@kw.sim.vm.gnt> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 6 Nov 2019 13:38:29 +0100 Message-ID: Subject: Re: [PATCH 13/62] gpio: gpio-f7188x: Use new GPIO_LINE_DIRECTION To: "Vaittinen, Matti" Cc: "simon.guinot@sequanux.org" , "mazziesaccount@gmail.com" , "linux-gpio@vger.kernel.org" , "bgolaszewski@baylibre.com" , "linux-kernel@vger.kernel.org" , "linus.walleij@linaro.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matti, On Wed, Nov 6, 2019 at 7:45 AM Vaittinen, Matti wrote: > On Wed, 2019-11-06 at 06:34 +0100, Simon Guinot wrote: > > On Tue, Nov 05, 2019 at 12:16:03PM +0200, Matti Vaittinen wrote: > > > It's hard for occasional GPIO code reader/writer to know if values > > > 0/1 > > > equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and > > > GPIO_LINE_DIRECTION_OUT to help them out. > > > > > > Signed-off-by: Matti Vaittinen > > > --- > > > drivers/gpio/gpio-f7188x.c | 5 ++++- > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio- > > > f7188x.c > > > index fdc639f856f1..cadd02993539 100644 > > > --- a/drivers/gpio/gpio-f7188x.c > > > +++ b/drivers/gpio/gpio-f7188x.c > > > @@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct > > > gpio_chip *chip, unsigned offset) > > > > > > superio_exit(sio->addr); > > > > > > - return !(dir & 1 << offset); > > > + if (dir & 1 << offset) > > > + return GPIO_LINE_DIRECTION_OUT; > > > + > > > + return GPIO_LINE_DIRECTION_IN > > > > Hi Matti, > > > > I am probably missing something but I can't find > > GPIO_LINE_DIRECTION_IN > > and GPIO_LINE_DIRECTION_OUT defined anywhere. > > Sorry. I accidentally sent the patch 01/62 to limited audience - and > also messed up the message-ID from the series so threading messages is > probably not working :( I did resend the patch adding defines to all > reviewers yesterday - title should be "[RESEND PATCH 01/62] gpio: Add > definition for GPIO direction". > > > Besides I am an occasional code reader/writer and I find the original > > code easy to understand. > > Glad to hear that. When I read code: > > return !(dir & 1 << offset); > > It's impossible for me to tell if dir having bit at offset 'offset' set > means IN or OUT - I know the meaning of code, it checks this bit for > in/out - but which dir value is IN and which is OUT? > > When this is written as: > > if (dir & 1 << offset) > return GPIO_LINE_DIRECTION_OUT; > > return GPIO_LINE_DIRECTION_IN > > it get's quite obvious even for me that having the matching bit set > means direction to be OUT. "suggest parentheses around... " warning? if (dir & BIT(offset)) ... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds