Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp410146pxu; Tue, 1 Dec 2020 14:34:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxLfWa191pa7vya5/0lsR4YNrEKhj12wia97WzM8XePhUa7u7/tWUqO3CQC0r5aqgcRzTE X-Received: by 2002:a17:906:54c8:: with SMTP id c8mr5231696ejp.253.1606862081644; Tue, 01 Dec 2020 14:34:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606862081; cv=none; d=google.com; s=arc-20160816; b=O6yZK6tIsH4W0Ho8bfTh0a35s5QCIdsxuki8CqmjYAG6JbpsJEDjRgDugwaG3/BZ1L 3kid7wcolP0oy04F/vLJ54Z1jCnne6RWWLWOuCI2919y4bDhpNeGZNmjtT8f91cshVYr ujQbMCeD25R7K1ndXUat+Myv1elCrTCZB0PaempxtfOKqHl93ISFUT8Zp0kHtFicN+uW MbJglSNuOm31tMLYErUpGVXAmwFMDN2fGmfbJvXcZzktEM5pt9HJY8d2k0BN8VjHFEce FEBYJlIi2wcTXklZpF5FhiwA2XmSTynbBlsHALkRr5EnGKfRUZEml02lqWpF/JQxx+Ms rs5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=w4cK0K3y48qhpDVf2yRpLr6owLXpMgy3LHbZh1RDI2o=; b=dNwqVHiEPiLlhXuaXO3TQ+DYbGSKMl0j7ktKnx2F5EbqzCAv1jmcQPPNU9yZUtNt9G G/Kz0riReXP4cWkKP764tgRNZqRF2QL4K/BzPUSf2oopaR9DgQNEVHVPFl61rZw0TvGe ogw+QyrCwXTDkn4uYau0qqPtWUzRtZ4/xOUbKgKbUI9vJzCoXIo1zflMENfUysXuLUny tm24CHgC9pliT3fyUxID/Vpzzt+LFinUalOtjzBrfgDCPpM1j0bH0OIZv5UupbfzgY7n pibQ9/R9ESoK9bq8jcmtKHI4MrVaCOSfTl9YSZXKQhOf50OtLHqO6b9xP5+MwYCScP8A fEsg== 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 hj13si826943ejb.475.2020.12.01.14.34.19; Tue, 01 Dec 2020 14:34:41 -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 S1730694AbgLAL41 (ORCPT + 99 others); Tue, 1 Dec 2020 06:56:27 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8173 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729631AbgLAL41 (ORCPT ); Tue, 1 Dec 2020 06:56:27 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4ClgX445Qmz15VtD; Tue, 1 Dec 2020 19:55:16 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Tue, 1 Dec 2020 19:55:37 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH drm/hisilicon v2 3/4] drm/irq: Add the new api to install irq Date: Tue, 1 Dec 2020 19:55:53 +0800 Message-ID: <1606823754-52451-4-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606823754-52451-1-git-send-email-tiantao6@hisilicon.com> References: <1606823754-52451-1-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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. + * + * if the driver uses devm_drm_irq_install, there is no need + * 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); + + 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