Re: [PATCH 3/5] i2c: Congatec Board Controller i2c bus driver

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

 



Hi Thomas,

On Fri, Aug 09, 2024 at 04:52:07PM GMT, Thomas Richard wrote:
> Add i2c support for the Congatec Board Controller.

do you mind adding some more description?

> Signed-off-by: Thomas Richard <thomas.richard@xxxxxxxxxxx>

...

> +config I2C_CGBC
> +	tristate "Congatec I2C Controller"
> +	depends on MFD_CGBC
> +	help
> +	  This enables the I2C bus interfaces for the Congatec Board

This what? :-)

> +	  Controller.
> +
> +	  This driver can also be built as a module. If so, the module will
> +	  be called i2c-cgbc.ko.
> +

...

> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/i2c.h>
> +#include <linux/iopoll.h>

please sort includes in alphabetical order?

> +#include <linux/mfd/cgbc.h>

...

> +enum i2c_state {
> +	STATE_DONE = 0,
> +	STATE_INIT,
> +	STATE_START,
> +	STATE_READ,
> +	STATE_WRITE,
> +	STATE_ERROR,
> +};

can you please use the cgbc prefix for this enum and all the
members?

...

> +	if (bus_frequency > CGBC_I2C_FREQ_MAX_HZ ||
> +	    bus_frequency < CGBC_I2C_FREQ_MIN_HZ) {
> +		dev_warn(i2c->dev, "invalid frequency %u, using default\n", bus_frequency);

should this rather be a dev_info()? (supernit: please start with
capital leter).

> +		bus_frequency = I2C_MAX_STANDARD_MODE_FREQ;
> +	}
> +
> +	cmd[0] = CGBC_I2C_CMD_SPEED | algo_data->bus_id;
> +	cmd[1] = cgbc_i2c_freq_to_reg(bus_frequency);
> +
> +	ret = cgbc_command(cgbc, &cmd, sizeof(cmd), &data, 1, NULL);
> +	if (ret)
> +		return dev_err_probe(i2c->dev, ret,
> +				     "Failed to initialize I2C bus %s",
> +				     adap->name);
> +
> +	cmd[1] = 0x00;
> +
> +	ret = cgbc_command(cgbc, &cmd, sizeof(cmd), &data, 1, NULL);
> +	if (ret)
> +		return dev_err_probe(i2c->dev, ret,
> +				     "Failed to get I2C bus frequency");
> +
> +	bus_frequency = cgbc_i2c_reg_to_freq(data);
> +
> +	dev_dbg(i2c->dev, "%s is running at %d Hz\n", adap->name, bus_frequency);
> +
> +	/*
> +	 * The read_maxtime_us is the maximum time to wait during a read to get
> +	 * data. At maximum CGBC_I2C_READ_MAX_LEN can be read by command.
> +	 * So calculate the max time to size correctly the timeout.
> +	 */

this comment is a bit wild, can we rephrase to something like:

/*
 * The read_maxtime_us variable represents the maximum time to wait
 * for data during a read operation. The maximum amount of data that
 * can be read by a command is CGBC_I2C_READ_MAX_LEN.
 * Therefore, calculate the max time to properly size the timeout.
 */

(it's a suggestion, please choose the words you prefer).

Andi




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux