Skip to content

Commit a87cd38

Browse files
committed
Merge remote-tracking branch 'regmap/for-7.3' into regmap-next
2 parents 4b05ccb + ef4f235 commit a87cd38

7 files changed

Lines changed: 67 additions & 27 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
@@ -412,11 +412,16 @@ static int rbtree_all(const void *key, const struct rb_node *node)
412412
* volatile. In general drivers can choose not to use the provided
413413
* syncing functionality if they so require.
414414
*
415+
* This pushes cached changes made while cache_only (e.g. suspend) down
416+
* to hardware. The caller must disable cache_only before calling this
417+
* function.
418+
*
415419
* Return a negative value on failure, 0 on success.
416420
*/
417421
int regcache_sync(struct regmap *map)
418422
{
419-
int ret = 0;
423+
int sync_ret = 0;
424+
int selector_ret = 0;
420425
unsigned int i;
421426
const char *name;
422427
bool bypass;
@@ -428,6 +433,12 @@ int regcache_sync(struct regmap *map)
428433
BUG_ON(!map->cache_ops);
429434

430435
map->lock(map->lock_arg);
436+
437+
if (WARN_ON(map->cache_only)) {
438+
map->unlock(map->lock_arg);
439+
return -EINVAL;
440+
}
441+
431442
/* Remember the initial bypass state */
432443
bypass = map->cache_bypass;
433444
dev_dbg(map->dev, "Syncing %s cache\n",
@@ -441,21 +452,21 @@ int regcache_sync(struct regmap *map)
441452
/* Apply any patch first */
442453
map->cache_bypass = true;
443454
for (i = 0; i < map->patch_regs; i++) {
444-
ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def);
445-
if (ret != 0) {
455+
sync_ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def);
456+
if (sync_ret != 0) {
446457
dev_err(map->dev, "Failed to write %x = %x: %d\n",
447-
map->patch[i].reg, map->patch[i].def, ret);
458+
map->patch[i].reg, map->patch[i].def, sync_ret);
448459
goto out;
449460
}
450461
}
451462
map->cache_bypass = false;
452463

453464
if (map->cache_ops->sync)
454-
ret = map->cache_ops->sync(map, 0, map->max_register);
465+
sync_ret = map->cache_ops->sync(map, 0, map->max_register);
455466
else
456-
ret = regcache_default_sync(map, 0, map->max_register);
467+
sync_ret = regcache_default_sync(map, 0, map->max_register);
457468

458-
if (ret == 0)
469+
if (sync_ret == 0)
459470
map->cache_dirty = false;
460471

461472
out:
@@ -477,10 +488,11 @@ int regcache_sync(struct regmap *map)
477488
if (regcache_read(map, this->selector_reg, &i) != 0)
478489
continue;
479490

480-
ret = _regmap_write(map, this->selector_reg, i);
481-
if (ret != 0) {
491+
selector_ret = _regmap_write(map, this->selector_reg, i);
492+
if (selector_ret != 0) {
493+
map->cache_dirty = true;
482494
dev_err(map->dev, "Failed to write %x = %x: %d\n",
483-
this->selector_reg, i, ret);
495+
this->selector_reg, i, selector_ret);
484496
break;
485497
}
486498
}
@@ -491,7 +503,7 @@ int regcache_sync(struct regmap *map)
491503

492504
trace_regcache_sync(map, name, "stop");
493505

494-
return ret;
506+
return sync_ret ? sync_ret : selector_ret;
495507
}
496508
EXPORT_SYMBOL_GPL(regcache_sync);
497509

@@ -521,6 +533,10 @@ int regcache_sync_region(struct regmap *map, unsigned int min,
521533

522534
map->lock(map->lock_arg);
523535

536+
if (WARN_ON(map->cache_only)) {
537+
map->unlock(map->lock_arg);
538+
return -EINVAL;
539+
}
524540
/* Remember the initial bypass state */
525541
bypass = map->cache_bypass;
526542

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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ typedef void (*regmap_hw_free_context)(void *context);
587587
* must serialise with respect to non-async I/O.
588588
* @reg_write: Write a single register value to the given register address. This
589589
* write operation has to complete when returning from the function.
590-
* @reg_write_noinc: Write multiple register value to the same register. This
590+
* @reg_noinc_write: Write multiple register values to the same register. This
591591
* write operation has to complete when returning from the function.
592592
* @reg_update_bits: Update bits operation to be used against volatile
593593
* registers, intended for devices supporting some mechanism
@@ -596,6 +596,8 @@ typedef void (*regmap_hw_free_context)(void *context);
596596
* @read: Read operation. Data is returned in the buffer used to transmit
597597
* data.
598598
* @reg_read: Read a single register value from a given register address.
599+
* @reg_noinc_read: Read multiple register values from the same register. This
600+
* read operation has to complete when returning from the function.
599601
* @free_context: Free context.
600602
* @async_alloc: Allocate a regmap_async() structure.
601603
* @read_flag_mask: Mask to be set in the top byte of the register when doing
@@ -991,7 +993,8 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
991993
/**
992994
* regmap_init_sdw_mbq_cfg() - Initialise MBQ SDW register map with config
993995
*
994-
* @sdw: Device that will be interacted with
996+
* @dev: &struct device that will be interacted with
997+
* @sdw: Soundwire device that will be interacted with
995998
* @config: Configuration for register map
996999
* @mbq_config: Properties for the MBQ registers
9971000
*
@@ -1584,6 +1587,7 @@ regmap_fields_force_update_bits(struct regmap_field *field, unsigned int id,
15841587
* struct regmap_irq_type - IRQ type definitions.
15851588
*
15861589
* @type_reg_offset: Offset register for the irq type setting.
1590+
* @type_reg_mask: Device interrupt mask
15871591
* @type_rising_val: Register value to configure RISING type irq.
15881592
* @type_falling_val: Register value to configure FALLING type irq.
15891593
* @type_level_low_val: Register value to configure LEVEL_LOW type irq.
@@ -1717,6 +1721,8 @@ struct regmap_irq_chip_data;
17171721
* main status base, [0, num_config_regs[ for any config
17181722
* register base, and [0, num_regs[ for any other base.
17191723
* If unspecified then regmap_irq_get_irq_reg_linear() is used.
1724+
* @irq_reqres: Callback function to request IRQ resources (may be %NULL)
1725+
* @irq_relres: Callback function to release IRQ resources (may be %NULL)
17201726
* @irq_drv_data: Driver specific IRQ data which is passed as parameter when
17211727
* driver specific pre/post interrupt handler is called.
17221728
*
@@ -1770,6 +1776,8 @@ struct regmap_irq_chip {
17701776
void *irq_drv_data);
17711777
unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
17721778
unsigned int base, int index);
1779+
int (*irq_reqres)(void *irq_drv_data, irq_hw_number_t hwirq);
1780+
void (*irq_relres)(void *irq_drv_data, irq_hw_number_t hwirq);
17731781
void *irq_drv_data;
17741782
};
17751783

0 commit comments

Comments
 (0)