Skip to content

Commit

Permalink
Merge tag 'regmap-fix-v5.19-rc3' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/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()
  • Loading branch information
Linus Torvalds committed Jun 24, 2022
2 parents bc3b897 + 3f05010 commit 7bc8354
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
8 changes: 5 additions & 3 deletions drivers/base/regmap/regmap-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *map = d->map;
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;

type = irq_data->type.type_falling_val | irq_data->type.type_rising_val;
Expand All @@ -268,14 +269,14 @@ static void regmap_irq_enable(struct irq_data *data)
* at the corresponding offset in regmap_irq_set_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
mask = irq_data->mask;

if (d->chip->clear_on_unmask)
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)
Expand Down Expand Up @@ -386,6 +387,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
subreg = &chip->sub_reg_offsets[b];
for (i = 0; i < subreg->num_regs; i++) {
unsigned int offset = subreg->offset[i];
unsigned int index = offset / map->reg_stride;

if (chip->not_fixed_stride)
ret = regmap_read(map,
Expand All @@ -394,7 +396,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
else
ret = regmap_read(map,
chip->status_base + offset,
&data->status_buf[offset]);
&data->status_buf[index]);

if (ret)
break;
Expand Down
15 changes: 8 additions & 7 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1880,8 +1880,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
*/
bool regmap_can_raw_write(struct regmap *map)
{
return map->bus && map->bus->write && map->format.format_val &&
map->format.format_reg;
return map->write && map->format.format_val && map->format.format_reg;
}
EXPORT_SYMBOL_GPL(regmap_can_raw_write);

Expand Down Expand Up @@ -2155,10 +2154,9 @@ int regmap_noinc_write(struct regmap *map, unsigned int reg,
size_t write_len;
int ret;

if (!map->bus)
return -EINVAL;
if (!map->bus->write)
if (!map->write)
return -ENOTSUPP;

if (val_len % map->format.val_bytes)
return -EINVAL;
if (!IS_ALIGNED(reg, map->reg_stride))
Expand Down Expand Up @@ -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
* single write operations.
*/
if (!map->bus || !map->format.parse_inplace) {
if (!map->write || !map->format.parse_inplace) {
map->lock(map->lock_arg);
for (i = 0; i < val_count; i++) {
unsigned int ival;
Expand Down Expand Up @@ -2904,6 +2902,9 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg,
size_t read_len;
int ret;

if (!map->read)
return -ENOTSUPP;

if (val_len % map->format.val_bytes)
return -EINVAL;
if (!IS_ALIGNED(reg, map->reg_stride))
Expand Down Expand Up @@ -3017,7 +3018,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
if (val_count == 0)
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);
if (ret != 0)
return ret;
Expand Down

0 comments on commit 7bc8354

Please sign in to comment.