lkml.org 
[lkml]   [2014]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch V4 08/42] x86, ACPI, irq: enhance error handling in function acpi_register_gsi()
On Mon, 9 Jun 2014, Jiang Liu wrote:

> Function mp_register_gsi() may return invalid GSI if error happens,
> so enhance acpi_register_gsi() to handle possible error cases.

Can you please explain how that happens? I think I know it, but it'd
be nice if it would be documented.

> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> ---
> arch/x86/kernel/acpi/boot.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
> index 392360c607dc..f201579cd0df 100644
> --- a/arch/x86/kernel/acpi/boot.c
> +++ b/arch/x86/kernel/acpi/boot.c
> @@ -97,6 +97,8 @@ static u32 isa_irq_to_gsi[NR_IRQS_LEGACY] __read_mostly = {
> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
> };
>
> +#define ACPI_INVALID_GSI INT_MIN
> +
> static unsigned int gsi_to_irq(unsigned int gsi)
> {
> unsigned int irq = gsi + NR_IRQS_LEGACY;
> @@ -441,7 +443,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,
> polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
> ret = io_apic_set_pci_routing(dev, gsi_to_irq(gsi), &irq_attr);
> if (ret < 0)
> - gsi = INT_MIN;
> + gsi = ACPI_INVALID_GSI;
>
> return gsi;
> }
> @@ -666,13 +668,13 @@ int (*acpi_suspend_lowlevel)(void);
> */
> int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
> {
> - unsigned int irq;
> unsigned int plat_gsi = gsi;

The assignemend of gsi to plat_gsi is pointless

> plat_gsi = (*__acpi_register_gsi)(dev, gsi, trigger, polarity);

__acpi_register_gsi is a function pointer, so

plat_gsi = __acpi_register_gsi(dev, gsi, trigger, polarity);

is completely correct and way simpler to read.

> - irq = gsi_to_irq(plat_gsi);
> + if (plat_gsi != ACPI_INVALID_GSI)
> + return gsi_to_irq(plat_gsi);
>
> - return irq;
> + return -1;
> }
> EXPORT_SYMBOL_GPL(acpi_register_gsi);

No need to repost the whole series. Just reply with a new version to
this.

Thanks,

tglx


\
 
 \ /
  Last update: 2014-06-10 01:41    [W:0.440 / U:2.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site