From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755495Ab2LLVyT (ORCPT ); Wed, 12 Dec 2012 16:54:19 -0500 Received: from mail-pb0-f46.google.com ([209.85.160.46]:64448 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754602Ab2LLVyO (ORCPT ); Wed, 12 Dec 2012 16:54:14 -0500 Date: Wed, 12 Dec 2012 13:54:04 -0800 From: Greg Kroah-Hartman To: Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij , Felipe Balbi , Benoit Cousson , Dmitry Torokhov , Thomas Petazzoni , Mitch Bradley , Mark Brown , Ulf Hansson , "Rafael J. Wysocki" , Kevin Hilman , Jean-Christophe PLAGNIOL-VILLARD , Rickard Andersson , Russell King Subject: Re: [PATCH v2] drivers/pinctrl: grab default handles from device core Message-ID: <20121212215404.GA18555@kroah.com> References: <1355343907-11535-1-git-send-email-linus.walleij@stericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1355343907-11535-1-git-send-email-linus.walleij@stericsson.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 12, 2012 at 09:25:07PM +0100, Linus Walleij wrote: > From: Linus Walleij > > This makes the device core auto-grab the pinctrl handle and set > the "default" (PINCTRL_STATE_DEFAULT) state for every device > that is present in the device model right before probe. This will > account for the lion's share of embedded silicon devcies. > > A modification of the semantics for pinctrl_get() is also done: > previously if the pinctrl handle for a certain device was already > taken, the pinctrl core would return an error. Now, since the > core may have already default-grabbed the handle and set its > state to "default", if the handle was already taken, this will > be disregarded and the located, previously instanitated handle > will be returned to the caller. > > This way all code in drivers explicitly requesting their pinctrl > handlers will still be functional, and drivers that want to > explicitly retrieve and switch their handles can still do that. > But if the desired functionality is just boilerplate of this > type in the probe() function: > > struct pinctrl *p; > > p = devm_pinctrl_get_select_default(&dev); > if (IS_ERR(p)) { > if (PTR_ERR(p) == -EPROBE_DEFER) > return -EPROBE_DEFER; > dev_warn(&dev, "no pinctrl handle\n"); > } > > The discussion began with the addition of such boilerplate > to the omap4 keypad driver: > http://marc.info/?l=linux-input&m=135091157719300&w=2 > > A previous approach using notifiers was discussed: > http://marc.info/?l=linux-kernel&m=135263661110528&w=2 > This failed because it could not handle deferred probes. > > This patch alone does not solve the entire dilemma faced: > whether code should be distributed into the drivers or > if it should be centralized to e.g. a PM domain. But it > solves the immediate issue of the addition of boilerplate > to a lot of drivers that just want to grab the default > state. As mentioned, they can later explicitly retrieve > the handle and set different states, and this could as > well be done by e.g. PM domains as it is only related > to a certain struct device * pointer. > > Cc: Felipe Balbi > Cc: Benoit Cousson > Cc: Dmitry Torokhov > Cc: Thomas Petazzoni > Cc: Mitch Bradley > Cc: Mark Brown > Cc: Ulf Hansson > Cc: Rafael J. Wysocki > Cc: Kevin Hilman > Cc: Jean-Christophe PLAGNIOL-VILLARD > Cc: Rickard Andersson > Cc: Greg Kroah-Hartman > Cc: Russell King > Signed-off-by: Linus Walleij > --- > ChangeLog v1->v2: > - Only store a pointer in the device struct, and only allocate > this if it's really used by the device. > - Seeking ACK on this from Greg (and others who like it) so I > can merge it through the pinctrl subsystem. It looks ok, but this can't go in for 3.8, sorry, please wait for 3.9. greg k-h