This series of patches updates i2c probes in clk to use the simple
probe variant (simple as in "single argument"), probe_new, following
one of two scenarios.
In the first scenario, the existing probe function
int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
(see struct i2c_driver in include/linux/i2c.h) doesn't use the id
argument, so it can be trivially converted to
int (*probe_new)(struct i2c_client *client);
and the i2c_driver declaration updated to use .probe_new instead of
.probe.
In the second scenario, the probe function does use the id argument.
In this case, the relevant part of the calling code,
/*
* When there are no more users of probe(),
* rename probe_new to probe.
*/
if (driver->probe_new)
status = driver->probe_new(client);
else if (driver->probe)
status = driver->probe(client,
i2c_match_id(driver->id_table, client));
else
status = -EINVAL;
(from drivers/i2c/i2c-core-base.c) is moved down into the probe
function, typically along the lines of
const struct i2c_device_id *id = i2c_match_id(ids, id);
where ids is the i2c_device_id table. The latter needs to be declared
before the probe function; as suggested by Wolfram Sang, the full
definition is moved above the probe function.
Changes since v1:
- the pair of patches have been split up into a single patch series
with one patch per modified file, and the commit titles adjusted
accordingly
- renesas-pcie has been added
Stephen Kitt (10):
clk: cdce706: use simple i2c probe function
clk: cdce925: use i2c_match_id and simple i2c probe
clk: cs2000-cp: use simple i2c probe function
clk: max9485: use simple i2c probe function
clk: si514: use simple i2c probe function
clk: si5341: use simple i2c probe function
clk: si5351: use i2c_match_id and simple i2c probe
clk: si544: use i2c_match_id and simple i2c probe
clk: si570: use i2c_match_id and simple i2c probe
clk: renesas-pcie: use simple i2c probe function
drivers/clk/clk-cdce706.c | 5 ++---
drivers/clk/clk-cdce925.c | 24 ++++++++++++------------
drivers/clk/clk-cs2000-cp.c | 5 ++---
drivers/clk/clk-max9485.c | 5 ++---
drivers/clk/clk-renesas-pcie.c | 4 ++--
drivers/clk/clk-si514.c | 5 ++---
drivers/clk/clk-si5341.c | 5 ++---
drivers/clk/clk-si5351.c | 24 ++++++++++++------------
drivers/clk/clk-si544.c | 22 +++++++++++-----------
drivers/clk/clk-si570.c | 24 ++++++++++++------------
10 files changed, 59 insertions(+), 64 deletions(-)
--
2.27.0
As part of the ongoing i2c transition to the simple probe
("probe_new"), this patch uses i2c_match_id to retrieve the
driver_data for the probed device. The id parameter is thus no longer
necessary and the simple probe can be used instead.
Signed-off-by: Stephen Kitt <[email protected]>
---
drivers/clk/clk-cdce925.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/clk/clk-cdce925.c b/drivers/clk/clk-cdce925.c
index 308b353815e1..ef9a2d44e40c 100644
--- a/drivers/clk/clk-cdce925.c
+++ b/drivers/clk/clk-cdce925.c
@@ -634,11 +634,20 @@ static struct regmap_bus regmap_cdce925_bus = {
.read = cdce925_regmap_i2c_read,
};
-static int cdce925_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static const struct i2c_device_id cdce925_id[] = {
+ { "cdce913", CDCE913 },
+ { "cdce925", CDCE925 },
+ { "cdce937", CDCE937 },
+ { "cdce949", CDCE949 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, cdce925_id);
+
+static int cdce925_probe(struct i2c_client *client)
{
struct clk_cdce925_chip *data;
struct device_node *node = client->dev.of_node;
+ const struct i2c_device_id *id = i2c_match_id(cdce925_id, client);
const char *parent_name;
const char *pll_clk_name[MAX_NUMBER_OF_PLLS] = {NULL,};
struct clk_init_data init;
@@ -814,15 +823,6 @@ static int cdce925_probe(struct i2c_client *client,
return err;
}
-static const struct i2c_device_id cdce925_id[] = {
- { "cdce913", CDCE913 },
- { "cdce925", CDCE925 },
- { "cdce937", CDCE937 },
- { "cdce949", CDCE949 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, cdce925_id);
-
static const struct of_device_id clk_cdce925_of_match[] = {
{ .compatible = "ti,cdce913" },
{ .compatible = "ti,cdce925" },
@@ -837,7 +837,7 @@ static struct i2c_driver cdce925_driver = {
.name = "cdce925",
.of_match_table = of_match_ptr(clk_cdce925_of_match),
},
- .probe = cdce925_probe,
+ .probe_new = cdce925_probe,
.id_table = cdce925_id,
};
module_i2c_driver(cdce925_driver);
--
2.27.0
The i2c probe function here doesn't use the id information provided in
its second argument, so the single-parameter i2c probe function
("probe_new") can be used instead.
This avoids scanning the identifier tables during probes.
Signed-off-by: Stephen Kitt <[email protected]>
---
drivers/clk/clk-si514.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/clk-si514.c b/drivers/clk/clk-si514.c
index 364b62b9928d..4481c4303534 100644
--- a/drivers/clk/clk-si514.c
+++ b/drivers/clk/clk-si514.c
@@ -327,8 +327,7 @@ static const struct regmap_config si514_regmap_config = {
.volatile_reg = si514_regmap_is_volatile,
};
-static int si514_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static int si514_probe(struct i2c_client *client)
{
struct clk_si514 *data;
struct clk_init_data init;
@@ -394,7 +393,7 @@ static struct i2c_driver si514_driver = {
.name = "si514",
.of_match_table = clk_si514_of_match,
},
- .probe = si514_probe,
+ .probe_new = si514_probe,
.remove = si514_remove,
.id_table = si514_id,
};
--
2.27.0
On Thu, Apr 07, 2022 at 05:18:26PM +0200, Stephen Kitt wrote:
> The i2c probe function here doesn't use the id information provided in
> its second argument, so the single-parameter i2c probe function
> ("probe_new") can be used instead.
>
> This avoids scanning the identifier tables during probes.
>
> Signed-off-by: Stephen Kitt <[email protected]>
Reviewed-by: Wolfram Sang <[email protected]>
On Thu, Apr 07, 2022 at 05:18:23PM +0200, Stephen Kitt wrote:
> As part of the ongoing i2c transition to the simple probe
> ("probe_new"), this patch uses i2c_match_id to retrieve the
> driver_data for the probed device. The id parameter is thus no longer
> necessary and the simple probe can be used instead.
>
> Signed-off-by: Stephen Kitt <[email protected]>
Reviewed-by: Wolfram Sang <[email protected]>
Quoting Stephen Kitt (2022-04-07 08:18:26)
> The i2c probe function here doesn't use the id information provided in
> its second argument, so the single-parameter i2c probe function
> ("probe_new") can be used instead.
>
> This avoids scanning the identifier tables during probes.
>
> Signed-off-by: Stephen Kitt <[email protected]>
> ---
Applied to clk-next
Quoting Stephen Kitt (2022-04-07 08:18:23)
> As part of the ongoing i2c transition to the simple probe
> ("probe_new"), this patch uses i2c_match_id to retrieve the
> driver_data for the probed device. The id parameter is thus no longer
> necessary and the simple probe can be used instead.
>
> Signed-off-by: Stephen Kitt <[email protected]>
> ---
Applied to clk-next