From: Andi Shyti <andi.shyti@linux.intel.com>
To: "Cavitt, Jonathan" <jonathan.cavitt@intel.com>
Cc: Thorsten Blum <thorsten.blum@toblux.com>,
"jani.nikula@linux.intel.com" <jani.nikula@linux.intel.com>,
"joonas.lahtinen@linux.intel.com"
<joonas.lahtinen@linux.intel.com>,
"Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
"tursulin@ursulin.net" <tursulin@ursulin.net>,
"airlied@gmail.com" <airlied@gmail.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] drm/i915: Explicitly cast divisor and use div_u64()
Date: Wed, 7 Aug 2024 15:58:30 +0100 [thread overview]
Message-ID: <ZrOLlofTKS_xKWrC@ashyti-mobl2.lan> (raw)
In-Reply-To: <CH0PR11MB544400E7751E4A4090DBB387E5BE2@CH0PR11MB5444.namprd11.prod.outlook.com>
Hi Thorsten,
> > /* This check is primarily to ensure that oa_period <=
> > - * UINT32_MAX (before passing to do_div which only
> > + * UINT32_MAX (before passing it to div_u64 which only
> > * accepts a u32 denominator), but we can also skip
> > * checking anything < 1Hz which implicitly can't be
> > * limited via an integer oa_max_sample_rate.
> > */
> > if (oa_period <= NSEC_PER_SEC) {
> > - u64 tmp = NSEC_PER_SEC;
> > - do_div(tmp, oa_period);
> > - oa_freq_hz = tmp;
> > + oa_freq_hz = div_u64(NSEC_PER_SEC, (u32)oa_period);
> > } else
> > oa_freq_hz = 0;
>
> Non-blocking suggestion: this looks like it can be inlined. And if the
> inline route is taken, it might be best to invert the conditional check
> like such:
>
> oa_freq_hz = oa_period > NSEC_PER_SEC ? 0 :
> div_u64(NSEC_PER_SEC, (u32)oa_period);
>
> I think this is just a matter of preference, though. The explicit if-else
> block is definitely clearer.
It's also stylistically wrong given that now the if/else don't
need the brackets anymore, triggering a checkpatch error.
Thorsten do you mind resending it either following Jonathan's
suggestion (my favourite, as well) or fix the bracket issue
following the kernel style.
Andi
next prev parent reply other threads:[~2024-08-07 14:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 16:03 [PATCH v2] drm/i915: Explicitly cast divisor and use div_u64() Thorsten Blum
2024-08-05 17:09 ` ✓ Fi.CI.BAT: success for " Patchwork
2024-08-05 19:34 ` [PATCH v2] " Cavitt, Jonathan
2024-08-07 14:58 ` Andi Shyti [this message]
2024-08-06 3:15 ` ✗ Fi.CI.IGT: failure for " Patchwork
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=ZrOLlofTKS_xKWrC@ashyti-mobl2.lan \
--to=andi.shyti@linux.intel.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jonathan.cavitt@intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=thorsten.blum@toblux.com \
--cc=tursulin@ursulin.net \
/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