From patchwork Thu Sep 22 17:25:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Francois Moine X-Patchwork-Id: 9347821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF8B7607D0 for ; Fri, 23 Sep 2016 09:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACCF22A94B for ; Fri, 23 Sep 2016 09:14:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1BF12A94D; Fri, 23 Sep 2016 09:14:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=2.0 tests=BAYES_00, DATE_IN_PAST_12_24, FREEMAIL_FROM,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 383312A94B for ; Fri, 23 Sep 2016 09:14:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bnMXB-0002Ae-Fd; Fri, 23 Sep 2016 09:12:41 +0000 Received: from smtp2-g21.free.fr ([212.27.42.2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bnMWL-00013S-Ic for linux-arm-kernel@lists.infradead.org; Fri, 23 Sep 2016 09:11:56 +0000 Received: from localhost (unknown [37.161.93.240]) by smtp2-g21.free.fr (Postfix) with ESMTP id E93D72003E9; Fri, 23 Sep 2016 11:11:28 +0200 (CEST) X-Mailbox-Line: From db01bc189cca1f6a5b90cbeebc8d4dc1119cb91c Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Jean-Francois Moine Date: Thu, 22 Sep 2016 19:25:23 +0200 Subject: [PATCH v3 2/4] regulator: axp20x: duplicate the MFD axp20x-rsb code To: Chen-Yu Tsai , Mark Rutland , Rob Herring X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160923_021150_037570_539FE74B X-CRM114-Status: UNSURE ( 8.96 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The axp20x rsb driver handles many different devices. Duplicating its code in a generic regulator driver permits to probe/remove individual devices. Signed-off-by: Jean-Francois Moine --- drivers/regulator/axp-regulator.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/regulator/axp-regulator.h | 6 ++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/regulator/axp-regulator.c b/drivers/regulator/axp-regulator.c index 0d7adb6..17943fb 100644 --- a/drivers/regulator/axp-regulator.c +++ b/drivers/regulator/axp-regulator.c @@ -303,6 +303,45 @@ int axp_regulator_create(struct device *dev, } EXPORT_SYMBOL_GPL(axp_regulator_create); +/* probe/remove RSB devices */ +int axp_rsb_probe(struct sunxi_rsb_device *rdev, + struct axp20x_dev *axp20x, + const struct axp_cfg *axp_cfg) +{ + int ret; + + axp20x->dev = &rdev->dev; + axp20x->irq = rdev->irq; + dev_set_drvdata(&rdev->dev, axp20x); + + ret = axp20x_match_device(axp20x); + if (ret) + return ret; + + axp20x->regmap = devm_regmap_init_sunxi_rsb(rdev, + axp20x->regmap_cfg); + if (IS_ERR(axp20x->regmap)) { + ret = PTR_ERR(axp20x->regmap); + dev_err(&rdev->dev, "regmap init failed: %d\n", ret); + return ret; + } + + ret = axp20x_device_probe(axp20x); + if (ret < 0) + return ret; + + return axp_regulator_create(&rdev->dev, axp_cfg); +} +EXPORT_SYMBOL_GPL(axp_rsb_probe); + +int axp_rsb_remove(struct sunxi_rsb_device *rdev) +{ + struct axp20x_dev *axp20x = sunxi_rsb_device_get_drvdata(rdev); + + return axp20x_device_remove(axp20x); +} +EXPORT_SYMBOL_GPL(axp_rsb_remove); + MODULE_AUTHOR("Carlo Caione "); MODULE_DESCRIPTION("Regulator Module for AXP PMIC"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/regulator/axp-regulator.h b/drivers/regulator/axp-regulator.h index 0adf1b0..085eaa0 100644 --- a/drivers/regulator/axp-regulator.h +++ b/drivers/regulator/axp-regulator.h @@ -124,4 +124,10 @@ struct axp_cfg { int axp_regulator_create(struct device *dev, const struct axp_cfg *axp_cfg); +struct sunxi_rsb_device; +int axp_rsb_probe(struct sunxi_rsb_device *rdev, + struct axp20x_dev *axp20x, + const struct axp_cfg *axp_cfg); +int axp_rsb_remove(struct sunxi_rsb_device *rdev); + #endif /* __AXP_REGULATOR_H__ */