Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp703607pxu; Wed, 2 Dec 2020 00:50:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzU7/wLXZ7lBWA9M/2LenDlR4DiHc1flq6vvfVakvYQIyPBtt9unW7SdOFqnxgwnViEWius X-Received: by 2002:a17:906:13c5:: with SMTP id g5mr1296879ejc.125.1606899009433; Wed, 02 Dec 2020 00:50:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606899009; cv=none; d=google.com; s=arc-20160816; b=TROtbm48qye12aT3hCCkQTwW/GrBARVgEpxfRuHM7nZhfMLaw5UhbTOq2OSzasH6tW XneqS/gwUtTB/f/lvh9sRjqP/Up659uOdYJKAPZRfftQspI6PSWhn6vNvpclE4B0Fc2x xRw2sTbdYIpg8CIzpMGowuVQM0wDcYwT1V41WVHP49lyhlRwaK5oj99GKxxFpwPnpuJP yn/4YVWnVEYrroaDKLItHn5jnN6gW4xZBP+Qlo78ePRtC+ZKjIq5OABCIG3KQMNpF6RN jdUxzus/tAFDghGIEgNCIoeM3Vp+WgoZXMHnch0Ru1SR0qkF2vsLhAGhi5xCKRTrsNCP VBrw== 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=yUQ87u3X++ZxyB7JVyJEs6s4DCtj0wq8YcC0RFCaCP2AjyBhWnTcs61bdreWEhR6QW v+r0FLHtFvINLO2+9LwpfLHVKVxqdQxsSEbRUa+9x7cw1bt/hikrnO2bcYX2UISbxagp dooJMewp9AMAWDuj3dAqSZe1rJsovlTlQOd2/IR87DcsOTXGEpAb4RV39SHWO0RU38vl 0/7IiHNcqdsaxPDO45GXqJ0pijgULZzxotyv+5+PR0924A6/s8ggg57y/OPwfBD4a3t1 kulF+fp2ftlL3p8DNJzqgGyiWzDCUHDWYeg5G+aAFDNjQkzAejXh0IBVW75EqYL7Ido0 IjfQ== 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 ng3si486149ejb.344.2020.12.02.00.49.46; Wed, 02 Dec 2020 00:50:09 -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 S2387724AbgLBIrp (ORCPT + 99 others); Wed, 2 Dec 2020 03:47:45 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8230 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729217AbgLBIrp (ORCPT ); Wed, 2 Dec 2020 03:47:45 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CmCHm01zFzkgqt; Wed, 2 Dec 2020 16:46:28 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Wed, 2 Dec 2020 16:46:59 +0800 From: Tian Tao To: , , , , , , , , , CC: Subject: [PATCH drm/hisilicon 2/3] drm/irq: Add the new api to install irq Date: Wed, 2 Dec 2020 16:47:14 +0800 Message-ID: <1606898835-40775-3-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606898835-40775-1-git-send-email-tiantao6@hisilicon.com> References: <1606898835-40775-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