Revert "regmap: Add bulk read/write callbacks into regmap_config"
This reverts commit 31642219f27a which is
commit d77e745613680c54708470402e2b623dcd769681 upstream.
It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.
Bug: 161946584
Change-Id: I30c32ccdd4216c9f29ca4aa5c432518c203f444f
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 93e0284..b190591 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -108,10 +108,6 @@
int (*reg_write)(void *context, unsigned int reg, unsigned int val);
int (*reg_update_bits)(void *context, unsigned int reg,
unsigned int mask, unsigned int val);
- /* Bulk read/write */
- int (*read)(void *context, const void *reg_buf, size_t reg_size,
- void *val_buf, size_t val_size);
- int (*write)(void *context, const void *data, size_t count);
bool defer_caching;
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 6adb345..ab92412 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -835,15 +835,12 @@
map->reg_stride_order = ilog2(map->reg_stride);
else
map->reg_stride_order = -1;
- map->use_single_read = config->use_single_read || !(config->read || (bus && bus->read));
- map->use_single_write = config->use_single_write || !(config->write || (bus && bus->write));
- map->can_multi_write = config->can_multi_write && (config->write || (bus && bus->write));
+ map->use_single_read = config->use_single_read || !bus || !bus->read;
+ map->use_single_write = config->use_single_write || !bus || !bus->write;
+ map->can_multi_write = config->can_multi_write && bus && bus->write;
if (bus) {
map->max_raw_read = bus->max_raw_read;
map->max_raw_write = bus->max_raw_write;
- } else if (config->max_raw_read && config->max_raw_write) {
- map->max_raw_read = config->max_raw_read;
- map->max_raw_write = config->max_raw_write;
}
map->dev = dev;
map->bus = bus;
@@ -877,16 +874,7 @@
map->read_flag_mask = bus->read_flag_mask;
}
- if (config && config->read && config->write) {
- map->reg_read = _regmap_bus_read;
-
- /* Bulk read/write */
- map->read = config->read;
- map->write = config->write;
-
- reg_endian = REGMAP_ENDIAN_NATIVE;
- val_endian = REGMAP_ENDIAN_NATIVE;
- } else if (!bus) {
+ if (!bus) {
map->reg_read = config->reg_read;
map->reg_write = config->reg_write;
map->reg_update_bits = config->reg_update_bits;
@@ -903,14 +891,11 @@
} else {
map->reg_read = _regmap_bus_read;
map->reg_update_bits = bus->reg_update_bits;
- /* Bulk read/write */
- map->read = bus->read;
- map->write = bus->write;
-
- reg_endian = regmap_get_reg_endian(bus, config);
- val_endian = regmap_get_val_endian(dev, bus, config);
}
+ reg_endian = regmap_get_reg_endian(bus, config);
+ val_endian = regmap_get_val_endian(dev, bus, config);
+
switch (config->reg_bits + map->reg_shift) {
case 2:
switch (config->val_bits) {
@@ -1683,6 +1668,8 @@
size_t len;
int i;
+ WARN_ON(!map->bus);
+
/* Check for unwritable or noinc registers in range
* before we start
*/
@@ -1764,7 +1751,7 @@
val = work_val;
}
- if (map->async && map->bus && map->bus->async_write) {
+ if (map->async && map->bus->async_write) {
struct regmap_async *async;
trace_regmap_async_write_start(map, reg, val_len);
@@ -1832,10 +1819,10 @@
* write.
*/
if (val == work_val)
- ret = map->write(map->bus_context, map->work_buf,
- map->format.reg_bytes +
- map->format.pad_bytes +
- val_len);
+ ret = map->bus->write(map->bus_context, map->work_buf,
+ map->format.reg_bytes +
+ map->format.pad_bytes +
+ val_len);
else if (map->bus->gather_write)
ret = map->bus->gather_write(map->bus_context, map->work_buf,
map->format.reg_bytes +
@@ -1854,7 +1841,7 @@
memcpy(buf, map->work_buf, map->format.reg_bytes);
memcpy(buf + map->format.reg_bytes + map->format.pad_bytes,
val, val_len);
- ret = map->write(map->bus_context, buf, len);
+ ret = map->bus->write(map->bus_context, buf, len);
kfree(buf);
} else if (ret != 0 && !map->cache_bypass && map->format.parse_val) {
@@ -1911,7 +1898,7 @@
struct regmap_range_node *range;
struct regmap *map = context;
- WARN_ON(!map->format.format_write);
+ WARN_ON(!map->bus || !map->format.format_write);
range = _regmap_range_lookup(map, reg);
if (range) {
@@ -1924,7 +1911,8 @@
trace_regmap_hw_write_start(map, reg, 1);
- ret = map->write(map->bus_context, map->work_buf, map->format.buf_size);
+ ret = map->bus->write(map->bus_context, map->work_buf,
+ map->format.buf_size);
trace_regmap_hw_write_done(map, reg, 1);
@@ -1944,7 +1932,7 @@
{
struct regmap *map = context;
- WARN_ON(!map->format.format_val);
+ WARN_ON(!map->bus || !map->format.format_val);
map->format.format_val(map->work_buf + map->format.reg_bytes
+ map->format.pad_bytes, val, 0);
@@ -1958,7 +1946,7 @@
static inline void *_regmap_map_get_context(struct regmap *map)
{
- return (map->bus || (!map->bus && map->read)) ? map : map->bus_context;
+ return (map->bus) ? map : map->bus_context;
}
int _regmap_write(struct regmap *map, unsigned int reg,
@@ -2368,7 +2356,7 @@
u8 = buf;
*u8 |= map->write_flag_mask;
- ret = map->write(map->bus_context, buf, len);
+ ret = map->bus->write(map->bus_context, buf, len);
kfree(buf);
@@ -2674,7 +2662,9 @@
struct regmap_range_node *range;
int ret;
- if (!map->read)
+ WARN_ON(!map->bus);
+
+ if (!map->bus || !map->bus->read)
return -EINVAL;
range = _regmap_range_lookup(map, reg);
@@ -2690,9 +2680,9 @@
map->read_flag_mask);
trace_regmap_hw_read_start(map, reg, val_len / map->format.val_bytes);
- ret = map->read(map->bus_context, map->work_buf,
- map->format.reg_bytes + map->format.pad_bytes,
- val, val_len);
+ ret = map->bus->read(map->bus_context, map->work_buf,
+ map->format.reg_bytes + map->format.pad_bytes,
+ val, val_len);
trace_regmap_hw_read_done(map, reg, val_len / map->format.val_bytes);
@@ -2803,6 +2793,8 @@
unsigned int v;
int ret, i;
+ if (!map->bus)
+ return -EINVAL;
if (val_len % map->format.val_bytes)
return -EINVAL;
if (!IS_ALIGNED(reg, map->reg_stride))
@@ -2817,7 +2809,7 @@
size_t chunk_count, chunk_bytes;
size_t chunk_regs = val_count;
- if (!map->read) {
+ if (!map->bus->read) {
ret = -ENOTSUPP;
goto out;
}
@@ -2877,7 +2869,7 @@
* @val: Pointer to data buffer
* @val_len: Length of output buffer in bytes.
*
- * The regmap API usually assumes that bulk read operations will read a
+ * The regmap API usually assumes that bulk bus read operations will read a
* range of registers. Some devices have certain registers for which a read
* operation read will read from an internal FIFO.
*
@@ -2895,6 +2887,10 @@
size_t read_len;
int ret;
+ if (!map->bus)
+ return -EINVAL;
+ if (!map->bus->read)
+ return -ENOTSUPP;
if (val_len % map->format.val_bytes)
return -EINVAL;
if (!IS_ALIGNED(reg, map->reg_stride))
@@ -3008,7 +3004,7 @@
if (val_count == 0)
return -EINVAL;
- if (map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
+ if (map->bus && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
ret = regmap_raw_read(map, reg, val, val_bytes * val_count);
if (ret != 0)
return ret;
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 7b76f48..2b49ce6 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -296,12 +296,6 @@
* if the function require special handling with lock and reg
* handling and the operation cannot be represented as a simple
* update_bits operation on a bus such as SPI, I2C, etc.
- * @read: Optional callback that if filled will be used to perform all the
- * bulk reads from the registers. Data is returned in the buffer used
- * to transmit data.
- * @write: Same as above for writing.
- * @max_raw_read: Max raw read size that can be used on the device.
- * @max_raw_write: Max raw write size that can be used on the device.
* @fast_io: Register IO is fast. Use a spinlock instead of a mutex
* to perform locking. This field is ignored if custom lock/unlock
* functions are used (see fields lock/unlock of struct regmap_config).
@@ -386,12 +380,6 @@
int (*reg_write)(void *context, unsigned int reg, unsigned int val);
int (*reg_update_bits)(void *context, unsigned int reg,
unsigned int mask, unsigned int val);
- /* Bulk read/write */
- int (*read)(void *context, const void *reg_buf, size_t reg_size,
- void *val_buf, size_t val_size);
- int (*write)(void *context, const void *data, size_t count);
- size_t max_raw_read;
- size_t max_raw_write;
bool fast_io;