Re: [PATCH v6 2/8] i2c: muxes: add support for tsd,mule-i2c multiplexer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Thu, Jul 25, 2024 at 03:27:48PM +0200, Farouk Bouabid wrote:
> Theobroma Systems Mule is an MCU that emulates a set of I2C devices,
> among which an amc6821 and devices that are reachable through an I2C-mux.
> The devices on the mux can be selected by writing the appropriate device
> number to an I2C config register (amc6821 reg 0xff).
> 
> This driver is expected to be probed as a platform device with amc6821
> as its parent i2c device.
> 
> Add support for the mule-i2c-mux platform driver. The amc6821 driver
> support for the mux will be added in a later commit.

Seems like DT maintainers are happy with the approach. From the I2C
perspective, this seems suitable as well. Just a few minor comments. Can
be fixed incrementally, from my POV. But basically:

Reviewed-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>


> +static inline int __mux_select(struct regmap *regmap, u32 dev)
> +{
> +	return regmap_write(regmap, MUX_CONFIG_REG, dev);
> +}

Does this really need to be a seperate function? I'd vote for merging it
into 'mux_select'. Also the __-prefix often means unlocked versions of
some call, so it is also a bit misleading.

> +static int mule_i2c_mux_probe(struct platform_device *pdev)
> +{
> +	struct device *mux_dev = &pdev->dev;
> +	struct mule_i2c_reg_mux *priv;
> +	struct i2c_client *client;
> +	struct i2c_mux_core *muxc;
> +	struct device_node *dev;
> +	unsigned int readback;
> +	int ndev, ret;
> +	bool old_fw;
> +
> +	/* Count devices on the mux */
> +	ndev = of_get_child_count(mux_dev->of_node);
> +	dev_dbg(mux_dev, "%d devices on the mux\n", ndev);
> +
> +	client = to_i2c_client(mux_dev->parent);
> +
> +	muxc = i2c_mux_alloc(client->adapter, mux_dev, ndev, sizeof(*priv),
> +			     I2C_MUX_LOCKED, mux_select, mux_deselect);
> +	if (!muxc)
> +		return dev_err_probe(mux_dev, -ENOMEM,
> +				     "Failed to allocate mux struct\n");

alloc_functions usually print something when failing.

> +		ret = i2c_mux_add_adapter(muxc, 0, reg);
> +		if (ret)
> +			return dev_err_probe(mux_dev, ret,
> +					     "Failed to add i2c mux adapter %d\n", reg);

The 'add_adapter' functions for sure print something when failing.

Thanks!

   Wolfram

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux