From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyswF-0005qF-BU for barebox@lists.infradead.org; Fri, 24 Jul 2020 08:20:19 +0000 Message-ID: <795d7b96dea1b9f6ab60020f9725c185d9f0822c.camel@pengutronix.de> From: Lucas Stach Date: Fri, 24 Jul 2020 10:20:16 +0200 In-Reply-To: References: MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: gpio generic driver To: "Barbier, Renaud" , "barebox@lists.infradead.org" Am Donnerstag, den 23.07.2020, 19:51 +0000 schrieb Barbier, Renaud: > Question regarding the function below: > > static int bgpio_get(struct gpio_chip *gc, unsigned int gpio) > { > struct bgpio_chip *bgc = to_bgpio_chip(gc); > > ~ return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio); > } > > This returns the value from the register i.e the value as in 0x01000000 for bit 3BE or 28LE. This is what I see using the drivers/gpio/gpio-mpc8xxx.c driver. > > Is it not supposed to return just 0 or 1? > > Linux has > > return !!(gc->read_reg(gc->reg_dat) & bgpio_line2mask(gc, gpio)); This shouldn't make a difference when the return value is just used in a condition, but it may confuse other uses which expect the normalized 1/0 form. Care to send a patch to change this to the more correct Linux version? Regards, Lucas _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox