Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5177492imm; Tue, 9 Oct 2018 10:50:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV61uKJ346PgnnFO4EOZhnpSRPeQwqS9RjbC7zTpUdRNg+K4/oT74tTK8+aVwGshslArxjYJV X-Received: by 2002:a62:178f:: with SMTP id 137-v6mr30300314pfx.215.1539107425349; Tue, 09 Oct 2018 10:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539107425; cv=none; d=google.com; s=arc-20160816; b=drUHa2908jZUA3QW9Q2UNkpsjBHUJVJuYyNn8RDWV7L7KUTfZItHTYKAJ9aW1MCD2Q Xx38FOBRNQtvVWBQ0uDyGS4SFOARwB/9KAzfekhswk66L3vpgjvurIEhOPj7kJaoEGTe I92o05mf10Kw4SWMtP75bLYbAPVRcEmCsWl5lyumLVpctKIjXopsakRyanZ4RuocyXmI quAwtymsOHU5IR4Cn3LfKsg0KFpP8ZtK8mXl5wZvt0y1Qe3QUpzbW/0uI9SQCVLjq/+j OM2m6/O2SJavBK/2TcwYWtBKU11SVkN3CQHPZUQ4dd/L+ABbfwHqd+AlnMyD6sZCCsAy 8YMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hn+LAQuKpXXAJd1XDrQ9rpJaQnh2Y9vgJgOmoRdmONs=; b=xxjLMdNJoKw96WHANR8L31PKH+fxWHdS4Z49vp4sgt0sKHFFn6CJq5s048SMkpwI0e ejpSWZlAEQ2Ng+hO4hCGzupUWtoiHz6ExT4bnSc/gMe+kUDO6j4N4R9owrlMuGrUDAzm 21PWl3uFFp6ZvtUJoTP78XMl7bytFVSWWBRw7DWnU/A26rI2bVW1PSgdZdBn5439klQ+ ysgWkFOHccVWwVDMU6cpBWZnKuMjXO1DXsyrbSuWt/4u+QowiemAdcACyVIq0x2DdB7b MUxLYMPsuulKDKD4521A5ojHQlGq1XutfJPylzKE8usg06sTsoShqdLV/XqJIDiTJKDX y65Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f69vUUng; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o5-v6si20901561plk.95.2018.10.09.10.50.10; Tue, 09 Oct 2018 10:50:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@chromium.org header.s=google header.b=f69vUUng; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbeJJBHS (ORCPT + 99 others); Tue, 9 Oct 2018 21:07:18 -0400 Received: from mail-vk1-f195.google.com ([209.85.221.195]:44156 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727485AbeJJBHS (ORCPT ); Tue, 9 Oct 2018 21:07:18 -0400 Received: by mail-vk1-f195.google.com with SMTP id b2-v6so593485vkd.11 for ; Tue, 09 Oct 2018 10:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hn+LAQuKpXXAJd1XDrQ9rpJaQnh2Y9vgJgOmoRdmONs=; b=f69vUUngqAuZT2J/fTSrHAWbbzo2kellpSItiAQNRttRjT/xha3l+kZ+HSLXCnorba X0PJCjorSrXbEFlGdZIssR5LHk/RjHrRW+edoBfTztfLGr4PRHxi3gNK8rkJNSkN/unn ydr3kNjCqyJdc2uszJzvIUTZz/skYE4hKeS/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hn+LAQuKpXXAJd1XDrQ9rpJaQnh2Y9vgJgOmoRdmONs=; b=cpVvgFk6ZGDVnNmaO8j92DvpJGAACLjgNV4f8A419nNArACoqca1Jwf/TkaARhMQTz BZ8mipUQrjfM0yei7fQ84iltUJUiNPKpHH2MfDy1mqvlbi24XZtUN/cX3t3aa0q1SxmU QCB125eAuekHN0o1INqcmZrFYw0hOHzQH8hDh0VqgSLJ+ztg/TzBuJtNuR0axZQnocwe DaVDTVq+1sSrPmJdOKN2Tyggu9wvilDwi1hBZQCJV20Pay7QG/aa1aNwCuqsK07dKoOs fDLIM2jpdFY27L9Zg4Bhow/kvSDgjZFJpYvIUHF/Wn3XG94OCgSKYrqa0NOsqXM2Bxrm mGMQ== X-Gm-Message-State: ABuFfoisq8/deqHJltu/OGiCgaUI2audvbo0US5t45enZNNxLwqsA9rP WYPY5tpYJisCVLDIpMVd+cOr8zrWhVk= X-Received: by 2002:a1f:b215:: with SMTP id b21-v6mr5514176vkf.0.1539107350153; Tue, 09 Oct 2018 10:49:10 -0700 (PDT) Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com. [209.85.217.51]) by smtp.gmail.com with ESMTPSA id f188-v6sm3223494vke.53.2018.10.09.10.49.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 10:49:08 -0700 (PDT) Received: by mail-vs1-f51.google.com with SMTP id m5so2390232vsk.6 for ; Tue, 09 Oct 2018 10:49:08 -0700 (PDT) X-Received: by 2002:a67:1141:: with SMTP id 62-v6mr10837852vsr.213.1539107347783; Tue, 09 Oct 2018 10:49:07 -0700 (PDT) MIME-Version: 1.0 References: <1538574265-30235-1-git-send-email-alokc@codeaurora.org> <1538574265-30235-4-git-send-email-alokc@codeaurora.org> <153904219713.119890.7463642233895152532@swboyd.mtv.corp.google.com> <153910152600.119890.14820584405992384926@swboyd.mtv.corp.google.com> In-Reply-To: <153910152600.119890.14820584405992384926@swboyd.mtv.corp.google.com> From: Doug Anderson Date: Tue, 9 Oct 2018 10:48:55 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V5 3/3] spi: spi-geni-qcom: Add SPI driver support for GENI based QUP To: Stephen Boyd Cc: alokc@codeaurora.org, Mark Brown , LKML , linux-spi , Matthias Kaehlcke , linux-arm-msm , Girish Mahadevan , Dilip Kota Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Oct 9, 2018 at 9:12 AM Stephen Boyd wrote: > > Quoting Doug Anderson (2018-10-08 16:52:36) > > Hi, > > > > On Mon, Oct 8, 2018 at 4:43 PM Stephen Boyd wrote: > > > > + mas->irq = platform_get_irq(pdev, 0); > > > > + if (mas->irq < 0) { > > > > + ret = mas->irq; > > > > + dev_err(&pdev->dev, "Err getting IRQ %d\n", ret); > > > > + goto spi_geni_probe_runtime_disable; > > > > + } > > > > > > Nitpick: If you got the irq earlier before allocating anything then nothing has > > > to be put on failure path. > > > > I think this might have been in response to previous feedback from you > > suggesting that we should get the irq as late as possible. Ah, here > > ya go: > > > > https://lkml.kernel.org/r/153780767551.119890.9339380838620508307@swboyd.mtv.corp.google.com > > Yes I suggested we register for the irq as last as possible, but I > didn't suggest calling platform_get_irq() this late. It could be called > earlier so that if there isn't any irq then nothing to do besides return > failure. Ah, you're suggesting separating the platform_get_irq() and the request_irq() so that we call platform_get_irq() as the first thing in the function but don't do the request_irq() until later. Yeah, that could be done and I guess if you feel strongly about it I wouldn't object to the change, but I don't feel it buys us a lot and I kind of like keeping the two next to each other. Specifically why I don't think it buys us a lot: 1. You still need the "dev_err" print, right? platform_get_irq() doesn't automatically print errors for you I think. 2. You now need a local variable "irq". By putting the platform_get_irq() before the memory allocation you now can't store it directly in mas->irq. We could try using "ret" as a temporary variable but that seems worse in this case since it'd be a bit fragile. 3. You don't get rid of any error labels / error handling so we don't really save any code When I tried this my diffstat says 8 lines added and 7 removed, so a net increase in LOC FWIW. I'm relying in gmail so my patch will be whitespace-damaged (sigh), but you can find a clean one at: https://chromium.googlesource.com/chromiumos/third_party/kernel/+/e0325d618e209c22379e3a4269c14627b19243a8%5E%21/#F0 ...the basic idea is this though: @@ -543,6 +543,13 @@ struct spi_geni_master *mas; struct resource *res; struct geni_se *se; + int irq; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(&pdev->dev, "Err getting IRQ %d\n", irq); + return irq; + } spi = spi_alloc_master(&pdev->dev, sizeof(*mas)); if (!spi) @@ -553,6 +560,7 @@ mas->dev = &pdev->dev; mas->se.dev = &pdev->dev; mas->se.wrapper = dev_get_drvdata(pdev->dev.parent); + mas->irq = irq; se = &mas->se; spi->bus_num = -1; @@ -589,13 +597,6 @@ if (ret) goto spi_geni_probe_runtime_disable; - mas->irq = platform_get_irq(pdev, 0); - if (mas->irq < 0) { - ret = mas->irq; - dev_err(&pdev->dev, "Err getting IRQ %d\n", ret); - goto spi_geni_probe_runtime_disable; - } - ret = request_irq(mas->irq, geni_spi_isr, IRQF_TRIGGER_HIGH, "spi_geni", spi); if (ret) -Doug