Skip to content

Commit 55a9341

Browse files
cricard13rafaeljw
authored andcommitted
ACPI: Rename acpi_gsi_get_irq_type to acpi_dev_get_irq_type and export symbol
acpi_gsi_get_irq_type could be use out of GSI purpose. Rename and make it available as a resource function. Acked-by: Mika Westerberg <[email protected]> Signed-off-by: Christophe Ricard <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 74bf8ef commit 55a9341

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

drivers/acpi/gsi.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,6 @@ enum acpi_irq_model_id acpi_irq_model;
1717

1818
static struct fwnode_handle *acpi_gsi_domain_id;
1919

20-
static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
21-
{
22-
switch (polarity) {
23-
case ACPI_ACTIVE_LOW:
24-
return trigger == ACPI_EDGE_SENSITIVE ?
25-
IRQ_TYPE_EDGE_FALLING :
26-
IRQ_TYPE_LEVEL_LOW;
27-
case ACPI_ACTIVE_HIGH:
28-
return trigger == ACPI_EDGE_SENSITIVE ?
29-
IRQ_TYPE_EDGE_RISING :
30-
IRQ_TYPE_LEVEL_HIGH;
31-
case ACPI_ACTIVE_BOTH:
32-
if (trigger == ACPI_EDGE_SENSITIVE)
33-
return IRQ_TYPE_EDGE_BOTH;
34-
default:
35-
return IRQ_TYPE_NONE;
36-
}
37-
}
38-
3920
/**
4021
* acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI
4122
* @gsi: GSI IRQ number to map
@@ -82,7 +63,7 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,
8263

8364
fwspec.fwnode = acpi_gsi_domain_id;
8465
fwspec.param[0] = gsi;
85-
fwspec.param[1] = acpi_gsi_get_irq_type(trigger, polarity);
66+
fwspec.param[1] = acpi_dev_get_irq_type(trigger, polarity);
8667
fwspec.param_count = 2;
8768

8869
return irq_create_fwspec_mapping(&fwspec);

drivers/acpi/resource.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/export.h>
2424
#include <linux/ioport.h>
2525
#include <linux/slab.h>
26+
#include <linux/irq.h>
2627

2728
#ifdef CONFIG_X86
2829
#define valid_IRQ(i) (((i) != 0) && ((i) != 2))
@@ -336,6 +337,31 @@ unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable)
336337
}
337338
EXPORT_SYMBOL_GPL(acpi_dev_irq_flags);
338339

340+
/**
341+
* acpi_dev_get_irq_type - Determine irq type.
342+
* @triggering: Triggering type as provided by ACPI.
343+
* @polarity: Interrupt polarity as provided by ACPI.
344+
*/
345+
unsigned int acpi_dev_get_irq_type(int triggering, int polarity)
346+
{
347+
switch (polarity) {
348+
case ACPI_ACTIVE_LOW:
349+
return triggering == ACPI_EDGE_SENSITIVE ?
350+
IRQ_TYPE_EDGE_FALLING :
351+
IRQ_TYPE_LEVEL_LOW;
352+
case ACPI_ACTIVE_HIGH:
353+
return triggering == ACPI_EDGE_SENSITIVE ?
354+
IRQ_TYPE_EDGE_RISING :
355+
IRQ_TYPE_LEVEL_HIGH;
356+
case ACPI_ACTIVE_BOTH:
357+
if (triggering == ACPI_EDGE_SENSITIVE)
358+
return IRQ_TYPE_EDGE_BOTH;
359+
default:
360+
return IRQ_TYPE_NONE;
361+
}
362+
}
363+
EXPORT_SYMBOL_GPL(acpi_dev_get_irq_type);
364+
339365
static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi)
340366
{
341367
res->start = gsi;

include/linux/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,
318318
bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
319319
struct resource_win *win);
320320
unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
321+
unsigned int acpi_dev_get_irq_type(int triggering, int polarity);
321322
bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
322323
struct resource *res);
323324

0 commit comments

Comments
 (0)