From patchwork Mon Oct 19 05:43:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Kumar X-Patchwork-Id: 532156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9C9E514031C for ; Mon, 19 Oct 2015 16:45:32 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752865AbbJSFn4 (ORCPT ); Mon, 19 Oct 2015 01:43:56 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:3490 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752617AbbJSFnx (ORCPT ); Mon, 19 Oct 2015 01:43:53 -0400 X-IronPort-AV: E=Sophos;i="5.17,700,1437462000"; d="scan'208";a="77987692" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw2-out.broadcom.com with ESMTP; 18 Oct 2015 23:13:09 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.235.1; Sun, 18 Oct 2015 22:43:53 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.235.1; Sun, 18 Oct 2015 22:43:52 -0700 Received: from pramodku-OptiPlex-7010.ban.broadcom.com (unknown [10.132.81.79]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 07F6F40FE5; Sun, 18 Oct 2015 22:40:50 -0700 (PDT) From: Pramod Kumar To: Rob Herring , Pawel Moll , "Mark Rutland" , Ian Campbell , Kumar Gala , Ray Jui , Scott Branden , Russell King , Linus Walleij , CC: BCM Kernel Feedback , Jason Uy , Masahiro Yamada , Thomas Gleixner , Laurent Pinchart , , , , Jonas Gorski , Pramod Kumar Subject: [PATCH 07/11] pinctrl: use ngpios propety from DT Date: Mon, 19 Oct 2015 11:13:14 +0530 Message-ID: <1445233398-27129-8-git-send-email-pramodku@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445233398-27129-1-git-send-email-pramodku@broadcom.com> References: <1445233398-27129-1-git-send-email-pramodku@broadcom.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Since identical hardware is used in several instances and all pins are not routed to pinctrl hence getting total number of gpios from DT make more sense hence stop using total number of gpios pins from drivers and extract it from DT. Signed-off-by: Pramod Kumar Reviewed-by: Ray Jui Reviewed-by: Scott Branden --- drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 45 +++++++------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c index 12a48f4..498a58a 100644 --- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c +++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c @@ -642,35 +642,11 @@ static void cygnus_gpio_unregister_pinconf(struct cygnus_gpio *chip) pinctrl_unregister(chip->pctl); } -struct cygnus_gpio_data { - unsigned num_gpios; -}; - -static const struct cygnus_gpio_data cygnus_cmm_gpio_data = { - .num_gpios = 24, -}; - -static const struct cygnus_gpio_data cygnus_asiu_gpio_data = { - .num_gpios = 146, -}; - -static const struct cygnus_gpio_data cygnus_crmu_gpio_data = { - .num_gpios = 6, -}; - static const struct of_device_id cygnus_gpio_of_match[] = { - { - .compatible = "brcm,cygnus-ccm-gpio", - .data = &cygnus_cmm_gpio_data, - }, - { - .compatible = "brcm,cygnus-asiu-gpio", - .data = &cygnus_asiu_gpio_data, - }, - { - .compatible = "brcm,cygnus-crmu-gpio", - .data = &cygnus_crmu_gpio_data, - } + { .compatible = "brcm,cygnus-ccm-gpio" }, + { .compatible = "brcm,cygnus-asiu-gpio" }, + { .compatible = "brcm,cygnus-crmu-gpio" }, + { } }; static int cygnus_gpio_probe(struct platform_device *pdev) @@ -681,14 +657,6 @@ static int cygnus_gpio_probe(struct platform_device *pdev) struct gpio_chip *gc; u32 ngpios; int irq, ret; - const struct of_device_id *match; - const struct cygnus_gpio_data *gpio_data; - - match = of_match_device(cygnus_gpio_of_match, dev); - if (!match) - return -ENODEV; - gpio_data = match->data; - ngpios = gpio_data->num_gpios; chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) @@ -713,6 +681,11 @@ static int cygnus_gpio_probe(struct platform_device *pdev) } } + if (of_property_read_u32(dev->of_node, "ngpios", &ngpios)) { + dev_err(&pdev->dev, "missing ngpios DT property\n"); + return -ENODEV; + } + spin_lock_init(&chip->lock); gc = &chip->gc;