Re: [PATCH v2 2/4] hw/i2c: Fix checkpatch line over 80 chars warnings

2024-04-18 Thread Cédric Le Goater

On 4/17/24 16:20, Philippe Mathieu-Daudé wrote:

On 17/4/24 08:24, Cédric Le Goater wrote:

Hello,

On 4/16/24 20:47, Philippe Mathieu-Daudé wrote:

We are going to modify these lines, fix their style
in order to avoid checkpatch.pl warnings:

   WARNING: line over 80 characters

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/hw/i2c/i2c.h    |  11 ++-
  include/hw/nvram/eeprom_at24c.h |   6 +-
  hw/arm/aspeed.c | 140 +++-
  hw/nvram/eeprom_at24c.c |   6 +-
  4 files changed, 98 insertions(+), 65 deletions(-)




-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), "dps310", 0x76);
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), "max31785", 
0x52);
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4), "tmp423", 0x4c);
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5), "tmp423", 0x4c);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+    "dps310", 0x76);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+    "max31785", 0x52);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4),
+    "tmp423", 0x4c);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5),
+    "tmp423", 0x4c);
  /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9), TYPE_TMP105,
- 0x4a);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9),
+    TYPE_TMP105, 0x4a);
  /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
   * good enough */
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11), "ds1338", 0x32);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11),
+    "ds1338", 0x32);


If the definitions were on a single line, they would be more
readable IMHO. So I would do the opposit change ...

An alternate solution could be to define an array of devices
at the machine class level, something like
   struct i2c_device [
   const char *type;
   uint8_t bus;
   uint8_t addr;
   } devices[] = { ... };


I agree this would be better, but this should be done separately
of this series. For now I propose not modifying hw/arm/aspeed.c
in this patch, and ignoring the checkpatch errors in the next
patch. What do you think?


sure, np.

Thanks,

C.




Re: [PATCH v2 2/4] hw/i2c: Fix checkpatch line over 80 chars warnings

2024-04-17 Thread Philippe Mathieu-Daudé

On 17/4/24 08:24, Cédric Le Goater wrote:

Hello,

On 4/16/24 20:47, Philippe Mathieu-Daudé wrote:

We are going to modify these lines, fix their style
in order to avoid checkpatch.pl warnings:

   WARNING: line over 80 characters

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/hw/i2c/i2c.h    |  11 ++-
  include/hw/nvram/eeprom_at24c.h |   6 +-
  hw/arm/aspeed.c | 140 +++-
  hw/nvram/eeprom_at24c.c |   6 +-
  4 files changed, 98 insertions(+), 65 deletions(-)



-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), 
"dps310", 0x76);
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), 
"max31785", 0x52);
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4), 
"tmp423", 0x4c);
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5), 
"tmp423", 0x4c);

+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+    "dps310", 0x76);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+    "max31785", 0x52);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4),
+    "tmp423", 0x4c);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5),
+    "tmp423", 0x4c);
  /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9), 
TYPE_TMP105,

- 0x4a);
+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9),
+    TYPE_TMP105, 0x4a);
  /* The witherspoon board expects Epson RX8900 I2C RTC but a 
ds1338 is

   * good enough */
-    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11), 
"ds1338", 0x32);

+    i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11),
+    "ds1338", 0x32);


If the definitions were on a single line, they would be more
readable IMHO. So I would do the opposit change ...

An alternate solution could be to define an array of devices
at the machine class level, something like
   struct i2c_device [
   const char *type;
   uint8_t bus;
   uint8_t addr;
   } devices[] = { ... };


I agree this would be better, but this should be done separately
of this series. For now I propose not modifying hw/arm/aspeed.c
in this patch, and ignoring the checkpatch errors in the next
patch. What do you think?



Re: [PATCH v2 2/4] hw/i2c: Fix checkpatch line over 80 chars warnings

2024-04-17 Thread Cédric Le Goater

Hello,

On 4/16/24 20:47, Philippe Mathieu-Daudé wrote:

We are going to modify these lines, fix their style
in order to avoid checkpatch.pl warnings:

   WARNING: line over 80 characters

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/hw/i2c/i2c.h|  11 ++-
  include/hw/nvram/eeprom_at24c.h |   6 +-
  hw/arm/aspeed.c | 140 +++-
  hw/nvram/eeprom_at24c.c |   6 +-
  4 files changed, 98 insertions(+), 65 deletions(-)

diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index c18a69e4b6..a1b3f4d179 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -31,7 +31,10 @@ struct I2CSlaveClass {
  /* Master to slave. Returns non-zero for a NAK, 0 for success. */
  int (*send)(I2CSlave *s, uint8_t data);
  
-/* Master to slave (asynchronous). Receiving slave must call i2c_ack(). */

+/*
+ * Master to slave (asynchronous).
+ * Receiving slave must call i2c_ack().
+ */
  void (*send_async)(I2CSlave *s, uint8_t data);
  
  /*

@@ -83,7 +86,8 @@ struct I2CPendingMaster {
  };
  
  typedef QLIST_HEAD(I2CNodeList, I2CNode) I2CNodeList;

-typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster) I2CPendingMasters;
+typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster)
+I2CPendingMasters;
  
  struct I2CBus {

  BusState qbus;
@@ -176,7 +180,8 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr);
   * Create the device state structure, initialize it, put it on the
   * specified @bus, and drop the reference to it (the device is realized).
   */
-I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr);
+I2CSlave *i2c_slave_create_simple(I2CBus *bus,
+  const char *name, uint8_t addr);
  
  /**

   * Realize and drop a reference an I2C slave device
diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
index acb9857b2a..9d29f0a69a 100644
--- a/include/hw/nvram/eeprom_at24c.h
+++ b/include/hw/nvram/eeprom_at24c.h
@@ -33,7 +33,9 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, 
uint32_t rom_size);
   * @bus, and drop the reference to it (the device is realized). Copies the 
data
   * from @init_rom to the beginning of the EEPROM memory buffer.
   */
-I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t 
rom_size,
-const uint8_t *init_rom, uint32_t 
init_rom_size);
+I2CSlave *at24c_eeprom_init_rom(I2CBus *bus,
+uint8_t address, uint32_t rom_size,
+const uint8_t *init_rom,
+uint32_t init_rom_size);
  
  #endif

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 93ca87fda2..8279ad748a 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -649,18 +649,23 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState 
*bmc)
  qdev_connect_gpio_out(dev, pca1_leds[i].gpio_id,
qdev_get_gpio_in(DEVICE(led), 0));
  }
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), "dps310", 0x76);
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), "max31785", 
0x52);
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4), "tmp423", 0x4c);
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5), "tmp423", 0x4c);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+"dps310", 0x76);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+"max31785", 0x52);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4),
+"tmp423", 0x4c);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5),
+"tmp423", 0x4c);
  
  /* The Witherspoon expects a TMP275 but a TMP105 is compatible */

-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9), TYPE_TMP105,
- 0x4a);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9),
+TYPE_TMP105, 0x4a);
  
  /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is

   * good enough */
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11), "ds1338", 0x32);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11),
+"ds1338", 0x32);


If the definitions were on a single line, they would be more
readable IMHO. So I would do the opposit change ...

An alternate solution could be to define an array of devices
at the machine class level, something like
  struct i2c_device [
  const char *type;
  uint8_t bus;
  uint8_t addr;
  } devices[] = { ... };


Thanks,

C.



  smbus_eeprom_init_one(aspeed_i2c_get_bus(>i2c, 11), 0x51,
eeprom_buf);
@@ -717,19 +722,20 @@ static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
  at24c_eeprom_init(aspeed_i2c_get_bus(>i2c, 1), 0x50, 32768);
  
  /* The fp5280g2 expects a 

[PATCH v2 2/4] hw/i2c: Fix checkpatch line over 80 chars warnings

2024-04-16 Thread Philippe Mathieu-Daudé
We are going to modify these lines, fix their style
in order to avoid checkpatch.pl warnings:

  WARNING: line over 80 characters

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/i2c/i2c.h|  11 ++-
 include/hw/nvram/eeprom_at24c.h |   6 +-
 hw/arm/aspeed.c | 140 +++-
 hw/nvram/eeprom_at24c.c |   6 +-
 4 files changed, 98 insertions(+), 65 deletions(-)

diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index c18a69e4b6..a1b3f4d179 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -31,7 +31,10 @@ struct I2CSlaveClass {
 /* Master to slave. Returns non-zero for a NAK, 0 for success. */
 int (*send)(I2CSlave *s, uint8_t data);
 
-/* Master to slave (asynchronous). Receiving slave must call i2c_ack(). */
+/*
+ * Master to slave (asynchronous).
+ * Receiving slave must call i2c_ack().
+ */
 void (*send_async)(I2CSlave *s, uint8_t data);
 
 /*
@@ -83,7 +86,8 @@ struct I2CPendingMaster {
 };
 
 typedef QLIST_HEAD(I2CNodeList, I2CNode) I2CNodeList;
-typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster) I2CPendingMasters;
+typedef QSIMPLEQ_HEAD(I2CPendingMasters, I2CPendingMaster)
+I2CPendingMasters;
 
 struct I2CBus {
 BusState qbus;
@@ -176,7 +180,8 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr);
  * Create the device state structure, initialize it, put it on the
  * specified @bus, and drop the reference to it (the device is realized).
  */
-I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr);
+I2CSlave *i2c_slave_create_simple(I2CBus *bus,
+  const char *name, uint8_t addr);
 
 /**
  * Realize and drop a reference an I2C slave device
diff --git a/include/hw/nvram/eeprom_at24c.h b/include/hw/nvram/eeprom_at24c.h
index acb9857b2a..9d29f0a69a 100644
--- a/include/hw/nvram/eeprom_at24c.h
+++ b/include/hw/nvram/eeprom_at24c.h
@@ -33,7 +33,9 @@ I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, 
uint32_t rom_size);
  * @bus, and drop the reference to it (the device is realized). Copies the data
  * from @init_rom to the beginning of the EEPROM memory buffer.
  */
-I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t 
rom_size,
-const uint8_t *init_rom, uint32_t 
init_rom_size);
+I2CSlave *at24c_eeprom_init_rom(I2CBus *bus,
+uint8_t address, uint32_t rom_size,
+const uint8_t *init_rom,
+uint32_t init_rom_size);
 
 #endif
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 93ca87fda2..8279ad748a 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -649,18 +649,23 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState 
*bmc)
 qdev_connect_gpio_out(dev, pca1_leds[i].gpio_id,
   qdev_get_gpio_in(DEVICE(led), 0));
 }
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), "dps310", 0x76);
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3), "max31785", 
0x52);
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4), "tmp423", 0x4c);
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5), "tmp423", 0x4c);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+"dps310", 0x76);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 3),
+"max31785", 0x52);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 4),
+"tmp423", 0x4c);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 5),
+"tmp423", 0x4c);
 
 /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9), TYPE_TMP105,
- 0x4a);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 9),
+TYPE_TMP105, 0x4a);
 
 /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
  * good enough */
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11), "ds1338", 0x32);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 11),
+"ds1338", 0x32);
 
 smbus_eeprom_init_one(aspeed_i2c_get_bus(>i2c, 11), 0x51,
   eeprom_buf);
@@ -717,19 +722,20 @@ static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)
 at24c_eeprom_init(aspeed_i2c_get_bus(>i2c, 1), 0x50, 32768);
 
 /* The fp5280g2 expects a TMP112 but a TMP105 is compatible */
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 2), TYPE_TMP105,
- 0x48);
-i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 2), TYPE_TMP105,
- 0x49);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 2),
+TYPE_TMP105, 0x48);
+i2c_slave_create_simple(aspeed_i2c_get_bus(>i2c, 2),
+TYPE_TMP105, 0x49);
 
 i2c_mux =