[Skiboot] [PATCH v2 2/5] hw/psi-p9: Make interrupt name array global

Cédric Le Goater clg at kaod.org
Thu Sep 5 17:02:35 AEST 2019


On 05/09/2019 05:08, Oliver O'Halloran wrote:
> The array is currently a static constant inside psi_p9_irq_name() which
> returns a malloc()ed pointer due to the API required by the interrupt
> source ops interface. Make the name array a static global and move it
> further up in the file so we can use it in other functions.
> 
> Signed-off-by: Oliver O'Halloran <oohall at gmail.com>

one related comment below.

Reviewed-by: Cédric Le Goater <clg at kaod.org>

Thanks,

C.

> ---
>  hw/psi.c | 54 +++++++++++++++++++++++++++---------------------------
>  1 file changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/hw/psi.c b/hw/psi.c
> index a74c105ff0ec..99ec06ac488a 100644
> --- a/hw/psi.c
> +++ b/hw/psi.c
> @@ -509,6 +509,33 @@ static const struct irq_source_ops psi_p8_irq_ops = {
>  	.name = psi_p8_irq_name,
>  };
>  
> +static const char *p9_psi_int_names[P9_PSI_NUM_IRQS] = {
> +	"psi:fsp",
> +	"psi:occ",
> +	"psi:fsi",
> +	"psi:lpchc",
> +	"psi:local_err",
> +	"psi:global_err",
> +	"psi:external",
> +	"psi:lpc_serirq_mux0", /* Have a callback to get name ? */
> +	"psi:lpc_serirq_mux1", /* Have a callback to get name ? */
> +	"psi:lpc_serirq_mux2", /* Have a callback to get name ? */
> +	"psi:lpc_serirq_mux3", /* Have a callback to get name ? */
> +	"psi:i2c",
> +	"psi:dio",
> +	"psi:psu"
> +};
> +
> +static char *psi_p9_irq_name(struct irq_source *is, uint32_t isn)
> +{
> +	struct psi *psi = is->data;
> +	uint32_t idx = isn - psi->interrupt;
> +
> +	if (idx >= ARRAY_SIZE(p9_psi_int_names))
> +		return NULL;
> +	return strdup(p9_psi_int_names[idx]);

I haven't seen any of the interrupt sources allocating the name returned.  

I think we could remove the strdup from all name() handlers and the free() 
from add_opal_interrupts() one day.


> +}
> +
>  static void psihb_p9_interrupt(struct irq_source *is, uint32_t isn)
>  {
>  	struct psi *psi = is->data;
> @@ -583,33 +610,6 @@ static uint64_t psi_p9_irq_attributes(struct irq_source *is __unused,
>  	return IRQ_ATTR_TARGET_OPAL | IRQ_ATTR_TYPE_LSI;
>  }
>  
> -static char *psi_p9_irq_name(struct irq_source *is, uint32_t isn)
> -{
> -	struct psi *psi = is->data;
> -	uint32_t idx = isn - psi->interrupt;
> -
> -	static const char *names[P9_PSI_NUM_IRQS] = {
> -		"psi:fsp",
> -		"psi:occ",
> -		"psi:fsi",
> -		"psi:lpchc",
> -		"psi:local_err",
> -		"psi:global_err",
> -		"psi:external",
> -		"psi:lpc_serirq_mux0", /* Have a callback to get name ? */
> -		"psi:lpc_serirq_mux1", /* Have a callback to get name ? */
> -		"psi:lpc_serirq_mux2", /* Have a callback to get name ? */
> -		"psi:lpc_serirq_mux3", /* Have a callback to get name ? */
> -		"psi:i2c",
> -		"psi:dio",
> -		"psi:psu"
> -	};
> -
> -	if (idx >= P9_PSI_NUM_IRQS)
> -		return NULL;
> -	return strdup(names[idx]);
> -}
> -
>  static const struct irq_source_ops psi_p9_irq_ops = {
>  	.interrupt = psihb_p9_interrupt,
>  	.attributes = psi_p9_irq_attributes,
> 



More information about the Skiboot mailing list