Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp772106pxu; Thu, 3 Dec 2020 12:12:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOXjbLwx/pUZ+w26GhiiuNXCbmHu85fTFvA5i+3tz+83KtYEiPRpK8EIjf8FnIEAcd6dzM X-Received: by 2002:a05:6402:312b:: with SMTP id dd11mr4577845edb.308.1607026357519; Thu, 03 Dec 2020 12:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607026357; cv=none; d=google.com; s=arc-20160816; b=jAMZZSiTsnD1Ahj0w12BcwEDkg9yh/LCAAmGwDQ5HQGpFTz/Gqvzuj2e0z/6UVd65F yZ0ToOfGtMoIkbq6UxFn7MgfL4NZUzkoL40X529RzkxQAq7BV/tXudILG0OxPLskEJMg dBrcRKhjiLnAJl/Pdu2SOQggXxlzOMfR+eTXDpoNoGtxke18tCQBpyiIw41L7o3syqkL eI+jECyEdizDfbat7pV61HbdzZCX/fsnWRmKXzkd5ph07dhuLkjRkOm+pr+vCphCuX1E jHQeHMzSB7Ng982WODDRz1qMJlJhA1WL6SvvI4fpibitMqFblBhbC25qIwjJgcpAG4Ey YyQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=pp49CJNwg1tNaburiW38uEDAcsVx0RLZKdc6aI0KdWQ=; b=Q31gFZIxYA0a/h13ki7v8sDBdeUwrCPdV3cDg+C213uXq7MWOHPLh5kx9lpoXrEuRC y8oIXbsV+pj6erwOrUZa89CluqC7FbcpvVL8NGbu1HXpghGduHxCdcvxcnJMeYGCIrIg WWV1FcFjWzBc5SLdLDsgLcqrPvYwzRNSa1yV06scWkjlLsShyY5YMUCP5oi50QQI6GP+ l/ghxvRogzT7Kypsta9RcCOR4w07U8/J+DFOumzafQww6X03cnJwSZTlsM0hLep/5EeK Wky0ps81CRyDI1CDlGTuPkklKc41kAxCYITTK5OSjrCxLWBPAXcW5LrQKcHy/oAck/YQ ErDw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si1491526edt.290.2020.12.03.12.12.14; Thu, 03 Dec 2020 12:12:37 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729251AbgLCUIE (ORCPT + 99 others); Thu, 3 Dec 2020 15:08:04 -0500 Received: from asavdk4.altibox.net ([109.247.116.15]:42400 "EHLO asavdk4.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgLCUIE (ORCPT ); Thu, 3 Dec 2020 15:08:04 -0500 Received: from ravnborg.org (unknown [188.228.123.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk4.altibox.net (Postfix) with ESMTPS id B63F880534; Thu, 3 Dec 2020 21:07:13 +0100 (CET) Date: Thu, 3 Dec 2020 21:07:11 +0100 From: Sam Ravnborg To: Tian Tao Cc: airlied@linux.ie, daniel@ffwll.ch, tzimmermann@suse.de, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH drm/hisilicon 2/3] drm/irq: Add the new api to install irq Message-ID: <20201203200711.GA74163@ravnborg.org> References: <1606898835-40775-1-git-send-email-tiantao6@hisilicon.com> <1606898835-40775-3-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1606898835-40775-3-git-send-email-tiantao6@hisilicon.com> X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=Itgwjo3g c=1 sm=1 tr=0 a=S6zTFyMACwkrwXSdXUNehg==:117 a=S6zTFyMACwkrwXSdXUNehg==:17 a=kj9zAlcOel0A:10 a=BTeA3XvPAAAA:8 a=e5mUnYsNAAAA:8 a=ZRss9xuAS5q6kMSJnlUA:9 a=CjuIK1q_8ugA:10 a=tafbbOV3vt1XuEhzTjGK:22 a=Vxmtnl_E_bksehYqCbjh:22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tian. On Wed, Dec 02, 2020 at 04:47:14PM +0800, Tian Tao wrote: > Add new api devm_drm_irq_install() to register interrupts, > no need to call drm_irq_uninstall() when the drm module is removed. > > Signed-off-by: Tian Tao Just a few details to fix. Sam > --- > drivers/gpu/drm/drm_irq.c | 35 +++++++++++++++++++++++++++++++++++ > include/drm/drm_irq.h | 2 +- > 2 files changed, 36 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c > index 09d6e9e..b363dec 100644 > --- a/drivers/gpu/drm/drm_irq.c > +++ b/drivers/gpu/drm/drm_irq.c > @@ -214,6 +214,41 @@ int drm_irq_uninstall(struct drm_device *dev) > } > EXPORT_SYMBOL(drm_irq_uninstall); > > +static void devm_drm_irq_uninstall(void *data) > +{ > + drm_irq_uninstall(data); > +} > + > +/** > + * devm_drm_irq_install - install IRQ handler > + * @dev: DRM device > + * @irq: IRQ number to install the handler for > + * > + * devm_drm_irq_install is a help function of drm_irq_install. Drop the extra space after "is a" > + * > + * if the driver uses devm_drm_irq_install, there is no need Start with capital "I" in If > + * to call drm_irq_uninstall when the drm module get unloaded, > + * as this will done automagically. > + * > + * Returns: > + * Zero on success or a negative error code on failure. > + */ > +int devm_drm_irq_install(struct drm_device *dev, int irq) > +{ > + int ret; > + > + ret = drm_irq_install(dev, irq); > + if (ret) > + return ret; > + > + ret = devm_add_action_or_reset(dev->dev, devm_drm_irq_uninstall, dev); > + if (ret) > + devm_drm_irq_uninstall(dev); devm_add_action_or_reset() will call devm_drm_irq_uninstall() if ret is != 0. See include/device.h. I guess that is the "_or_reset" part of the name that can tell us that. So you can drop the if condition as it just will cause the code to call drm_irq_uninstall() twice. > + > + return ret; > +} > +EXPORT_SYMBOL(devm_drm_irq_install); > + > #if IS_ENABLED(CONFIG_DRM_LEGACY) > int drm_legacy_irq_control(struct drm_device *dev, void *data, > struct drm_file *file_priv) > diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h > index d77f6e6..631b22f 100644 > --- a/include/drm/drm_irq.h > +++ b/include/drm/drm_irq.h > @@ -28,5 +28,5 @@ struct drm_device; > > int drm_irq_install(struct drm_device *dev, int irq); > int drm_irq_uninstall(struct drm_device *dev); > - > +int devm_drm_irq_install(struct drm_device *dev, int irq); > #endif > -- > 2.7.4 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel