Skip to content

Commit eaba4f6

Browse files
committed
Merge remote-tracking branch 'regmap/for-next' into sound/upstream-20260722
2 parents 6514127 + 9346394 commit eaba4f6

7 files changed

Lines changed: 59 additions & 25 deletions

File tree

drivers/base/regmap/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ struct regcache_ops {
189189
const char *name;
190190
enum regcache_type type;
191191
int (*init)(struct regmap *map);
192-
int (*exit)(struct regmap *map);
192+
void (*exit)(struct regmap *map);
193193
int (*populate)(struct regmap *map);
194194
#ifdef CONFIG_DEBUG_FS
195195
void (*debugfs_init)(struct regmap *map);

drivers/base/regmap/regcache-flat.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int regcache_flat_init(struct regmap *map)
5353
return -ENOMEM;
5454
}
5555

56-
static int regcache_flat_exit(struct regmap *map)
56+
static void regcache_flat_exit(struct regmap *map)
5757
{
5858
struct regcache_flat_data *cache = map->cache;
5959

@@ -62,8 +62,6 @@ static int regcache_flat_exit(struct regmap *map)
6262

6363
kfree(cache);
6464
map->cache = NULL;
65-
66-
return 0;
6765
}
6866

6967
static int regcache_flat_populate(struct regmap *map)

drivers/base/regmap/regcache-maple.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
112112
unsigned long *entry, *lower, *upper;
113113
/* initialized to work around false-positive -Wuninitialized warning */
114114
unsigned long lower_index = 0, lower_last = 0;
115-
unsigned long upper_index, upper_last;
115+
unsigned long upper_index = 0, upper_last = 0;
116116
int ret = 0;
117117

118118
lower = NULL;
@@ -307,15 +307,15 @@ static int regcache_maple_init(struct regmap *map)
307307
return 0;
308308
}
309309

310-
static int regcache_maple_exit(struct regmap *map)
310+
static void regcache_maple_exit(struct regmap *map)
311311
{
312312
struct maple_tree *mt = map->cache;
313313
MA_STATE(mas, mt, 0, UINT_MAX);
314314
unsigned int *entry;
315315

316316
/* if we've already been called then just return */
317317
if (!mt)
318-
return 0;
318+
return;
319319

320320
mas_lock(&mas);
321321
mas_for_each(&mas, entry, UINT_MAX)
@@ -325,8 +325,6 @@ static int regcache_maple_exit(struct regmap *map)
325325

326326
kfree(mt);
327327
map->cache = NULL;
328-
329-
return 0;
330328
}
331329

332330
static int regcache_maple_insert_block(struct regmap *map, int first,

drivers/base/regmap/regcache-rbtree.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
1818
unsigned int value);
19-
static int regcache_rbtree_exit(struct regmap *map);
19+
static void regcache_rbtree_exit(struct regmap *map);
2020

2121
struct regcache_rbtree_node {
2222
/* block of adjacent registers */
@@ -196,7 +196,7 @@ static int regcache_rbtree_init(struct regmap *map)
196196
return 0;
197197
}
198198

199-
static int regcache_rbtree_exit(struct regmap *map)
199+
static void regcache_rbtree_exit(struct regmap *map)
200200
{
201201
struct rb_node *next;
202202
struct regcache_rbtree_ctx *rbtree_ctx;
@@ -205,7 +205,7 @@ static int regcache_rbtree_exit(struct regmap *map)
205205
/* if we've already been called then just return */
206206
rbtree_ctx = map->cache;
207207
if (!rbtree_ctx)
208-
return 0;
208+
return;
209209

210210
/* free up the rbtree */
211211
next = rb_first(&rbtree_ctx->root);
@@ -221,8 +221,6 @@ static int regcache_rbtree_exit(struct regmap *map)
221221
/* release the resources */
222222
kfree(map->cache);
223223
map->cache = NULL;
224-
225-
return 0;
226224
}
227225

228226
static int regcache_rbtree_populate(struct regmap *map)

drivers/base/regmap/regcache.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,16 @@ static int rbtree_all(const void *key, const struct rb_node *node)
397397
* volatile. In general drivers can choose not to use the provided
398398
* syncing functionality if they so require.
399399
*
400+
* This pushes cached changes made while cache_only (e.g. suspend) down
401+
* to hardware. The caller must disable cache_only before calling this
402+
* function.
403+
*
400404
* Return a negative value on failure, 0 on success.
401405
*/
402406
int regcache_sync(struct regmap *map)
403407
{
404-
int ret = 0;
408+
int sync_ret = 0;
409+
int selector_ret = 0;
405410
unsigned int i;
406411
const char *name;
407412
bool bypass;
@@ -413,6 +418,12 @@ int regcache_sync(struct regmap *map)
413418
BUG_ON(!map->cache_ops);
414419

415420
map->lock(map->lock_arg);
421+
422+
if (WARN_ON(map->cache_only)) {
423+
map->unlock(map->lock_arg);
424+
return -EINVAL;
425+
}
426+
416427
/* Remember the initial bypass state */
417428
bypass = map->cache_bypass;
418429
dev_dbg(map->dev, "Syncing %s cache\n",
@@ -426,21 +437,21 @@ int regcache_sync(struct regmap *map)
426437
/* Apply any patch first */
427438
map->cache_bypass = true;
428439
for (i = 0; i < map->patch_regs; i++) {
429-
ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def);
430-
if (ret != 0) {
440+
sync_ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def);
441+
if (sync_ret != 0) {
431442
dev_err(map->dev, "Failed to write %x = %x: %d\n",
432-
map->patch[i].reg, map->patch[i].def, ret);
443+
map->patch[i].reg, map->patch[i].def, sync_ret);
433444
goto out;
434445
}
435446
}
436447
map->cache_bypass = false;
437448

438449
if (map->cache_ops->sync)
439-
ret = map->cache_ops->sync(map, 0, map->max_register);
450+
sync_ret = map->cache_ops->sync(map, 0, map->max_register);
440451
else
441-
ret = regcache_default_sync(map, 0, map->max_register);
452+
sync_ret = regcache_default_sync(map, 0, map->max_register);
442453

443-
if (ret == 0)
454+
if (sync_ret == 0)
444455
map->cache_dirty = false;
445456

446457
out:
@@ -462,10 +473,11 @@ int regcache_sync(struct regmap *map)
462473
if (regcache_read(map, this->selector_reg, &i) != 0)
463474
continue;
464475

465-
ret = _regmap_write(map, this->selector_reg, i);
466-
if (ret != 0) {
476+
selector_ret = _regmap_write(map, this->selector_reg, i);
477+
if (selector_ret != 0) {
478+
map->cache_dirty = true;
467479
dev_err(map->dev, "Failed to write %x = %x: %d\n",
468-
this->selector_reg, i, ret);
480+
this->selector_reg, i, selector_ret);
469481
break;
470482
}
471483
}
@@ -476,7 +488,7 @@ int regcache_sync(struct regmap *map)
476488

477489
trace_regcache_sync(map, name, "stop");
478490

479-
return ret;
491+
return sync_ret ? sync_ret : selector_ret;
480492
}
481493
EXPORT_SYMBOL_GPL(regcache_sync);
482494

@@ -506,6 +518,10 @@ int regcache_sync_region(struct regmap *map, unsigned int min,
506518

507519
map->lock(map->lock_arg);
508520

521+
if (WARN_ON(map->cache_only)) {
522+
map->unlock(map->lock_arg);
523+
return -EINVAL;
524+
}
509525
/* Remember the initial bypass state */
510526
bypass = map->cache_bypass;
511527

drivers/base/regmap/regmap-irq.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,35 @@ static int regmap_irq_set_wake(struct irq_data *data, unsigned int on)
296296
return 0;
297297
}
298298

299+
static int regmap_irq_reqres(struct irq_data *data)
300+
{
301+
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
302+
irq_hw_number_t hwirq = irqd_to_hwirq(data);
303+
304+
if (d->chip->irq_reqres)
305+
return d->chip->irq_reqres(d->chip->irq_drv_data, hwirq);
306+
307+
return 0;
308+
}
309+
310+
static void regmap_irq_relres(struct irq_data *data)
311+
{
312+
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
313+
irq_hw_number_t hwirq = irqd_to_hwirq(data);
314+
315+
if (d->chip->irq_relres)
316+
d->chip->irq_relres(d->chip->irq_drv_data, hwirq);
317+
}
318+
299319
static const struct irq_chip regmap_irq_chip = {
300320
.irq_bus_lock = regmap_irq_lock,
301321
.irq_bus_sync_unlock = regmap_irq_sync_unlock,
302322
.irq_disable = regmap_irq_disable,
303323
.irq_enable = regmap_irq_enable,
304324
.irq_set_type = regmap_irq_set_type,
305325
.irq_set_wake = regmap_irq_set_wake,
326+
.irq_request_resources = regmap_irq_reqres,
327+
.irq_release_resources = regmap_irq_relres,
306328
};
307329

308330
static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,

include/linux/regmap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,8 @@ struct regmap_irq_chip {
17701770
void *irq_drv_data);
17711771
unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
17721772
unsigned int base, int index);
1773+
int (*irq_reqres)(void *irq_drv_data, irq_hw_number_t hwirq);
1774+
void (*irq_relres)(void *irq_drv_data, irq_hw_number_t hwirq);
17731775
void *irq_drv_data;
17741776
};
17751777

0 commit comments

Comments
 (0)