diff mbox series

[v3,05/24] media: i2c: switch to use of_graph_get_next_device_endpoint()

Message ID 87h6iu6qjs.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series of: property: add port base loop | expand

Commit Message

Kuninori Morimoto Jan. 31, 2024, 5:05 a.m. UTC
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/media/i2c/adv7343.c              | 2 +-
 drivers/media/i2c/adv748x/adv748x-core.c | 2 +-
 drivers/media/i2c/adv7604.c              | 2 +-
 drivers/media/i2c/isl7998x.c             | 2 +-
 drivers/media/i2c/max9286.c              | 2 +-
 drivers/media/i2c/mt9p031.c              | 2 +-
 drivers/media/i2c/mt9v032.c              | 2 +-
 drivers/media/i2c/ov2659.c               | 2 +-
 drivers/media/i2c/ov5645.c               | 2 +-
 drivers/media/i2c/ov5647.c               | 2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 drivers/media/i2c/s5k5baf.c              | 2 +-
 drivers/media/i2c/tc358743.c             | 2 +-
 drivers/media/i2c/tda1997x.c             | 2 +-
 drivers/media/i2c/tvp514x.c              | 2 +-
 drivers/media/i2c/tvp5150.c              | 4 ++--
 drivers/media/i2c/tvp7002.c              | 2 +-
 17 files changed, 18 insertions(+), 18 deletions(-)

Comments

Rob Herring (Arm) Feb. 2, 2024, 5:49 p.m. UTC | #1
On Wed, Jan 31, 2024 at 05:05:27AM +0000, Kuninori Morimoto wrote:
> of_graph_get_next_endpoint() is now renamed to
> of_graph_get_next_device_endpoint(). Switch to it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/media/i2c/adv7343.c              | 2 +-
>  drivers/media/i2c/adv748x/adv748x-core.c | 2 +-
>  drivers/media/i2c/adv7604.c              | 2 +-
>  drivers/media/i2c/isl7998x.c             | 2 +-
>  drivers/media/i2c/max9286.c              | 2 +-
>  drivers/media/i2c/mt9p031.c              | 2 +-
>  drivers/media/i2c/mt9v032.c              | 2 +-
>  drivers/media/i2c/ov2659.c               | 2 +-
>  drivers/media/i2c/ov5645.c               | 2 +-
>  drivers/media/i2c/ov5647.c               | 2 +-
>  drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
>  drivers/media/i2c/s5k5baf.c              | 2 +-
>  drivers/media/i2c/tc358743.c             | 2 +-
>  drivers/media/i2c/tda1997x.c             | 2 +-
>  drivers/media/i2c/tvp514x.c              | 2 +-
>  drivers/media/i2c/tvp5150.c              | 4 ++--
>  drivers/media/i2c/tvp7002.c              | 2 +-
>  17 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
> index ff21cd4744d3..7e4eb2f8bf0d 100644
> --- a/drivers/media/i2c/adv7343.c
> +++ b/drivers/media/i2c/adv7343.c
> @@ -403,7 +403,7 @@ adv7343_get_pdata(struct i2c_client *client)
>  	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
>  		return client->dev.platform_data;
>  
> -	np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
> +	np = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);

This is assuming there's just 1 port and 1 endpoint, but let's be 
specific as the bindings are (first endpoint on port 0):

of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);

Note we could ask for endpoint 0 here, but the bindings generally allow 
for more than 1.

I imagine most of the other cases here are the same.

>  	if (!np)
>  		return NULL;
>  
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> index 3eb6d5e8f082..4e9e4cef8954 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -657,7 +657,7 @@ static int adv748x_parse_dt(struct adv748x_state *state)
>  	bool in_found = false;
>  	int ret;
>  
> -	for_each_endpoint_of_node(state->dev->of_node, ep_np) {
> +	for_each_device_endpoint_of_node(state->dev->of_node, ep_np) {

I would skip the rename.

Rob
Kuninori Morimoto Feb. 4, 2024, 11:44 p.m. UTC | #2
Hi Rob

> This is assuming there's just 1 port and 1 endpoint, but let's be 
> specific as the bindings are (first endpoint on port 0):
> 
> of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
> 
> Note we could ask for endpoint 0 here, but the bindings generally allow 
> for more than 1.
> 
> I imagine most of the other cases here are the same.

I will do it on new patch-set

> > -	for_each_endpoint_of_node(state->dev->of_node, ep_np) {
> > +	for_each_device_endpoint_of_node(state->dev->of_node, ep_np) {
> 
> I would skip the rename.

It is needed to avoid confuse, because new function will add
another endpoint loop.

see
https://lore.kernel.org/r/20240131100701.754a95ee@booty


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto
Rob Herring (Arm) Feb. 5, 2024, 4:55 p.m. UTC | #3
On Sun, Feb 04, 2024 at 11:44:39PM +0000, Kuninori Morimoto wrote:
> 
> Hi Rob
> 
> > This is assuming there's just 1 port and 1 endpoint, but let's be 
> > specific as the bindings are (first endpoint on port 0):
> > 
> > of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
> > 
> > Note we could ask for endpoint 0 here, but the bindings generally allow 
> > for more than 1.
> > 
> > I imagine most of the other cases here are the same.
> 
> I will do it on new patch-set
> 
> > > -	for_each_endpoint_of_node(state->dev->of_node, ep_np) {
> > > +	for_each_device_endpoint_of_node(state->dev->of_node, ep_np) {
> > 
> > I would skip the rename.
> 
> It is needed to avoid confuse, because new function will add
> another endpoint loop.
> 
> see
> https://lore.kernel.org/r/20240131100701.754a95ee@booty

I've read the threads already and think you should skip the rename. Just 
put 'port' in the name of the new one. That and taking a port number 
param should be enough distinction.

Rob
Kuninori Morimoto Feb. 5, 2024, 11:34 p.m. UTC | #4
Hi Rob

> I've read the threads already and think you should skip the rename. Just 
> put 'port' in the name of the new one.

OK

> That and taking a port number param should be enough distinction.

I think we want to use "port" directly instead of "port number"
on new function.

Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto
Kuninori Morimoto Feb. 6, 2024, 2:06 a.m. UTC | #5
Hi Rob, again

> > This is assuming there's just 1 port and 1 endpoint, but let's be 
> > specific as the bindings are (first endpoint on port 0):
> > 
> > of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
> > 
> > Note we could ask for endpoint 0 here, but the bindings generally allow 
> > for more than 1.
> > 
> > I imagine most of the other cases here are the same.

I'm bit confused here.
You mentioned that -1 is wrong in previous mail.

	Most cases are in the form of of_graph_get_next_endpoint(dev, NULL) 
	which is equivalent to of_graph_get_endpoint_by_regs(dev, 0, 0). 
	Technically, -1 instead of 0 is equivalent, but I'd argue is sloppy and 
	wrong.

But you mentioned -1 here, So, I will use it on next patch-set.


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto
diff mbox series

Patch

diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index ff21cd4744d3..7e4eb2f8bf0d 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -403,7 +403,7 @@  adv7343_get_pdata(struct i2c_client *client)
 	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
 		return client->dev.platform_data;
 
-	np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+	np = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
 	if (!np)
 		return NULL;
 
diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 3eb6d5e8f082..4e9e4cef8954 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -657,7 +657,7 @@  static int adv748x_parse_dt(struct adv748x_state *state)
 	bool in_found = false;
 	int ret;
 
-	for_each_endpoint_of_node(state->dev->of_node, ep_np) {
+	for_each_device_endpoint_of_node(state->dev->of_node, ep_np) {
 		of_graph_parse_endpoint(ep_np, &ep);
 		adv_info(state, "Endpoint %pOF on port %d", ep.local_node,
 			 ep.port);
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index b202a85fbeaa..5b98a688b5de 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3205,7 +3205,7 @@  static int adv76xx_parse_dt(struct adv76xx_state *state)
 	np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
 
 	/* Parse the endpoint. */
-	endpoint = of_graph_get_next_endpoint(np, NULL);
+	endpoint = of_graph_get_next_device_endpoint(np, NULL);
 	if (!endpoint)
 		return -EINVAL;
 
diff --git a/drivers/media/i2c/isl7998x.c b/drivers/media/i2c/isl7998x.c
index 73460688c356..1ef26dd8290c 100644
--- a/drivers/media/i2c/isl7998x.c
+++ b/drivers/media/i2c/isl7998x.c
@@ -580,7 +580,7 @@  static int isl7998x_get_nr_inputs(struct device_node *of_node)
 	unsigned int inputs = 0;
 	unsigned int i;
 
-	if (of_graph_get_endpoint_count(of_node) > ISL7998X_NUM_PADS)
+	if (of_graph_get_device_endpoint_count(of_node) > ISL7998X_NUM_PADS)
 		return -EINVAL;
 
 	/*
diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index fc1cf196ef01..7d0725285a24 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -1452,7 +1452,7 @@  static int max9286_parse_dt(struct max9286_priv *priv)
 	of_node_put(i2c_mux);
 
 	/* Parse the endpoints */
-	for_each_endpoint_of_node(dev->of_node, node) {
+	for_each_device_endpoint_of_node(dev->of_node, node) {
 		struct max9286_source *source;
 		struct of_endpoint ep;
 
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 348f1e1098fb..4832968ca50b 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1080,7 +1080,7 @@  mt9p031_get_pdata(struct i2c_client *client)
 	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
 		return client->dev.platform_data;
 
-	np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+	np = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
 	if (!np)
 		return NULL;
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 1c6f6cea1204..236a671857a1 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1008,7 +1008,7 @@  mt9v032_get_pdata(struct i2c_client *client)
 	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
 		return client->dev.platform_data;
 
-	np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+	np = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
 	if (!np)
 		return NULL;
 
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 2c3dbe164eb6..a909edadc8d5 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1388,7 +1388,7 @@  ov2659_get_pdata(struct i2c_client *client)
 	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
 		return client->dev.platform_data;
 
-	endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+	endpoint = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
 	if (!endpoint)
 		return NULL;
 
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index a70db7e601a4..cb04b2a71492 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1053,7 +1053,7 @@  static int ov5645_probe(struct i2c_client *client)
 	ov5645->i2c_client = client;
 	ov5645->dev = dev;
 
-	endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+	endpoint = of_graph_get_next_device_endpoint(dev->of_node, NULL);
 	if (!endpoint) {
 		dev_err(dev, "endpoint node not found\n");
 		return -EINVAL;
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index dcfe3129c63a..2772195f15e0 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1363,7 +1363,7 @@  static int ov5647_parse_dt(struct ov5647 *sensor, struct device_node *np)
 	struct device_node *ep;
 	int ret;
 
-	ep = of_graph_get_next_endpoint(np, NULL);
+	ep = of_graph_get_next_device_endpoint(np, NULL);
 	if (!ep)
 		return -EINVAL;
 
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index ed5b10731a14..a43f5c8bf770 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1555,7 +1555,7 @@  static int s5c73m3_get_dt_data(struct s5c73m3 *state)
 				     "failed to request gpio S5C73M3_RST\n");
 	gpiod_set_consumer_name(state->reset, "S5C73M3_RST");
 
-	node_ep = of_graph_get_next_endpoint(node, NULL);
+	node_ep = of_graph_get_next_device_endpoint(node, NULL);
 	if (!node_ep) {
 		dev_warn(dev, "no endpoint defined for node: %pOF\n", node);
 		return 0;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 67da2045f543..063b8ede4ffb 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1836,7 +1836,7 @@  static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
 			 state->mclk_frequency);
 	}
 
-	node_ep = of_graph_get_next_endpoint(node, NULL);
+	node_ep = of_graph_get_next_device_endpoint(node, NULL);
 	if (!node_ep) {
 		dev_err(dev, "no endpoint defined at node %pOF\n", node);
 		return -EINVAL;
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 2785935da497..9664fe1526e2 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -1895,7 +1895,7 @@  static int tc358743_probe_of(struct tc358743_state *state)
 		return dev_err_probe(dev, PTR_ERR(refclk),
 				     "failed to get refclk\n");
 
-	ep = of_graph_get_next_endpoint(dev->of_node, NULL);
+	ep = of_graph_get_next_device_endpoint(dev->of_node, NULL);
 	if (!ep) {
 		dev_err(dev, "missing endpoint node\n");
 		return -EINVAL;
diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
index 325e99125941..5b5379c7e56c 100644
--- a/drivers/media/i2c/tda1997x.c
+++ b/drivers/media/i2c/tda1997x.c
@@ -2307,7 +2307,7 @@  static int tda1997x_parse_dt(struct tda1997x_state *state)
 	pdata->vidout_sel_de = DE_FREF_SEL_DE_VHREF;
 
 	np = state->client->dev.of_node;
-	ep = of_graph_get_next_endpoint(np, NULL);
+	ep = of_graph_get_next_device_endpoint(np, NULL);
 	if (!ep)
 		return -EINVAL;
 
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index c37f605cb75f..f979d95b3b21 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -988,7 +988,7 @@  tvp514x_get_pdata(struct i2c_client *client)
 	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
 		return client->dev.platform_data;
 
-	endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+	endpoint = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
 	if (!endpoint)
 		return NULL;
 
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index e543b3f7a4d8..e8ad131fcd6b 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -2000,7 +2000,7 @@  static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
 	int ret;
 
 	/* At least 1 output and 1 input */
-	ep_num = of_graph_get_endpoint_count(np);
+	ep_num = of_graph_get_device_endpoint_count(np);
 	if (ep_num < 2 || ep_num > 5) {
 		dev_err(dev, "At least 1 input and 1 output must be connected to the device.\n");
 		return -EINVAL;
@@ -2017,7 +2017,7 @@  static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
 	 * tvp-5150 port@2
 	 *	endpoint (video bitstream output at YOUT[0-7] parallel bus)
 	 */
-	for_each_endpoint_of_node(np, ep_np) {
+	for_each_device_endpoint_of_node(np, ep_np) {
 		struct fwnode_handle *ep_fwnode = of_fwnode_handle(ep_np);
 		unsigned int next_connector = decoder->connectors_num;
 		struct of_endpoint ep;
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index a2d7bc799849..27f2a138bd09 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -893,7 +893,7 @@  tvp7002_get_pdata(struct i2c_client *client)
 	if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
 		return client->dev.platform_data;
 
-	endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+	endpoint = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
 	if (!endpoint)
 		return NULL;