From patchwork Mon Feb 10 15:22:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3619251 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 344F99F2D6 for ; Mon, 10 Feb 2014 15:35:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A469201D3 for ; Mon, 10 Feb 2014 15:35:51 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4542320148 for ; Mon, 10 Feb 2014 15:35:50 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCstb-0006dP-Pr; Mon, 10 Feb 2014 15:35:43 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCsok-0007x9-28; Mon, 10 Feb 2014 15:30:42 +0000 Received: from mail-ea0-f172.google.com ([209.85.215.172]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCsog-0007vs-Uc for linux-arm-kernel@lists.infradead.org; Mon, 10 Feb 2014 15:30:39 +0000 Received: by mail-ea0-f172.google.com with SMTP id l9so2595662eaj.17 for ; Mon, 10 Feb 2014 07:30:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:content-type; bh=on2D8MHW9TsZdEx8RxEyzQsYZnLtRnqw1uwM5uGMheM=; b=DgKzfaqguAuoXYSlZbBEp3arbR6pH+LnAURCvKo7ru1DN5RrqJ0ErZ4REypoesJVvW h0BUFeEystA16mvLonxd+GLlzhqpEX23LFuUg81TaGfXy3wzc26Fp2te4BAL3JLi3g4O riJ+aczXqavyQ9+YU3kGPspuPxNqboQmegnx5WoMgf3bjwLNEW8si5khwsutfxOs0kUn ZtXH7VdWhbypp0EiPI9WV2mNcvv9gKKFAB7QptBmwiUnpOfEs2+COYONq6ghj/xuSJAi DKqiGY8gBtf+hfErLt3ZuPO7QD+v1g7G8/Q2+BAZMNLGYbWZ+JOsBK2Rwz4+ZiUzFFUL Q8yw== X-Gm-Message-State: ALoCoQnBBC8/P++Xl+L3Z639h7F21mZK2S5rSmHBVsCNfSnU00dRKVPPY/KJvt/KoFusVo1lSHQM X-Received: by 10.14.198.132 with SMTP id v4mr36789654een.43.1392045783210; Mon, 10 Feb 2014 07:23:03 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id x6sm55977680eew.20.2014.02.10.07.22.57 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 10 Feb 2014 07:23:01 -0800 (PST) From: Michal Simek To: linux-arm-kernel@lists.infradead.org, Arnd Bergmann Subject: [RFC PATCH 1/3] regmap: Separate regmap dev initialization Date: Mon, 10 Feb 2014 16:22:33 +0100 Message-Id: <5998a942a3dbfb2ef965d000168cbd7007315630.1392045742.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140210_103039_099609_5DE79F12 X-CRM114-Status: GOOD ( 17.86 ) X-Spam-Score: -1.9 (-) Cc: Greg Kroah-Hartman , Michal Simek , Mark Brown , linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create special function regmap_attach_dev which can be called separately out of regmap_init. Signed-off-by: Michal Simek --- drivers/base/regmap/regmap.c | 41 ++++++++++++++++++++++++++++------------- include/linux/regmap.h | 2 ++ 2 files changed, 30 insertions(+), 13 deletions(-) -- 1.8.2.3 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index b897c1a..c766f5f 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -380,6 +380,28 @@ static void regmap_range_exit(struct regmap *map) kfree(map->selector_work_buf); } +int regmap_attach_dev(struct device *dev, struct regmap *map, + const struct regmap_config *config) +{ + struct regmap **m; + + map->dev = dev; + + regmap_debugfs_init(map, config->name); + + /* Add a devres resource for dev_get_regmap() */ + m = devres_alloc(dev_get_regmap_release, sizeof(*m), GFP_KERNEL); + if (!m) { + regmap_debugfs_exit(map); + return -ENOMEM; + } + *m = map; + devres_add(dev, m); + + return 0; +} +EXPORT_SYMBOL_GPL(regmap_attach_dev); + /** * regmap_init(): Initialise register map * @@ -397,7 +419,7 @@ struct regmap *regmap_init(struct device *dev, void *bus_context, const struct regmap_config *config) { - struct regmap *map, **m; + struct regmap *map; int ret = -EINVAL; enum regmap_endian reg_endian, val_endian; int i, j; @@ -734,25 +756,18 @@ skip_format_initialization: } } - regmap_debugfs_init(map, config->name); - ret = regcache_init(map, config); if (ret != 0) goto err_range; - /* Add a devres resource for dev_get_regmap() */ - m = devres_alloc(dev_get_regmap_release, sizeof(*m), GFP_KERNEL); - if (!m) { - ret = -ENOMEM; - goto err_debugfs; - } - *m = map; - devres_add(dev, m); + if (dev) + ret = regmap_attach_dev(dev, map, config); + if (ret != 0) + goto err_regcache; return map; -err_debugfs: - regmap_debugfs_exit(map); +err_regcache: regcache_exit(map); err_range: regmap_range_exit(map); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 4149f1a..fa4d079 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -317,6 +317,8 @@ struct regmap *regmap_init(struct device *dev, const struct regmap_bus *bus, void *bus_context, const struct regmap_config *config); +int regmap_attach_dev(struct device *dev, struct regmap *map, + const struct regmap_config *config); struct regmap *regmap_init_i2c(struct i2c_client *i2c, const struct regmap_config *config); struct regmap *regmap_init_spi(struct spi_device *dev,