From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Adrian Barnaś" <abarnas@google.com>
Cc: Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev
Subject: Re: [RFC] staging: media: atomisp: Simplyfy masking bit logic
Date: Tue, 2 Sep 2025 12:02:29 +0300 [thread overview]
Message-ID: <aLaypTjukJJloGuL@stanley.mountain> (raw)
In-Reply-To: <20250902073841.2338568-1-abarnas@google.com>
On Tue, Sep 02, 2025 at 07:38:40AM +0000, Adrian Barnaś wrote:
> Simplified masking logic in pci/hive_isp_css_common/host/vmem.c.
>
> ---
>
> I have tested this change on whole range of *valid* inputs, and it gives
> the same results as before, but this function seems to be little
> counter-intuitive as far as start is a (bit index) but end is
> (bit index + 1).
Yeah. The "end - 1" is unfortunate. I guess we accidentally started
counting from 1... I looked at how to remove it but got lost.
>
> It is follow up to: https://lore.kernel.org/linux-staging/20250901091050.1935505-1-abarnas@google.com/
> ---
> .../staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
> index 722b684fbc37..9703e39b7497 100644
> --- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
> +++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
> @@ -22,14 +22,14 @@ typedef hive_uedge *hive_wide;
> static inline hive_uedge
> subword(hive_uedge w, unsigned int start, unsigned int end)
> {
> - return (w & (((1ULL << (end - 1)) - 1) << 1 | 1)) >> start;
> + return (w & __GENMASK_ULL(end-1, 0)) >> start;
> }
>
> /* inverse subword bits move like this: MSB[xxxx____xxxx]LSB -> MSB[xxxx0000xxxx]LSB */
> static inline hive_uedge
> inv_subword(hive_uedge w, unsigned int start, unsigned int end)
> {
> - return w & (~(((1ULL << (end - 1)) - 1) << 1 | 1) | ((1ULL << start) - 1));
> + return w & (~__GENMASK_ULL(end-1, start));
> }
nit: white space. Add spaces. Remove parentheses.
These are supposed to be opposites, right? Subword and inverse Subword.
You could dress them up to make them look more opposite.
return (w & __GENMASK_ULL(end - 1, start)) >> start;
return w & ~__GENMASK_ULL(end - 1, start);
regards,
dan carpenter
next prev parent reply other threads:[~2025-09-02 9:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 7:38 Adrian Barnaś
2025-09-02 9:02 ` Dan Carpenter [this message]
2025-09-02 9:54 ` Andy Shevchenko
2025-09-02 10:12 ` Dan Carpenter
2025-09-02 13:10 ` Adrian Barnaś
2025-09-02 9:42 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aLaypTjukJJloGuL@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=abarnas@google.com \
--cc=andy@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®