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

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

 



On 8/14/24 01:24, Andi Shyti wrote:
> Hi Thomas,

Hi Andi,

Thanks for the review !!

> 
> 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?

I'll mention that there are 2 busses.

> 
>> 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? :-)

Rephrased it for next iteration.

> 
>> +	  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?

Fixed in the next iteration.

> 
>> +#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?

Ok, fixed in the next iteration.

> 
> ...
> 
>> +	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).

The driver i2c-xlp9xx has a similar message [1] and it uses a dev_warn().
So I don't know.
If you think dev_info() is more relevant in this case, I'll change it.
Supernit will be fixed in next iteration.

[1]
https://elixir.bootlin.com/linux/v6.11-rc6/source/drivers/i2c/busses/i2c-xlp9xx.c#L480

> 
>> +		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).

thanks for the rephrasing.

Thomas




[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