Commit a3fe09bc authored by Wolfram Sang's avatar Wolfram Sang

Merge tag 'at24-4.15-rc3-fixes-for-wolfram' of...

Merge tag 'at24-4.15-rc3-fixes-for-wolfram' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-current

Sakari fixed a regression introduced during the 4.15 merge window and
David submitted a fix for an issue that has existed in at24 since
introducing nvmem.
parents 04271ce9 7f6d2ecd
...@@ -562,7 +562,7 @@ static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf, ...@@ -562,7 +562,7 @@ static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf,
static int at24_read(void *priv, unsigned int off, void *val, size_t count) static int at24_read(void *priv, unsigned int off, void *val, size_t count)
{ {
struct at24_data *at24 = priv; struct at24_data *at24 = priv;
struct i2c_client *client; struct device *dev = &at24->client[0]->dev;
char *buf = val; char *buf = val;
int ret; int ret;
...@@ -572,11 +572,9 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) ...@@ -572,11 +572,9 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
if (off + count > at24->chip.byte_len) if (off + count > at24->chip.byte_len)
return -EINVAL; return -EINVAL;
client = at24_translate_offset(at24, &off); ret = pm_runtime_get_sync(dev);
ret = pm_runtime_get_sync(&client->dev);
if (ret < 0) { if (ret < 0) {
pm_runtime_put_noidle(&client->dev); pm_runtime_put_noidle(dev);
return ret; return ret;
} }
...@@ -592,7 +590,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) ...@@ -592,7 +590,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
status = at24->read_func(at24, buf, off, count); status = at24->read_func(at24, buf, off, count);
if (status < 0) { if (status < 0) {
mutex_unlock(&at24->lock); mutex_unlock(&at24->lock);
pm_runtime_put(&client->dev); pm_runtime_put(dev);
return status; return status;
} }
buf += status; buf += status;
...@@ -602,7 +600,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) ...@@ -602,7 +600,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
mutex_unlock(&at24->lock); mutex_unlock(&at24->lock);
pm_runtime_put(&client->dev); pm_runtime_put(dev);
return 0; return 0;
} }
...@@ -610,7 +608,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) ...@@ -610,7 +608,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
static int at24_write(void *priv, unsigned int off, void *val, size_t count) static int at24_write(void *priv, unsigned int off, void *val, size_t count)
{ {
struct at24_data *at24 = priv; struct at24_data *at24 = priv;
struct i2c_client *client; struct device *dev = &at24->client[0]->dev;
char *buf = val; char *buf = val;
int ret; int ret;
...@@ -620,11 +618,9 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) ...@@ -620,11 +618,9 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
if (off + count > at24->chip.byte_len) if (off + count > at24->chip.byte_len)
return -EINVAL; return -EINVAL;
client = at24_translate_offset(at24, &off); ret = pm_runtime_get_sync(dev);
ret = pm_runtime_get_sync(&client->dev);
if (ret < 0) { if (ret < 0) {
pm_runtime_put_noidle(&client->dev); pm_runtime_put_noidle(dev);
return ret; return ret;
} }
...@@ -640,7 +636,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) ...@@ -640,7 +636,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
status = at24->write_func(at24, buf, off, count); status = at24->write_func(at24, buf, off, count);
if (status < 0) { if (status < 0) {
mutex_unlock(&at24->lock); mutex_unlock(&at24->lock);
pm_runtime_put(&client->dev); pm_runtime_put(dev);
return status; return status;
} }
buf += status; buf += status;
...@@ -650,7 +646,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) ...@@ -650,7 +646,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
mutex_unlock(&at24->lock); mutex_unlock(&at24->lock);
pm_runtime_put(&client->dev); pm_runtime_put(dev);
return 0; return 0;
} }
...@@ -880,7 +876,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -880,7 +876,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
at24->nvmem_config.reg_read = at24_read; at24->nvmem_config.reg_read = at24_read;
at24->nvmem_config.reg_write = at24_write; at24->nvmem_config.reg_write = at24_write;
at24->nvmem_config.priv = at24; at24->nvmem_config.priv = at24;
at24->nvmem_config.stride = 4; at24->nvmem_config.stride = 1;
at24->nvmem_config.word_size = 1; at24->nvmem_config.word_size = 1;
at24->nvmem_config.size = chip.byte_len; at24->nvmem_config.size = chip.byte_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment