Re: [PATCH 1/2] regmap: cache: Do not panic for REGCACHE_NONE regmap

From: Alexander Stein
Date: Fri Mar 10 2023 - 08:35:24 EST


Hi Mark,

Am Freitag, 10. März 2023, 14:02:13 CET schrieb Mark Brown:
> * PGP Signed by an unknown key
>
> On Fri, Mar 10, 2023 at 08:39:10AM +0100, Alexander Stein wrote:
> > Most regcache operations do check for REGCACHE_NONE, before ensuring
> > doing BUG_ON(!map->cache_ops). The missing regcache_sync* functions
> > panic on REGCACHE_NONE regmaps instead. Add an early return for non-cached
> > ones.
>
> Why would we be trying to do a regcache_sync() on a device with
> no cache?

Indeed, that makes no sense. That's indicating a bug in a driver, but why do
we need to panic the kernel in this case?
On the other hand the same question applies to other regcache related
functions currently checking for non-cached maps. There is no common
behaviour:

panic:
* regcache_sync
* regcache_sync_region

returning -EINVAL:
* regcache_drop_region

returning -ENOSYS:
* regcache_read

returning success (0):
* regcache_write

early return (void return value):
* regcache_exit

Given all these possibilities I have no idea what's the right thing to do.

Best regards,
Alexander

--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/