* [PATCH 1/2] i2c: amd: Switch to guard(mutex)
@ 2025-02-17 12:47 Shyam Sundar S K
2025-02-17 12:47 ` [PATCH 2/2] i2c: dw: Update the master_xfer callback name Shyam Sundar S K
2025-02-17 20:19 ` [PATCH 1/2] i2c: amd: Switch to guard(mutex) Andy Shevchenko
0 siblings, 2 replies; 5+ messages in thread
From: Shyam Sundar S K @ 2025-02-17 12:47 UTC (permalink / raw)
To: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, Jan Dabros,
Andi Shyti
Cc: linux-i2c, Shyam Sundar S K, Sanket Goswami
Instead of using the 'goto label; mutex_unlock()' pattern use
'guard(mutex)' which will release the mutex when it goes out of scope.
Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i2c/busses/i2c-designware-amdpsp.c | 26 ++++++++--------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c
index 8fbd2a10c31a..404571ad61a8 100644
--- a/drivers/i2c/busses/i2c-designware-amdpsp.c
+++ b/drivers/i2c/busses/i2c-designware-amdpsp.c
@@ -151,19 +151,16 @@ static void release_bus(void)
static void psp_release_i2c_bus_deferred(struct work_struct *work)
{
- mutex_lock(&psp_i2c_access_mutex);
+ guard(mutex)(&psp_i2c_access_mutex);
/*
* If there is any pending transaction, cannot release the bus here.
* psp_release_i2c_bus() will take care of this later.
*/
if (psp_i2c_access_count)
- goto cleanup;
+ return;
release_bus();
-
-cleanup:
- mutex_unlock(&psp_i2c_access_mutex);
}
static DECLARE_DELAYED_WORK(release_queue, psp_release_i2c_bus_deferred);
@@ -171,11 +168,11 @@ static int psp_acquire_i2c_bus(void)
{
int status;
- mutex_lock(&psp_i2c_access_mutex);
+ guard(mutex)(&psp_i2c_access_mutex);
/* Return early if mailbox malfunctioned */
if (psp_i2c_mbox_fail)
- goto cleanup;
+ return 0;
psp_i2c_access_count++;
@@ -184,11 +181,11 @@ static int psp_acquire_i2c_bus(void)
* reservation period.
*/
if (psp_i2c_sem_acquired)
- goto cleanup;
+ return 0;
status = psp_send_i2c_req(PSP_I2C_REQ_ACQUIRE);
if (status)
- goto cleanup;
+ return 0;
psp_i2c_sem_acquired = jiffies;
@@ -201,18 +198,16 @@ static int psp_acquire_i2c_bus(void)
* communication with PSP. At any case i2c bus is granted to the caller,
* thus always return success.
*/
-cleanup:
- mutex_unlock(&psp_i2c_access_mutex);
return 0;
}
static void psp_release_i2c_bus(void)
{
- mutex_lock(&psp_i2c_access_mutex);
+ guard(mutex)(&psp_i2c_access_mutex);
/* Return early if mailbox was malfunctioned */
if (psp_i2c_mbox_fail)
- goto cleanup;
+ return;
/*
* If we are last owner of PSP semaphore, need to release arbitration
@@ -220,7 +215,7 @@ static void psp_release_i2c_bus(void)
*/
psp_i2c_access_count--;
if (psp_i2c_access_count)
- goto cleanup;
+ return;
/*
* Send a release command to PSP if the semaphore reservation timeout
@@ -228,9 +223,6 @@ static void psp_release_i2c_bus(void)
*/
if (!delayed_work_pending(&release_queue))
release_bus();
-
-cleanup:
- mutex_unlock(&psp_i2c_access_mutex);
}
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] i2c: dw: Update the master_xfer callback name
2025-02-17 12:47 [PATCH 1/2] i2c: amd: Switch to guard(mutex) Shyam Sundar S K
@ 2025-02-17 12:47 ` Shyam Sundar S K
2025-02-17 20:19 ` [PATCH 1/2] i2c: amd: Switch to guard(mutex) Andy Shevchenko
1 sibling, 0 replies; 5+ messages in thread
From: Shyam Sundar S K @ 2025-02-17 12:47 UTC (permalink / raw)
To: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, Jan Dabros,
Andi Shyti
Cc: linux-i2c, Shyam Sundar S K, Sanket Goswami
In light of the recent updates to the i2c subsystem, ensure to use the
correct callback names. Specifically, replace '.master_xfer' with '.xfer'.
Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/i2c/busses/i2c-designware-master.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 2569bf1a72e0..c5394229b77f 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -907,7 +907,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
}
static const struct i2c_algorithm i2c_dw_algo = {
- .master_xfer = i2c_dw_xfer,
+ .xfer = i2c_dw_xfer,
.functionality = i2c_dw_func,
};
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] i2c: amd: Switch to guard(mutex)
2025-02-17 12:47 [PATCH 1/2] i2c: amd: Switch to guard(mutex) Shyam Sundar S K
2025-02-17 12:47 ` [PATCH 2/2] i2c: dw: Update the master_xfer callback name Shyam Sundar S K
@ 2025-02-17 20:19 ` Andy Shevchenko
2025-02-18 7:09 ` Shyam Sundar S K
2025-02-24 9:53 ` Jarkko Nikula
1 sibling, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-02-17 20:19 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: Jarkko Nikula, Mika Westerberg, Jan Dabros, Andi Shyti, linux-i2c,
Sanket Goswami
On Mon, Feb 17, 2025 at 06:17:08PM +0530, Shyam Sundar S K wrote:
> Instead of using the 'goto label; mutex_unlock()' pattern use
> 'guard(mutex)' which will release the mutex when it goes out of scope.
Both LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
But next time either sent them separately (seems like they are independent),
or add a cover letter explaining what the big picture behind all the patches
as a whole.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] i2c: amd: Switch to guard(mutex)
2025-02-17 20:19 ` [PATCH 1/2] i2c: amd: Switch to guard(mutex) Andy Shevchenko
@ 2025-02-18 7:09 ` Shyam Sundar S K
2025-02-24 9:53 ` Jarkko Nikula
1 sibling, 0 replies; 5+ messages in thread
From: Shyam Sundar S K @ 2025-02-18 7:09 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jarkko Nikula, Mika Westerberg, Jan Dabros, Andi Shyti, linux-i2c,
Sanket Goswami
On 2/18/2025 01:49, Andy Shevchenko wrote:
> On Mon, Feb 17, 2025 at 06:17:08PM +0530, Shyam Sundar S K wrote:
>> Instead of using the 'goto label; mutex_unlock()' pattern use
>> 'guard(mutex)' which will release the mutex when it goes out of scope.
>
> Both LGTM,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> But next time either sent them separately (seems like they are independent),
> or add a cover letter explaining what the big picture behind all the patches
> as a whole.
>
Thanks! and.. for sure next time..
Thanks,
Shyam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] i2c: amd: Switch to guard(mutex)
2025-02-17 20:19 ` [PATCH 1/2] i2c: amd: Switch to guard(mutex) Andy Shevchenko
2025-02-18 7:09 ` Shyam Sundar S K
@ 2025-02-24 9:53 ` Jarkko Nikula
1 sibling, 0 replies; 5+ messages in thread
From: Jarkko Nikula @ 2025-02-24 9:53 UTC (permalink / raw)
To: Andy Shevchenko, Shyam Sundar S K
Cc: Mika Westerberg, Jan Dabros, Andi Shyti, linux-i2c,
Sanket Goswami
On 2/17/25 10:19 PM, Andy Shevchenko wrote:
> On Mon, Feb 17, 2025 at 06:17:08PM +0530, Shyam Sundar S K wrote:
>> Instead of using the 'goto label; mutex_unlock()' pattern use
>> 'guard(mutex)' which will release the mutex when it goes out of scope.
>
> Both LGTM,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> But next time either sent them separately (seems like they are independent),
> or add a cover letter explaining what the big picture behind all the patches
> as a whole.
>
To both:
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-24 9:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-17 12:47 [PATCH 1/2] i2c: amd: Switch to guard(mutex) Shyam Sundar S K
2025-02-17 12:47 ` [PATCH 2/2] i2c: dw: Update the master_xfer callback name Shyam Sundar S K
2025-02-17 20:19 ` [PATCH 1/2] i2c: amd: Switch to guard(mutex) Andy Shevchenko
2025-02-18 7:09 ` Shyam Sundar S K
2025-02-24 9:53 ` Jarkko Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox