From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Update the `riic_init_hw()` function to use the local `dev` pointer in
calls to `dev_err_probe()`. Previously, `riic_init_hw()` used
`riic->adapter.dev` in error reporting. Since this function is invoked
during the probe phase, the I2C adapter is not yet initialized, leading to
`(null) ...` being printed in error messages. This patch fixes the issue by
consistently using the local `dev` pointer, which points to
`riic->adapter.dev.parent`.
Additionally, replace `dev_err()` with `dev_err_probe()` throughout
`riic_init_hw()` for consistency.
Fixes: d982d66514192 ("i2c: riic: remove clock and frequency restrictions")
Fixes: 71dacb2565ed (i2c: riic: Simplify unsupported bus speed handling")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v1->v2
- Collected RB tag from Geert
---
drivers/i2c/busses/i2c-riic.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index bfaa2d728a76..01195ffd4c07 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic)
: I2C_MAX_FAST_MODE_FREQ;
if (t->bus_freq_hz > max_freq)
- return dev_err_probe(&riic->adapter.dev, -EINVAL,
+ return dev_err_probe(dev, -EINVAL,
"unsupported bus speed %uHz (%u max)\n",
t->bus_freq_hz, max_freq);
@@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic)
rate /= 2;
}
- if (brl > (0x1F + 3)) {
- dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n",
- (unsigned long)t->bus_freq_hz);
- return -EINVAL;
- }
+ if (brl > (0x1F + 3))
+ return dev_err_probe(dev, -EINVAL, "invalid speed (%lu). Too slow.\n",
+ (unsigned long)t->bus_freq_hz);
brh = total_ticks - brl;
--
2.43.0
Hi Prabhakar,
On Wed, Dec 18, 2024 at 12:16:11AM +0000, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Update the `riic_init_hw()` function to use the local `dev` pointer in
> calls to `dev_err_probe()`. Previously, `riic_init_hw()` used
> `riic->adapter.dev` in error reporting. Since this function is invoked
> during the probe phase, the I2C adapter is not yet initialized, leading to
> `(null) ...` being printed in error messages. This patch fixes the issue by
> consistently using the local `dev` pointer, which points to
> `riic->adapter.dev.parent`.
>
> Additionally, replace `dev_err()` with `dev_err_probe()` throughout
> `riic_init_hw()` for consistency.
>
> Fixes: d982d66514192 ("i2c: riic: remove clock and frequency restrictions")
> Fixes: 71dacb2565ed (i2c: riic: Simplify unsupported bus speed handling")
I'm not sure the Fixes are really necessary here, as it's not
really leading to a bug, but I can live with it. But, then, ...
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v1->v2
> - Collected RB tag from Geert
> ---
> drivers/i2c/busses/i2c-riic.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> index bfaa2d728a76..01195ffd4c07 100644
> --- a/drivers/i2c/busses/i2c-riic.c
> +++ b/drivers/i2c/busses/i2c-riic.c
> @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic)
> : I2C_MAX_FAST_MODE_FREQ;
>
> if (t->bus_freq_hz > max_freq)
> - return dev_err_probe(&riic->adapter.dev, -EINVAL,
> + return dev_err_probe(dev, -EINVAL,
> "unsupported bus speed %uHz (%u max)\n",
> t->bus_freq_hz, max_freq);
>
> @@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic)
> rate /= 2;
> }
>
> - if (brl > (0x1F + 3)) {
> - dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n",
> - (unsigned long)t->bus_freq_hz);
> - return -EINVAL;
> - }
> + if (brl > (0x1F + 3))
> + return dev_err_probe(dev, -EINVAL, "invalid speed (%lu). Too slow.\n",
> + (unsigned long)t->bus_freq_hz);
... I'm not happy with the splitting here: mixing a bug fix with
a cosmetic is wrong for two reasons:
- they are conceptually different;
- fixes take are applied to the -fixes branch and sent to the
weekly pull request.
I will appreciate if this second chunk is squashed with patch 1
and the first part has a patch on its own.
Thanks,
Andi
>
> brh = total_ticks - brl;
>
> --
> 2.43.0
>
Hi Andi,
On Thu, Dec 26, 2024 at 1:19 AM Andi Shyti <andi.shyti@kernel.org> wrote:
>
> Hi Prabhakar,
>
> On Wed, Dec 18, 2024 at 12:16:11AM +0000, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Update the `riic_init_hw()` function to use the local `dev` pointer in
> > calls to `dev_err_probe()`. Previously, `riic_init_hw()` used
> > `riic->adapter.dev` in error reporting. Since this function is invoked
> > during the probe phase, the I2C adapter is not yet initialized, leading to
> > `(null) ...` being printed in error messages. This patch fixes the issue by
> > consistently using the local `dev` pointer, which points to
> > `riic->adapter.dev.parent`.
> >
> > Additionally, replace `dev_err()` with `dev_err_probe()` throughout
> > `riic_init_hw()` for consistency.
> >
> > Fixes: d982d66514192 ("i2c: riic: remove clock and frequency restrictions")
> > Fixes: 71dacb2565ed (i2c: riic: Simplify unsupported bus speed handling")
>
> I'm not sure the Fixes are really necessary here, as it's not
> really leading to a bug, but I can live with it. But, then, ...
>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > v1->v2
> > - Collected RB tag from Geert
> > ---
> > drivers/i2c/busses/i2c-riic.c | 10 ++++------
> > 1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> > index bfaa2d728a76..01195ffd4c07 100644
> > --- a/drivers/i2c/busses/i2c-riic.c
> > +++ b/drivers/i2c/busses/i2c-riic.c
> > @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic)
> > : I2C_MAX_FAST_MODE_FREQ;
> >
> > if (t->bus_freq_hz > max_freq)
> > - return dev_err_probe(&riic->adapter.dev, -EINVAL,
> > + return dev_err_probe(dev, -EINVAL,
> > "unsupported bus speed %uHz (%u max)\n",
> > t->bus_freq_hz, max_freq);
> >
> > @@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic)
> > rate /= 2;
> > }
> >
> > - if (brl > (0x1F + 3)) {
> > - dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n",
> > - (unsigned long)t->bus_freq_hz);
> > - return -EINVAL;
> > - }
> > + if (brl > (0x1F + 3))
> > + return dev_err_probe(dev, -EINVAL, "invalid speed (%lu). Too slow.\n",
> > + (unsigned long)t->bus_freq_hz);
>
> ... I'm not happy with the splitting here: mixing a bug fix with
> a cosmetic is wrong for two reasons:
>
> - they are conceptually different;
> - fixes take are applied to the -fixes branch and sent to the
> weekly pull request.
>
> I will appreciate if this second chunk is squashed with patch 1
> and the first part has a patch on its own.
>
OK, I think the best approach here would be to promote this to patch
#1 ie just replacing `&riic->adapter.dev` with `dev` (as second chunk
also includes the fix along with cosmetic change) and then make patch
#2 as replacing `dev_err` with `dev_err_probe`.
Please let me know if this is OK with you.
Cheers,
Prabhakar
Hi,
On Thu, Dec 26, 2024 at 07:39:33AM +0000, Lad, Prabhakar wrote:
> On Thu, Dec 26, 2024 at 1:19 AM Andi Shyti <andi.shyti@kernel.org> wrote:
> > On Wed, Dec 18, 2024 at 12:16:11AM +0000, Prabhakar wrote:
> > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > >
> > > Update the `riic_init_hw()` function to use the local `dev` pointer in
> > > calls to `dev_err_probe()`. Previously, `riic_init_hw()` used
> > > `riic->adapter.dev` in error reporting. Since this function is invoked
> > > during the probe phase, the I2C adapter is not yet initialized, leading to
> > > `(null) ...` being printed in error messages. This patch fixes the issue by
> > > consistently using the local `dev` pointer, which points to
> > > `riic->adapter.dev.parent`.
> > >
> > > Additionally, replace `dev_err()` with `dev_err_probe()` throughout
> > > `riic_init_hw()` for consistency.
> > >
> > > Fixes: d982d66514192 ("i2c: riic: remove clock and frequency restrictions")
> > > Fixes: 71dacb2565ed (i2c: riic: Simplify unsupported bus speed handling")
> >
> > I'm not sure the Fixes are really necessary here, as it's not
> > really leading to a bug, but I can live with it. But, then, ...
On a second thought, I think this Fixes tag is not needed: there
is no bug as the missing reference is already handled.
> > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > > v1->v2
> > > - Collected RB tag from Geert
> > > ---
> > > drivers/i2c/busses/i2c-riic.c | 10 ++++------
> > > 1 file changed, 4 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> > > index bfaa2d728a76..01195ffd4c07 100644
> > > --- a/drivers/i2c/busses/i2c-riic.c
> > > +++ b/drivers/i2c/busses/i2c-riic.c
> > > @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic)
> > > : I2C_MAX_FAST_MODE_FREQ;
> > >
> > > if (t->bus_freq_hz > max_freq)
> > > - return dev_err_probe(&riic->adapter.dev, -EINVAL,
> > > + return dev_err_probe(dev, -EINVAL,
> > > "unsupported bus speed %uHz (%u max)\n",
> > > t->bus_freq_hz, max_freq);
> > >
> > > @@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic)
> > > rate /= 2;
> > > }
> > >
> > > - if (brl > (0x1F + 3)) {
> > > - dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n",
> > > - (unsigned long)t->bus_freq_hz);
> > > - return -EINVAL;
> > > - }
> > > + if (brl > (0x1F + 3))
> > > + return dev_err_probe(dev, -EINVAL, "invalid speed (%lu). Too slow.\n",
> > > + (unsigned long)t->bus_freq_hz);
> >
> > ... I'm not happy with the splitting here: mixing a bug fix with
> > a cosmetic is wrong for two reasons:
> >
> > - they are conceptually different;
> > - fixes take are applied to the -fixes branch and sent to the
> > weekly pull request.
> >
> > I will appreciate if this second chunk is squashed with patch 1
> > and the first part has a patch on its own.
> >
> OK, I think the best approach here would be to promote this to patch
> #1 ie just replacing `&riic->adapter.dev` with `dev` (as second chunk
> also includes the fix along with cosmetic change) and then make patch
> #2 as replacing `dev_err` with `dev_err_probe`.
>
> Please let me know if this is OK with you.
As Wolfram suggested, the dev_err_probe chunk can be squashed in
the patch 1 and make a single patch that is about
/dev_err/dev_err_probe. Further splitting based on internal
functions is a bit too much.
While the first chunk belongs to a different change.
Please, keep all the tags in your next version: I don't believe
anyone would object.
Thanks,
Andi
On Wed, Dec 18, 2024 at 12:16:11AM +0000, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Update the `riic_init_hw()` function to use the local `dev` pointer in
> calls to `dev_err_probe()`. Previously, `riic_init_hw()` used
> `riic->adapter.dev` in error reporting. Since this function is invoked
> during the probe phase, the I2C adapter is not yet initialized, leading to
> `(null) ...` being printed in error messages. This patch fixes the issue by
> consistently using the local `dev` pointer, which points to
> `riic->adapter.dev.parent`.
>
> Additionally, replace `dev_err()` with `dev_err_probe()` throughout
> `riic_init_hw()` for consistency.
>
> Fixes: d982d66514192 ("i2c: riic: remove clock and frequency restrictions")
> Fixes: 71dacb2565ed (i2c: riic: Simplify unsupported bus speed handling")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Maybe patches 1+2 can be squashed, but I leave this to Andi.
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Hi Prabhakar,
> diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> index bfaa2d728a76..01195ffd4c07 100644
> --- a/drivers/i2c/busses/i2c-riic.c
> +++ b/drivers/i2c/busses/i2c-riic.c
> @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic)
> : I2C_MAX_FAST_MODE_FREQ;
>
> if (t->bus_freq_hz > max_freq)
> - return dev_err_probe(&riic->adapter.dev, -EINVAL,
> + return dev_err_probe(dev, -EINVAL,
> "unsupported bus speed %uHz (%u max)\n",
> t->bus_freq_hz, max_freq);
Which branch are you on? This change has already been introduced
in commit 71dacb2565ed ("i2c: riic: Simplify unsupported bus
speed handling")
>
> @@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic)
> rate /= 2;
> }
>
> - if (brl > (0x1F + 3)) {
> - dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n",
> - (unsigned long)t->bus_freq_hz);
> - return -EINVAL;
> - }
> + if (brl > (0x1F + 3))
> + return dev_err_probe(dev, -EINVAL, "invalid speed (%lu). Too slow.\n",
> + (unsigned long)t->bus_freq_hz);
This is OK
Thanks,
Andi
>
> brh = total_ticks - brl;
>
> --
> 2.43.0
>
Hi Andi,
On Thu, Dec 19, 2024 at 12:21 PM Andi Shyti <andi.shyti@kernel.org> wrote:
>
> Hi Prabhakar,
>
> > diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> > index bfaa2d728a76..01195ffd4c07 100644
> > --- a/drivers/i2c/busses/i2c-riic.c
> > +++ b/drivers/i2c/busses/i2c-riic.c
> > @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic)
> > : I2C_MAX_FAST_MODE_FREQ;
> >
> > if (t->bus_freq_hz > max_freq)
> > - return dev_err_probe(&riic->adapter.dev, -EINVAL,
> > + return dev_err_probe(dev, -EINVAL,
> > "unsupported bus speed %uHz (%u max)\n",
> > t->bus_freq_hz, max_freq);
>
> Which branch are you on? This change has already been introduced
> in commit 71dacb2565ed ("i2c: riic: Simplify unsupported bus
> speed handling")
>
I'm on v6.13-rc3, the above change just replaces the first parameter
in dev_err_probe(). The change introduced in commit 71dacb2565ed
("i2c: riic: Simplify unsupported bus speed handling") does not update
the first parameter in dev_err_probe() which this patch addresses.
Actually I have fixes tag for commit 71dacb2565ed in the current
patch.
Cheers,
Prabhakar
Hi Prabhakar,
On Thu, Dec 19, 2024 at 12:44:50PM +0000, Lad, Prabhakar wrote:
> Hi Andi,
>
> On Thu, Dec 19, 2024 at 12:21 PM Andi Shyti <andi.shyti@kernel.org> wrote:
> >
> > Hi Prabhakar,
> >
> > > diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
> > > index bfaa2d728a76..01195ffd4c07 100644
> > > --- a/drivers/i2c/busses/i2c-riic.c
> > > +++ b/drivers/i2c/busses/i2c-riic.c
> > > @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic)
> > > : I2C_MAX_FAST_MODE_FREQ;
> > >
> > > if (t->bus_freq_hz > max_freq)
> > > - return dev_err_probe(&riic->adapter.dev, -EINVAL,
> > > + return dev_err_probe(dev, -EINVAL,
> > > "unsupported bus speed %uHz (%u max)\n",
> > > t->bus_freq_hz, max_freq);
> >
> > Which branch are you on? This change has already been introduced
> > in commit 71dacb2565ed ("i2c: riic: Simplify unsupported bus
> > speed handling")
> >
> I'm on v6.13-rc3, the above change just replaces the first parameter
> in dev_err_probe(). The change introduced in commit 71dacb2565ed
> ("i2c: riic: Simplify unsupported bus speed handling") does not update
> the first parameter in dev_err_probe() which this patch addresses.
> Actually I have fixes tag for commit 71dacb2565ed in the current
> patch.
oh, yes, sorry, ignore that :-)
Andi
© 2016 - 2025 Red Hat, Inc.