diff mbox series

[v1,2/5] Input: edt-ft5x06 - refactor condition in edt_ft5x06_debugfs_mode_set()

Message ID 20200303180917.12563-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/5] Input: of_touchscreen - explicitly choose axis | expand

Commit Message

Andy Shevchenko March 3, 2020, 6:09 p.m. UTC
For better reading unroll nested conditions to simple if-else-if.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/input/touchscreen/edt-ft5x06.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Dmitry Torokhov March 7, 2020, 1:11 a.m. UTC | #1
On Tue, Mar 03, 2020 at 08:09:14PM +0200, Andy Shevchenko wrote:
> For better reading unroll nested conditions to simple if-else-if.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/input/touchscreen/edt-ft5x06.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index d2587724c52a..cb67104c6934 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -666,10 +666,10 @@ static int edt_ft5x06_debugfs_mode_set(void *data, u64 mode)
>  
>  	mutex_lock(&tsdata->mutex);
>  
> -	if (mode != tsdata->factory_mode) {
> -		retval = mode ? edt_ft5x06_factory_mode(tsdata) :
> -				edt_ft5x06_work_mode(tsdata);
> -	}
> +	if (mode && !tsdata->factory_mode)
> +		retval = edt_ft5x06_factory_mode(tsdata);
> +	else if (!mode && tsdata->factory_mode)
> +		retval = edt_ft5x06_work_mode(tsdata);

Sorry, I find the original better, as I read it

	if mode changing then
		activate desired mode (either factory or normal mode)

Thanks.
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index d2587724c52a..cb67104c6934 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -666,10 +666,10 @@  static int edt_ft5x06_debugfs_mode_set(void *data, u64 mode)
 
 	mutex_lock(&tsdata->mutex);
 
-	if (mode != tsdata->factory_mode) {
-		retval = mode ? edt_ft5x06_factory_mode(tsdata) :
-				edt_ft5x06_work_mode(tsdata);
-	}
+	if (mode && !tsdata->factory_mode)
+		retval = edt_ft5x06_factory_mode(tsdata);
+	else if (!mode && tsdata->factory_mode)
+		retval = edt_ft5x06_work_mode(tsdata);
 
 	mutex_unlock(&tsdata->mutex);