diff mbox

[v3,1/2] acpi: Fix proper return code for function acpi_gsi_to_irq

Message ID 20160112183228.GK30558@pd.tnic (mailing list archive)
State New, archived
Headers show

Commit Message

Borislav Petkov Jan. 12, 2016, 6:32 p.m. UTC
On Tue, Jan 12, 2016 at 10:26:04AM -0800, Tuan Phan wrote:
> So are you good with it?

How about this instead:

---

Comments

Tuan Phan Jan. 12, 2016, 6:46 p.m. UTC | #1
On Tue, Jan 12, 2016 at 10:32 AM, Borislav Petkov <bp@alien8.de> wrote:
> On Tue, Jan 12, 2016 at 10:26:04AM -0800, Tuan Phan wrote:
>> So are you good with it?
>
> How about this instead:
>
> ---
> diff --git a/drivers/acpi/gsi.c b/drivers/acpi/gsi.c
> index fa4585a6914e..e42f6b7eac13 100644
> --- a/drivers/acpi/gsi.c
> +++ b/drivers/acpi/gsi.c
> @@ -46,17 +46,22 @@ static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
>   * Returns: linux IRQ number on success (>0)
>   *          -EINVAL on failure
>   */
> -int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
> +int acpi_gsi_to_irq(u32 gsi)
>  {
> +       unsigned int irq;
> +
>         struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id,
>                                                         DOMAIN_BUS_ANY);
>
> -       *irq = irq_find_mapping(d, gsi);
> +       irq = irq_find_mapping(d, gsi);
>         /*
>          * *irq == 0 means no mapping, that should
>          * be reported as a failure
>          */
> -       return (*irq > 0) ? *irq : -EINVAL;
> +       if (irq > 0)
> +               return irq;
> +       else
> +               return -EINVAL;
>  }
>  EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);

Well, it basically the same as old code except the change of API
interface. And it requires some changes in ACPI core and X86/I64 arch
code. Do we really want to go with this solution instead of just
return 0 on success and -EINVAL on failure?
Borislav Petkov Jan. 12, 2016, 7:21 p.m. UTC | #2
On Tue, Jan 12, 2016 at 10:46:15AM -0800, Tuan Phan wrote:
> Well, it basically the same as old code except the change of API
> interface. And it requires some changes in ACPI core and X86/I64 arch
> code.

That's why I said:

"Patch 1 could be improved. It is Rafael's call in the end of the day."
diff mbox

Patch

diff --git a/drivers/acpi/gsi.c b/drivers/acpi/gsi.c
index fa4585a6914e..e42f6b7eac13 100644
--- a/drivers/acpi/gsi.c
+++ b/drivers/acpi/gsi.c
@@ -46,17 +46,22 @@  static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
  * Returns: linux IRQ number on success (>0)
  *          -EINVAL on failure
  */
-int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
+int acpi_gsi_to_irq(u32 gsi)
 {
+	unsigned int irq;
+
 	struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id,
 							DOMAIN_BUS_ANY);
 
-	*irq = irq_find_mapping(d, gsi);
+	irq = irq_find_mapping(d, gsi);
 	/*
 	 * *irq == 0 means no mapping, that should
 	 * be reported as a failure
 	 */
-	return (*irq > 0) ? *irq : -EINVAL;
+	if (irq > 0)
+		return irq;
+	else
+		return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);