summaryrefslogtreecommitdiffstats
path: root/drivers/misc/eeprom/ee1004.c
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2019-05-06 15:15:39 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-24 20:42:50 +0200
commit5d458751749abda241b7d0a16136c3d49080cf07 (patch)
tree7eb7dbe7301ceb88ad7136697891a25249b59049 /drivers/misc/eeprom/ee1004.c
parentlkdtm: support llvm-objcopy (diff)
downloadlinux-5d458751749abda241b7d0a16136c3d49080cf07.tar.xz
linux-5d458751749abda241b7d0a16136c3d49080cf07.zip
eeprom: ee1004: Move selected page detection to a separate function
No functional change, this is in preparation for future needs. Signed-off-by: Jean Delvare <jdelvare@suse.de> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/eeprom/ee1004.c')
-rw-r--r--drivers/misc/eeprom/ee1004.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c
index 276c1690ea1b..6c6348f816cc 100644
--- a/drivers/misc/eeprom/ee1004.c
+++ b/drivers/misc/eeprom/ee1004.c
@@ -57,6 +57,24 @@ MODULE_DEVICE_TABLE(i2c, ee1004_ids);
/*-------------------------------------------------------------------------*/
+static int ee1004_get_current_page(void)
+{
+ int err;
+
+ err = i2c_smbus_read_byte(ee1004_set_page[0]);
+ if (err == -ENXIO) {
+ /* Nack means page 1 is selected */
+ return 1;
+ }
+ if (err < 0) {
+ /* Anything else is a real error, bail out */
+ return err;
+ }
+
+ /* Ack means page 0 is selected, returned value meaningless */
+ return 0;
+}
+
static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf,
unsigned int offset, size_t count)
{
@@ -190,17 +208,10 @@ static int ee1004_probe(struct i2c_client *client,
}
/* Remember current page to avoid unneeded page select */
- err = i2c_smbus_read_byte(ee1004_set_page[0]);
- if (err == -ENXIO) {
- /* Nack means page 1 is selected */
- ee1004_current_page = 1;
- } else if (err < 0) {
- /* Anything else is a real error, bail out */
+ err = ee1004_get_current_page();
+ if (err < 0)
goto err_clients;
- } else {
- /* Ack means page 0 is selected, returned value meaningless */
- ee1004_current_page = 0;
- }
+ ee1004_current_page = err;
dev_dbg(&client->dev, "Currently selected page: %d\n",
ee1004_current_page);
mutex_unlock(&ee1004_bus_lock);