Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp905349ybm; Wed, 27 May 2020 10:47:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCAUdsiL9iYKedK5sGtSjFknUGU1QPkDS5w8pGg6ijVITFrDdI5pCKtlNo6cd1eSjEL+m5 X-Received: by 2002:a50:fa8d:: with SMTP id w13mr23766268edr.280.1590601655658; Wed, 27 May 2020 10:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590601655; cv=none; d=google.com; s=arc-20160816; b=wYZd6wiYxx9uU6LGC2ANeqifbKDovt6hpi7OUxW4mETilUW6PAFGOQSc6DooAhvGBc 2bXbL4ion+IkOpD0rVAriqv3NlDG+w0Jw51XLDYW/B3GfoY/9rjP8WpTV/xdGYt0ZMFe 6P6/fRUXLy6YIhZoklkhJCSL3RcuIjHZAWrSVNtxagdF/PtOf0bIv2v4593Cxa68RpG3 J2xvWUZlF81TAXvxpYylgOGApbGj5sy9lPJQ2fVrx7aHt6h8D9GiHl9OvIsVRJgWYLNA AheCLeELLDP44ptK69YRoO1EK6XmdSGs7ZST7ISn9YcAJPZZ8oVJO8OyOo9exNyKV9l5 jc2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7UTCqkxw0E37ZcBKPLbqUR2FGWZfkP4x8wzUp0dtX/k=; b=DxehpW7laa44M3DTh9buolbwMgy3ui0WlTMYD/BsTVqtdwFYf54qPW/dGCByKsU6s1 mbcF+hwQBMrNMLWj3jetDAJ9rxzjYpjMXW02y1EaqsGap/+MWW+KuOECCFHgJdjJO/84 +xZEGSTrvBXrgGIvxvsJiOheUxlWCZHNMgnobsmjjC28YTkcfcWC4nQw1du0fXrcIdkW SCc1pEAHxnAm47v/rEQzRlVhgd0hItb4PQcrWZI9PQitWMbct9DFRT+IIH2pg7d6sSTe QY5md25gFerrhFCQzVCIV0NXtTXuU9UIfrqnNST/n/IpzdwO/Wj5BMu4AqwPpOShUelB sb1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mNi677ae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gu10si2401980ejb.38.2020.05.27.10.47.12; Wed, 27 May 2020 10:47:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mNi677ae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388091AbgE0NbT (ORCPT + 99 others); Wed, 27 May 2020 09:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730207AbgE0NbS (ORCPT ); Wed, 27 May 2020 09:31:18 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9449BC08C5C1; Wed, 27 May 2020 06:31:18 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id r10so11750024pgv.8; Wed, 27 May 2020 06:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7UTCqkxw0E37ZcBKPLbqUR2FGWZfkP4x8wzUp0dtX/k=; b=mNi677aeVfuSkx3f4deL/wnpijuZIzMsoVJWy5PShY7ns358wJ1GPJNbaVn57opoAA O+5RWhEWaK87ucSC24X+AZnOWh2G4etnlDd+wpCLu4hu/TlwiAiZO1pDSGxeEI86fnLv 457ZunE4EkQPoK7e1AIPdlDvBaD09EltUWyPo09idX7ZsOHssLtjt1+EoQnxknff8BdK Y07N6In5JMLvsbe/mTNFgY57PzSgiscV8wQJlzI9luqAJkpsBMSNQwl/PqHzhIvbLcJv TL2N535JvGFddEk/o9+yP6JXfOBJzgY2pofYk+FORPYAHgJsuuOqqMi3IJQR3E8jOnpp xodg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7UTCqkxw0E37ZcBKPLbqUR2FGWZfkP4x8wzUp0dtX/k=; b=ZjMucQ6GhK/oK71737n3+5H5c7RMnJzlEx1U9IKQQMW0JZ05m04Wel9lIRC1s+8+o/ yDTX6MECwZhhUnZ40/YXoNQVK5zBJjQFnGlH/utaLNE8gn4/Mfnttp+wpz/ysOlp+Fpg 1I/LSyEr6p5I0jjolPzkj2MCS1n6sJ+TyhLfSuWZrVFmgbtOGqnGl6dSINwn9ZE9wQOP GIeJriMRTgMa0QFvjcLJbEAulxTRIGALUc8WyGMbdr1QghJ+lMrnVtisV8ycHBVVjDOY G/JpN2fDbEBFmk/Y9+P3fSINSfgLlbvNkc2nX21dzSZKEplvB+d3mkfIrBlLFYgeFljX ySaw== X-Gm-Message-State: AOAM530V+vb07ZZ/qZ5+aKZ8CDiZ2FZe1E+NjV94cakYB8zUQKqTRfwk yGjV8NcJgu9WWH+Fik3Ujng= X-Received: by 2002:aa7:8691:: with SMTP id d17mr4033851pfo.308.1590586277744; Wed, 27 May 2020 06:31:17 -0700 (PDT) Received: from localhost ([144.34.194.82]) by smtp.gmail.com with ESMTPSA id z8sm2099093pgc.80.2020.05.27.06.31.16 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 May 2020 06:31:17 -0700 (PDT) Date: Wed, 27 May 2020 21:31:12 +0800 From: Dejin Zheng To: Grygorii Strashko Cc: gregkh@linuxfoundation.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Wolfram Sang Subject: Re: [PATCH v2 1/2] drivers: provide devm_platform_request_irq() Message-ID: <20200527133112.GC7143@nuc8i5> References: <20200523145157.16257-1-zhengdejin5@gmail.com> <20200523145157.16257-2-zhengdejin5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 26, 2020 at 08:11:22PM +0300, Grygorii Strashko wrote: > > > On 23/05/2020 17:51, Dejin Zheng wrote: > > It will call devm_request_irq() after platform_get_irq() function > > in many drivers, sometimes, it is not right for the error handling > > of these two functions in some drivers. so provide this function > > to simplify the driver. > > > > Cc: Michal Simek > > Cc: Wolfram Sang > > Signed-off-by: Dejin Zheng > > --- > > v1 -> v2: > > - The patch content has not changed. just resend it by this discussion: > > https://patchwork.ozlabs.org/project/linux-i2c/patch/20200520144821.8069-1-zhengdejin5@gmail.com/ > > > > drivers/base/platform.c | 33 +++++++++++++++++++++++++++++++++ > > include/linux/platform_device.h | 4 ++++ > > 2 files changed, 37 insertions(+) > > > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > > index c0d0a5490ac6..1d2fd1ea3bc5 100644 > > --- a/drivers/base/platform.c > > +++ b/drivers/base/platform.c > > @@ -275,6 +275,39 @@ int platform_irq_count(struct platform_device *dev) > > } > > EXPORT_SYMBOL_GPL(platform_irq_count); > > +/** > > + * devm_platform_request_irq - get an irq and allocate an interrupt > > + * line for a managed device > > + * @pdev: platform device > > + * @num: IRQ number index > > + * @irq: get an IRQ for a device if irq != NULL > > + * @handler: function to be called when the IRQ occurs > > + * @irqflags: interrupt type flags > > + * @devname: an ascii name for the claiming device, dev_name(dev) if NULL > > + * @dev_id: a cookie passed back to the handler function > > + * > > + * Return: zero on success, negative error number on failure. > > + */ > > +int devm_platform_request_irq(struct platform_device *pdev, unsigned int num, > > + unsigned int *irq, irq_handler_t handler, > > + unsigned long irqflags, const char *devname, void *dev_id) > > +{ > > + int tmp_irq, ret; > > + > > + tmp_irq = platform_get_irq(pdev, num); > > + if (tmp_irq < 0) > > + return tmp_irq; > > + > > + ret = devm_request_irq(&pdev->dev, tmp_irq, handler, irqflags, > > + devname, dev_id); > > + if (ret < 0) > > + dev_err(&pdev->dev, "can't request IRQ\n"); > > + else if (irq != NULL) > > + *irq = tmp_irq; > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(devm_platform_request_irq); > > + > > /** > > * platform_get_resource_byname - get a resource for a device by name > > * @dev: platform device > > diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h > > index 77a2aada106d..d94652deea5c 100644 > > --- a/include/linux/platform_device.h > > +++ b/include/linux/platform_device.h > > @@ -11,6 +11,7 @@ > > #define _PLATFORM_DEVICE_H_ > > #include > > +#include > > #define PLATFORM_DEVID_NONE (-1) > > #define PLATFORM_DEVID_AUTO (-2) > > @@ -70,6 +71,9 @@ devm_platform_ioremap_resource_byname(struct platform_device *pdev, > > extern int platform_get_irq(struct platform_device *, unsigned int); > > extern int platform_get_irq_optional(struct platform_device *, unsigned int); > > extern int platform_irq_count(struct platform_device *); > > +extern int devm_platform_request_irq(struct platform_device *pdev, > > + unsigned int num, unsigned int *irq, irq_handler_t handler, > > + unsigned long irqflags, const char *devname, void *dev_id); > > > it has to be documented in devres.rst > Grygorii, Thnaks! I will add it in patch v3. BTW, the Gmail will prevent me sending messages to a large number of recipients, So I reduced some recipients, but still retained i2c and linux kernel mail list. sorry! BR, Dejin > > extern struct resource *platform_get_resource_byname(struct platform_device *, > > unsigned int, > > const char *); > > > > > > -- > Best regards, > grygorii