History

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()

Linus Torvalds committed 4 years ago

Commit 7bc83542 parents bc3b897 3f050102 files · +13 −10Browse files

Unified · Split

2 files
  1. drivers/base/regmap/regmap-irq.c +5 −3
  2. drivers/base/regmap/regmap.c +8 −7
drivers/base/regmap/regmap-irq.c+5−3
@@ -252,6 +252,7 @@ static void regmap_irq_enable(struct irq_data *data) · 251 unmodified lines
252252 struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
253253 struct regmap *map = d->map;
254254 const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
255+ unsigned int reg = irq_data->reg_offset / map->reg_stride;
255256 unsigned int mask, type;
256257
257258 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) · 10 unmodified lines
268269 * at the corresponding offset in regmap_irq_set_type().
269270 */
270271 if (d->chip->type_in_mask && type)
271− mask = d->type_buf[irq_data->reg_offset / map->reg_stride];
272+ mask = d->type_buf[reg] & irq_data->mask;
272273 else
273274 mask = irq_data->mask;
274275
275276 if (d->chip->clear_on_unmask)
276277 d->clear_status = true;
277278
278− d->mask_buf[irq_data->reg_offset / map->reg_stride] &= ~mask;
279+ d->mask_buf[reg] &= ~mask;
279280 }
280281
281282 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, · 104 unmodified lines
386387 subreg = &chip->sub_reg_offsets[b];
387388 for (i = 0; i < subreg->num_regs; i++) {
388389 unsigned int offset = subreg->offset[i];
390+ unsigned int index = offset / map->reg_stride;
389391
390392 if (chip->not_fixed_stride)
391393 ret = regmap_read(map,
@@ -394,7 +396,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data, · 2 unmodified lines
394396 else
395397 ret = regmap_read(map,
396398 chip->status_base + offset,
397− &data->status_buf[offset]);
399+ &data->status_buf[index]);
398400
399401 if (ret)
400402 break;
drivers/base/regmap/regmap.c+8−7
@@ -1880,8 +1880,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg, · 1879 unmodified lines
18801880 */
18811881 bool regmap_can_raw_write(struct regmap *map)
18821882 {
1883− return map->bus && map->bus->write && map->format.format_val &&
1884− map->format.format_reg;
1883+ return map->write && map->format.format_val && map->format.format_reg;
18851884 }
18861885 EXPORT_SYMBOL_GPL(regmap_can_raw_write);
18871886
@@ -2155,10 +2154,9 @@ int regmap_noinc_write(struct regmap *map, unsigned int reg, · 267 unmodified lines
21552154 size_t write_len;
21562155 int ret;
21572156
2158− if (!map->bus)
2159− return -EINVAL;
2160− if (!map->bus->write)
2157+ if (!map->write)
21612158 return -ENOTSUPP;
2159+
21622160 if (val_len % map->format.val_bytes)
21632161 return -EINVAL;
21642162 if (!IS_ALIGNED(reg, map->reg_stride))
@@ -2278,7 +2276,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, · 113 unmodified lines
22782276 * Some devices don't support bulk write, for them we have a series of
22792277 * single write operations.
22802278 */
2281− if (!map->bus || !map->format.parse_inplace) {
2279+ if (!map->write || !map->format.parse_inplace) {
22822280 map->lock(map->lock_arg);
22832281 for (i = 0; i < val_count; i++) {
22842282 unsigned int ival;
@@ -2904,6 +2902,9 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg, · 619 unmodified lines
29042902 size_t read_len;
29052903 int ret;
29062904
2905+ if (!map->read)
2906+ return -ENOTSUPP;
2907+
29072908 if (val_len % map->format.val_bytes)
29082909 return -EINVAL;
29092910 if (!IS_ALIGNED(reg, map->reg_stride))
@@ -3017,7 +3018,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, · 107 unmodified lines
30173018 if (val_count == 0)
30183019 return -EINVAL;
30193020
3020− if (map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
3021+ if (map->read && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
30213022 ret = regmap_raw_read(map, reg, val, val_bytes * val_count);
30223023 if (ret != 0)
30233024 return ret;