From patchwork Fri Oct 31 20:32:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 39976 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 682612405B for ; Fri, 31 Oct 2014 20:32:25 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf4639303lbj.11 for ; Fri, 31 Oct 2014 13:32:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=0v8Q2z6HENiiAySNn3jEZQJMJuLvbWbfeUWcuZup+Xw=; b=Ni+FB4pceQglJe3NxgeelwSFlKx+k0sV37dIcTOAvoxVYDm921zGrlMhvyGXICR5yr VYEyuE6kb8uBn7y4ZOJC+AqVyKEQf8SIGWS6k4z0syEikhjBUNmduFI6GNyelCP4hYmQ IfN2d1MvJSDhJltbV0bo6iYdhLNz/7G5Qe07F69trJbcCGOFLlaBVW5strNej8SAPE/W hrkrBitRKP7udkIsh/ELBFoPYvi1hlC5ASsF93qxQxmHQFnYjhUs9VwAFA1+WHAXC54v Rjt8aegGMEqpFvhjJHneURb8YtLnVyFkt0X83cgQQyWbkMppHp5VE4cgU5K4x5qHt4Oo hCIQ== X-Gm-Message-State: ALoCoQlITF6JFdmP5W4jqC3Kl2c1NYiSAex3YoBfqooBe3Rsl9/gl3D5vQsWd2fwq1wkIZ/uyiqV X-Received: by 10.112.140.132 with SMTP id rg4mr733193lbb.12.1414787544234; Fri, 31 Oct 2014 13:32:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.200 with SMTP id v8ls313287lag.25.gmail; Fri, 31 Oct 2014 13:32:23 -0700 (PDT) X-Received: by 10.112.167.200 with SMTP id zq8mr2268010lbb.61.1414787543809; Fri, 31 Oct 2014 13:32:23 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id i7si18681212lbc.8.2014.10.31.13.32.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 13:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id 10so6707759lbg.36 for ; Fri, 31 Oct 2014 13:32:23 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr28558779lbb.74.1414787543656; Fri, 31 Oct 2014 13:32:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp257114lbz; Fri, 31 Oct 2014 13:32:22 -0700 (PDT) X-Received: by 10.70.5.227 with SMTP id v3mr118835pdv.165.1414787542068; Fri, 31 Oct 2014 13:32:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ua6si631057pab.116.2014.10.31.13.32.21 for ; Fri, 31 Oct 2014 13:32:22 -0700 (PDT) Received-SPF: none (google.com: netdev-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757289AbaJaUcT (ORCPT + 3 others); Fri, 31 Oct 2014 16:32:19 -0400 Received: from mail-la0-f50.google.com ([209.85.215.50]:57123 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755603AbaJaUcR (ORCPT ); Fri, 31 Oct 2014 16:32:17 -0400 Received: by mail-la0-f50.google.com with SMTP id hz20so4385401lab.9 for ; Fri, 31 Oct 2014 13:32:16 -0700 (PDT) X-Received: by 10.152.22.135 with SMTP id d7mr28986882laf.46.1414787536266; Fri, 31 Oct 2014 13:32:16 -0700 (PDT) Received: from localhost.localdomain (c83-254-157-117.bredband.comhem.se. [83.254.157.117]) by mx.google.com with ESMTPSA id pm3sm4822691lbb.15.2014.10.31.13.32.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Oct 2014 13:32:15 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, Nicolas Pitre , "David S. Miller" Cc: Linus Walleij Subject: [PATCH] smc91x: retrieve IRQ and trigger flags in a modern way Date: Fri, 31 Oct 2014 21:32:06 +0100 Message-Id: <1414787526-11197-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The SMC91x is written to explicitly look up the IRQ resource from the platform device and extract the IRQ and flags, however the platform_get_irq() does additional things, like call of_irq_get() in the device tree case, which will translate the IRQ using the irqdomain and defer the probe if the IRQ host cannot be found. As we're not looking up the resource, this will not retrieve the IRQ flags, but that is better done using irqd_get_trigger_type(), as the trigger is what the driver wants to modify. We take care to preserve the semantics that will make the trigger type provided from the resource override any local specifier. Tested on the Nomadik NHK15 which has its SMC91x IRQ line connected to a STMPE2401 GPIO expander on I2C. Signed-off-by: Linus Walleij --- drivers/net/ethernet/smsc/smc91x.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c index 5e94d00b96b3..7747d506646a 100644 --- a/drivers/net/ethernet/smsc/smc91x.c +++ b/drivers/net/ethernet/smsc/smc91x.c @@ -2207,9 +2207,10 @@ static int smc_drv_probe(struct platform_device *pdev) const struct of_device_id *match = NULL; struct smc_local *lp; struct net_device *ndev; - struct resource *res, *ires; + struct resource *res; unsigned int __iomem *addr; unsigned long irq_flags = SMC_IRQ_FLAGS; + unsigned long irq_resflags; int ret; ndev = alloc_etherdev(sizeof(struct smc_local)); @@ -2279,16 +2280,19 @@ static int smc_drv_probe(struct platform_device *pdev) goto out_free_netdev; } - ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!ires) { + ndev->irq = platform_get_irq(pdev, 0); + if (ndev->irq <= 0) { ret = -ENODEV; goto out_release_io; } - - ndev->irq = ires->start; - - if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK) - irq_flags = ires->flags & IRQF_TRIGGER_MASK; + /* + * If this platform does not specify any special irqflags, or if + * the resource supplies a trigger, override the irqflags with + * the trigger flags from the resource. + */ + irq_resflags = irqd_get_trigger_type(irq_get_irq_data(ndev->irq)); + if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK) + irq_flags = irq_resflags & IRQF_TRIGGER_MASK; ret = smc_request_attrib(pdev, ndev); if (ret)