From patchwork Tue Dec 17 14:12:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 181889 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp5754529och; Tue, 17 Dec 2019 06:12:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxKzXlb3E/6FdHNU6dLOz7+MM4k1NLvRsPM8FJaVkCk6Qwbsjk9qgoSgizx/g54jcf29AMh X-Received: by 2002:a05:6830:1e7c:: with SMTP id m28mr22283690otr.131.1576591968122; Tue, 17 Dec 2019 06:12:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576591968; cv=none; d=google.com; s=arc-20160816; b=BSqiipnbho0LSgF6X4buYjOnqqg/93l/NS/OlzBsBZFtcuQDDzk9JGaahKVnJL1CzD dF3ingEk+63Wvgt0CnBbrCjWnQ9mvPJWQlxT2NOrcCzl6f9c6d4o4KvNLQ5TjqTpbuo4 D4UMEGDdlau14zFQqffcPk/GnVZiD8RR52jNrYBBOKrL9ia3SXbNLcgUphyJ8jG4rpE3 ZpcNM3/ohFX7WzbguhHN9wdubgNn7mjniW/AAaTw5UMnc91BFmHhXTcF7OsZ6zYpKMjj Qv8oUJfOPTVNzXqF/MJb1ahnSP0u2UcIJeeEUCxqYCO8YQKRtlOTfiggU78nlKmJWbdi F7nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ePTZT8w1yYKU+6XZIw1VRbjDByrT55QH4Bd608l9VoE=; b=cz9nAxvznKSWetZptx/xGvh52LO4qFSZ+vDBXuFqHu11DDYGFa2MWh14JfSS3aNUn3 U4pxRWPeRz4hKvQo5o2aaAP2/Kb/4JM8b+w0oAfh95/gW/h45Rj4aGeh2fIJdYrKFFGT pyVnOUxMpYve4Fso1gx7QyF+G1UqzkYsLYXAwBsscg2GQldItPU4sI0bDxhwqHnjc3Qm xiXV5XkpQKOEp/SpUZfjg8BfItkPRamSrG4eu9IviK0S1qaWQtfJDOiPw2GCmkF91TT2 +m0v/kj8/Gcz7BGFpnFaMSCAaB98vkAOVMs+tAOIKqJP57VjgDoRmX0U+hliV5IaLGTb Av3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mPMdDFNx; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (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 c6si12180614oto.283.2019.12.17.06.12.47; Tue, 17 Dec 2019 06:12:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mPMdDFNx; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728725AbfLQOMr (ORCPT + 5 others); Tue, 17 Dec 2019 09:12:47 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41134 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728560AbfLQOMr (ORCPT ); Tue, 17 Dec 2019 09:12:47 -0500 Received: by mail-lf1-f65.google.com with SMTP id m30so7061847lfp.8 for ; Tue, 17 Dec 2019 06:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ePTZT8w1yYKU+6XZIw1VRbjDByrT55QH4Bd608l9VoE=; b=mPMdDFNxfkvoL3lABqC3oWe3u054uDodPUHv0x86h7OcsQtn/2fAP24i/g11zmJsU9 6a+/49hXnTEOPUMFdWVqc0a9ncPQW55SA/VDa77puyW0yoAsXDzem91ZYBkAPiunoGxJ M3jB5f0HbN/0GqLid7AGYsAub5wbXCK6MTJUG732MO+ybVx+H/kX7SONxTaSg2lsQRO3 Ax4I4Ke4ZwPNjsi8sted3o/A2+89KFahiDtLrGYd++jxdIh8D9+mr7/rqg2abnheNs3e 8gam1tgxPkYclzIn1KPpWu51PgByIncJiL+jVvdyDLMwcLEIHoLfPnlUc21I76ooWHWa gaPw== 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:mime-version :content-transfer-encoding; bh=ePTZT8w1yYKU+6XZIw1VRbjDByrT55QH4Bd608l9VoE=; b=l3eep6ERJTI4a9cVd0DWcEyDpsQCk0UKmaXQ52dkUQEMFmTXTILeoLFk95FAL52q6c iOaCnJlm9gF+4wN99ye0CWWX9iUiMDKoeGPQqRc/df0OxIoX9z0wuujGCck8XCPWJzlk bPiwAblRhf1tjv/kK+v28Ub6pVA8RVO5Y+Lh1oTPt9inD2rzGVNbESO7QmMFLBjJq610 lzj+535S5mn18SfiwLd7WW2+jkI8evwFTiCdmNuGyFPMpel9UIE/e0tj8Ks3N6C7Qhs9 UBND3P8da8mVMe+MaCVl3tm3HP1HjZ5hcA8lDIKiuHn1ASNIoAfvmC1lSwcnN4pS6obz QAcQ== X-Gm-Message-State: APjAAAW/0KnEcq8oxyodZTIpY5EyAw1nYZll/uoT00sc35Fy0PFIvsFG njKVG95daIBUOuDvuK6RE+vBgwX0MMM= X-Received: by 2002:ac2:544f:: with SMTP id d15mr3061840lfn.126.1576591965244; Tue, 17 Dec 2019 06:12:45 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id y23sm12849736ljk.6.2019.12.17.06.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2019 06:12:43 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, Linus Walleij , Eugeniu Rosca , Veeraiyan Chidambaram , Yoshihiro Shimoda Subject: [PATCH] usb: renesas_usbhs: Switch to GPIO descriptor Date: Tue, 17 Dec 2019 15:12:41 +0100 Message-Id: <20191217141241.57639-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The Renesas USBHS driver includes a bit of surplus headers and uses the old GPIO API so let's switch it to use the GPIO descriptor. I noticed that the enable_gpio inside renesas_usbhs_driver_param isn't really referenced anywhere, and it is also the wrong type (u32) so let's just delete it and use a local variable instead. Cc: Eugeniu Rosca Cc: Veeraiyan Chidambaram Cc: Yoshihiro Shimoda Signed-off-by: Linus Walleij --- drivers/usb/renesas_usbhs/common.c | 22 +++++++++------------- drivers/usb/renesas_usbhs/rcar2.c | 2 -- include/linux/usb/renesas_usbhs.h | 2 -- 3 files changed, 9 insertions(+), 17 deletions(-) -- 2.23.0 diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index d438b7871446..3af91b2b8f76 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -8,11 +8,10 @@ */ #include #include -#include +#include #include #include #include -#include #include #include #include @@ -592,7 +591,8 @@ static int usbhs_probe(struct platform_device *pdev) struct usbhs_priv *priv; struct resource *irq_res; struct device *dev = &pdev->dev; - int ret, gpio; + struct gpio_desc *gpiod; + int ret; u32 tmp; /* check device node */ @@ -657,10 +657,9 @@ static int usbhs_probe(struct platform_device *pdev) priv->dparam.pio_dma_border = 64; /* 64byte */ if (!of_property_read_u32(dev_of_node(dev), "renesas,buswait", &tmp)) priv->dparam.buswait_bwait = tmp; - gpio = of_get_named_gpio_flags(dev_of_node(dev), "renesas,enable-gpio", - 0, NULL); - if (gpio > 0) - priv->dparam.enable_gpio = gpio; + gpiod = devm_gpiod_get_optional(dev, "renesas,enable", GPIOD_IN); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); /* FIXME */ /* runtime power control ? */ @@ -708,13 +707,10 @@ static int usbhs_probe(struct platform_device *pdev) usbhs_sys_clock_ctrl(priv, 0); /* check GPIO determining if USB function should be enabled */ - if (priv->dparam.enable_gpio) { - gpio_request_one(priv->dparam.enable_gpio, GPIOF_IN, NULL); - ret = !gpio_get_value(priv->dparam.enable_gpio); - gpio_free(priv->dparam.enable_gpio); + if (gpiod) { + ret = !gpiod_get_value(gpiod); if (ret) { - dev_warn(dev, "USB function not selected (GPIO %d)\n", - priv->dparam.enable_gpio); + dev_warn(dev, "USB function not selected (GPIO)\n"); ret = -ENOTSUPP; goto probe_end_mod_exit; } diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c index 440d213e1749..7f2f06586ea5 100644 --- a/drivers/usb/renesas_usbhs/rcar2.c +++ b/drivers/usb/renesas_usbhs/rcar2.c @@ -6,8 +6,6 @@ * Copyright (C) 2019 Renesas Electronics Corporation */ -#include -#include #include #include "common.h" #include "rcar2.h" diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 6914475bbc86..d418c55523a7 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -170,8 +170,6 @@ struct renesas_usbhs_driver_param { */ int pio_dma_border; /* default is 64byte */ - u32 enable_gpio; - /* * option: */