[PATCH v1 04/13] hw/arm/aspeed: Make create_pca9554() available for use by other Aspeed machines

Jamin Lin via posted 13 patches 3 weeks, 1 day ago
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>
[PATCH v1 04/13] hw/arm/aspeed: Make create_pca9554() available for use by other Aspeed machines
Posted by Jamin Lin via 3 weeks, 1 day ago
The function create_pca9554() is now made globally accessible so that
it can be reused by different Aspeed machine source files.

Originally, this helper was declared static inside aspeed.c,
restricting its visibility. As future Aspeed machine implementations
will also require PCA9554 I²C device setup, the function has been
exported by removing the static keyword and adding its prototype
to aspeed.h.

This change promotes better code reuse and consistency across
machine initialization code.

No functional changes.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 include/hw/arm/aspeed.h | 1 +
 hw/arm/aspeed.c         | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
index d4d63996a6..fbe684d505 100644
--- a/include/hw/arm/aspeed.h
+++ b/include/hw/arm/aspeed.h
@@ -61,5 +61,6 @@ struct AspeedMachineClass {
 
 void aspeed_machine_class_init_cpus_defaults(MachineClass *mc);
 void create_pca9552(AspeedSoCState *soc, int bus_id, int addr);
+I2CSlave *create_pca9554(AspeedSoCState *soc, int bus_id, int addr);
 
 #endif
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 2695f0c11b..8a22696da9 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -542,7 +542,7 @@ void create_pca9552(AspeedSoCState *soc, int bus_id, int addr)
                             TYPE_PCA9552, addr);
 }
 
-static I2CSlave *create_pca9554(AspeedSoCState *soc, int bus_id, int addr)
+I2CSlave *create_pca9554(AspeedSoCState *soc, int bus_id, int addr)
 {
     return i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, bus_id),
                             TYPE_PCA9554, addr);
-- 
2.43.0


Re: [SPAM] [PATCH v1 04/13] hw/arm/aspeed: Make create_pca9554() available for use by other Aspeed machines
Posted by Cédric Le Goater 2 weeks, 2 days ago
On 10/23/25 12:01, Jamin Lin wrote:
> The function create_pca9554() is now made globally accessible so that
> it can be reused by different Aspeed machine source files.
> 
> Originally, this helper was declared static inside aspeed.c,
> restricting its visibility. As future Aspeed machine implementations
> will also require PCA9554 I²C device setup, the function has been
> exported by removing the static keyword and adding its prototype
> to aspeed.h.
> 
> This change promotes better code reuse and consistency across
> machine initialization code.
> 
> No functional changes.
> 
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> ---
>   include/hw/arm/aspeed.h | 1 +
>   hw/arm/aspeed.c         | 2 +-
>   2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h
> index d4d63996a6..fbe684d505 100644
> --- a/include/hw/arm/aspeed.h
> +++ b/include/hw/arm/aspeed.h
> @@ -61,5 +61,6 @@ struct AspeedMachineClass {
>   
>   void aspeed_machine_class_init_cpus_defaults(MachineClass *mc);
>   void create_pca9552(AspeedSoCState *soc, int bus_id, int addr);
> +I2CSlave *create_pca9554(AspeedSoCState *soc, int bus_id, int addr);

Please add an 'aspeed_' prefix.


Thanks,

C.


>   
>   #endif
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index 2695f0c11b..8a22696da9 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -542,7 +542,7 @@ void create_pca9552(AspeedSoCState *soc, int bus_id, int addr)
>                               TYPE_PCA9552, addr);
>   }
>   
> -static I2CSlave *create_pca9554(AspeedSoCState *soc, int bus_id, int addr)
> +I2CSlave *create_pca9554(AspeedSoCState *soc, int bus_id, int addr)
>   {
>       return i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, bus_id),
>                               TYPE_PCA9554, addr);