Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp714919imu; Thu, 3 Jan 2019 05:56:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ul6kELMoQRIK361lWGDmu338F1xsGpSx0qdYH10wOfGJOFsV5Vnu5sDRENPirl51j8Sqs8 X-Received: by 2002:a62:26c7:: with SMTP id m190mr49097780pfm.79.1546523807488; Thu, 03 Jan 2019 05:56:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546523807; cv=none; d=google.com; s=arc-20160816; b=BdxGvptGqcwoGwW1WffTPJB1f1H38JjZhZRur10xF2FGiw6+r2WGI9s8mT1xt/FIU0 weJkNInt5v8c+VudQ3iYwQQeKS+EzoMMxo7KT/diPVWQxCNN07TNGntExunmzRcccUwb uMSBP4IbomFclyK1vXjPp3mUj3kCAg5CyWLYyrLFCPwMtSwryydBSkSKBPZZPV3zhA5V IYf1WeQIzEq1hnfUg6TF7GFqSBOZ74tAVpgEDLhwqVNrTcpVUvNeLEl3ecRAs+EmeT3j MkJy1DYrvGYpfTCe19qZEsqYvnkmdU6kcVTvSPZwO5hxrpLVyaYA8gdwwQSyZvqxFTWf Pe8w== 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; bh=LNsMCQvi3YESu2jFZko6wer3qJnV5q2cyJUAqddcti8=; b=ArrGH5Ae5U72CO1hq0Jq86lvX+aARw6a8m6wlHrZM+4kv9KIxFKEzMXs12GPszjHVi t9gu/3OodaMRZRLUihxpnawL80VIrpK2RcO9SmfUzK0LShHC0fA5w17vfzpsOwSZTcmT OyFL1TkCDDxrh9E40I4rGg+hbmmYoaIywBnpQam6sltP9zP2dt4MZ3M2sXhG5Apa1J/W zeDMMaf5yk98UCEVkJtrN9kBiZ4iD2gmmV9TJPhJG921TWm32Af76K5Dmiyb/qX/iOZV qdwG5pzXa2USTpfOd8HGAFRFbKV2/UC5L/GltmgE3B5pDsLmPctA7rx/88RZhM7f9IU9 V71Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v35si45280823pgl.130.2019.01.03.05.56.29; Thu, 03 Jan 2019 05:56:47 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730555AbfACJki (ORCPT + 99 others); Thu, 3 Jan 2019 04:40:38 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:45132 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730544AbfACJki (ORCPT ); Thu, 3 Jan 2019 04:40:38 -0500 Received: by mail-ot1-f66.google.com with SMTP id 32so28875714ota.12 for ; Thu, 03 Jan 2019 01:40:37 -0800 (PST) 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=LNsMCQvi3YESu2jFZko6wer3qJnV5q2cyJUAqddcti8=; b=G5Me+Ef/4Iz8ociIMOBbj2Xx4HlfIAHCBXPwkv9XjQfal2BbewCC0aWA0R3kdaP/xr GOkyMUmu3tyieos5jebxCa+2Btzg+uWKhMBCBFsPoBhbxnRVEmmuQtDDJce+4jAQyAyJ XkP3DLU3E9U4Om7N6gvybVH9GyYXHjuYUPQgwgmgmuKA3ZLbDquidLt5Iib9W4ROiWgh PxUMyO58l40pHN87nYdcjhpWr8W0aIEfL8glCjgZ4xn4wJ3luSHljMsse1gubpqd0qyP fs2OPaOkpIoC0OHUt8aLECSl5+yr1SgSNWK5g88N+e/45Yasy2dtpK+75oh7y5/9SPwR qZ5w== X-Gm-Message-State: AJcUukcLFttWRJifkCCYIP6x6PNy267Cs4QWduRuohUWbSAKEC3xbOcp s6sXm1sWMW10J+mNcklBz6pUQx0CIwem1z8RYpg= X-Received: by 2002:a9d:7f0d:: with SMTP id j13mr30890239otq.119.1546508437044; Thu, 03 Jan 2019 01:40:37 -0800 (PST) MIME-Version: 1.0 References: <20190102185106.56913-1-swboyd@chromium.org> In-Reply-To: <20190102185106.56913-1-swboyd@chromium.org> From: "Rafael J. Wysocki" Date: Thu, 3 Jan 2019 10:40:26 +0100 Message-ID: Subject: Re: [PATCH v3] driver core: platform: Add an error message to platform_get_irq*() To: Stephen Boyd Cc: Rob Herring , Andrzej Hajda , Andy Shevchenko , Bartlomiej Zolnierkiewicz , Mark Brown , Greg Kroah-Hartman , javierm@redhat.com, Linux ARM , Linux Kernel Mailing List , Russell King - ARM Linux , Marek Szyprowski , "Rafael J. Wysocki" 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 On Wed, Jan 2, 2019 at 7:51 PM Stephen Boyd wrote: > > A grep of the kernel shows that many drivers print an error message if > they fail to get the irq they're looking for. Furthermore, those drivers > all decide to print the device name, or not, and the irq they were > requesting, or not, etc. Let's consolidate all these error messages into > the API itself, allowing us to get rid of the error messages in each > driver. > > Signed-off-by: Stephen Boyd > --- > > Changes from v2: > * Don't refactor platform_get_irq(), just wrap it > > Changes from v1: > * Update error text to indicate irq index instead of IRQn, use %u > > drivers/base/platform.c | 31 +++++++++++++++++++++++-------- > 1 file changed, 23 insertions(+), 8 deletions(-) > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index 1c958eb33ef4..388461306dd4 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -79,12 +79,7 @@ struct resource *platform_get_resource(struct platform_device *dev, > } > EXPORT_SYMBOL_GPL(platform_get_resource); > > -/** > - * platform_get_irq - get an IRQ for a device > - * @dev: platform device > - * @num: IRQ number index > - */ > -int platform_get_irq(struct platform_device *dev, unsigned int num) > +static int __platform_get_irq(struct platform_device *dev, unsigned int num) > { > #ifdef CONFIG_SPARC > /* sparc does not have irqs represented as IORESOURCE_IRQ resources */ > @@ -130,6 +125,22 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) > return r ? r->start : -ENXIO; > #endif > } > + > +/** > + * platform_get_irq - get an IRQ for a device > + * @dev: platform device > + * @num: IRQ number index > + */ > +int platform_get_irq(struct platform_device *dev, unsigned int num) > +{ > + int ret; > + > + ret = __platform_get_irq(dev, num); > + if (ret < 0 && ret != -EPROBE_DEFER) > + dev_err(&dev->dev, "IRQ index %u not found\n", num); Why don't you log the error code too? > + > + return ret; > +} > EXPORT_SYMBOL_GPL(platform_get_irq); > > /** > @@ -142,7 +153,7 @@ int platform_irq_count(struct platform_device *dev) > { > int ret, nr = 0; > > - while ((ret = platform_get_irq(dev, nr)) >= 0) > + while ((ret = __platform_get_irq(dev, nr)) >= 0) > nr++; > > if (ret == -EPROBE_DEFER) > @@ -195,7 +206,11 @@ int platform_get_irq_byname(struct platform_device *dev, const char *name) > } > > r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); > - return r ? r->start : -ENXIO; > + if (r) > + return r->start; > + > + dev_err(&dev->dev, "IRQ %s not found\n", name); > + return -ENXIO; > } > EXPORT_SYMBOL_GPL(platform_get_irq_byname); > > -- > Sent by a computer through tubes >