From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E006EC433DB for ; Sun, 14 Feb 2021 06:53:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A111B64DBA for ; Sun, 14 Feb 2021 06:53:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A111B64DBA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0SKKKngmzWUxV2eaGvaEOSq9GPQIJ1uh4ztUHf3Xams=; b=d4GFyIH05kDOPXD5JWk2b/2M/ h4ip4jMpibqftL/+KAarBZTOWTuzsB97iqe2RbY+iSbbC3AIFZKqen+IZ39YdfH1eT2zB1j1jxBB8 6UWqM+Ulku/TcqN3+Xrmte+BFRLCcnsHaDPqtK30ovJLOJGP7AyCqgq4Vd81B2TqTp8KPpDqKsVA9 7a9QSf+Q0r6I7OWCttX9RPLiIBXZsnskHcURsVFM5FqEpW75wzuDjXYGWurv9P7F5CZtena0xOtmN +FH4ZrkpCIbEZk6MkR7Re8AsN/9nlQyu2WEpBh1n4VbisOGz1pQj2FljcLnfbgDYgOwzZ53uGybxH 9NzMMQ5Ww==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBBGA-000200-7i; Sun, 14 Feb 2021 06:51:58 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lBBG7-0001zS-Gr for linux-arm-kernel@lists.infradead.org; Sun, 14 Feb 2021 06:51:56 +0000 Received: by mail-pg1-x534.google.com with SMTP id t25so2424804pga.2 for ; Sat, 13 Feb 2021 22:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=X2EJKn2Q5rmq+Yi9UK1APlcp90jXtUQBQHq0JTIDyGY=; b=EEvOdBt0QbtV8R/q53cLymQtUHeaiajLDue8tEgMdASxfrbKvdbnTA12gZ1HGDsXcd /mcCcI2M4PkkJ8nidENX2iyftZ1d9eNmHKSHGf3ycQVepOghTPYUdPxnvQEuWYd9Y3iO 2L9kiEuTosBuBLSDSL0U9mFgWO0bILDVajIq5sVxzHSwvy7cd2PZuedsI9tfngy4oVcb 4GUTbU394aiBmvOhKeMvTLsYv9BuPUzYCKgxJjFacymsuyOHkAgmEXu9DHTqg6QmpOdt vSg8soGAZfaTAWOLU5XnAnjz5sYb+XvyU260g9nGESL+q+fogv0luQ1DKvsbt8nxyPHK MHtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=X2EJKn2Q5rmq+Yi9UK1APlcp90jXtUQBQHq0JTIDyGY=; b=Q8jw5JfGIyk5pPvUZjp1woXIhuRQ5YTUsGzo5DG8C04vVk6gVLloHZL15ma6y2b19/ e9jopPJfDwqYu2i0nundMPvetNrYU6AZBHjtNsJjp4FrCWjVOD7nxH7LTwSfWBEp9vFn I80ZWgGlwVTmvD0OOyFPk0+eQInEL2MW/3ydSfUeZ2Nw4m0QRvCtJ6U98c0rb+QrX5Eb BxrPgbJi4mebT1+bdsztPTsno0Jsmv7qMRKc3OTRoiEeQGgL6xD5ls57ZRYY2ztP2K7n SjVThOf+jN830ne+RPb3nXcgfRUoqTszt2d9bekQdz5kq5pNfw74UUrw6X/GcorieJcm aTAA== X-Gm-Message-State: AOAM533VhdtAHPajnZqSr3OTdt7D9hfWQgwp477DvuJiDBRXToAK3t+J RGjQxf0CkQs8OaMaCCVTBoHJOrzdbZZO2g== X-Google-Smtp-Source: ABdhPJydcyGXyLoACItzieFkASH7cpQXcenXtosFDDiga3+BJmDb43KItdmpqcS+BBnx1+iWKQf0NQ== X-Received: by 2002:a05:6a00:1a48:b029:1ce:64d9:70e6 with SMTP id h8-20020a056a001a48b02901ce64d970e6mr10344356pfv.8.1613285512592; Sat, 13 Feb 2021 22:51:52 -0800 (PST) Received: from shinobu ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id fv11sm13261957pjb.18.2021.02.13.22.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Feb 2021 22:51:52 -0800 (PST) Date: Sun, 14 Feb 2021 15:51:45 +0900 From: William Breathitt Gray To: Syed Nayyar Waris Subject: Re: [PATCH v2 3/3] gpio: xilinx: Utilize generic bitmap_get_value and _set_value Message-ID: References: <1b1f706b60e4c571c4f17d53ac640e8bd8384856.1613134924.git.syednwaris@gmail.com> MIME-Version: 1.0 In-Reply-To: <1b1f706b60e4c571c4f17d53ac640e8bd8384856.1613134924.git.syednwaris@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210214_015155_710028_5757EFB4 X-CRM114-Status: GOOD ( 22.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, amit.kucheria@verdurent.com, arnd@arndb.de, yamada.masahiro@socionext.com, linus.walleij@linaro.org, daniel.lezcano@linaro.org, michal.simek@xilinx.com, linux-kernel@vger.kernel.org, bgolaszewski@baylibre.com, rrichter@marvell.com, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, rui.zhang@intel.com, linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============1940319019797332671==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============1940319019797332671== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AVko8d8iE+KHQT32" Content-Disposition: inline --AVko8d8iE+KHQT32 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 12, 2021 at 06:52:00PM +0530, Syed Nayyar Waris wrote: > This patch reimplements the xgpio_set_multiple() function in > drivers/gpio/gpio-xilinx.c to use the new generic functions: > bitmap_get_value() and bitmap_set_value(). The code is now simpler > to read and understand. Moreover, instead of looping for each bit > in xgpio_set_multiple() function, now we can check each channel at > a time and save cycles. >=20 > Cc: William Breathitt Gray > Cc: Bartosz Golaszewski > Cc: Michal Simek > Signed-off-by: Syed Nayyar Waris Acked-by: William Breathitt Gray > --- > drivers/gpio/gpio-xilinx.c | 63 +++++++++++++++++++------------------- > 1 file changed, 32 insertions(+), 31 deletions(-) >=20 > diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c > index be539381fd82..8445e69cf37b 100644 > --- a/drivers/gpio/gpio-xilinx.c > +++ b/drivers/gpio/gpio-xilinx.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include "gpiolib.h" > =20 > /* Register Offset Definitions */ > #define XGPIO_DATA_OFFSET (0x0) /* Data register */ > @@ -141,37 +142,37 @@ static void xgpio_set_multiple(struct gpio_chip *gc= , unsigned long *mask, > { > unsigned long flags; > struct xgpio_instance *chip =3D gpiochip_get_data(gc); > - int index =3D xgpio_index(chip, 0); > - int offset, i; > - > - spin_lock_irqsave(&chip->gpio_lock[index], flags); > - > - /* Write to GPIO signals */ > - for (i =3D 0; i < gc->ngpio; i++) { > - if (*mask =3D=3D 0) > - break; > - /* Once finished with an index write it out to the register */ > - if (index !=3D xgpio_index(chip, i)) { > - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + > - index * XGPIO_CHANNEL_OFFSET, > - chip->gpio_state[index]); > - spin_unlock_irqrestore(&chip->gpio_lock[index], flags); > - index =3D xgpio_index(chip, i); > - spin_lock_irqsave(&chip->gpio_lock[index], flags); > - } > - if (__test_and_clear_bit(i, mask)) { > - offset =3D xgpio_offset(chip, i); > - if (test_bit(i, bits)) > - chip->gpio_state[index] |=3D BIT(offset); > - else > - chip->gpio_state[index] &=3D ~BIT(offset); > - } > - } > - > - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + > - index * XGPIO_CHANNEL_OFFSET, chip->gpio_state[index]); > - > - spin_unlock_irqrestore(&chip->gpio_lock[index], flags); > + u32 *const state =3D chip->gpio_state; > + unsigned int *const width =3D chip->gpio_width; > + > + DECLARE_BITMAP(old, 64); > + DECLARE_BITMAP(new, 64); > + DECLARE_BITMAP(changed, 64); > + > + spin_lock_irqsave(&chip->gpio_lock[0], flags); > + spin_lock(&chip->gpio_lock[1]); > + > + bitmap_set_value(old, 64, state[0], width[0], 0); > + bitmap_set_value(old, 64, state[1], width[1], width[0]); > + bitmap_replace(new, old, bits, mask, gc->ngpio); > + > + bitmap_set_value(old, 64, state[0], 32, 0); > + bitmap_set_value(old, 64, state[1], 32, 32); > + state[0] =3D bitmap_get_value(new, 0, width[0]); > + state[1] =3D bitmap_get_value(new, width[0], width[1]); > + bitmap_set_value(new, 64, state[0], 32, 0); > + bitmap_set_value(new, 64, state[1], 32, 32); > + bitmap_xor(changed, old, new, 64); > + > + if (((u32 *)changed)[0]) > + xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET, > + state[0]); > + if (((u32 *)changed)[1]) > + xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + > + XGPIO_CHANNEL_OFFSET, state[1]); > + > + spin_unlock(&chip->gpio_lock[1]); > + spin_unlock_irqrestore(&chip->gpio_lock[0], flags); > } > =20 > /** > --=20 > 2.29.0 >=20 --AVko8d8iE+KHQT32 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAmAoyIAACgkQhvpINdm7 VJLDwRAAkYbiWj65z4jjrxx7Cxv/DP6zH0wtwqBb+BeZ2zO5gk3GonfpTqtDqvOq 2som9X4hM57nzTZnY1Mom2RqM3csY5YpsyBB0s9QeBe5CcdhdGZ21ZkX9vqZp/5+ 8VVjgTg1vO4jwZzKtulztcuJsgBjhHd5lLoPGpBplXHuJobzPQ5mx/ffC1x4wyGi d59bXrd1Wzed6rxRTWKm/tBIqVITbyYHiXkBbUYJm5cF27xfar5S4tSkhuTs09S8 3rEgmPplulTPm4XyKKmlQfyEH5VANMfSswPQx0wIP6iYtI6rN4RuCM/ZYD4lcGhe Ez0KtpbnRyF211ieo4BKgjbUcFcp8g5/6QZlU1FYCJxWnxF9OtElnAVcHBlzPOrL Mp3RLUDaxoytqXAJy+wLEHbf1Z8CcHdiJ1gFYDNl4TpPEyjkJ1j/XLVGb/JOoPKG 1KtzT/fvQRK0G5xKXuB33RsoFoj8G/Olm4+6VxOO7MvOw7LMZRCF1wZbwCmwwVPU BcSsPr4dlFfzbrHiZhW07ilMi/dWChVolBb1/BjK+x9vEYYIufl+YSinPhO7x8Wp FgUi1Z/9bzA/T/kE4V4NLXrVanq+PxhWlzqvm5qHNpsIRp9PiwFVHw22nxlWeVBZ lbvaPOSA156Aac2Y0UVfNQQ10VWV2ieJ3FpNI9xnjICxp6QOydo= =o/OB -----END PGP SIGNATURE----- --AVko8d8iE+KHQT32-- --===============1940319019797332671== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============1940319019797332671==--