diff mbox

[v4,1/3] acpi: Rename acpi_gsi_get_irq_type to acpi_get_irq_type and export symbol

Message ID 1449527952-8399-2-git-send-email-christophe-h.ricard@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christophe Ricard Dec. 7, 2015, 10:39 p.m. UTC
acpi_gsi_get_irq_type could be use out of gsi purpose.

Rename and make it available as a utility function.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
 drivers/acpi/gsi.c   | 21 +--------------------
 drivers/acpi/utils.c | 21 +++++++++++++++++++++
 include/linux/acpi.h |  2 ++
 3 files changed, 24 insertions(+), 20 deletions(-)

Comments

Mika Westerberg Dec. 8, 2015, 11:28 a.m. UTC | #1
On Mon, Dec 07, 2015 at 11:39:10PM +0100, Christophe Ricard wrote:
> acpi_gsi_get_irq_type could be use out of gsi purpose.
> 
> Rename and make it available as a utility function.
> 
> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>

There is already a function acpi_dev_irq_flags() converts ACPI flags to
Linux resource IRQ flags. Any reason you are not using that?
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christophe Ricard Dec. 8, 2015, 9:57 p.m. UTC | #2
Hi Mika,

gpio irq type are usually denoted using IRQ_TYPE_xxx.
Lukily acpi_dev_irq_flags would work for  because IORESOURCE_IRQ and 
IRQ_TYPE numbers match.
In include/linux/ioport.h, IORESOURCE_IRQ looks to be more related with 
PnP stuff:
"PnP IRQ specific bits (IORESOURCE_BITS)"

I believe changes done in this patch take benefit of another existing 
function used in acpi gsi context that is doing the
job as expected.

Do you still believe acpi_dev_irq_flags is more appropriate ?

Best Regards
Christophe

On 08/12/2015 12:28, Mika Westerberg wrote:
> On Mon, Dec 07, 2015 at 11:39:10PM +0100, Christophe Ricard wrote:
>> acpi_gsi_get_irq_type could be use out of gsi purpose.
>>
>> Rename and make it available as a utility function.
>>
>> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
> There is already a function acpi_dev_irq_flags() converts ACPI flags to
> Linux resource IRQ flags. Any reason you are not using that?

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mika Westerberg Dec. 9, 2015, 1:36 p.m. UTC | #3
On Tue, Dec 08, 2015 at 10:57:19PM +0100, Christophe Ricard wrote:
> I believe changes done in this patch take benefit of another existing
> function used in acpi gsi context that is doing the
> job as expected.
> 
> Do you still believe acpi_dev_irq_flags is more appropriate ?

I don't have strong feelings about that. I just wanted to point out
there already exists such function.

However, if you do use acpi_gsi_get_irq_type() I think it should be
placed to the same file as acpi_dev_irq_flags().
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko Dec. 9, 2015, 2:19 p.m. UTC | #4
On Wed, Dec 9, 2015 at 3:36 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> On Tue, Dec 08, 2015 at 10:57:19PM +0100, Christophe Ricard wrote:
>> I believe changes done in this patch take benefit of another existing
>> function used in acpi gsi context that is doing the
>> job as expected.
>>
>> Do you still believe acpi_dev_irq_flags is more appropriate ?
>
> I don't have strong feelings about that. I just wanted to point out
> there already exists such function.
>
> However, if you do use acpi_gsi_get_irq_type() I think it should be
> placed to the same file as acpi_dev_irq_flags().

And perhaps renamed accordingly

acpi_dev_get_irq_type() I suppose.
diff mbox

Patch

diff --git a/drivers/acpi/gsi.c b/drivers/acpi/gsi.c
index fa4585a..2828351 100644
--- a/drivers/acpi/gsi.c
+++ b/drivers/acpi/gsi.c
@@ -17,25 +17,6 @@  enum acpi_irq_model_id acpi_irq_model;
 
 static struct fwnode_handle *acpi_gsi_domain_id;
 
-static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
-{
-	switch (polarity) {
-	case ACPI_ACTIVE_LOW:
-		return trigger == ACPI_EDGE_SENSITIVE ?
-		       IRQ_TYPE_EDGE_FALLING :
-		       IRQ_TYPE_LEVEL_LOW;
-	case ACPI_ACTIVE_HIGH:
-		return trigger == ACPI_EDGE_SENSITIVE ?
-		       IRQ_TYPE_EDGE_RISING :
-		       IRQ_TYPE_LEVEL_HIGH;
-	case ACPI_ACTIVE_BOTH:
-		if (trigger == ACPI_EDGE_SENSITIVE)
-			return IRQ_TYPE_EDGE_BOTH;
-	default:
-		return IRQ_TYPE_NONE;
-	}
-}
-
 /**
  * acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI
  * @gsi: GSI IRQ number to map
@@ -82,7 +63,7 @@  int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,
 
 	fwspec.fwnode = acpi_gsi_domain_id;
 	fwspec.param[0] = gsi;
-	fwspec.param[1] = acpi_gsi_get_irq_type(trigger, polarity);
+	fwspec.param[1] = acpi_get_irq_type(trigger, polarity);
 	fwspec.param_count = 2;
 
 	return irq_create_fwspec_mapping(&fwspec);
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 475c907..715b24b 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -33,6 +33,27 @@ 
 #define _COMPONENT		ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME("utils");
 
+unsigned int acpi_get_irq_type(int trigger, int polarity)
+{
+	switch (polarity) {
+	case ACPI_ACTIVE_LOW:
+		return trigger == ACPI_EDGE_SENSITIVE ?
+		       IRQ_TYPE_EDGE_FALLING :
+		       IRQ_TYPE_LEVEL_LOW;
+	case ACPI_ACTIVE_HIGH:
+		return trigger == ACPI_EDGE_SENSITIVE ?
+		       IRQ_TYPE_EDGE_RISING :
+		       IRQ_TYPE_LEVEL_HIGH;
+	case ACPI_ACTIVE_BOTH:
+		if (trigger == ACPI_EDGE_SENSITIVE)
+			return IRQ_TYPE_EDGE_BOTH;
+	default:
+		return IRQ_TYPE_NONE;
+	}
+}
+EXPORT_SYMBOL_GPL(acpi_get_irq_type);
+
+
 /* --------------------------------------------------------------------------
                             Object Evaluation Helpers
    -------------------------------------------------------------------------- */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index d863e12..b0c5a11 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -204,6 +204,8 @@  int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
 void acpi_set_irq_model(enum acpi_irq_model_id model,
 			struct fwnode_handle *fwnode);
 
+unsigned int acpi_get_irq_type(int trigger, int polarity);
+
 #ifdef CONFIG_X86_IO_APIC
 extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
 #else