[PATCH 4/4] Input: stmfts - use client to make future code cleaner

David Heidelberg via B4 Relay posted 4 patches 1 month, 3 weeks ago
[PATCH 4/4] Input: stmfts - use client to make future code cleaner
Posted by David Heidelberg via B4 Relay 1 month, 3 weeks ago
From: Petr Hodina <petr.hodina@protonmail.com>

Make code cleaner, compiler will optimize it away anyway.

Preparation for FTM5 support, where more steps are needed.

Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
---
 drivers/input/touchscreen/stmfts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index 4b166b0a9a5a6..06845a00348cc 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -747,9 +747,10 @@ static int stmfts_runtime_suspend(struct device *dev)
 static int stmfts_runtime_resume(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
+	struct i2c_client *client = sdata->client;
 	int ret;
 
-	ret = i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_OUT);
+	ret = i2c_smbus_write_byte(client, STMFTS_SLEEP_OUT);
 	if (ret)
 		dev_err(dev, "failed to resume device: %d\n", ret);
 

-- 
2.51.0
Re: [PATCH 4/4] Input: stmfts - use client to make future code cleaner
Posted by Dmitry Torokhov 1 month, 3 weeks ago
Hi David,

On Mon, Dec 15, 2025 at 03:30:04PM +0100, David Heidelberg via B4 Relay wrote:
> From: Petr Hodina <petr.hodina@protonmail.com>
> 
> Make code cleaner, compiler will optimize it away anyway.
> 
> Preparation for FTM5 support, where more steps are needed.
> 
> Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
> Signed-off-by: David Heidelberg <david@ixit.cz>
> ---
>  drivers/input/touchscreen/stmfts.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
> index 4b166b0a9a5a6..06845a00348cc 100644
> --- a/drivers/input/touchscreen/stmfts.c
> +++ b/drivers/input/touchscreen/stmfts.c
> @@ -747,9 +747,10 @@ static int stmfts_runtime_suspend(struct device *dev)
>  static int stmfts_runtime_resume(struct device *dev)
>  {
>  	struct stmfts_data *sdata = dev_get_drvdata(dev);
> +	struct i2c_client *client = sdata->client;
>  	int ret;
>  
> -	ret = i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_OUT);
> +	ret = i2c_smbus_write_byte(client, STMFTS_SLEEP_OUT);

Sorry but I do not see how using a temporary cleans things up compared
to a simple structure member access, given that it happens only once
here.

>  	if (ret)
>  		dev_err(dev, "failed to resume device: %d\n", ret);
>  
> 

Thanks.

-- 
Dmitry
Re: [PATCH 4/4] Input: stmfts - use client to make future code cleaner
Posted by David Heidelberg 1 month, 3 weeks ago
On 16/12/2025 07:13, Dmitry Torokhov wrote:
> Hi David,
> 
> On Mon, Dec 15, 2025 at 03:30:04PM +0100, David Heidelberg via B4 Relay wrote:
>> From: Petr Hodina <petr.hodina@protonmail.com>
>>
>> Make code cleaner, compiler will optimize it away anyway.
>>
>> Preparation for FTM5 support, where more steps are needed.
>>
>> Signed-off-by: Petr Hodina <petr.hodina@protonmail.com>
>> Signed-off-by: David Heidelberg <david@ixit.cz>
>> ---
>>   drivers/input/touchscreen/stmfts.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
>> index 4b166b0a9a5a6..06845a00348cc 100644
>> --- a/drivers/input/touchscreen/stmfts.c
>> +++ b/drivers/input/touchscreen/stmfts.c
>> @@ -747,9 +747,10 @@ static int stmfts_runtime_suspend(struct device *dev)
>>   static int stmfts_runtime_resume(struct device *dev)
>>   {
>>   	struct stmfts_data *sdata = dev_get_drvdata(dev);
>> +	struct i2c_client *client = sdata->client;
>>   	int ret;
>>   
>> -	ret = i2c_smbus_write_byte(sdata->client, STMFTS_SLEEP_OUT);
>> +	ret = i2c_smbus_write_byte(client, STMFTS_SLEEP_OUT);
> 
> Sorry but I do not see how using a temporary cleans things up compared
> to a simple structure member access, given that it happens only once
> here.

Thank you for applying rest of patchset.

This one can be postponed together with introducing fts5 support (where 
we need do more steps here).

David

> 
>>   	if (ret)
>>   		dev_err(dev, "failed to resume device: %d\n", ret);
>>   
>>
> 
> Thanks.
> 

-- 
David Heidelberg