Skip to contentSkip to conversation

char: convert to use new I2C API

PATCH In review Wolfram Sang 3 participants 11 messages Mar 26, 2020 – May 13, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover char: convert to use new I2C API

We are deprecating calls which return NULL in favor of new variants which return an ERR_PTR. Only build tested.

Wolfram Sang (1):
char: ipmi: convert to use i2c_new_client_device()

 drivers/char/ipmi/ipmi_ssif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 char: ipmi: convert to use i2c_new_client_device()

Move away from the deprecated API.

---
 drivers/char/ipmi/ipmi_ssif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_ssif.c +2 -2
index 8ac390c2b514..2791b799e33d 100644
@@ -1945,8 +1945,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
 	if (adev->type != &i2c_adapter_type)
 		return 0;
 
-	addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-						 &addr_info->binfo);
+	addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev),
+							&addr_info->binfo);
 
 	if (!addr_info->adapter_name)
 		return 1; /* Only try the first I2C adapter by default. */
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 1/1] char: ipmi: convert to use i2c_new_client_device()

Quoted 3 lines · Wolfram Sang

Move away from the deprecated API.

Can we have this now so I can remove the old API in the next merge window?

Quoted 22 lines
---
 drivers/char/ipmi/ipmi_ssif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_ssif.c +2 -2
index 8ac390c2b514..2791b799e33d 100644
@@ -1945,8 +1945,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
 	if (adev->type != &i2c_adapter_type)
 		return 0;
 
-	addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-						 &addr_info->binfo);
+	addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev),
+							&addr_info->binfo);
 
 	if (!addr_info->adapter_name)
 		return 1; /* Only try the first I2C adapter by default. */
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#3 lore raw

Re: [PATCH 1/1] char: ipmi: convert to use i2c_new_client_device()

In reply to Wolfram Sang
Quoted 3 lines · Wolfram Sang

Move away from the deprecated API.

Ok by me.

Do you want me to take this, or is this part of something else? I can submit it if you like.

-corey

Quoted 22 lines
---
 drivers/char/ipmi/ipmi_ssif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_ssif.c +2 -2
index 8ac390c2b514..2791b799e33d 100644
@@ -1945,8 +1945,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
 	if (adev->type != &i2c_adapter_type)
 		return 0;
 
-	addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-						 &addr_info->binfo);
+	addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev),
+							&addr_info->binfo);
 
 	if (!addr_info->adapter_name)
 		return 1; /* Only try the first I2C adapter by default. */
Signature · 1 line
2.20.1
#4 lore raw

Re: [PATCH 1/1] char: ipmi: convert to use i2c_new_client_device()

Quoted 11 lines · Corey Minyard
Quoted 3 lines · Wolfram Sang

Move away from the deprecated API.

Ok by me.

Do you want me to take this, or is this part of something else? I can submit it if you like.

I'd prefer if you take it. But I can take it if it is easier for you.

Thanks!

#5 lore raw

Re: [PATCH 1/1] char: ipmi: convert to use i2c_new_client_device()

In reply to Wolfram Sang
Quoted 1 line · Wolfram Sang

Move away from the deprecated API.

Well, I should have looked a little closer first... comment inline

Quoted 11 lines
---
 drivers/char/ipmi/ipmi_ssif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_ssif.c +0 -0
index 8ac390c2b514..2791b799e33d 100644

drivers/char/ipmi/ipmi_ssif.c static int ssif_adapter_handler(struct device *adev, void *opaque) · line 1949

Quoted 7 lines
drivers/char/ipmi/ipmi_ssif.c +2 -2
@@ -1945,8 +1945,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
 	if (adev->type != &i2c_adapter_type)
 		return 0;
 
-	addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-						 &addr_info->binfo);
+	addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev),
+							&addr_info->binfo);

i2c_new_client_device returns an ERR_PTR, not NULL on error. So this needs some more work. I'll send something out soon.

-corey

Quoted 6 lines
drivers/char/ipmi/ipmi_ssif.c +0 -0
 	if (!addr_info->adapter_name)
 		return 1; /* Only try the first I2C adapter by default. */
Signature · 1 line
2.20.1
#6 lore raw

Re: [PATCH 1/1] char: ipmi: convert to use i2c_new_client_device()

Quoted 7 lines

drivers/char/ipmi/ipmi_ssif.c static int ssif_adapter_handler(struct device *adev, void *opaque) · line 1949

Quoted 5 lines
drivers/char/ipmi/ipmi_ssif.c +2 -2
-	addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-						 &addr_info->binfo);
+	addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev),
+							&addr_info->binfo);

i2c_new_client_device returns an ERR_PTR, not NULL on error. So this

Yes, this is the main motivation for the new API.

Quoted 1 line

needs some more work. I'll send something out soon.

Why does it need that work? 'added_client' is only used with i2c_unregister_device() which has been fixed to handle ERR_PTR as well. Or am I missing something?

#7 lore raw

Re: [PATCH 1/1] char: ipmi: convert to use i2c_new_client_device()

Quoted 8 lines · Wolfram Sang
Quoted 7 lines

drivers/char/ipmi/ipmi_ssif.c static int ssif_adapter_handler(struct device *adev, void *opaque) · line 1949

Quoted 5 lines
drivers/char/ipmi/ipmi_ssif.c +2 -2
-	addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-						 &addr_info->binfo);
+	addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev),
+							&addr_info->binfo);

i2c_new_client_device returns an ERR_PTR, not NULL on error. So this

Quoted 8 lines

Yes, this is the main motivation for the new API.

Quoted 1 line

needs some more work. I'll send something out soon.

Why does it need that work? 'added_client' is only used with i2c_unregister_device() which has been fixed to handle ERR_PTR as well. Or am I missing something?

No, I didn't look to see if i2c_unregister_device could handle that.

-corey

#8 lore raw

PATCH 1/1 char: ipmi: convert to use i2c_new_client_device()

In reply to Wolfram Sang

From: Wolfram Sang <[email protected]>

Move away from the deprecated API.

Based on a patch by Wolfram Sang <[email protected]>.

---
I think this works.

 drivers/char/ipmi/ipmi_ssif.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_ssif.c +4 -2
index b7145f370d3b..65563e5e5731 100644
@@ -1943,12 +1943,14 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 static int ssif_adapter_handler(struct device *adev, void *opaque)
 {
 	struct ssif_addr_info *addr_info = opaque;
+	struct i2c_client *cl;
 
 	if (adev->type != &i2c_adapter_type)
 		return 0;
 
-	addr_info->added_client = i2c_new_device(to_i2c_adapter(adev),
-						 &addr_info->binfo);
+	cl = i2c_new_client_device(to_i2c_adapter(adev), &addr_info->binfo);
+	if (!IS_ERR(cl))
+		addr_info->added_client = cl;
 
 	if (!addr_info->adapter_name)
 		return 1; /* Only try the first I2C adapter by default. */
Signature · 1 line
2.17.1
#9 lore raw

Re: [PATCH] char: ipmi: convert to use i2c_new_client_device()

Quoted 9 lines · On Tue, May 12, 2020 at 04:45:32PM -0500, [email protected] wrote:

From: Wolfram Sang <[email protected]>

Move away from the deprecated API.

Based on a patch by Wolfram Sang <[email protected]>.

---
I think this works.

Yes, we can do it like this (despite the question from earlier if it is really needed). I fixed other drivers using this pattern, too.

As Stephen Rothwell pointed out, you either need to remove my "From:" or add my SoB. I am fine with both.

Thanks,

Wolfram

#10 lore raw

Re: [PATCH] char: ipmi: convert to use i2c_new_client_device()

Quoted 5 lines · Wolfram Sang
Quoted 4 lines · On Tue, May 12, 2020 at 04:45:32PM -0500, [email protected] wrote:

From: Wolfram Sang <[email protected]>

Move away from the deprecated API.

Quoted 8 lines
Quoted 5 lines

Based on a patch by Wolfram Sang <[email protected]>.

---
I think this works.

Yes, we can do it like this (despite the question from earlier if it is really needed). I fixed other drivers using this pattern, too.

I was wondering whether this is really needed, too, but I'm not 100% sure it can be removed in all cases. This is the safer route.

Quoted 3 lines

As Stephen Rothwell pointed out, you either need to remove my "From:" or add my SoB. I am fine with both.

It was enough of a rewrite that you as the author didn't seem right. I've fixed the From line, sorry about that.

-corey

Quoted 5 lines

Thanks,

Wolfram