Re: [tip: objtool/urgent] objtool, media: dib8000: Prevent divide-by-zero in dib8000_set_dds()

From: Josh Poimboeuf
Date: Tue Mar 25 2025 - 21:46:28 EST


On Wed, Mar 26, 2025 at 06:42:39AM +0800, Mauro Carvalho Chehab wrote:
> > + u32 internal = dib8000_read32(state, 23) / 1000;
> > +
> > ratio = 4;
> > - unit_khz_dds_val = (1<<26) / (dib8000_read32(state, 23) / 1000);
> > +
> > + unit_khz_dds_val = (1<<26) / (internal ?: 1);
>
> This is theoretical, as in practice dib8096 won't likely be tuning
> if reading this register would return zero, but at least for my
> eyes, it would sound better to set unit_khz_dds_val to 1 internal
> is zero, instead of 1<<26.

I don't pretend to understand this device, I just figured one is the
closest you can get to zero :-)

So something like this instead?

diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
index cfe59c3255f7..c80134ff511b 100644
--- a/drivers/media/dvb-frontends/dib8000.c
+++ b/drivers/media/dvb-frontends/dib8000.c
@@ -2705,7 +2705,7 @@ static void dib8000_set_dds(struct dib8000_state *state, s32 offset_khz)

ratio = 4;

- unit_khz_dds_val = (1<<26) / (internal ?: 1);
+ unit_khz_dds_val = internal ? ((1<<26) / internal) : 1;
if (offset_khz < 0)
dds = (1 << 26) - (abs_offset_khz * unit_khz_dds_val);
else