Re: [alsa-devel] [RFC PATCH 1/2] regmap: add configurable lock class key for lockdep

From: Lars-Peter Clausen
Date: Tue Jun 30 2015 - 07:02:26 EST


On 06/30/2015 06:56 AM, Nicolas Boichat wrote:
On Mon, Jun 29, 2015 at 04:34:11PM +0100, Mark Brown wrote:
On Mon, Jun 29, 2015 at 04:18:11PM +0200, Lars-Peter Clausen wrote:
Leaves us pretty much with only two options. Either add a lock key pointer
to regmap_config which needs to be manually initialized. Or wrap all
regmap_init() variants to create a static lock key. I'd slightly prefer the
later. We can avoid most of the boiler-plate code by using some helper
macros to generate the wrappers.

It's better to keep the bodges in the core, yes.

Partial attempt below. Of course all other _init functions will need to be
converted as well. I'd like to get feedback before I do the rest of the work.

Looks good to me.

The macro part is quite repetitive and I don't think it can be simplified.

How about something like

#ifdef CONFIG_LOCKDEP

#define regmap_lockdep_wrapper(fn, ...) \
( \
({ \
static struct lock_class_key _key; \
fn(__VA_ARGS__, &_key, \
KBUILD_BASENAME ":" \
__stringify(__LINE__) ":" \
"(" #config ")->_lock"); \
}) \
)

#else
#define regmap_lockdep_wrapper(fn, ...) fn(__VA_ARGS__, NULL, NULL)
#endif

#define regmap_init_i2c(i2c, config) \
regmap_lockdep_wrapper(__regmap_init_i2c, i2c, config)
...


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/