From owner-freebsd-current@freebsd.org Tue Dec 8 04:40:26 2015 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8918B9D385D for ; Tue, 8 Dec 2015 04:40:26 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-ob0-x230.google.com (mail-ob0-x230.google.com [IPv6:2607:f8b0:4003:c01::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 566461C13 for ; Tue, 8 Dec 2015 04:40:26 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by obcse5 with SMTP id se5so5856975obc.3 for ; Mon, 07 Dec 2015 20:40:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=E7y+m0FHNzQTqjRWcDxEJqkVL8dL3Gbz5QVSZv234Z0=; b=DAYBLoboJNThKUDbhLYGOR8XPkSyVIKviCAm5XxN9bL/v7S1E1ZST+m4bVqXfwyXgX wBqSyYYiAk0RO6StfCswEtK7vKkR2DURI6D/QzCp7E4Eo6HMhqPqP9Wpsto6oIl/j0oK fuHTeKkckQ2/+rOl5Hf5aF349wG7VQpWa0DdTcYj58c9pT8Wcwu4ou5ineF+soGl2wbG EXy/qeLCygypMfE2HcV89NT7m+ma36+hw4Kj2RXX2JZaFis8qgri7q9XnWaGdjwuMKxH vqVOQZdt8m0DNsusWe9sFnbJmsbkjQtaWUXufrhQJ3PCUCqav3mOA0QOk/b+zLjPyC57 cQKg== MIME-Version: 1.0 X-Received: by 10.60.39.200 with SMTP id r8mr751547oek.81.1449549625535; Mon, 07 Dec 2015 20:40:25 -0800 (PST) Received: by 10.182.241.201 with HTTP; Mon, 7 Dec 2015 20:40:25 -0800 (PST) Reply-To: araujo@FreeBSD.org In-Reply-To: <20151208031327.GA17554@thinkpad.swarthmore.edu> References: <20151208031327.GA17554@thinkpad.swarthmore.edu> Date: Tue, 8 Dec 2015 12:40:25 +0800 Message-ID: Subject: Re: [PATCH] XOR uses From: Marcelo Araujo To: Michael McConville Cc: freebsd-current Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2015 04:40:26 -0000 Hi Michael, What would be the advantage of it? I still prefer explicit than implicit. The current code is much more readable. Best, 2015-12-08 11:13 GMT+08:00 Michael McConville : > A minor simplification patch: > > > Index: sys/arm/allwinner/a10_gpio.c > =================================================================== > --- sys/arm/allwinner/a10_gpio.c (revision 291978) > +++ sys/arm/allwinner/a10_gpio.c (working copy) > @@ -356,10 +356,7 @@ > sc = device_get_softc(dev); > A10_GPIO_LOCK(sc); > data = A10_GPIO_READ(sc, A10_GPIO_GP_DAT(bank)); > - if (data & (1 << pin)) > - data &= ~(1 << pin); > - else > - data |= (1 << pin); > + data ^= (1 << pin); > A10_GPIO_WRITE(sc, A10_GPIO_GP_DAT(bank), data); > A10_GPIO_UNLOCK(sc); > > Index: sys/arm/altera/socfpga/socfpga_gpio.c > =================================================================== > --- sys/arm/altera/socfpga/socfpga_gpio.c (revision 291978) > +++ sys/arm/altera/socfpga/socfpga_gpio.c (working copy) > @@ -336,10 +336,7 @@ > > GPIO_LOCK(sc); > reg = READ4(sc, GPIO_SWPORTA_DR); > - if (reg & (1 << i)) > - reg &= ~(1 << i); > - else > - reg |= (1 << i); > + reg ^= (1 << i); > WRITE4(sc, GPIO_SWPORTA_DR, reg); > GPIO_UNLOCK(sc); > > Index: sys/arm/rockchip/rk30xx_gpio.c > =================================================================== > --- sys/arm/rockchip/rk30xx_gpio.c (revision 291978) > +++ sys/arm/rockchip/rk30xx_gpio.c (working copy) > @@ -375,10 +375,7 @@ > return (EINVAL); > RK30_GPIO_LOCK(sc); > data = RK30_GPIO_READ(sc, RK30_GPIO_SWPORT_DR); > - if (data & (1U << pin)) > - data &= ~(1U << pin); > - else > - data |= (1U << pin); > + data ^= (1U << pin); > RK30_GPIO_WRITE(sc, RK30_GPIO_SWPORT_DR, data); > RK30_GPIO_UNLOCK(sc); > > Index: sys/arm/samsung/exynos/exynos5_pad.c > =================================================================== > --- sys/arm/samsung/exynos/exynos5_pad.c (revision 291978) > +++ sys/arm/samsung/exynos/exynos5_pad.c (working copy) > @@ -722,10 +722,7 @@ > > GPIO_LOCK(sc); > reg = READ4(sc, bank.port, bank.con + 0x4); > - if (reg & (1 << pin_shift)) > - reg &= ~(1 << pin_shift); > - else > - reg |= (1 << pin_shift); > + reg ^= (1 << pin_shift); > WRITE4(sc, bank.port, bank.con + 0x4, reg); > GPIO_UNLOCK(sc); > > Index: sys/dev/nand/nandsim_ctrl.c > =================================================================== > --- sys/dev/nand/nandsim_ctrl.c (revision 291978) > +++ sys/dev/nand/nandsim_ctrl.c (working copy) > @@ -388,9 +388,6 @@ > rand = random(); > if ((rand % 1000000) < chip->error_ratio) { > bit = rand % 8; > - if (*byte & (1 << bit)) > - *byte &= ~(1 << bit); > - else > - *byte |= (1 << bit); > + *byte ^= (1 << bit); > } > } > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)