Commit 7bc83546 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regmap-fix-v5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull regmap fixes from Mark Brown:
 "Two sets of fixes - one for things that were missed with the support
  for custom bulk I/O operations introduced in the last merge window,
  and another for some long standing issues with regmap-irq which affect
  a fairly small subset of devices"

* tag 'regmap-fix-v5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
  regmap-irq: Fix offset/index mismatch in read_sub_irq_data()
  regmap-irq: Fix a bug in regmap_irq_enable() for type_in_mask chips
  regmap: Wire up regmap_config provided bulk write in missed functions
  regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set
  regmap: Re-introduce bulk read support check in regmap_bulk_read()
parents bc3b8977 3f05010f
...@@ -252,6 +252,7 @@ static void regmap_irq_enable(struct irq_data *data) ...@@ -252,6 +252,7 @@ static void regmap_irq_enable(struct irq_data *data)
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
struct regmap *map = d->map; struct regmap *map = d->map;
const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq); const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
unsigned int reg = irq_data->reg_offset / map->reg_stride;
unsigned int mask, type; unsigned int mask, type;
type = irq_data->type.type_falling_val | irq_data->type.type_rising_val; type = irq_data->type.type_falling_val | irq_data->type.type_rising_val;
...@@ -268,14 +269,14 @@ static void regmap_irq_enable(struct irq_data *data) ...@@ -268,14 +269,14 @@ static void regmap_irq_enable(struct irq_data *data)
* at the corresponding offset in regmap_irq_set_type(). * at the corresponding offset in regmap_irq_set_type().
*/ */
if (d->chip->type_in_mask && type) if (d->chip->type_in_mask && type)
mask = d->type_buf[irq_data->reg_offset / map->reg_stride]; mask = d->type_buf[reg] & irq_data->mask;
else else
mask = irq_data->mask; mask = irq_data->mask;
if (d->chip->clear_on_unmask) if (d->chip->clear_on_unmask)
d->clear_status = true; d->clear_status = true;
d->mask_buf[irq_data->reg_offset / map->reg_stride] &= ~mask; d->mask_buf[reg] &= ~mask;
} }
static void regmap_irq_disable(struct irq_data *data) static void regmap_irq_disable(struct irq_data *data)
...@@ -386,6 +387,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data, ...@@ -386,6 +387,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
subreg = &chip->sub_reg_offsets[b]; subreg = &chip->sub_reg_offsets[b];
for (i = 0; i < subreg->num_regs; i++) { for (i = 0; i < subreg->num_regs; i++) {
unsigned int offset = subreg->offset[i]; unsigned int offset = subreg->offset[i];
unsigned int index = offset / map->reg_stride;
if (chip->not_fixed_stride) if (chip->not_fixed_stride)
ret = regmap_read(map, ret = regmap_read(map,
...@@ -394,7 +396,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data, ...@@ -394,7 +396,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
else else
ret = regmap_read(map, ret = regmap_read(map,
chip->status_base + offset, chip->status_base + offset,
&data->status_buf[offset]); &data->status_buf[index]);
if (ret) if (ret)
break; break;
......
...@@ -1880,8 +1880,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg, ...@@ -1880,8 +1880,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
*/ */
bool regmap_can_raw_write(struct regmap *map) bool regmap_can_raw_write(struct regmap *map)
{ {
return map->bus && map->bus->write && map->format.format_val && return map->write && map->format.format_val && map->format.format_reg;
map->format.format_reg;
} }
EXPORT_SYMBOL_GPL(regmap_can_raw_write); EXPORT_SYMBOL_GPL(regmap_can_raw_write);
...@@ -2155,10 +2154,9 @@ int regmap_noinc_write(struct regmap *map, unsigned int reg, ...@@ -2155,10 +2154,9 @@ int regmap_noinc_write(struct regmap *map, unsigned int reg,
size_t write_len; size_t write_len;
int ret; int ret;
if (!map->bus) if (!map->write)
return -EINVAL;
if (!map->bus->write)
return -ENOTSUPP; return -ENOTSUPP;
if (val_len % map->format.val_bytes) if (val_len % map->format.val_bytes)
return -EINVAL; return -EINVAL;
if (!IS_ALIGNED(reg, map->reg_stride)) if (!IS_ALIGNED(reg, map->reg_stride))
...@@ -2278,7 +2276,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, ...@@ -2278,7 +2276,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
* Some devices don't support bulk write, for them we have a series of * Some devices don't support bulk write, for them we have a series of
* single write operations. * single write operations.
*/ */
if (!map->bus || !map->format.parse_inplace) { if (!map->write || !map->format.parse_inplace) {
map->lock(map->lock_arg); map->lock(map->lock_arg);
for (i = 0; i < val_count; i++) { for (i = 0; i < val_count; i++) {
unsigned int ival; unsigned int ival;
...@@ -2904,6 +2902,9 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg, ...@@ -2904,6 +2902,9 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg,
size_t read_len; size_t read_len;
int ret; int ret;
if (!map->read)
return -ENOTSUPP;
if (val_len % map->format.val_bytes) if (val_len % map->format.val_bytes)
return -EINVAL; return -EINVAL;
if (!IS_ALIGNED(reg, map->reg_stride)) if (!IS_ALIGNED(reg, map->reg_stride))
...@@ -3017,7 +3018,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, ...@@ -3017,7 +3018,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
if (val_count == 0) if (val_count == 0)
return -EINVAL; return -EINVAL;
if (map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) { if (map->read && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
ret = regmap_raw_read(map, reg, val, val_bytes * val_count); ret = regmap_raw_read(map, reg, val, val_bytes * val_count);
if (ret != 0) if (ret != 0)
return ret; return ret;
......
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