diff mbox series

[v2,2/3] net: mdio: aspeed: Introduce read write function for c22 and c45

Message ID 20220406012002.15128-3-potin.lai@quantatw.com
State Not Applicable, archived
Headers show
Series [v2,1/3] net: mdio: aspeed: move reg accessing part into separate functions | expand

Commit Message

Potin Lai April 6, 2022, 1:20 a.m. UTC
Add following additional functions to move out the implementation from
aspeed_mdio_read() and aspeed_mdio_write().

c22:
 - aspeed_mdio_read_c22()
 - aspeed_mdio_write_c22()

c45:
 - aspeed_mdio_read_c45()
 - aspeed_mdio_write_c45()

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
---
 drivers/net/mdio/mdio-aspeed.c | 46 +++++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 12 deletions(-)

Comments

Andrew Lunn April 6, 2022, 12:17 p.m. UTC | #1
> +static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
> +{
> +	dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d\n", __func__, addr,
> +		regnum);
> +
> +	if (regnum & MII_ADDR_C45)
> +		return aspeed_mdio_read_c45(bus, addr, regnum);
> +
> +	return aspeed_mdio_read_c22(bus, addr, regnum);
> +}
> +
>  static int aspeed_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
>  {
>  	dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d, val: 0x%x\n",
>  		__func__, addr, regnum, val);
>  
> -	/* Just clause 22 for the moment */
>  	if (regnum & MII_ADDR_C45)
> -		return -EOPNOTSUPP;
> +		return aspeed_mdio_write_c45(bus, addr, regnum, val);
>  
> -	return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_WRITE,
> -			      addr, regnum, val);
> +	return aspeed_mdio_write_c22(bus, addr, regnum, val);
>  }

Hi Portin

Nice structure. This will helper with future cleanup where C22 and C45
will be completely separated, and the c45 variants will be directly
passed dev_ad and reg, rather than have to extract them from regnum.

A few process issues.

Please read the netdev FAQ. The subject list should indicate the tree,
and there should be an patch 0/3 which explains the big picture of
what the patchset does. 0/3 will then be used for the merge commit.

     Andrew
Potin Lai April 6, 2022, 4:33 p.m. UTC | #2
Andrew Lunn 於 6/04/2022 8:17 pm 寫道:
>> +static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
>> +{
>> +	dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d\n", __func__, addr,
>> +		regnum);
>> +
>> +	if (regnum & MII_ADDR_C45)
>> +		return aspeed_mdio_read_c45(bus, addr, regnum);
>> +
>> +	return aspeed_mdio_read_c22(bus, addr, regnum);
>> +}
>> +
>>  static int aspeed_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
>>  {
>>  	dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d, val: 0x%x\n",
>>  		__func__, addr, regnum, val);
>>  
>> -	/* Just clause 22 for the moment */
>>  	if (regnum & MII_ADDR_C45)
>> -		return -EOPNOTSUPP;
>> +		return aspeed_mdio_write_c45(bus, addr, regnum, val);
>>  
>> -	return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_WRITE,
>> -			      addr, regnum, val);
>> +	return aspeed_mdio_write_c22(bus, addr, regnum, val);
>>  }
> Hi Portin
>
> Nice structure. This will helper with future cleanup where C22 and C45
> will be completely separated, and the c45 variants will be directly
> passed dev_ad and reg, rather than have to extract them from regnum.
>
> A few process issues.
>
> Please read the netdev FAQ. The subject list should indicate the tree,
> and there should be an patch 0/3 which explains the big picture of
> what the patchset does. 0/3 will then be used for the merge commit.
>
>      Andrew

Hi Andrew,

Thank you for the notice, it looks like I missed sent out patch 0/3. I will resend whole v2 patches again with tree name.


Potin
diff mbox series

Patch

diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c
index f22be2f069e9..5becddb56117 100644
--- a/drivers/net/mdio/mdio-aspeed.c
+++ b/drivers/net/mdio/mdio-aspeed.c
@@ -79,17 +79,10 @@  static int aspeed_mdio_get_data(struct mii_bus *bus)
 	return FIELD_GET(ASPEED_MDIO_DATA_MIIRDATA, data);
 }
 
-static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
+static int aspeed_mdio_read_c22(struct mii_bus *bus, int addr, int regnum)
 {
 	int rc;
 
-	dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d\n", __func__, addr,
-		regnum);
-
-	/* Just clause 22 for the moment */
-	if (regnum & MII_ADDR_C45)
-		return -EOPNOTSUPP;
-
 	rc = aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_READ,
 			    addr, regnum, 0);
 	if (rc < 0)
@@ -98,17 +91,46 @@  static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
 	return aspeed_mdio_get_data(bus);
 }
 
+static int aspeed_mdio_write_c22(struct mii_bus *bus, int addr, int regnum,
+				 u16 val)
+{
+	return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_WRITE,
+			      addr, regnum, val);
+}
+
+static int aspeed_mdio_read_c45(struct mii_bus *bus, int addr, int regnum)
+{
+	/* TODO: add c45 support */
+	return -EOPNOTSUPP;
+}
+
+static int aspeed_mdio_write_c45(struct mii_bus *bus, int addr, int regnum,
+				 u16 val)
+{
+	/* TODO: add c45 support */
+	return -EOPNOTSUPP;
+}
+
+static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
+{
+	dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d\n", __func__, addr,
+		regnum);
+
+	if (regnum & MII_ADDR_C45)
+		return aspeed_mdio_read_c45(bus, addr, regnum);
+
+	return aspeed_mdio_read_c22(bus, addr, regnum);
+}
+
 static int aspeed_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
 {
 	dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d, val: 0x%x\n",
 		__func__, addr, regnum, val);
 
-	/* Just clause 22 for the moment */
 	if (regnum & MII_ADDR_C45)
-		return -EOPNOTSUPP;
+		return aspeed_mdio_write_c45(bus, addr, regnum, val);
 
-	return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_WRITE,
-			      addr, regnum, val);
+	return aspeed_mdio_write_c22(bus, addr, regnum, val);
 }
 
 static int aspeed_mdio_probe(struct platform_device *pdev)