usb: typec: ucsi: ccg: Adjustments for common code in two functions
Subsystems (3)
cover usb: typec: ucsi: ccg: Adjustments for common code in two functions
From: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:19:01 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use common code in ccg_write()
Use common code in ccg_read()
drivers/usb/typec/ucsi/ucsi_ccg.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
--
2.46.1
PATCH 1/2 usb: typec: ucsi: ccg: Use common code in ccg_write()
From: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:00:23 +0200
Add a label so that three statements can be better reused at the end of this function implementation.
This issue was detected by using the Coccinelle software.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +4 -4
@@ -306,14 +306,14 @@ static int ccg_write(struct ucsi_ccg *uc, u16 rab, const u8 *data, u32 len) status =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs));if (status <0 ) {dev_err (uc->dev,"i2c_transfer failed %d\n" , status); -pm_runtime_put_sync (uc->dev); -kfree (buf); -return status; + goto put_sync; } + status =0 ; +put_sync:pm_runtime_put_sync (uc->dev);kfree (buf); -return 0 ; +return status; }static int ccg_op_region_update (struct ucsi_ccg *uc,u32 cci)
--
2.46.1
Re: [PATCH 1/2] usb: typec: ucsi: ccg: Use common code in ccg_write()
Quoted 9 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:00:23 +0200Add a label so that three statements can be better reused at the end of this function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Quoted 29 lines
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/usb/typec/ucsi/ucsi_ccg.c +4
-5@@ -306,14 +306,14 @@ static int ccg_write(struct ucsi_ccg *uc, u16 rab, const u8 *data, u32 len) status =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs));if (status <0 ) {dev_err (uc->dev,"i2c_transfer failed %d\n" , status); -pm_runtime_put_sync (uc->dev); -kfree (buf); -return status; + goto put_sync; } + status =0 ; +put_sync:pm_runtime_put_sync (uc->dev);kfree (buf); -return 0 ; +return status; }static int ccg_op_region_update (struct ucsi_ccg *uc,u32 cci) --2.46.1
Signature · 1 line
heikki
PATCH 2/2 usb: typec: ucsi: ccg: Use common code in ccg_read()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:08:07 +0200
Add a label so that two statements can be better reused at the end of this function implementation.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +4 -3
@@ -269,15 +269,16 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) status =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs));if (status <0 ) {dev_err (uc->dev,"i2c_transfer failed %d\n" , status); -pm_runtime_put_sync (uc->dev); -return status; + goto put_sync; } rab += rlen; rem_len -= rlen; } + status =0 ; +put_sync:pm_runtime_put_sync (uc->dev); -return 0 ; +return status; }static int ccg_write (struct ucsi_ccg *uc,u16 rab,const u8 *data,u32 len)
--
2.46.1
Re: [PATCH 2/2] usb: typec: ucsi: ccg: Use common code in ccg_read()
Quoted 7 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:08:07 +0200Add a label so that two statements can be better reused at the end of this function implementation.
Signed-off-by Markus Elfring <[email protected]>
Quoted 30 lines
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/usb/typec/ucsi/ucsi_ccg.c +4
-4@@ -269,15 +269,16 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) status =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs));if (status <0 ) {dev_err (uc->dev,"i2c_transfer failed %d\n" , status); -pm_runtime_put_sync (uc->dev); -return status; + goto put_sync; } rab += rlen; rem_len -= rlen; } + status =0 ; +put_sync:pm_runtime_put_sync (uc->dev); -return 0 ; +return status; }static int ccg_write (struct ucsi_ccg *uc,u16 rab,const u8 *data,u32 len) --2.46.1
Signature · 1 line
heikki
Quoted 6 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:19:01 +0200A few update suggestions were taken into account
from static source code analysis.
Quoted 6 lines
Markus Elfring (2):
Use common code inccg_write()
Use common code inccg_read()drivers/usb/typec/ucsi/ucsi_ccg.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
For the series:
Signature · 2 lines
With best wishes Dmitry
Quoted 11 lines · Dmitry Baryshkov
Quoted 10 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:19:01 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (2):
Use common code inccg_write()
Use common code inccg_read()
Quoted 6 lines
Quoted 2 lines
drivers/usb/typec/ucsi/ucsi_ccg.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)For the series:
Acked-by Dmitry Baryshkov <[email protected]>
I believe there is no-one to take it, but in any case the thing is that kfree() probably can be done using __free(). Then PM runtime handled differently.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 13 lines · Andy Shevchenko
Quoted 11 lines · Dmitry Baryshkov
Quoted 10 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 25 Sep 2024 19:19:01 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (2):
Use common code inccg_write()
Use common code inccg_read()
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
drivers/usb/typec/ucsi/ucsi_ccg.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)For the series:
Acked-by Dmitry Baryshkov <[email protected]>I believe there is no-one to take it,
I guessed so.
Quoted 2 lines
but in any case the thing is that
kfree()
probably can be done using__free(). Then PM runtime handled differently.
That's a separate cleanup in my opinion.
Signature · 2 lines
With best wishes Dmitry
Quoted 3 lines · Dmitry Baryshkov
Quoted 1 line · Andy Shevchenko
On Thu, Sep 26, 2024 at 12:26:24AM +0300, Dmitry Baryshkov wrote:
...
Quoted 4 lines
Quoted 2 lines
but in any case the thing is that
kfree()
probably can be done using__free(). Then PM runtime handled differently.That's a separate cleanup in my opinion.
Yes and for that we do not need an intermediate change, right?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Baryshkov
Quoted 1 line · Andy Shevchenko
On Thu, Sep 26, 2024 at 12:26:24AM +0300, Dmitry Baryshkov wrote:
Quoted 8 lines
...
Quoted 4 lines
Quoted 2 lines
but in any case the thing is that
kfree()
probably can be done using__free(). Then PM runtime handled differently.That's a separate cleanup in my opinion.
Yes and for that we do not need an intermediate change, right?
I don't have a strong opinion here (and I don't feel a strong need to move existing code into using cleanup.h just for the sake of it).
Signature · 2 lines
With best wishes Dmitry