From: Wolfgang Denk Date: Fri, 23 Aug 2019 11:34:53 +0200 Subject: [U-Boot] [PATCH v4 2/4] armv8: ls2088aqds: The ls2088aqds board supports the I2C driver model. In-Reply-To: <20190726112403.32842-2-chuanhua.han@nxp.com> References: <20190726112403.32842-1-chuanhua.han@nxp.com> <20190726112403.32842-2-chuanhua.han@nxp.com> Message-ID: <20190823093453.78ADC240085@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Chuanhua Han, In message <20190726112403.32842-2-chuanhua.han@nxp.com> you wrote: > This patch is updating ls2088aqds board init code to support DM_I2C. ... > +struct reg_pair { > + uint addr; > + u8 *val; > +}; > + > static void sgmii_configure_repeater(int serdes_port) > { > struct mii_dev *bus; > uint8_t a = 0xf; > - int i, j, ret; > + int i, j, k, ret; > int dpmac_id = 0, dpmac, mii_bus = 0; > unsigned short value; > char dev[2][20] = {"LS2080A_QDS_MDIO0", "LS2080A_QDS_MDIO3"}; > @@ -104,10 +109,30 @@ static void sgmii_configure_repeater(int serdes_port) > uint8_t ch_b_eq[] = {0x1, 0x2, 0x3, 0x7}; > uint8_t ch_b_ctl2[] = {0x81, 0x82, 0x83, 0x84}; > > + u8 reg_val[6] = {0x18, 0x38, 0x4, 0x14, 0xb5, 0x20}; > + struct reg_pair reg_pair[10] = { > + {6, ®_val[0]}, {4, ®_val[1]}, > + {8, ®_val[2]}, {0xf, NULL}, > + {0x11, NULL}, {0x16, NULL}, > + {0x18, NULL}, {0x23, ®_val[3]}, > + {0x2d, ®_val[4]}, {4, ®_val[5]}, > + }; Argh... this is pretty much unreadable. Why do you use a pointer for "val" in your struct reg_pair? Would it not be much simpler to use something like this: struct reg_pair { uint addr; u8 val; } ... struct reg_pair reg_pair[] = { {0x06, 0x18}, {0x04, 0x38}, {0x08, 0x04}, {0x0F, 0}, {0x11, 0}, {0x16, 0}, {0x18, 0}, {0x23, 0x14}, {0x2D, 0xB5}, {0x04, 0x20}, }} ? Also, you should add some comments what all these magic numbers mean. As is, nobody is able to understand what you are doing here. This must be explained! Also, a comment should be added that (and why) some of the values get inserted dynamically later down in the code. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The easiest way to figure the cost of living is to take your income and add ten percent.