summaryrefslogtreecommitdiffstats
path: root/drivers/misc/eeprom
diff options
context:
space:
mode:
authorBartosz Golaszewski <brgl@bgdev.pl>2018-03-19 10:17:14 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-03-23 16:25:00 +0100
commitf1a640c5dc701f661d4359d86601a845a41858d0 (patch)
tree2bb84313746cf805149fc6869db57f6b985bdc52 /drivers/misc/eeprom
parent11288b7c70d89b2587cca3dc5dd004df49ff8daf (diff)
downloadlinux-f1a640c5dc701f661d4359d86601a845a41858d0.tar.bz2
eeprom: at24: provide and use at24_base_client_dev()
Use a helper function for accessing the device struct of the base i2c client. This routine is named in a way that reflects its purpose unlike the previously hand-coded dereferencing. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/eeprom')
-rw-r--r--drivers/misc/eeprom/at24.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 90adca1251cc..633fbdb218e4 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -263,6 +263,11 @@ static struct at24_client *at24_translate_offset(struct at24_data *at24,
return &at24->client[i];
}
+static struct device *at24_base_client_dev(struct at24_data *at24)
+{
+ return &at24->client[0].client->dev;
+}
+
static size_t at24_adjust_read_count(struct at24_data *at24,
unsigned int offset, size_t count)
{
@@ -374,7 +379,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
int ret;
at24 = priv;
- dev = &at24->client[0].client->dev;
+ dev = at24_base_client_dev(at24);
if (unlikely(!count))
return count;
@@ -421,7 +426,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
int ret;
at24 = priv;
- dev = &at24->client[0].client->dev;
+ dev = at24_base_client_dev(at24);
if (unlikely(!count))
return -EINVAL;