* [PATCH v2 0/2] i2c: Reduce use of i2c_of_match_device()
@ 2025-02-13 11:45 Andy Shevchenko
2025-02-13 11:45 ` [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data() Andy Shevchenko
2025-02-13 11:45 ` [PATCH v2 2/2] i2c: Unexport i2c_of_match_device() Andy Shevchenko
0 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2025-02-13 11:45 UTC (permalink / raw)
To: Andy Shevchenko, Sebastian Reichel, Bence Csókás,
Wolfram Sang, linux-i2c, linux-kernel, linux-pm
Cc: Samuel Holland, Sebastian Reichel
The i2c_of_match_device() was developed as internal API and was exported just
in case well before we get an idea of the generic helper for getting driver
data for the matched device. For all the times of i2c_of_match_device() being
exported there were _only_ three users, two of which had been already converted
to better API. For preventing the use of i2c_of_match_device(), make it private
to I²C subsystem.
This is assumed to go via I²C tree, but can be done differently taking into
account the immutable tag or branch for involved subsystems.
In v2:
- collected tags (Sebastian)
- removed one leftover in the first patch
Andy Shevchenko (2):
power: ip5xxx_power: Make use of i2c_get_match_data()
i2c: Unexport i2c_of_match_device()
drivers/i2c/i2c-core-of.c | 1 -
drivers/i2c/i2c-core.h | 9 +++++++++
drivers/power/supply/ip5xxx_power.c | 7 ++-----
include/linux/i2c.h | 11 -----------
4 files changed, 11 insertions(+), 17 deletions(-)
--
2.45.1.3035.g276e886db78b
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data()
2025-02-13 11:45 [PATCH v2 0/2] i2c: Reduce use of i2c_of_match_device() Andy Shevchenko
@ 2025-02-13 11:45 ` Andy Shevchenko
2025-02-13 12:09 ` Vladimir Zapolskiy
` (2 more replies)
2025-02-13 11:45 ` [PATCH v2 2/2] i2c: Unexport i2c_of_match_device() Andy Shevchenko
1 sibling, 3 replies; 8+ messages in thread
From: Andy Shevchenko @ 2025-02-13 11:45 UTC (permalink / raw)
To: Andy Shevchenko, Sebastian Reichel, Bence Csókás,
Wolfram Sang, linux-i2c, linux-kernel, linux-pm
Cc: Samuel Holland, Sebastian Reichel
Get matching data in one step by switching to use i2c_get_match_data().
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/power/supply/ip5xxx_power.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
index c448e0ac0dfa..a293b2765771 100644
--- a/drivers/power/supply/ip5xxx_power.c
+++ b/drivers/power/supply/ip5xxx_power.c
@@ -828,10 +828,9 @@ static void ip5xxx_setup_regs(struct device *dev, struct ip5xxx *ip5xxx,
static int ip5xxx_power_probe(struct i2c_client *client)
{
- const struct ip5xxx_regfield_config *fields = &ip51xx_fields;
+ const struct ip5xxx_regfield_config *fields;
struct power_supply_config psy_cfg = {};
struct device *dev = &client->dev;
- const struct of_device_id *of_id;
struct power_supply *psy;
struct ip5xxx *ip5xxx;
@@ -843,9 +842,7 @@ static int ip5xxx_power_probe(struct i2c_client *client)
if (IS_ERR(ip5xxx->regmap))
return PTR_ERR(ip5xxx->regmap);
- of_id = i2c_of_match_device(dev->driver->of_match_table, client);
- if (of_id)
- fields = (const struct ip5xxx_regfield_config *)of_id->data;
+ fields = i2c_get_match_data(client) ?: &ip51xx_fields;
ip5xxx_setup_regs(dev, ip5xxx, fields);
psy_cfg.of_node = dev->of_node;
--
2.45.1.3035.g276e886db78b
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] i2c: Unexport i2c_of_match_device()
2025-02-13 11:45 [PATCH v2 0/2] i2c: Reduce use of i2c_of_match_device() Andy Shevchenko
2025-02-13 11:45 ` [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data() Andy Shevchenko
@ 2025-02-13 11:45 ` Andy Shevchenko
2025-02-13 12:08 ` Vladimir Zapolskiy
2025-02-13 15:51 ` Wolfram Sang
1 sibling, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2025-02-13 11:45 UTC (permalink / raw)
To: Andy Shevchenko, Sebastian Reichel, Bence Csókás,
Wolfram Sang, linux-i2c, linux-kernel, linux-pm
Cc: Samuel Holland, Sebastian Reichel
i2c_of_match_device() is not used anymore outside of I²C framework,
unexport it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/i2c/i2c-core-of.c | 1 -
drivers/i2c/i2c-core.h | 9 +++++++++
include/linux/i2c.h | 11 -----------
3 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index a6c407d36800..02feee6c9ba9 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -157,7 +157,6 @@ const struct of_device_id
return i2c_of_match_device_sysfs(matches, client);
}
-EXPORT_SYMBOL_GPL(i2c_of_match_device);
#if IS_ENABLED(CONFIG_OF_DYNAMIC)
static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h
index 36587f38dff3..4797ba88331c 100644
--- a/drivers/i2c/i2c-core.h
+++ b/drivers/i2c/i2c-core.h
@@ -84,8 +84,17 @@ static inline void i2c_acpi_remove_space_handler(struct i2c_adapter *adapter) {
#ifdef CONFIG_OF
void of_i2c_register_devices(struct i2c_adapter *adap);
+const struct of_device_id *i2c_of_match_device(const struct of_device_id *matches,
+ struct i2c_client *client);
+
#else
static inline void of_i2c_register_devices(struct i2c_adapter *adap) { }
+static inline
+const struct of_device_id *i2c_of_match_device(const struct of_device_id *matches,
+ struct i2c_client *client)
+{
+ return NULL;
+}
#endif
extern struct notifier_block i2c_of_notifier;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 2b2af24d2a43..997e80649889 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -1029,10 +1029,6 @@ static inline struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node
return i2c_get_adapter_by_fwnode(of_fwnode_handle(node));
}
-const struct of_device_id
-*i2c_of_match_device(const struct of_device_id *matches,
- struct i2c_client *client);
-
int of_i2c_get_board_info(struct device *dev, struct device_node *node,
struct i2c_board_info *info);
@@ -1053,13 +1049,6 @@ static inline struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node
return NULL;
}
-static inline const struct of_device_id
-*i2c_of_match_device(const struct of_device_id *matches,
- struct i2c_client *client)
-{
- return NULL;
-}
-
static inline int of_i2c_get_board_info(struct device *dev,
struct device_node *node,
struct i2c_board_info *info)
--
2.45.1.3035.g276e886db78b
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] i2c: Unexport i2c_of_match_device()
2025-02-13 11:45 ` [PATCH v2 2/2] i2c: Unexport i2c_of_match_device() Andy Shevchenko
@ 2025-02-13 12:08 ` Vladimir Zapolskiy
2025-02-13 15:51 ` Wolfram Sang
1 sibling, 0 replies; 8+ messages in thread
From: Vladimir Zapolskiy @ 2025-02-13 12:08 UTC (permalink / raw)
To: Andy Shevchenko, Sebastian Reichel, Bence Csókás,
Wolfram Sang, linux-i2c, linux-kernel, linux-pm
Cc: Samuel Holland, Sebastian Reichel
On 2/13/25 13:45, Andy Shevchenko wrote:
> i2c_of_match_device() is not used anymore outside of I²C framework,
> unexport it.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data()
2025-02-13 11:45 ` [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data() Andy Shevchenko
@ 2025-02-13 12:09 ` Vladimir Zapolskiy
2025-02-13 12:24 ` Vladimir Zapolskiy
2025-02-13 15:51 ` Wolfram Sang
2 siblings, 0 replies; 8+ messages in thread
From: Vladimir Zapolskiy @ 2025-02-13 12:09 UTC (permalink / raw)
To: Andy Shevchenko, Sebastian Reichel, Bence Csókás,
Wolfram Sang, linux-i2c, linux-kernel, linux-pm
Cc: Samuel Holland, Sebastian Reichel
On 2/13/25 13:45, Andy Shevchenko wrote:
> Get matching data in one step by switching to use i2c_get_match_data().
>
> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data()
2025-02-13 11:45 ` [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data() Andy Shevchenko
2025-02-13 12:09 ` Vladimir Zapolskiy
@ 2025-02-13 12:24 ` Vladimir Zapolskiy
2025-02-13 15:51 ` Wolfram Sang
2 siblings, 0 replies; 8+ messages in thread
From: Vladimir Zapolskiy @ 2025-02-13 12:24 UTC (permalink / raw)
To: Andy Shevchenko, Sebastian Reichel, Bence Csókás,
Wolfram Sang, linux-i2c, linux-kernel, linux-pm
Cc: Samuel Holland, Sebastian Reichel
On 2/13/25 13:45, Andy Shevchenko wrote:
> Get matching data in one step by switching to use i2c_get_match_data().
>
> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Now sending the tag from my different email address for the sake of consistency.
Thank you for the change.
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data()
2025-02-13 11:45 ` [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data() Andy Shevchenko
2025-02-13 12:09 ` Vladimir Zapolskiy
2025-02-13 12:24 ` Vladimir Zapolskiy
@ 2025-02-13 15:51 ` Wolfram Sang
2 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2025-02-13 15:51 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sebastian Reichel, Bence Csókás, linux-i2c,
linux-kernel, linux-pm, Samuel Holland, Sebastian Reichel
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
On Thu, Feb 13, 2025 at 01:45:04PM +0200, Andy Shevchenko wrote:
> Get matching data in one step by switching to use i2c_get_match_data().
>
> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
> Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] i2c: Unexport i2c_of_match_device()
2025-02-13 11:45 ` [PATCH v2 2/2] i2c: Unexport i2c_of_match_device() Andy Shevchenko
2025-02-13 12:08 ` Vladimir Zapolskiy
@ 2025-02-13 15:51 ` Wolfram Sang
1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2025-02-13 15:51 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sebastian Reichel, Bence Csókás, linux-i2c,
linux-kernel, linux-pm, Samuel Holland, Sebastian Reichel
[-- Attachment #1: Type: text/plain, Size: 329 bytes --]
On Thu, Feb 13, 2025 at 01:45:05PM +0200, Andy Shevchenko wrote:
> i2c_of_match_device() is not used anymore outside of I²C framework,
> unexport it.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-02-13 15:51 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 11:45 [PATCH v2 0/2] i2c: Reduce use of i2c_of_match_device() Andy Shevchenko
2025-02-13 11:45 ` [PATCH v2 1/2] power: ip5xxx_power: Make use of i2c_get_match_data() Andy Shevchenko
2025-02-13 12:09 ` Vladimir Zapolskiy
2025-02-13 12:24 ` Vladimir Zapolskiy
2025-02-13 15:51 ` Wolfram Sang
2025-02-13 11:45 ` [PATCH v2 2/2] i2c: Unexport i2c_of_match_device() Andy Shevchenko
2025-02-13 12:08 ` Vladimir Zapolskiy
2025-02-13 15:51 ` Wolfram Sang
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).