From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752769AbbF3LCW (ORCPT ); Tue, 30 Jun 2015 07:02:22 -0400 Received: from smtp-out-020.synserver.de ([212.40.185.20]:1127 "EHLO smtp-out-020.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbbF3LCP (ORCPT ); Tue, 30 Jun 2015 07:02:15 -0400 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 19299 Message-ID: <55927732.4060207@metafoo.de> Date: Tue, 30 Jun 2015 13:02:10 +0200 From: Lars-Peter Clausen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Nicolas Boichat , Mark Brown CC: Oder Chiou , alsa-devel@alsa-project.org, Anatol Pomozov , Mauro Carvalho Chehab , Takashi Iwai , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Liam Girdwood , Antti Palosaari , Bard Liao , Arjan van de Ven , Ingo Molnar Subject: Re: [alsa-devel] [RFC PATCH 1/2] regmap: add configurable lock class key for lockdep References: <558C1824.8020204@metafoo.de> <20150625153325.GR14071@sirena.org.uk> <558C229D.4090409@metafoo.de> <20150625160817.GT14071@sirena.org.uk> <5591414D.6080802@metafoo.de> <559153A3.1000006@metafoo.de> <20150629153411.GG11162@sirena.org.uk> <20150630045655.GA38694@google.com> In-Reply-To: <20150630045655.GA38694@google.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) ...