[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e6814ec7-b9fb-4185-9929-1e463ef518f6@vivo.com>
Date: Tue, 8 Jul 2025 10:05:58 +0800
From: Qianfeng Rong <rongqianfeng@...o.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: Patrice Chotard <patrice.chotard@...s.st.com>,
Andi Shyti <andi.shyti@...nel.org>, linux-arm-kernel@...ts.infradead.org,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
opensource.kernel@...o.com
Subject: Re: [PATCH v2] i2c: busses: Use min() to improve code
在 2025/7/7 17:40, Jonathan Cameron 写道:
>> Signed-off-by: Qianfeng Rong <rongqianfeng@...o.com>
>> Reviewed-by: Patrice Chotard <patrice.chotard@...s.st.com>
> Drive by review...
>
> I'd add Wolfram as +CC at least. May well pick it off the list
> of course.
Thanks for your reminder.
>> ---
>> drivers/i2c/busses/i2c-st.c | 12 +++---------
>> 1 file changed, 3 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
>> index 750fff3d2389..285d8a05ab36 100644
>> --- a/drivers/i2c/busses/i2c-st.c
>> +++ b/drivers/i2c/busses/i2c-st.c
>> @@ -422,10 +422,7 @@ static void st_i2c_wr_fill_tx_fifo(struct st_i2c_dev *i2c_dev)
>> tx_fstat = readl_relaxed(i2c_dev->base + SSC_TX_FSTAT);
>> tx_fstat &= SSC_TX_FSTAT_STATUS;
>>
>> - if (c->count < (SSC_TXFIFO_SIZE - tx_fstat))
>> - i = c->count;
>> - else
>> - i = SSC_TXFIFO_SIZE - tx_fstat;
>> + i = min(c->count, SSC_TXFIFO_SIZE - tx_fstat);
> Add
> #include <linux/minmax.h>
>
>
> Given it is now one statement perhaps cleaner toput it
> as the loop initializer
>
> for (i = min(c->count, SSC_TXFIFO_SIZE - tx_fstat);
> i > 0; i--, c->count--, c->buf++)
>
Got it. Will do in the next version.
Best regards,
Qianfeng
Powered by blists - more mailing lists