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=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 607BAC4741F for ; Tue, 10 Nov 2020 17:44:45 +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 F31892076E for ; Tue, 10 Nov 2020 17:44:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="E2+p9s/n"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iFSVLGMV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F31892076E 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=uWa3Kybg7wpq5eJnVhJF9CmfWPDfwX0NHpSYhOM3eGY=; b=E2+p9s/nVQFbMB44XtNuLqRmn LUVQ9SPntUe1nvN+drzH282PyC1uQWE13PxBiVJPN3+9PN1sdyd/HBsx4ddOMnlupg9Xe1uTHir5d L8GIEnT8OGFuUZwJoBYYnHbqDR9wxCc7RT8yPG+IpNVTtyi+5LMHzRMNkPWHJo1F091BmxwKBK0Dq Hb0VbIcxkh5BttYhsPbLkH4hF67F4G3qDqiIWw05v7YW0PNaxmipf8L6W0N2vgnzX4LytIf4iWTJX ybiFqB1OVwRII4wa85R5VCsD+xnMk9wSudXZtLOO1YcHX2zAIJNoReugS2XFPvG74i6lSc78BdbFa EwsVmm7vg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcXg8-00068G-Qg; Tue, 10 Nov 2020 17:43:36 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcXg6-00067B-ME for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 17:43:35 +0000 Received: by mail-qt1-x841.google.com with SMTP id 7so4790913qtp.1 for ; Tue, 10 Nov 2020 09:43:32 -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=DKkPU+8hqJwckrB66qB9FLVQlvNA5eR+TbpWXqlMT4I=; b=iFSVLGMVyBy4qKxQeFHL+M7wlTMsuNJM1upYnG91TFB8htl2Zih8wZKxR+JvJwAzuH JXLoqa8hgDBz5pEF71R30ICrxocy5etvcED+WcT480rL2XoHW+p0isEc2bDuYdmH8ZSC uCsFUsZO2lF1SRsZ7urH8zemaY0v7vAaxY+DU8jupxcP0sxMR2YW9sdxwAfFfQPWwGEF Dk/owg/zyX7xH7CPdVfVevxC7KpWTeOzjsBpSoQK0KIi3bGGXPGlX7Dt9rESy9UmkgGv mqDS6mCBkf1pUvgfALdABgihsGF0sRsZOsNIucVrppXhoZ2538Oixf2tRRM6d4rDl2yI RUvg== 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=DKkPU+8hqJwckrB66qB9FLVQlvNA5eR+TbpWXqlMT4I=; b=TgXrrPzv0yEmMLZzlTp9wlp6nwkFPPu/jZbGWb6LouVpdGyQpIN4nPKOjCRNzICc64 JcNxAN+n9wFdy/Hh+zlwwJYjcO1xClPSHBpCFfCmzbN2XMKbf3zRPfN4o2MWF5TuMpp0 QfNusofKpvYp+Lkh6/9+wYSfkEFK/7lrCWQO/DT8ZSHGqNXlLH2aJP+4DSMqecbKy5Q4 Uze38U8YwvPeWLgtSV1AS9f95QWIWsBSl13NQObnAXnC9VDwknK4G5UKMkjFeZFXXfdM GsPbaBMUEA7rZaxS0H5GeRPaMXFRs6kxIewxZtiTI3ory29YgRQHldgRXMLh1bGG3Q92 VrZw== X-Gm-Message-State: AOAM531+epqaacLVjcdx2775yWIk050jE9JVCywDlA6OFe7h4gL63uft i6VQ80ifT1VkfYBekruOK9Q= X-Google-Smtp-Source: ABdhPJx8fmOkO1d0v3o7izwEVdKHZLmUW17kkIhYIu7BLwqcnnBiAzFBRTCnR7QpXD9MuZSEhAvKAA== X-Received: by 2002:ac8:d48:: with SMTP id r8mr19197194qti.69.1605030211198; Tue, 10 Nov 2020 09:43:31 -0800 (PST) Received: from shinobu (072-189-064-225.res.spectrum.com. [72.189.64.225]) by smtp.gmail.com with ESMTPSA id o14sm8694953qto.16.2020.11.10.09.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 09:43:30 -0800 (PST) Date: Tue, 10 Nov 2020 12:43:16 -0500 From: William Breathitt Gray To: Syed Nayyar Waris Subject: Re: [PATCH v12 4/4] gpio: xilinx: Utilize generic bitmap_get_value and _set_value Message-ID: <20201110174316.GA12192@shinobu> References: <20201109123411.GA19869@syed> <20201109134128.GA5596@shinobu> <20201109164529.GA28710@syed.domain.name> <20201109171140.GA14045@shinobu> <20201109172220.GI4077@smile.fi.intel.com> <20201109173107.GA14643@shinobu> <20201110123538.GA3193@shinobu> MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_124334_771064_D4BE02E9 X-CRM114-Status: GOOD ( 32.41 ) 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: Arnd Bergmann , Bartosz Golaszewski , Linus Walleij , Michal Simek , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" , Andrew Morton , Andy Shevchenko , Linux ARM Content-Type: multipart/mixed; boundary="===============1092896230866275923==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============1092896230866275923== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 10, 2020 at 10:52:42PM +0530, Syed Nayyar Waris wrote: > On Tue, Nov 10, 2020 at 6:05 PM William Breathitt Gray > wrote: > > > > On Tue, Nov 10, 2020 at 11:02:43AM +0100, Michal Simek wrote: > > > > > > > > > On 09. 11. 20 18:31, William Breathitt Gray wrote: > > > > On Mon, Nov 09, 2020 at 07:22:20PM +0200, Andy Shevchenko wrote: > > > >> On Mon, Nov 09, 2020 at 12:11:40PM -0500, William Breathitt Gray w= rote: > > > >>> On Mon, Nov 09, 2020 at 10:15:29PM +0530, Syed Nayyar Waris wrote: > > > >>>> On Mon, Nov 09, 2020 at 03:41:53PM +0100, Arnd Bergmann wrote: > > > >> > > > >> ... > > > >> > > > >>>> static inline void bitmap_set_value(unsigned long *map, > > > >>>> - unsigned long value, > > > >>>> + unsigned long value, const = size_t length, > > > >>>> unsigned long start, unsign= ed long nbits) > > > >>>> { > > > >>>> const size_t index =3D BIT_WORD(start); > > > >>>> @@ -15,6 +15,10 @@ static inline void bitmap_set_value(unsigned = long *map, > > > >>>> } else { > > > >>>> map[index + 0] &=3D ~BITMAP_FIRST_WORD_MASK(sta= rt); > > > >>>> map[index + 0] |=3D value << offset; > > > >>>> + > > > >>>> + if (index + 1 >=3D length) > > > >>>> + __builtin_unreachable(); > > > >>>> + > > > >>>> map[index + 1] &=3D ~BITMAP_LAST_WORD_MASK(star= t + nbits); > > > >>>> map[index + 1] |=3D value >> space; > > > >>>> } > > > >>> > > > >>> Hi Syed, > > > >>> > > > >>> Let's rename 'length' to 'nbits' as Arnd suggested, and rename 'n= bits' > > > >>> to value_width. > > > >> > > > >> length here is in longs. I guess this is the point of entire patch. > > > > > > > > Ah yes, this should become 'const unsigned long nbits' and represen= t the > > > > length of the bitmap in bits and not longs. >=20 > Hi William, Andy and All, >=20 > Thank You for reviewing. I was looking into the review comments and I > have a question on the above. >=20 > Actually, in bitmap_set_value(), the intended comparison is to be made > between 'index + 1' and 'length' (which is now renamed as 'nbits'). > That is, the comparison would look-like as follows: > if (index + 1 >=3D nbits) >=20 > The 'index' is getting populated with BIT_WORD(start). > The 'index' variable in above is the actual index of the bitmap array, > while in previous mail it is suggested to use 'nbits' which represent > the length of the bitmap in bits and not longs. >=20 > Isn't it comparing two different things? index of array (not the > bit-wise-length) on left hand side and nbits (bit-wise-length) on > right hand side? >=20 > Have I misunderstood something? If yes, request to clarify. >=20 > Or do I have to first divide 'nbits' by BITS_PER_LONG and then compare > it with 'index + 1'? Something like this? >=20 > Regards > Syed Nayyar Waris The array elements of the bitmap memory region are abstracted away for the covenience of the users of the bitmap_* functions; the driver authors are able to treat their bitmaps as just a set of contiguous bits and not worry about where the division between array elements happen. So to match the interface of the other bitmap_* functions, you should take in nbits and figure out the actual array length by dividing by BITS_PER_LONG inside bitmap_set_value(). Then you can use your conditional check (index + 1 >=3D length) like you have been doing so far. William Breathitt Gray --bg08WKrSYDhXBjb5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAl+q0SkACgkQhvpINdm7 VJKhMRAAricUh4JzphV3n0FFvtd+6BR3bMIY06bgAWbzFhvOBj4P78ZZCZTabPS4 ba11PaSdWz4ZHIiOihh+22uiEdIKYGz0cnYE1ZmvDg62HGqkwbpIQX3ei5wR37aQ R2LG0yCryexwxpKwPfiJ5hlSx9MBhaGOi9ptSRQM+OD0WYqyn+YDcXDhnBA6NEXa yDpqEkoA0w5BOuBHIxb4aUeKx58bz2n2mRCTi68QtMg5e8n6sww5gAQV1Vxg56IZ qY0BoE7JwReQI54fo/TuiIgR145pvYoTFsBO5VnTmXd/E4AN+9k4TBZMinVv3saj 2qH0Az6xs9LEhpD1acgLh8v3EjM8uFzUcRUDaKRZU4BUiXMBdB8CQpHqqWoQUiDS 8nV4jaZE34dFwHRbB13Bl67FztviugMyul8Hv1oPdbOeaY3CSuy7Up8j5kI0YcVJ tl+Ev9Df2GPkLzV+Am9XP62GN5lZ3DnCLdpYRs+VIK3cdzgNLD4rMF3rIjHeFEHV jWdpF/SqlX9+6rWYpxFmUXaafBUVWB3E/ExDXgATeiEeQC1jmVVVHZ43JBSrQi81 CsaQtRs0fpxuyT1HhG/y6yFMzooZAkrvCAsbiS7yCyYm1AAvsSUjybkdTsklzVUo +s3CiEe7Wz40kn/BJHIWUy0fiwWgdKCROw8C8bzEdKEUco60EB8= =lx3m -----END PGP SIGNATURE----- --bg08WKrSYDhXBjb5-- --===============1092896230866275923== 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 --===============1092896230866275923==--