From patchwork Sat Feb 13 15:15:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8300151 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 232319F38B for ; Sat, 13 Feb 2016 15:16:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21E902025B for ; Sat, 13 Feb 2016 15:16:16 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E428B203C4 for ; Sat, 13 Feb 2016 15:16:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aUbvh-0000Vo-Jm; Sat, 13 Feb 2016 15:16:13 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aUbvg-0000Vg-GS for tpmdd-devel@lists.sourceforge.net; Sat, 13 Feb 2016 15:16:12 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.66 as permitted sender) client-ip=74.125.82.66; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f66.google.com; Received: from mail-wm0-f66.google.com ([74.125.82.66]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1aUbvf-0004gn-Jk for tpmdd-devel@lists.sourceforge.net; Sat, 13 Feb 2016 15:16:12 +0000 Received: by mail-wm0-f66.google.com with SMTP id c200so7881341wme.0 for ; Sat, 13 Feb 2016 07:16:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AbOGL+lou7onCAll3X+k5M9+Tu76le46R7Uo2MPares=; b=OeXabLiA9gLnzgwLP4cpNaFfyTXS6sDKN7A7Xa+UN0/A8eY/5P3Uxq5bj2HvtaznqV zflSTvYBD3llrrNiLYZV57mLGpBuCNGmv9l8wboCMHVaEAswhwVYLgtA+4SgziAKnAGu udWiptpX3Yqzi9rlTKI5Pu2c389u+JWZlyM6/M2lyVudmvWrVLOdJN/XwTzbs2Lt1Gly 9Cjh3mrDrnHMTwyHuSasgey2YqmWVoH4IPyc2xlNF229tdgjeIdQJLXlu2ncoUj6i2qn cb5gBVuZgOEPDGEzeQVXg2xVhr+/9uBgxU3KQZDV1qYYD/WAJT/FnIIXSbubp1ywtr0z U30g== X-Gm-Message-State: AG10YORK089H5WiNl6QPzRHL3izwYjoRiADqXrgZ8TGYipxzplo6UWTcSkZFoFEpoy+i1g== X-Received: by 10.28.24.80 with SMTP id 77mr1895640wmy.16.1455376565633; Sat, 13 Feb 2016 07:16:05 -0800 (PST) Received: from localhost.localdomain (AMarseille-654-1-450-135.w92-150.abo.wanadoo.fr. [92.150.10.135]) by smtp.gmail.com with ESMTPSA id v66sm7129466wmb.18.2016.02.13.07.16.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Feb 2016 07:16:04 -0800 (PST) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com, peterhuewe@gmx.de Date: Sat, 13 Feb 2016 16:15:35 +0100 Message-Id: <1455376535-9549-13-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455376535-9549-1-git-send-email-christophe-h.ricard@st.com> References: <1455376535-9549-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1aUbvf-0004gn-Jk Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, christophe.ricard@gmail.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH v2 12/12] tpm/st33zp24/spi: Change xxx_request_resources header X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, 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 Simplify st33zp24_spi_acpi_request_resources, st33zp24_spi_of_request_resources and st33zp24_spi_request_resources to have the same prototype and using spi_get_drvdata. Reviewed-by: Jarkko Sakkinen Signed-off-by: Christophe Ricard --- drivers/char/tpm/st33zp24/spi.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index b9b74ae..ded0859 100644 --- a/drivers/char/tpm/st33zp24/spi.c +++ b/drivers/char/tpm/st33zp24/spi.c @@ -228,9 +228,9 @@ static const struct st33zp24_phy_ops spi_phy_ops = { .recv = st33zp24_spi_recv, }; -static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy) +static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev) { - struct spi_device *spi_dev = phy->spi_device; + struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev); const struct acpi_device_id *id; struct gpio_desc *gpiod_lpcpd; struct device *dev; @@ -249,7 +249,7 @@ static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy) gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1, GPIOD_OUT_HIGH); if (IS_ERR(gpiod_lpcpd)) { - dev_err(&client->dev, + dev_err(dev, "Failed to retrieve lpcpd-gpios from acpi.\n"); phy->io_lpcpd = -1; /* @@ -265,23 +265,23 @@ static int st33zp24_spi_acpi_request_resources(struct st33zp24_i2c_phy *phy) return 0; } -static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy) +static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev) { + struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev); struct device_node *pp; - struct spi_device *dev = phy->spi_device; int gpio; int ret; - pp = dev->dev.of_node; + pp = spi_dev->dev.of_node; if (!pp) { - dev_err(&dev->dev, "No platform data\n"); + dev_err(&spi_dev->dev, "No platform data\n"); return -ENODEV; } /* Get GPIO from device tree */ gpio = of_get_named_gpio(pp, "lpcpd-gpios", 0); if (gpio < 0) { - dev_err(&dev->dev, + dev_err(&spi_dev->dev, "Failed to retrieve lpcpd-gpios from dts.\n"); phy->io_lpcpd = -1; /* @@ -292,10 +292,10 @@ static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy) return 0; } /* GPIO request and configuration */ - ret = devm_gpio_request_one(&dev->dev, gpio, + ret = devm_gpio_request_one(&spi_dev->dev, gpio, GPIOF_OUT_INIT_HIGH, "TPM IO LPCPD"); if (ret) { - dev_err(&dev->dev, "Failed to request lpcpd pin\n"); + dev_err(&spi_dev->dev, "Failed to request lpcpd pin\n"); return -ENODEV; } phy->io_lpcpd = gpio; @@ -303,9 +303,9 @@ static int st33zp24_spi_of_request_resources(struct st33zp24_spi_phy *phy) return 0; } -static int st33zp24_spi_request_resources(struct spi_device *dev, - struct st33zp24_spi_phy *phy) +static int st33zp24_spi_request_resources(struct spi_device *dev) { + struct st33zp24_spi_phy *phy = spi_get_drvdata(dev); struct st33zp24_platform_data *pdata; int ret; @@ -357,17 +357,20 @@ static int st33zp24_spi_probe(struct spi_device *dev) return -ENOMEM; phy->spi_device = dev; + + spi_set_drvdata(dev, phy); + pdata = dev->dev.platform_data; if (!pdata && dev->dev.of_node) { - ret = st33zp24_spi_of_request_resources(phy); + ret = st33zp24_spi_of_request_resources(dev); if (ret) return ret; } else if (pdata) { - ret = st33zp24_spi_request_resources(dev, phy); + ret = st33zp24_spi_request_resources(dev); if (ret) return ret; } else if (ACPI_HANDLE(&dev->dev)) { - ret = st33zp24_spi_acpi_request_resources(phy); + ret = st33zp24_spi_acpi_request_resources(dev); if (ret) return ret; }