From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Wolfram Sang <wsa@kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [PATCH 1/2] i2c: consider devices with of_match_table during i2c device probing
Date: Wed, 26 Aug 2020 13:29:37 +0900 [thread overview]
Message-ID: <20200826042938.3259-1-sergey.senozhatsky@gmail.com> (raw)
Unlike acpi_match_device(), acpi_driver_match_device() does
consider devices that provide of_match_table and performs
of_compatible() matching for such devices. The key point here is
that ACPI of_compatible() matching - acpi_of_match_device() - is
part of ACPI and does not depend on CONFIG_OF.
Consider the following case:
o !CONFIG_OF system
o probing of i2c device that provides .of_match_table, but no .id_table
i2c_device_probe()
...
if (!driver->id_table &&
!i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
!i2c_of_match_device(dev->driver->of_match_table, client)) {
status = -ENODEV;
goto put_sync_adapter;
}
i2c_of_match_device() depends on CONFIG_OF and, thus, is always false.
i2c_acpi_match_device() does ACPI match only, no of_comtatible() matching
takes place, even though the device provides .of_match_table and ACPI,
technically, is capable of matching such device. The result is -ENODEV.
Probing will succeed, however, if we'd use .of_match_table aware ACPI
matching.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/i2c/i2c-core-acpi.c | 10 ++++------
drivers/i2c/i2c-core-base.c | 2 +-
drivers/i2c/i2c-core.h | 10 +++-------
3 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 2ade99b105b9..1dd152ae75e5 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -276,14 +276,12 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)
dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
}
-const struct acpi_device_id *
-i2c_acpi_match_device(const struct acpi_device_id *matches,
- struct i2c_client *client)
+bool i2c_acpi_match_device(struct device *dev, struct i2c_client *client)
{
- if (!(client && matches))
- return NULL;
+ if (!client)
+ return false;
- return acpi_match_device(matches, &client->dev);
+ return acpi_driver_match_device(&client->dev, dev->driver);
}
static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 34a9609f256d..35ec6335852b 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -480,7 +480,7 @@ static int i2c_device_probe(struct device *dev)
* or ACPI ID table is supplied for the probing device.
*/
if (!driver->id_table &&
- !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
+ !i2c_acpi_match_device(dev, client) &&
!i2c_of_match_device(dev->driver->of_match_table, client)) {
status = -ENODEV;
goto put_sync_adapter;
diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h
index 94ff1693b391..7ee6a6e3fb8d 100644
--- a/drivers/i2c/i2c-core.h
+++ b/drivers/i2c/i2c-core.h
@@ -59,19 +59,15 @@ static inline int __i2c_check_suspended(struct i2c_adapter *adap)
}
#ifdef CONFIG_ACPI
-const struct acpi_device_id *
-i2c_acpi_match_device(const struct acpi_device_id *matches,
- struct i2c_client *client);
+bool i2c_acpi_match_device(struct device *dev, struct i2c_client *client);
void i2c_acpi_register_devices(struct i2c_adapter *adap);
int i2c_acpi_get_irq(struct i2c_client *client);
#else /* CONFIG_ACPI */
static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { }
-static inline const struct acpi_device_id *
-i2c_acpi_match_device(const struct acpi_device_id *matches,
- struct i2c_client *client)
+bool i2c_acpi_match_device(struct device *dev, struct i2c_client *client)
{
- return NULL;
+ return false;
}
static inline int i2c_acpi_get_irq(struct i2c_client *client)
--
2.28.0
next reply other threads:[~2020-08-26 4:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 4:29 Sergey Senozhatsky [this message]
2020-08-26 4:29 ` [PATCH 2/2] i2c: do not export i2c_of_match_device() symbol Sergey Senozhatsky
2020-08-26 5:07 ` [PATCH 1/2] i2c: consider devices with of_match_table during i2c device probing Sergey Senozhatsky
2020-08-26 5:08 ` Wolfram Sang
2020-08-26 5:25 ` Sergey Senozhatsky
2020-08-26 9:53 ` Andy Shevchenko
2020-08-26 9:56 ` Andy Shevchenko
2020-08-26 10:24 ` Sergey Senozhatsky
2020-08-26 10:38 ` Sergey Senozhatsky
2020-08-26 10:54 ` Andy Shevchenko
2020-08-26 11:23 ` Wolfram Sang
2020-08-26 14:18 ` Sergey Senozhatsky
2020-08-26 14:34 ` Andy Shevchenko
2020-08-26 14:50 ` Sergey Senozhatsky
2020-08-26 10:09 ` Sergey Senozhatsky
2020-08-26 7:19 ` kernel test robot
2020-08-26 12:38 ` kernel test robot
2020-08-26 12:56 ` kernel test robot
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=20200826042938.3259-1-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=wsa@kernel.org \
/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).