linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] power: supply: minor improvements to sbs-manager and battery
@ 2017-10-29 15:35 Wolfram Sang
  2017-10-29 15:35 ` [PATCH 1/3] power: supply: sbs-battery: remove superfluous variable init Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wolfram Sang @ 2017-10-29 15:35 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-pm, Phil Reid, sre, Wolfram Sang

Here are three patches I came up with when doing the code review for Phil
Reid's V11 series for the sbs-manager. This code is not upstream yet but resides
in this branch (already with these patches applied):

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/sbs-manager

Since Sebastian was super-fast in reviewing these patches, I will merge the
above branch pretty soon into i2c/for-next if nobody objects.

Thanks!


Wolfram Sang (3):
  power: supply: sbs-battery: remove superfluous variable init
  power: supply: sbs-battery: remove unchecked return var
  power: supply: sbs-message: fix some code style issues

 drivers/power/supply/sbs-battery.c | 12 ++++--------
 drivers/power/supply/sbs-manager.c |  7 ++++---
 2 files changed, 8 insertions(+), 11 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] power: supply: sbs-battery: remove superfluous variable init
  2017-10-29 15:35 [PATCH 0/3] power: supply: minor improvements to sbs-manager and battery Wolfram Sang
@ 2017-10-29 15:35 ` Wolfram Sang
  2017-10-29 15:35 ` [PATCH 2/3] power: supply: sbs-battery: remove unchecked return var Wolfram Sang
  2017-10-29 15:35 ` [PATCH 3/3] power: supply: sbs-message: fix some code style issues Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2017-10-29 15:35 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-pm, Phil Reid, sre, Wolfram Sang, Sebastian Reichel

Those variables are immediately assigned a value afterwards.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/power/supply/sbs-battery.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 8dd4bd70c561cc..fb61da370947f4 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -177,10 +177,8 @@ static bool force_load;
 static int sbs_read_word_data(struct i2c_client *client, u8 address)
 {
 	struct sbs_info *chip = i2c_get_clientdata(client);
+	int retries = chip->i2c_retry_count;
 	s32 ret = 0;
-	int retries = 1;
-
-	retries = chip->i2c_retry_count;
 
 	while (retries > 0) {
 		ret = i2c_smbus_read_word_data(client, address);
@@ -204,7 +202,7 @@ static int sbs_read_string_data(struct i2c_client *client, u8 address,
 {
 	struct sbs_info *chip = i2c_get_clientdata(client);
 	s32 ret = 0, block_length = 0;
-	int retries_length = 1, retries_block = 1;
+	int retries_length, retries_block;
 	u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1];
 
 	retries_length = chip->i2c_retry_count;
@@ -269,10 +267,8 @@ static int sbs_write_word_data(struct i2c_client *client, u8 address,
 	u16 value)
 {
 	struct sbs_info *chip = i2c_get_clientdata(client);
+	int retries = chip->i2c_retry_count;
 	s32 ret = 0;
-	int retries = 1;
-
-	retries = chip->i2c_retry_count;
 
 	while (retries > 0) {
 		ret = i2c_smbus_write_word_data(client, address, value);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] power: supply: sbs-battery: remove unchecked return var
  2017-10-29 15:35 [PATCH 0/3] power: supply: minor improvements to sbs-manager and battery Wolfram Sang
  2017-10-29 15:35 ` [PATCH 1/3] power: supply: sbs-battery: remove superfluous variable init Wolfram Sang
@ 2017-10-29 15:35 ` Wolfram Sang
  2017-10-29 15:35 ` [PATCH 3/3] power: supply: sbs-message: fix some code style issues Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2017-10-29 15:35 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-pm, Phil Reid, sre, Wolfram Sang, Sebastian Reichel

Since the return value is not checked anyhow, we don't need to store it.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/power/supply/sbs-battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index fb61da370947f4..83d7b4115857e3 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -556,7 +556,7 @@ static int sbs_get_battery_serial_number(struct i2c_client *client,
 	if (ret < 0)
 		return ret;
 
-	ret = sprintf(sbs_serial, "%04x", ret);
+	sprintf(sbs_serial, "%04x", ret);
 	val->strval = sbs_serial;
 
 	return 0;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] power: supply: sbs-message: fix some code style issues
  2017-10-29 15:35 [PATCH 0/3] power: supply: minor improvements to sbs-manager and battery Wolfram Sang
  2017-10-29 15:35 ` [PATCH 1/3] power: supply: sbs-battery: remove superfluous variable init Wolfram Sang
  2017-10-29 15:35 ` [PATCH 2/3] power: supply: sbs-battery: remove unchecked return var Wolfram Sang
@ 2017-10-29 15:35 ` Wolfram Sang
  2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2017-10-29 15:35 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-pm, Phil Reid, sre, Wolfram Sang, Sebastian Reichel

Use 'unsigned int' and curly braces for 'else'.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/power/supply/sbs-manager.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/sbs-manager.c b/drivers/power/supply/sbs-manager.c
index 3e3ad09c5f11c3..ccb4217b963869 100644
--- a/drivers/power/supply/sbs-manager.c
+++ b/drivers/power/supply/sbs-manager.c
@@ -193,7 +193,7 @@ static int sbsm_select(struct i2c_mux_core *muxc, u32 chan)
 	return ret;
 }
 
-static int sbsm_gpio_get_value(struct gpio_chip *gc, unsigned off)
+static int sbsm_gpio_get_value(struct gpio_chip *gc, unsigned int off)
 {
 	struct sbsm_data *data = gpiochip_get_data(gc);
 	int ret;
@@ -209,7 +209,7 @@ static int sbsm_gpio_get_value(struct gpio_chip *gc, unsigned off)
  * This needs to be defined or the GPIO lib fails to register the pin.
  * But the 'gpio' is always an input.
  */
-static int sbsm_gpio_direction_input(struct gpio_chip *gc, unsigned off)
+static int sbsm_gpio_direction_input(struct gpio_chip *gc, unsigned int off)
 {
 	return 0;
 }
@@ -229,8 +229,9 @@ static int sbsm_do_alert(struct device *dev, void *d)
 			driver->alert(client, I2C_PROTOCOL_SMBUS_ALERT, 0);
 		else
 			dev_warn(&client->dev, "no driver alert()!\n");
-	} else
+	} else {
 		dev_dbg(&client->dev, "alert with no driver\n");
+	}
 	device_unlock(dev);
 
 	return -EBUSY;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-29 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-29 15:35 [PATCH 0/3] power: supply: minor improvements to sbs-manager and battery Wolfram Sang
2017-10-29 15:35 ` [PATCH 1/3] power: supply: sbs-battery: remove superfluous variable init Wolfram Sang
2017-10-29 15:35 ` [PATCH 2/3] power: supply: sbs-battery: remove unchecked return var Wolfram Sang
2017-10-29 15:35 ` [PATCH 3/3] power: supply: sbs-message: fix some code style issues Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).