diff mbox series

[v2,2/7] eeprom: at24: change at24_translate_offset return type

Message ID 9b0019a9-f272-e345-d814-fcb05f978554@gmail.com
State Superseded
Delegated to: Bartosz Golaszewski
Headers show
Series eeprom: at24: switch driver to regmap_i2c | expand

Commit Message

Heiner Kallweit Nov. 16, 2017, 8:26 p.m. UTC
Change return type of at24_translate_offset to *at24_client to make
member regmap accessible for subsequent patches of this series.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- rebased
---
 drivers/misc/eeprom/at24.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Bartosz Golaszewski Nov. 21, 2017, 10 a.m. UTC | #1
2017-11-16 21:26 GMT+01:00 Heiner Kallweit <hkallweit1@gmail.com>:
> Change return type of at24_translate_offset to *at24_client to make
> member regmap accessible for subsequent patches of this series.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> v2:
> - rebased
> ---
>  drivers/misc/eeprom/at24.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 911cce8ec..1411fa029 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -267,8 +267,8 @@ MODULE_DEVICE_TABLE(acpi, at24_acpi_ids);
>   * one "eeprom" file not four, but larger reads would fail when
>   * they crossed certain pages.
>   */
> -static struct i2c_client *at24_translate_offset(struct at24_data *at24,
> -                                               unsigned int *offset)
> +static struct at24_client *at24_translate_offset(struct at24_data *at24,
> +                                                unsigned int *offset)
>  {
>         unsigned i;
>
> @@ -280,7 +280,7 @@ static struct i2c_client *at24_translate_offset(struct at24_data *at24,
>                 *offset &= 0xff;
>         }
>
> -       return at24->client[i].client;
> +       return &at24->client[i];
>  }
>
>  static ssize_t at24_eeprom_read_smbus(struct at24_data *at24, char *buf,
> @@ -290,7 +290,7 @@ static ssize_t at24_eeprom_read_smbus(struct at24_data *at24, char *buf,
>         struct i2c_client *client;
>         int status;
>
> -       client = at24_translate_offset(at24, &offset);
> +       client = at24_translate_offset(at24, &offset)->client;

Please do something like:

struct at24_client *at24;
struct i2c_client *client;

at24 = at24_translate_offset(at24, &offset);
client = at24->client;

I find it more readable like that and we don't hide the type of the
return value of at24_translate_offset().

Thanks,
Bartosz
diff mbox series

Patch

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 911cce8ec..1411fa029 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -267,8 +267,8 @@  MODULE_DEVICE_TABLE(acpi, at24_acpi_ids);
  * one "eeprom" file not four, but larger reads would fail when
  * they crossed certain pages.
  */
-static struct i2c_client *at24_translate_offset(struct at24_data *at24,
-						unsigned int *offset)
+static struct at24_client *at24_translate_offset(struct at24_data *at24,
+						 unsigned int *offset)
 {
 	unsigned i;
 
@@ -280,7 +280,7 @@  static struct i2c_client *at24_translate_offset(struct at24_data *at24,
 		*offset &= 0xff;
 	}
 
-	return at24->client[i].client;
+	return &at24->client[i];
 }
 
 static ssize_t at24_eeprom_read_smbus(struct at24_data *at24, char *buf,
@@ -290,7 +290,7 @@  static ssize_t at24_eeprom_read_smbus(struct at24_data *at24, char *buf,
 	struct i2c_client *client;
 	int status;
 
-	client = at24_translate_offset(at24, &offset);
+	client = at24_translate_offset(at24, &offset)->client;
 
 	if (count > io_limit)
 		count = io_limit;
@@ -324,7 +324,7 @@  static ssize_t at24_eeprom_read_i2c(struct at24_data *at24, char *buf,
 	u8 msgbuf[2];
 
 	memset(msg, 0, sizeof(msg));
-	client = at24_translate_offset(at24, &offset);
+	client = at24_translate_offset(at24, &offset)->client;
 
 	if (count > io_limit)
 		count = io_limit;
@@ -373,7 +373,7 @@  static ssize_t at24_eeprom_read_serial(struct at24_data *at24, char *buf,
 	u8 addrbuf[2];
 	int status;
 
-	client = at24_translate_offset(at24, &offset);
+	client = at24_translate_offset(at24, &offset)->client;
 
 	memset(msg, 0, sizeof(msg));
 	msg[0].addr = client->addr;
@@ -426,7 +426,7 @@  static ssize_t at24_eeprom_read_mac(struct at24_data *at24, char *buf,
 	u8 addrbuf[2];
 	int status;
 
-	client = at24_translate_offset(at24, &offset);
+	client = at24_translate_offset(at24, &offset)->client;
 
 	memset(msg, 0, sizeof(msg));
 	msg[0].addr = client->addr;
@@ -481,7 +481,7 @@  static ssize_t at24_eeprom_write_smbus_block(struct at24_data *at24,
 	struct i2c_client *client;
 	ssize_t status = 0;
 
-	client = at24_translate_offset(at24, &offset);
+	client = at24_translate_offset(at24, &offset)->client;
 	count = at24_adjust_write_count(at24, offset, count);
 
 	loop_until_timeout(timeout, write_time) {
@@ -508,7 +508,7 @@  static ssize_t at24_eeprom_write_smbus_byte(struct at24_data *at24,
 	struct i2c_client *client;
 	ssize_t status = 0;
 
-	client = at24_translate_offset(at24, &offset);
+	client = at24_translate_offset(at24, &offset)->client;
 
 	loop_until_timeout(timeout, write_time) {
 		status = i2c_smbus_write_byte_data(client, offset, buf[0]);
@@ -534,7 +534,7 @@  static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf,
 	ssize_t status = 0;
 	int i = 0;
 
-	client = at24_translate_offset(at24, &offset);
+	client = at24_translate_offset(at24, &offset)->client;
 	count = at24_adjust_write_count(at24, offset, count);
 
 	msg.addr = client->addr;
@@ -574,7 +574,7 @@  static int at24_read(void *priv, unsigned int off, void *val, size_t count)
 	if (unlikely(!count))
 		return count;
 
-	client = at24_translate_offset(at24, &off);
+	client = at24_translate_offset(at24, &off)->client;
 
 	ret = pm_runtime_get_sync(&client->dev);
 	if (ret < 0) {
@@ -619,7 +619,7 @@  static int at24_write(void *priv, unsigned int off, void *val, size_t count)
 	if (unlikely(!count))
 		return -EINVAL;
 
-	client = at24_translate_offset(at24, &off);
+	client = at24_translate_offset(at24, &off)->client;
 
 	ret = pm_runtime_get_sync(&client->dev);
 	if (ret < 0) {