Re: [PATCH RFC 2/4] regcache: use the regmap scoped lock guard

From: Peng Fan

Date: Mon Sep 21 2026 - 20:28:21 EST


Hi Mark,

On Mon, Sep 21, 2026 at 11:19:29AM +0200, Mark Brown wrote:
>On Mon, Sep 21, 2026 at 02:03:34PM +0800, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@xxxxxxx>
>>
>> Convert the open-coded map->lock()/map->unlock() users in regcache.c
>> to the regmap scoped guard introduced for regmap.c. Use
>> scoped_guard(regmap, ...) where the locked region is a subsection of
>
>> @@ -432,73 +428,69 @@ int regcache_sync(struct regmap *map)
>
>> + for (i = 0; i < map->patch_regs; i++) {
>> + sync_ret = _regmap_write(map, map->patch[i].reg, map->patch[i].def);
>> + if (sync_ret != 0) {
>> + dev_err(map->dev, "Failed to write %x = %x: %d\n",
>> + map->patch[i].reg, map->patch[i].def, sync_ret);
>> + goto out;
>> + }
>> }
>
>This has the mixing scoped guard and goto thing I keep raising.

The logic is as:
scoped_guard(regmap, map) {
if (xy)
goto out;
out:
yz;
}

The out is still in the scoped_guard region, so no issue per my understanding.

But indeed, it is not good to have goto in scoped_guard. V2 will not have
scoped_guard and goto mixed.

Thanks
Peng