linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mark Gross <mgross@linux.intel.com>, Wolfram Sang <wsa@the-dreams.de>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Andy Shevchenko <andy@infradead.org>,
	platform-driver-x86@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-acpi@vger.kernel.org
Subject: [RFC 4/4] platform/x86: i2c-multi-instantiate: Add IRQ_RESOURCE_GPIO_OPTIONAL IRQ type
Date: Thu,  5 Nov 2020 09:00:14 +0100	[thread overview]
Message-ID: <20201105080014.45410-5-hdegoede@redhat.com> (raw)
In-Reply-To: <20201105080014.45410-1-hdegoede@redhat.com>

Most I2C-drivers treat IRQs as optional and in some cases ACPI
devices managed by i2c-multi-instantiate.c may have a GpioInt resource
specified on some systems, while it is not there on others.

Add a new IRQ_RESOURCE_GPIO_OPTIONAL IRQ type, which still tries to get
a GpioInt IRQ, but does not consider it a fatal error when this fails.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index cbccfcbed44c..55c6d6e8d576 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -15,10 +15,11 @@
 #include <linux/platform_device.h>
 #include <linux/types.h>
 
-#define IRQ_RESOURCE_TYPE	GENMASK(1, 0)
-#define IRQ_RESOURCE_NONE	0
-#define IRQ_RESOURCE_GPIO	1
-#define IRQ_RESOURCE_APIC	2
+#define IRQ_RESOURCE_TYPE		GENMASK(1, 0)
+#define IRQ_RESOURCE_NONE		0
+#define IRQ_RESOURCE_GPIO		1
+#define IRQ_RESOURCE_GPIO_OPTIONAL	2
+#define IRQ_RESOURCE_APIC		3
 
 struct i2c_inst_data {
 	const char *type;
@@ -64,6 +65,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 	struct i2c_board_info board_info = {};
 	struct device *dev = &pdev->dev;
 	struct acpi_device *adev;
+	bool irq_optional;
 	char name[32];
 	int i, ret;
 
@@ -94,10 +96,14 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 			 inst_data[i].type, i);
 		board_info.dev_name = name;
 		board_info.fwnode = dev->fwnode;
+		irq_optional = false;
 		switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {
+		case IRQ_RESOURCE_GPIO_OPTIONAL:
+			irq_optional = true;
+			fallthrough;
 		case IRQ_RESOURCE_GPIO:
 			ret = acpi_dev_gpio_irq_get(adev, inst_data[i].irq_idx);
-			if (ret < 0) {
+			if (ret < 0 && (!irq_optional || ret != -ENOENT)) {
 				dev_err(dev, "Error requesting irq at index %d: %d\n",
 					inst_data[i].irq_idx, ret);
 				goto error;
-- 
2.28.0


  parent reply	other threads:[~2020-11-05  8:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05  8:00 [RFC 0/4] platform/x86: i2c-multi-instantiate: Pass ACPI fwnode to instantiated i2c-clients Hans de Goede
2020-11-05  8:00 ` [RFC 1/4] i2c: core: Allow i2c_board_info to specify that the core should not try to find an IRQ Hans de Goede
2020-11-05  8:00 ` [RFC 2/4] platform/x86: i2c-multi-instantiate: Set i2c_board_info.irq to -ENOENT when no IRQ is specified Hans de Goede
2020-11-05  8:00 ` [RFC 3/4] platform/x86: i2c-multi-instantiate: Pass ACPI fwnode to instantiated I2C-clients Hans de Goede
2020-11-05 10:31   ` Andy Shevchenko
2020-11-05  8:00 ` Hans de Goede [this message]
2020-11-05 10:36   ` [RFC 4/4] platform/x86: i2c-multi-instantiate: Add IRQ_RESOURCE_GPIO_OPTIONAL IRQ type Andy Shevchenko
2020-11-05 10:38 ` [RFC 0/4] platform/x86: i2c-multi-instantiate: Pass ACPI fwnode to instantiated i2c-clients Andy Shevchenko
2020-11-09 11:33   ` Hans de Goede
2020-11-10 10:10     ` Andy Shevchenko
2020-11-10 11:14       ` Hans de Goede
2020-11-10 14:47         ` Andy Shevchenko
2020-11-24 10:35           ` Hans de Goede
2020-11-24 11:35             ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201105080014.45410-5-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@infradead.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).