From patchwork Wed Dec 5 12:47:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152889 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255545ljp; Wed, 5 Dec 2018 04:47:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/WltncQV8WC6bXlKdzLOVKtIL0cqj/+mUgfh9ufm6a73AZt5XBcQR/bba6+U8g/oBVFmObY X-Received: by 2002:a62:13c3:: with SMTP id 64mr24122830pft.93.1544014054516; Wed, 05 Dec 2018 04:47:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014054; cv=none; d=google.com; s=arc-20160816; b=0BZZrIW/HmeD69F+iWvvJH6tJKO0HxYJ7GjQAl3p94Jc0lakVe0Sqei5kxCwZ+AEuo sTN1m+ioqTIIZEePxmvVPAhb1wONGPi+Dtl1n1N8DVt3NQFCmnXaHwjGZ3LRCxNE8Ysc JbEQaDKmgjTOSRquh6MZBtALebaKivBsvFN6l94Yr1Uwonu9hxr0R7konjT9Kr8xkv6q 8UDvqbnorqMohivRyIkmE33oMV67w4QwZ+sxkI0o3j7f7ilhmkp0AkEykFARdRNKj2Gk kAFvfFu1i9xipM/PptNQyyPE81m1xdK/Dxg5T5Hv2p9UkHoF5+9ufeVfihuaxLfUW+PY eCRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2ZdeI+S0mKXmTl9lH41eV3IJqLOaBO08NcKqTZaINT8=; b=RSdhExwRwguOZmCHccLKTDb7uE8dge+rr0l/ys0OfbfzDmKuGUiK7SuQoEo+QrZol2 Vo6zEm/gzZBbfJ8WVEaCPGKiFpw9rnKUBHkefUZ/oSBmH/xB/oVC5dnq6ZLuUJk9mQoC OTVUSv4Z93k1gnQTk7ungYg7uHDU/gGp3XeqHZhUTyE6lroiqzeY3PRwLrUYSpQgjYLr vf2lKJoj9jyhs99XaURD2+SzNL6zu4LQS4KxL1mPyagwcK9JJGx9Fb8Yrcpilc25+Sqi Czd42N1PydERr3g7sk2Gz+TIEmLAgLmXfXC4dF5tsJYdcvj8VcYDGlj6fJPHnhJJVkHt pWwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cswpk6Te; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si17730638pgi.388.2018.12.05.04.47.34; Wed, 05 Dec 2018 04:47:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cswpk6Te; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727541AbeLEMrc (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:32 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35128 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbeLEMrb (ORCPT ); Wed, 5 Dec 2018 07:47:31 -0500 Received: by mail-lj1-f193.google.com with SMTP id x85-v6so18212733ljb.2 for ; Wed, 05 Dec 2018 04:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2ZdeI+S0mKXmTl9lH41eV3IJqLOaBO08NcKqTZaINT8=; b=Cswpk6Te3/pE48LlZcysWCgvv9a5y+lfNoMIiwnX9EAAITplyt9r3wnJm5TET/d89L T+FA/Jbsw+pM+Cfolysl3C/2hYlv6LW0aW8rTuQAL1d3ZIbhliIVDw6ROq0zJudd1lEn zS6QKnTeLtwjhm8xh+9kEOW0ef4nBOypkLhtw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2ZdeI+S0mKXmTl9lH41eV3IJqLOaBO08NcKqTZaINT8=; b=nNAuMoRLaMXUwN8UoIXknJBo0wjpTyu6Lmaq0QZ8bg4Bg1VZCQ+qdBbsdYOceVFOhm g7ioViEJBJSqWJEbqW9kvthEeklZS5JILy5TMDX7lSBTCeQR1UDb94c5p9NcWdq6jR1W nmUC1X1utXHZ9seAntWO+VnRBAwrcyvSrhLF5rWTgtFEbA9yZEkBpdyKHm+KO12OVh0R ZjGv3omQ4DfTbBX6SQ0iK7NstgoDTsEEQ1SofSA+Aeh86QncbVVQncTiTUdPzeBUYUTH fQUkkiQRn1RAks0dQWNRtKtyz8Rk3R7SBPTrGuffBI56d7N2xfurVuG9NiCLzsrUu3VY i4Mg== X-Gm-Message-State: AA+aEWZePWLMKVEJBVRge9JydhDbKVlunRafHfnJNOy9F8iMa3iv8Ax/ +NcOHO8OCZfNEZqewNqrwEYkFw== X-Received: by 2002:a2e:8007:: with SMTP id j7-v6mr16061825ljg.22.1544014048723; Wed, 05 Dec 2018 04:47:28 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:27 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 00/15 v3] Regulator ena_gpiod fixups Date: Wed, 5 Dec 2018 13:47:06 +0100 Message-Id: <20181205124721.26624-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Here is a third iteration of these fixups after thinking over Marek's remarks on the v2 version. Also available in git branch gpio-descriptors-regulator-fixup in the GPIO git tree: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/log/?h=gpio-descriptors-regulator-fixup I added two fixup item to the list: making the gpiod from of node respect nonexlusive flags and fixing the shared regulators in devm_gpiod_get*. To make sure GPIO descriptors are never left dangling (as far as I can tell!) I use this stepwise approach: 1. Fix the regulator_register() in the core to guarantee that after calling this with a valid GPIO descriptor in ena_gpiod it will be gpiod_put() if there is any problem. 2. Fix up simple descriptor consumers to just gpiod_get() and let the core take over the descriptor. Only handle the errorpath up to this point. 3. Export gpiod_get_from_of_node() and let max77686 obtain a GPIO descriptor from the device tree without any devres make-up in the DT parsing callback. 4. Make gpiod_get_from_of_node() respect the GPIOD_FLAGS_BIT_NONEXCLUSIVE flag. 5. Fix up devm_gpiod_get_* to respect the GPIOD_FLAGS_BIT_NONEXCLUSIVE flag. 6. Invent devm_gpiod_unhinge() that will remove the devres monitoring of a devm_* allocated GPIO descriptor right before handling it over to the regulator core, and use this in the otherwise hairy da9211, s5m8767, tps65090 and s2mps11 drivers. Linus Walleij (15): regulator: core: Track dangling GPIO descriptors regulator: fixed: Let core handle GPIO descriptor regulator: lm363x: Let core handle GPIO descriptor regulator: lp8788-ldo: Let core handle GPIO descriptor regulator: max8952: Let core handle GPIO descriptor regulator: max8973: Let core handle GPIO descriptor gpio: Export gpiod_get_from_of_node() regulator: max77686: Let core handle GPIO descriptor gpio: Enable nonexclusive gpiods from DT nodes gpio: devres: Handle nonexclusive GPIOs gpio: Add devm_gpiod_unhinge() regulator: da9211: Hand over GPIO to regulator core regulator: s5m8767: Hand over GPIO to regulator core regulator: tps65090: Hand over GPIO to regulator core regulator: s2mps11: Hand over GPIO to regulator core Documentation/driver-model/devres.txt | 1 + drivers/gpio/gpiolib-devres.c | 80 ++++++++++++++++++++++---- drivers/gpio/gpiolib.c | 2 + drivers/gpio/gpiolib.h | 6 -- drivers/regulator/core.c | 55 ++++++++++++++---- drivers/regulator/da9211-regulator.c | 6 ++ drivers/regulator/fixed.c | 6 +- drivers/regulator/lm363x-regulator.c | 8 ++- drivers/regulator/lp8788-ldo.c | 8 ++- drivers/regulator/max77686-regulator.c | 14 +++-- drivers/regulator/max8952.c | 10 +++- drivers/regulator/max8973-regulator.c | 23 +++++--- drivers/regulator/s2mps11.c | 7 ++- drivers/regulator/s5m8767.c | 9 ++- drivers/regulator/tps65090-regulator.c | 6 ++ include/linux/gpio/consumer.h | 23 ++++++++ 16 files changed, 214 insertions(+), 50 deletions(-) -- 2.19.2