diff mbox series

[3/4] usb: typec: tcpci_rt1711h: Add rxdz_sel variable to struct rt1711h_chip_info

Message ID 20230820184402.102486-4-biju.das.jz@bp.renesas.com
State New
Headers show
Series onvert enum->pointer for data in the rt1711h match tables | expand

Commit Message

Biju Das Aug. 20, 2023, 6:44 p.m. UTC
The RT1715 needs 0.35V/0.75V rx threshold for rd/rp whereas it is 0.4V/0.7V
for RT1711H. Add rxdz_sel variable to struct rt1711h_chip_info for
handling this difference.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/usb/typec/tcpm/tcpci_rt1711h.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andy Shevchenko Aug. 21, 2023, 1:06 p.m. UTC | #1
On Sun, Aug 20, 2023 at 07:44:01PM +0100, Biju Das wrote:
> The RT1715 needs 0.35V/0.75V rx threshold for rd/rp whereas it is 0.4V/0.7V
> for RT1711H. Add rxdz_sel variable to struct rt1711h_chip_info for
> handling this difference.

...

>  struct rt1711h_chip_info {
>  	u16 did;
> +	u32 rxdz_sel;
>  };

Again, run pahole. And see the difference, if any, depending on the place of a
new member. Note, some 64-bit architectures may require 8-byte alignment even
for 4-byte members.

...

>  static const struct rt1711h_chip_info rt1711h = {
>  	.did = RT1711H_DID,
> +	.rxdz_sel = 0,
>  };

Unneeded change.
Geert Uytterhoeven Aug. 21, 2023, 1:33 p.m. UTC | #2
Hi Andy,

On Mon, Aug 21, 2023 at 3:06 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Sun, Aug 20, 2023 at 07:44:01PM +0100, Biju Das wrote:
> > The RT1715 needs 0.35V/0.75V rx threshold for rd/rp whereas it is 0.4V/0.7V
> > for RT1711H. Add rxdz_sel variable to struct rt1711h_chip_info for
> > handling this difference.
>
> ...
>
> >  struct rt1711h_chip_info {
> >       u16 did;
> > +     u32 rxdz_sel;
> >  };
>
> Again, run pahole. And see the difference, if any, depending on the place of a
> new member. Note, some 64-bit architectures may require 8-byte alignment even
> for 4-byte members.

Doesn't make a difference, the size and alignment of a structure are
always multiples of the largest alignment of each of the members, so
the structure size will be 8 bytes on both 32-bit and 64-bit (except
on m68k, where it will be 6 bytes).

Either you have 2 bytes did, 2 bytes hole, and 4 bytes rxdz_sel, or
4 bytes rxdz, 2 bytes did, and 2 bytes hole (except on m68k, where
there won't be any holes).

Gr{oetje,eeting}s,

                        Geert
Andy Shevchenko Aug. 21, 2023, 3:26 p.m. UTC | #3
On Mon, Aug 21, 2023 at 03:33:29PM +0200, Geert Uytterhoeven wrote:
> On Mon, Aug 21, 2023 at 3:06 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Sun, Aug 20, 2023 at 07:44:01PM +0100, Biju Das wrote:
> > > The RT1715 needs 0.35V/0.75V rx threshold for rd/rp whereas it is 0.4V/0.7V
> > > for RT1711H. Add rxdz_sel variable to struct rt1711h_chip_info for
> > > handling this difference.

...

> > >  struct rt1711h_chip_info {
> > >       u16 did;
> > > +     u32 rxdz_sel;
> > >  };
> >
> > Again, run pahole. And see the difference, if any, depending on the place of a
> > new member. Note, some 64-bit architectures may require 8-byte alignment even
> > for 4-byte members.
> 
> Doesn't make a difference, the size and alignment of a structure are
> always multiples of the largest alignment of each of the members, so
> the structure size will be 8 bytes on both 32-bit and 64-bit (except
> on m68k, where it will be 6 bytes).
> 
> Either you have 2 bytes did, 2 bytes hole, and 4 bytes rxdz_sel, or
> 4 bytes rxdz, 2 bytes did, and 2 bytes hole (except on m68k, where
> there won't be any holes).

And I said "if any".
My suggestion is to check with pahole to be sure it's already good enough.
diff mbox series

Patch

diff --git a/drivers/usb/typec/tcpm/tcpci_rt1711h.c b/drivers/usb/typec/tcpm/tcpci_rt1711h.c
index c9392919226a..1b1753895ca5 100644
--- a/drivers/usb/typec/tcpm/tcpci_rt1711h.c
+++ b/drivers/usb/typec/tcpm/tcpci_rt1711h.c
@@ -53,6 +53,7 @@ 
 
 struct rt1711h_chip_info {
 	u16 did;
+	u32 rxdz_sel;
 };
 
 struct rt1711h_chip {
@@ -204,10 +205,7 @@  static inline int rt1711h_init_cc_params(struct rt1711h_chip *chip, u8 status)
 	if ((cc1 >= TYPEC_CC_RP_1_5 && cc2 < TYPEC_CC_RP_DEF) ||
 	    (cc2 >= TYPEC_CC_RP_1_5 && cc1 < TYPEC_CC_RP_DEF)) {
 		rxdz_en = BMCIO_RXDZEN;
-		if (chip->info->did == RT1715_DID)
-			rxdz_sel = RT1711H_BMCIO_RXDZSEL;
-		else
-			rxdz_sel = 0;
+		rxdz_sel = chip->info->rxdz_sel;
 	} else {
 		rxdz_en = 0;
 		rxdz_sel = RT1711H_BMCIO_RXDZSEL;
@@ -397,10 +395,12 @@  static void rt1711h_remove(struct i2c_client *client)
 
 static const struct rt1711h_chip_info rt1711h = {
 	.did = RT1711H_DID,
+	.rxdz_sel = 0,
 };
 
 static const struct rt1711h_chip_info rt1715 = {
 	.did = RT1715_DID,
+	.rxdz_sel = RT1711H_BMCIO_RXDZSEL,
 };
 
 static const struct i2c_device_id rt1711h_id[] = {