From patchwork Sat Oct 28 13:37:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 117394 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp610781qgn; Sat, 28 Oct 2017 06:41:47 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SXMZUvgsEn1fhlWlb8YiRZggqMdcdrxvzfPgIqXFUJJ6j0+1B7u8KT1XkXNIN7Y6aWD3BW X-Received: by 10.98.67.154 with SMTP id l26mr3502182pfi.212.1509198107754; Sat, 28 Oct 2017 06:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509198107; cv=none; d=google.com; s=arc-20160816; b=rehg9PS3l9FTuw1JLi87UO3/djVJ0m7naavH+/GdIgEsMrBo+DzwcrMeoIFwu+TO1s yBW42teS2h78ox7EsNmMb5VRgxf2xtJ6C8CXAyBEy4deGJAsfHDpWcjS8DGqoZnhAOLy 0EQ+gG4qfAlj+pAQJ8gNSeq0Wrvhhty8YRNCfOqtBgT9NG+PIsMwzRA8NwuqfLYO3LvE ALDLQ7Jpl43mM6545VN9Gr+o2f57YAWZmXqhnvs7ITUH1lNj+a8xf+87Fmj3IR3bZWf8 tvdd7IpNPwxNsvqK/W56KFhvnN4FcO7I8jLTDQSmY/yPKQBawzXpcwAodJEf3n+WT9TR zc+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=lhpoxTfvQPCAVkPpaz8FL4DLsgzv8WXiJp+cxIKNJMY=; b=V4a2b5q6cSbn4g3RO/E9Dbyn4rkws46XrzglkP1Txli+yoFH/8B+7IlSTVwMPf8MsI 3cAcRZkhAvTK5wr9HpNwCl2+XDU8p+OLMQjH7Y3Sm4PVXL5S1VpxrY86vQHQyB/EnMQV OZ12jHnxxz7HHpkRdJ2s/cv1vhFVDJ1ZF30KXFRrLmuhKPDxZt+TNtBznYilShodrmnN io2tVMLVFFwzuJN2LgcRONgmkfLQOAfdEuIxZKSkTENRe6pYGOJE9tSfsZSudSrsJSWX 9RVZeyylfH0b+igQpdmxutA+QyLnG+AXw/pzNI8AhRB3OZTUttDNo6F3WXCIOREmKuU0 b+bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aneD2eL5; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (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 l185si372828pfc.43.2017.10.28.06.41.47; Sat, 28 Oct 2017 06:41:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aneD2eL5; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751230AbdJ1Nlr (ORCPT + 6 others); Sat, 28 Oct 2017 09:41:47 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44086 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751199AbdJ1Nlq (ORCPT ); Sat, 28 Oct 2017 09:41:46 -0400 Received: by mail-lf0-f67.google.com with SMTP id 75so10142687lfx.1 for ; Sat, 28 Oct 2017 06:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T3nh4bv9rVhDl/oOltjHj3cm6mQyEfO+QdiH0zP/Kyg=; b=aneD2eL5cH5X9aImjgaROeiBkLvLBboKugVqlJNdV+XohiESu1SiHf1G0jkt5/wTJZ KYuGrdbnwDQTKMBbTeTKYyxwzeULYDkFBtYwnKMdRW3c6hTQFL770Dct1oHbN7jHBl7G Wf4WDi0kWF72L/OsTsW4LJyjDlFLcZQYMs3Jw= 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:in-reply-to :references; bh=T3nh4bv9rVhDl/oOltjHj3cm6mQyEfO+QdiH0zP/Kyg=; b=Ry60+BaHFNq8wiKa6+JsyUxg+Gj8Pt2NZesrnQ4AgcFAx9UcwsJ+ullsgoyZOoLlrN BndQldrUjVX3uuWrYH6DENmuIuLtZQHhAI47Vx9ldOXevxmmCpb2E/yYhfFbK9jWBYcV f/aNv+70uOk7MD+GMGY64GFjyvORopb/P+T1+wLRRik6sQWsVs1MFCgainjWxZN2z57w QuK5CaPDD1a4OW4PfZA+Y29e9lgiWKF13++kBtML1TfpxNWzWQKgY14WB7qcEDXVyrZ0 YSqjxgNOsFlGbYRWx/r9dyCWTvNzrPnvL0cLjUzvsTnOJ0l+s5QKYCU7614MnbgPZ5Lx Jxfg== X-Gm-Message-State: AMCzsaUTjy4808xYl47BPLZMoqEnoXw2DFbsbQUY5toDqDqYSi0NYWk/ K4ftKRjA3koC1rsvoQg2B58BC30SKTY= X-Received: by 10.25.143.198 with SMTP id s67mr959648lfk.143.1509198104593; Sat, 28 Oct 2017 06:41:44 -0700 (PDT) Received: from localhost.localdomain (c-567171d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.113.86]) by smtp.gmail.com with ESMTPSA id r23sm2447913lja.32.2017.10.28.06.41.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Oct 2017 06:41:43 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Hans Ulli Kroll , Florian Fainelli Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 3/4] pinctrl: gemini: Use generic DT parser Date: Sat, 28 Oct 2017 15:37:18 +0200 Message-Id: <20171028133719.27528-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171028133719.27528-1-linus.walleij@linaro.org> References: <20171028133719.27528-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We can just use the generic Device Tree parser code in this driver and save some code. Signed-off-by: Linus Walleij --- drivers/pinctrl/Kconfig | 1 + drivers/pinctrl/pinctrl-gemini.c | 66 +++------------------------------------- 2 files changed, 5 insertions(+), 62 deletions(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Hans Ulli Kroll diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index 1778cf4f81c7..98b2d5dcbda7 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -151,6 +151,7 @@ config PINCTRL_GEMINI depends on ARCH_GEMINI default ARCH_GEMINI select PINMUX + select GENERIC_PINCONF select MFD_SYSCON config PINCTRL_MCP23S08 diff --git a/drivers/pinctrl/pinctrl-gemini.c b/drivers/pinctrl/pinctrl-gemini.c index 7ffd768c0e02..18fb5ff8a442 100644 --- a/drivers/pinctrl/pinctrl-gemini.c +++ b/drivers/pinctrl/pinctrl-gemini.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -1918,73 +1920,13 @@ static void gemini_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, seq_printf(s, " " DRIVER_NAME); } -static int gemini_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev, - struct device_node *np, - struct pinctrl_map **map, - unsigned int *reserved_maps, - unsigned int *num_maps) -{ - int ret; - const char *function = NULL; - const char *group; - struct property *prop; - - ret = of_property_read_string(np, "function", &function); - if (ret < 0) - return ret; - - ret = of_property_count_strings(np, "groups"); - if (ret < 0) - return ret; - - ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, - num_maps, ret); - if (ret < 0) - return ret; - - of_property_for_each_string(np, "groups", prop, group) { - ret = pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, - num_maps, group, function); - if (ret < 0) - return ret; - pr_debug("ADDED FUNCTION %s <-> GROUP %s\n", - function, group); - } - - return 0; -} - -static int gemini_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, - struct device_node *np_config, - struct pinctrl_map **map, - unsigned int *num_maps) -{ - unsigned int reserved_maps = 0; - struct device_node *np; - int ret; - - *map = NULL; - *num_maps = 0; - - for_each_child_of_node(np_config, np) { - ret = gemini_pinctrl_dt_subnode_to_map(pctldev, np, map, - &reserved_maps, num_maps); - if (ret < 0) { - pinctrl_utils_free_map(pctldev, *map, *num_maps); - return ret; - } - } - - return 0; -}; - static const struct pinctrl_ops gemini_pctrl_ops = { .get_groups_count = gemini_get_groups_count, .get_group_name = gemini_get_group_name, .get_group_pins = gemini_get_group_pins, .pin_dbg_show = gemini_pin_dbg_show, - .dt_node_to_map = gemini_pinctrl_dt_node_to_map, - .dt_free_map = pinctrl_utils_free_map, + .dt_node_to_map = pinconf_generic_dt_node_to_map_group, + .dt_free_map = pinconf_generic_dt_free_map, }; /**