Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp498907pxu; Thu, 26 Nov 2020 04:17:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyd/FSfaeDczthEOhmkoxdi1DHaRlwHMvC1XKoenUBJ2kcubpLnsxOnmp7KpUFpxeA9vWg5 X-Received: by 2002:a05:6402:cb4:: with SMTP id cn20mr2311136edb.186.1606393075443; Thu, 26 Nov 2020 04:17:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606393075; cv=none; d=google.com; s=arc-20160816; b=s0sbGoOjWJzfyV7Vm7gHjB9nvGz82fmqds3DwS2pjHFvEJ/jRLA6L66smuKDGJ2o4z VDOdIiGAeLq9CN6Zp+iONnxwJ6Pe+LyjO5O05zOByfmD0nWj87ELXIkN/f6j/tgLc4ri hJQRq+mC1zEZ+F0t43Ywm9fAkProJK7EJsrwzyOWMwTLN3XQVbLoOA+AzOCPeflIw62E 0bQ53aRnVyjmRu8SyRIo9hp4fcAw0YIXeO+sjx3Ye7GBcY31dZuoPu71Tx56DFxetAPD AIlLKOsbAXr6wU6avZUxOS07aINSb0u9zVqyx/KktO+BebTVegh2rkfGtztu6XQsMUeK TlcA== 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=X2a56B8xpaZvjVk6mfeNyaTYJix7W2sdP0yl4igngtE=; b=GCQeJZIuMX85Phehrod8lQeD1G70ATp7eBWIpg2UWP/afcpQPTfPVrZ9JY7e9XzZbd 7p8BKnB8kqk9PVg/R7s2ITT7okQSjixmollQ7eup3qTjCSkO12I3fUeE2stXXNssfD6B Oj5+VWQSjQQoyOs4Ef8BXGZf3u/fEIoLtM9QFA9z37Ov9Yd5ZDGLbHsW2CW17ZdnoLJn 3smnz3MH5aEysFryatuA7+EW9vFaKwrDe+ChUu2ZplPT5IoJLGAL2VeIQwwqFBRTZy/1 MmvURnGas7nxAKUhDLywdx1wxRedQ+sT/egIH48OIclhfjjL+Zq7vmugd+ocEWbEYQHd tfIw== 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 b6si3418846edq.479.2020.11.26.04.17.33; Thu, 26 Nov 2020 04:17:55 -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 S2387535AbgKZMCK (ORCPT + 99 others); Thu, 26 Nov 2020 07:02:10 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:8411 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730579AbgKZMCJ (ORCPT ); Thu, 26 Nov 2020 07:02:09 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Chbvr1Vr9z74Dm; Thu, 26 Nov 2020 20:01:44 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Thu, 26 Nov 2020 20:02:00 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH drm/hisilicon 2/3] drm/irq: Add the new api to install irq Date: Thu, 26 Nov 2020 20:02:19 +0800 Message-ID: <1606392140-57954-3-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606392140-57954-1-git-send-email-tiantao6@hisilicon.com> References: <1606392140-57954-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 | 34 ++++++++++++++++++++++++++++++++++ include/drm/drm_irq.h | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 09d6e9e..983ad6b 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -214,6 +214,40 @@ 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 the help function of drm_irq_install, + * when the driver uses devm_drm_irq_install, there is no need + * to call drm_irq_uninstall when the drm module is uninstalled, + * and 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(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