* [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic
@ 2026-03-25 11:20 Prabhakar
2026-03-25 12:30 ` Geert Uytterhoeven
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Prabhakar @ 2026-03-25 11:20 UTC (permalink / raw)
To: Yoshihiro Shimoda, Vinod Koul, Neil Armstrong, Geert Uytterhoeven,
Magnus Damm, Pavel Machek
Cc: linux-renesas-soc, linux-phy, linux-kernel, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Read USB2_ADPCTRL once in rcar_gen3_check_id() instead of issuing
multiple MMIO reads, and derive both IDDIG and VBUSVALID from the same
value.
Drop the redundant !! operator, as assigning a masked u32 value to a
bool already performs the required normalization. Simplify the logic by
comparing the ID and VBUS status directly, which is equivalent to the
previous conditional but easier to follow.
Reported-by: Pavel Machek <pavel@nabladev.com>
Closes: https://lore.kernel.org/all/acJVCOdlchLiSe5n@duo.ucw.cz/
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v1->v2:
- Rebased on top of latest next-20260324
- Combined variable declarations and assignments and dropped
redundant !! operator
- Updated commit message
- Corrected the link for closes tag
---
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 79e820e2fe55..9a45d840efeb 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -314,13 +314,11 @@ static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan *ch)
static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
{
if (ch->phy_data->vblvl_ctrl) {
- bool vbus_valid;
- bool device;
+ u32 val = readl(ch->base + USB2_ADPCTRL);
+ bool vbus_valid = val & USB2_ADPCTRL_VBUSVALID;
+ bool device = val & USB2_ADPCTRL_IDDIG;
- device = !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
- vbus_valid = !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_VBUSVALID);
-
- return vbus_valid ? device : !device;
+ return device == vbus_valid;
}
if (!ch->uses_otg_pins)
--
2.53.0
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic
2026-03-25 11:20 [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic Prabhakar
@ 2026-03-25 12:30 ` Geert Uytterhoeven
2026-04-27 11:36 ` Lad, Prabhakar
2026-05-03 17:16 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2026-03-25 12:30 UTC (permalink / raw)
To: Prabhakar
Cc: Yoshihiro Shimoda, Vinod Koul, Neil Armstrong, Magnus Damm,
Pavel Machek, linux-renesas-soc, linux-phy, linux-kernel,
Biju Das, Fabrizio Castro, Lad Prabhakar
On Wed, 25 Mar 2026 at 12:20, Prabhakar <prabhakar.csengg@gmail.com> wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Read USB2_ADPCTRL once in rcar_gen3_check_id() instead of issuing
> multiple MMIO reads, and derive both IDDIG and VBUSVALID from the same
> value.
>
> Drop the redundant !! operator, as assigning a masked u32 value to a
> bool already performs the required normalization. Simplify the logic by
> comparing the ID and VBUS status directly, which is equivalent to the
> previous conditional but easier to follow.
>
> Reported-by: Pavel Machek <pavel@nabladev.com>
> Closes: https://lore.kernel.org/all/acJVCOdlchLiSe5n@duo.ucw.cz/
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> v1->v2:
> - Rebased on top of latest next-20260324
> - Combined variable declarations and assignments and dropped
> redundant !! operator
> - Updated commit message
> - Corrected the link for closes tag
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic
2026-03-25 11:20 [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic Prabhakar
2026-03-25 12:30 ` Geert Uytterhoeven
@ 2026-04-27 11:36 ` Lad, Prabhakar
2026-05-03 17:16 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Lad, Prabhakar @ 2026-04-27 11:36 UTC (permalink / raw)
To: Vinod Koul
Cc: Yoshihiro Shimoda, Pavel Machek, Magnus Damm, Geert Uytterhoeven,
Neil Armstrong, linux-renesas-soc, linux-phy, linux-kernel,
Biju Das, Fabrizio Castro, Lad Prabhakar
Hi Vinod,
On Wed, Mar 25, 2026 at 11:20 AM Prabhakar <prabhakar.csengg@gmail.com> wrote:
>
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Read USB2_ADPCTRL once in rcar_gen3_check_id() instead of issuing
> multiple MMIO reads, and derive both IDDIG and VBUSVALID from the same
> value.
>
> Drop the redundant !! operator, as assigning a masked u32 value to a
> bool already performs the required normalization. Simplify the logic by
> comparing the ID and VBUS status directly, which is equivalent to the
> previous conditional but easier to follow.
>
> Reported-by: Pavel Machek <pavel@nabladev.com>
> Closes: https://lore.kernel.org/all/acJVCOdlchLiSe5n@duo.ucw.cz/
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> v1->v2:
> - Rebased on top of latest next-20260324
> - Combined variable declarations and assignments and dropped
> redundant !! operator
> - Updated commit message
> - Corrected the link for closes tag
> ---
> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
Gentle ping.
Cheers,
Prabhakar
> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> index 79e820e2fe55..9a45d840efeb 100644
> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
> @@ -314,13 +314,11 @@ static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan *ch)
> static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
> {
> if (ch->phy_data->vblvl_ctrl) {
> - bool vbus_valid;
> - bool device;
> + u32 val = readl(ch->base + USB2_ADPCTRL);
> + bool vbus_valid = val & USB2_ADPCTRL_VBUSVALID;
> + bool device = val & USB2_ADPCTRL_IDDIG;
>
> - device = !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG);
> - vbus_valid = !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_VBUSVALID);
> -
> - return vbus_valid ? device : !device;
> + return device == vbus_valid;
> }
>
> if (!ch->uses_otg_pins)
> --
> 2.53.0
>
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic
2026-03-25 11:20 [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic Prabhakar
2026-03-25 12:30 ` Geert Uytterhoeven
2026-04-27 11:36 ` Lad, Prabhakar
@ 2026-05-03 17:16 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2026-05-03 17:16 UTC (permalink / raw)
To: Yoshihiro Shimoda, Neil Armstrong, Geert Uytterhoeven,
Magnus Damm, Pavel Machek, Prabhakar
Cc: linux-renesas-soc, linux-phy, linux-kernel, Biju Das,
Fabrizio Castro, Lad Prabhakar
On Wed, 25 Mar 2026 11:20:39 +0000, Prabhakar wrote:
> Read USB2_ADPCTRL once in rcar_gen3_check_id() instead of issuing
> multiple MMIO reads, and derive both IDDIG and VBUSVALID from the same
> value.
>
> Drop the redundant !! operator, as assigning a masked u32 value to a
> bool already performs the required normalization. Simplify the logic by
> comparing the ID and VBUS status directly, which is equivalent to the
> previous conditional but easier to follow.
>
> [...]
Applied, thanks!
[1/1] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic
commit: f67ab4706ab72af29c331b21f431c463b00d447a
Best regards,
--
~Vinod
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-03 17:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 11:20 [PATCH v2] phy: renesas: rcar-gen3-usb2: Simplify ID/VBUS detection logic Prabhakar
2026-03-25 12:30 ` Geert Uytterhoeven
2026-04-27 11:36 ` Lad, Prabhakar
2026-05-03 17:16 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox