All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Guenter Roeck <linux@roeck-us.net>,
	Nick Dyer <nick@shmanahar.org>
Subject: [PATCH 26/33] Input: atmel_mxt_ts - Drop unnecessary error messages and other changes
Date: Wed, 18 Jan 2017 09:46:47 -0800	[thread overview]
Message-ID: <1484761614-12225-27-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1484761614-12225-1-git-send-email-linux@roeck-us.net>

Error messages after memory allocation failures are unnecessary and
can be dropped.
Other relevant changes:
  Simplify error return

This conversion was done automatically with coccinelle using the
following semantic patches. The semantic patches and the scripts
used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches

- Drop unused variables
- Drop unnecessary braces around conditional return statements
- Use local structure pointers consistently
- Drop error message after devm_kzalloc() failure
- Replace 'if (e) return e; return 0;' with 'return e;'

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 47 +++++++-------------------------
 1 file changed, 10 insertions(+), 37 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index e5d185fe69b9..ca027503627e 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -585,7 +585,6 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state,
 
 static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
 {
-	int ret;
 	u8 buf[2];
 
 	if (unlock) {
@@ -596,11 +595,7 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
 		buf[1] = 0x01;
 	}
 
-	ret = mxt_bootloader_write(data, buf, 2);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mxt_bootloader_write(data, buf, 2);
 }
 
 static int __mxt_read_reg(struct i2c_client *client,
@@ -1167,15 +1162,9 @@ static int mxt_t6_command(struct mxt_data *data, u16 cmd_offset,
 
 static int mxt_acquire_irq(struct mxt_data *data)
 {
-	int error;
-
 	enable_irq(data->irq);
 
-	error = mxt_process_messages_until_invalid(data);
-	if (error)
-		return error;
-
-	return 0;
+	return mxt_process_messages_until_invalid(data);
 }
 
 static int mxt_soft_reset(struct mxt_data *data)
@@ -1198,12 +1187,8 @@ static int mxt_soft_reset(struct mxt_data *data)
 
 	mxt_acquire_irq(data);
 
-	ret = mxt_wait_for_completion(data, &data->reset_completion,
-				      MXT_RESET_TIMEOUT);
-	if (ret)
-		return ret;
-
-	return 0;
+	return mxt_wait_for_completion(data, &data->reset_completion,
+				       MXT_RESET_TIMEOUT);
 }
 
 static void mxt_update_crc(struct mxt_data *data, u8 cmd, u8 value)
@@ -1504,10 +1489,8 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg)
 			MXT_INFO_CHECKSUM_SIZE;
 	config_mem_size = data->mem_size - cfg_start_ofs;
 	config_mem = kzalloc(config_mem_size, GFP_KERNEL);
-	if (!config_mem) {
-		dev_err(dev, "Failed to allocate memory\n");
+	if (!config_mem)
 		return -ENOMEM;
-	}
 
 	ret = mxt_prepare_cfg_mem(data, cfg, data_pos, cfg_start_ofs,
 				  config_mem, config_mem_size);
@@ -1555,14 +1538,9 @@ static int mxt_get_info(struct mxt_data *data)
 {
 	struct i2c_client *client = data->client;
 	struct mxt_info *info = &data->info;
-	int error;
 
 	/* Read 7-byte info block starting at address 0 */
-	error = __mxt_read_reg(client, 0, sizeof(*info), info);
-	if (error)
-		return error;
-
-	return 0;
+	return __mxt_read_reg(client, 0, sizeof(*info), info);
 }
 
 static void mxt_free_input_device(struct mxt_data *data)
@@ -1609,10 +1587,8 @@ static int mxt_get_object_table(struct mxt_data *data)
 
 	table_size = data->info.object_num * sizeof(struct mxt_object);
 	object_table = kzalloc(table_size, GFP_KERNEL);
-	if (!object_table) {
-		dev_err(&data->client->dev, "Failed to allocate memory\n");
+	if (!object_table)
 		return -ENOMEM;
-	}
 
 	error = __mxt_read_reg(client, MXT_OBJECT_START, table_size,
 			object_table);
@@ -2045,10 +2021,9 @@ static int mxt_initialize(struct mxt_data *data)
 		if (error) {
 			dev_info(&client->dev, "Trying alternate bootloader address\n");
 			error = mxt_probe_bootloader(data, true);
-			if (error) {
+			if (error)
 				/* Chip is not in appmode or bootloader mode */
 				return error;
-			}
 		}
 
 		/* OK, we are in bootloader, see if we can recover */
@@ -2509,7 +2484,7 @@ static void mxt_debug_init(struct mxt_data *data)
 		dbg->t37_pages = MXT1386_COLUMNS * MXT1386_PAGES_PER_COLUMN;
 	else
 		dbg->t37_pages = DIV_ROUND_UP(data->xsize *
-					      data->info.matrix_ysize *
+					      info->matrix_ysize *
 					      sizeof(u16),
 					      sizeof(dbg->t37_buf->data));
 
@@ -3117,10 +3092,8 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		return PTR_ERR(pdata);
 
 	data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL);
-	if (!data) {
-		dev_err(&client->dev, "Failed to allocate memory\n");
+	if (!data)
 		return -ENOMEM;
-	}
 
 	snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0",
 		 client->adapter->nr, client->addr);
-- 
2.7.4

  parent reply	other threads:[~2017-01-18 17:52 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-18 17:46 [PATCH 00/33] Input: Automated coccinelle cleanup Guenter Roeck
2017-01-18 17:46 ` [PATCH 01/33] Input: adp5520-keys - Drop unnecessary error messages and other changes Guenter Roeck
2017-01-18 17:46 ` [PATCH 02/33] Input: bcm-keypad - Drop unnecessary call to platform_set_drvdata " Guenter Roeck
2017-01-18 17:46 ` [PATCH 03/33] Input: cap11xx - Drop unnecessary call to i2c_set_clientdata " Guenter Roeck
2017-01-18 17:46 ` [PATCH 04/33] Input: cros_ec_keyb - Drop unnecessary call to dev_set_drvdata " Guenter Roeck
2017-01-18 18:39   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 05/33] Input: imx_keypad - Drop unnecessary error messages " Guenter Roeck
2017-01-18 17:46 ` [PATCH 06/33] Input: samsung-keypad " Guenter Roeck
2017-01-18 17:46 ` [PATCH 07/33] Input: sh_keysc " Guenter Roeck
2017-01-18 17:46 ` [PATCH 08/33] Input: spear-keyboard " Guenter Roeck
2017-01-19  3:56   ` Viresh Kumar
2017-01-18 17:46 ` [PATCH 09/33] Input: sun4i-lradc-keys - Drop unnecessary call to platform_set_drvdata " Guenter Roeck
2017-01-18 17:46   ` Guenter Roeck
2017-02-02  7:45   ` Chen-Yu Tsai
2017-02-02  7:45     ` Chen-Yu Tsai
2017-01-18 17:46 ` [PATCH 10/33] Input: twl4030_keypad " Guenter Roeck
2017-01-18 19:45   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 11/33] Input: ab8500-ponkey " Guenter Roeck
2017-01-18 19:45   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 12/33] Input: axp20x-pek - Use devm_add_action_or_reset " Guenter Roeck
2017-02-02  7:43   ` Chen-Yu Tsai
2017-01-18 17:46 ` [PATCH 13/33] Input: bfin_rotary - Use 'dev' instead of dereferencing it " Guenter Roeck
2017-01-18 19:39   ` Dmitry Torokhov
2017-01-18 20:35     ` Guenter Roeck
2017-01-19  4:58       ` Joe Perches
2017-01-19  8:25         ` Guenter Roeck
2017-01-18 17:46 ` [PATCH 14/33] Input: gpio_decoder - Drop unnecessary call to platform_set_drvdata " Guenter Roeck
2017-01-18 19:40   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 15/33] Input: kxtj9 - Drop unnecessary error messages " Guenter Roeck
2017-01-18 17:46 ` [PATCH 16/33] Input: mma8450 - Drop unnecessary call to i2c_set_clientdata " Guenter Roeck
2017-01-18 19:41   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 17/33] Input: retu-pwrbutton - Simplify error return " Guenter Roeck
2017-01-18 17:46 ` [PATCH 18/33] Input: soc_button_array - Use 'dev' instead of dereferencing it " Guenter Roeck
2017-01-18 19:42   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 19/33] Input: tps65218-pwrbutton - Drop unnecessary call to platform_set_drvdata " Guenter Roeck
2017-01-18 19:44   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 20/33] Input: elan_i2c_core - Use 'dev' instead of dereferencing it " Guenter Roeck
2017-01-18 17:46 ` [PATCH 21/33] Input: arc_ps2 - Drop unnecessary error messages " Guenter Roeck
2017-01-18 17:46 ` [PATCH 22/33] Input: at32psif " Guenter Roeck
2017-01-18 19:13   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 23/33] Input: xilinx_ps2 - Use 'dev' instead of dereferencing it " Guenter Roeck
2017-01-18 17:46   ` Guenter Roeck
2017-01-18 17:46   ` Guenter Roeck
2017-01-18 19:17   ` Dmitry Torokhov
2017-01-18 19:17     ` Dmitry Torokhov
2017-01-18 19:17     ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 24/33] Input: ar1021_i2c - Drop unnecessary call to i2c_set_clientdata " Guenter Roeck
2017-01-18 19:21   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 25/33] Input: atmel-wm97xx - Drop unnecessary error messages " Guenter Roeck
2017-01-18 19:23   ` Dmitry Torokhov
2017-01-18 17:46 ` Guenter Roeck [this message]
2017-01-18 17:46 ` [PATCH 27/33] Input: eeti_ts " Guenter Roeck
2017-01-18 19:26   ` Dmitry Torokhov
2017-01-18 17:46 ` [PATCH 28/33] Input: egalax_ts - Drop unnecessary call to i2c_set_clientdata " Guenter Roeck
2017-01-18 19:31   ` Dmitry Torokhov
2017-01-18 20:32     ` Guenter Roeck
2017-01-18 17:46 ` [PATCH 29/33] Input: melfas_mip4 - Use devm_add_action_or_reset " Guenter Roeck
2017-01-18 19:28   ` Dmitry Torokhov
2017-01-18 20:36 ` [PATCH 30/33] Input: raydium_i2c_ts - Simplify error return " Guenter Roeck
2017-01-18 20:36   ` [PATCH 31/33] Input: rohm_bu21023 - Use 'dev' instead of dereferencing it " Guenter Roeck
2017-01-18 20:36   ` [PATCH 32/33] Input: sis_i2c - Drop unnecessary call to i2c_set_clientdata " Guenter Roeck
2017-01-18 22:27     ` Dmitry Torokhov
2017-01-18 20:36   ` [PATCH 33/33] Input: sx8654 " Guenter Roeck
2017-03-14  6:43   ` [PATCH 30/33] Input: raydium_i2c_ts - Simplify error return " Jeffrey Lin (林義章)
2017-01-19  1:42 ` [PATCH 00/33] Input: Automated coccinelle cleanup Joe Perches
2017-01-19  5:04   ` Guenter Roeck
2017-01-19  5:06     ` Joe Perches
2017-01-19  8:19       ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484761614-12225-27-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick@shmanahar.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.