[PATCH] realtek: Fix kernel dependencies on CONFIG_MDIO_SMBUS

Bjørn Mork bjorn at mork.no
Tue Mar 15 05:32:17 PDT 2022


Birger Koblitz <mail at birger-koblitz.de> writes:

> --- a/target/linux/realtek/patches-5.10/712-net-phy-sfp-add-support-for-SMBus.patch
> +++ b/target/linux/realtek/patches-5.10/712-net-phy-sfp-add-support-for-SMBus.patch
> @@ -10,10 +10,11 @@ Signed-off-by: Antoine Tenart <antoine.tenart at bootlin.com>
>
>  --- a/drivers/net/phy/sfp.c
>  +++ b/drivers/net/phy/sfp.c
> -@@ -412,32 +412,72 @@ static int sfp_i2c_write(struct sfp *sfp
> +@@ -412,32 +412,78 @@ static int sfp_i2c_write(struct sfp *sfp
>   	return ret == ARRAY_SIZE(msgs) ? len : 0;
>   }
>
> ++#ifdef CONFIG_MDIO_SMBUS
>  +static int sfp_smbus_read(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
>  +			  size_t len)
>  +{
> @@ -42,6 +43,7 @@ Signed-off-by: Antoine Tenart <antoine.tenart at bootlin.com>
>  +
>  +	return sfp->i2c_mii->write(sfp->i2c_mii, bus_addr, dev_addr, val);
>  +}
> ++#endif
>  +
>   static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
>   {
> @@ -69,6 +71,7 @@ Signed-off-by: Antoine Tenart <antoine.tenart at bootlin.com>
>  +
>  +		mii->name = "SFP I2C Bus";
>  +	} else if (i2c_check_functionality(i2c, I2C_FUNC_SMBUS_BYTE_DATA)) {
> ++#ifdef CONFIG_MDIO_SMBUS
>  +		sfp->read = sfp_smbus_read;
>  +		sfp->write = sfp_smbus_write;
>  +
> @@ -79,6 +82,9 @@ Signed-off-by: Antoine Tenart <antoine.tenart at bootlin.com>
>  -	i2c_mii->name = "SFP I2C Bus";
>  -	i2c_mii->phy_mask = ~0;
>  +		mii->name = "SFP SMBus";
> ++#else
> ++		return -EINVAL;
> ++#endif
>  +	} else {
>  +		return -EINVAL;
>  +	}

Yuck!

Why the heck can't this be made generic, auto-configured by DTS props
and upstreamed?  There is a reason for this, you know:

bjorn at miraculix:/usr/local/src/git/linux$ git grep -E '^#ifdef' drivers/net/phy/sfp.c|wc -c
0



Bjørn



More information about the openwrt-devel mailing list