From patchwork Sat Jun 3 10:59:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng <15330273260@189.cn> X-Patchwork-Id: 102830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1597304vqr; Sat, 3 Jun 2023 04:19:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ485lqEI/oBOwHo6X3jjGPXa6rNLF4dLk8xX4tSDAb34+fj7d5eDrPicprska7yGrBxO5X1 X-Received: by 2002:a05:6a00:1945:b0:652:4291:7cf5 with SMTP id s5-20020a056a00194500b0065242917cf5mr6454816pfk.9.1685791196380; Sat, 03 Jun 2023 04:19:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685791196; cv=none; d=google.com; s=arc-20160816; b=qRU43ey8DcwqIKoE5aJhjnLnqZ+NvjyHQnLXD1HTf7gQgYD/Plb8f5dmx8k/ZJYtHS gb1LBgj3/4Nemd0Vz3rUDijthhSWTyrUm6RwC15N+BbmHtwo02ZCcVRrssesGOuI+iba Ll1WDws9yEPr6rivqJl0em2CGrOkFQLUquDMvSMeRKh7SPSsfdvTJ6t0zyjn0BEtQuS3 DiGGykhLuVT70oyYnjnw/yrMY21hHfttj95JH7xFKU2Ae9nzRmYToclKvm38TguTFt4l k5haOY7xrbeyv/ZyDNRb1sXHByCbnIHpxmQYQTFtv68/5TYddVoSsOHSBAxXUOJznEIs 3IBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :hmm_source_type:hmm_attache_num:hmm_source_ip; bh=kqnJsqXUbHaYvBkRjOgecB9z2kzUIUo/LeB77D69mf0=; b=sHNQJWeDCXNHMvmmlQYc7odewmM9bNMhKBT7wRloGC5d3u/5d8AdF5LEU6I8fcJq7n VKHlsLw13D4gohp7+/5Y7im22fw6efb88z5Fu8qR2c9MLcc5A+tIetT0i9kZ0CZMn9+j IeSOt9PIbZoipvmOZ6QZr5f+0ILJYhxMdWki1XsoUTkDmmgF4YTqxH0zaCu49k7gWkOE pRjN71bITZvv5CTmMi5+Uh5qicMKZbH9wN4/yHR5OfnoqJiji8cfwmPe85XCo/LjVyGM kP3o8gZALXdy0lju9MKa3NtJWdfRr2S1Z6xdwwvDLZLev3b/foSmPqYvhcmbRudm7Sm7 3y4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k137-20020a633d8f000000b0053fee168aabsi2573118pga.742.2023.06.03.04.19.41; Sat, 03 Jun 2023 04:19:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232212AbjFCLAO (ORCPT + 99 others); Sat, 3 Jun 2023 07:00:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjFCLAK (ORCPT ); Sat, 3 Jun 2023 07:00:10 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DA166E1 for ; Sat, 3 Jun 2023 04:00:06 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.43:51732.1826327623 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.43]) by 189.cn (HERMES) with SMTP id E0446100239; Sat, 3 Jun 2023 19:00:05 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-7vx9t with ESMTP id c23bd1fc2e904056b40e5c6747f144d1 for l.stach@pengutronix.de; Sat, 03 Jun 2023 19:00:05 CST X-Transaction-ID: c23bd1fc2e904056b40e5c6747f144d1 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn From: Sui Jingfeng <15330273260@189.cn> To: Lucas Stach , Christian Gmeiner , Daniel Vetter , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [PATCH v7 1/7] drm/etnaviv: add a dedicated function to register an irq handler Date: Sat, 3 Jun 2023 18:59:37 +0800 Message-Id: <20230603105943.3042766-2-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230603105943.3042766-1-15330273260@189.cn> References: <20230603105943.3042766-1-15330273260@189.cn> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767680189329603998?= X-GMAIL-MSGID: =?utf-8?q?1767680189329603998?= From: Sui Jingfeng Because getting IRQ from a device is platform-dependent, PCI devices have different methods for getting an IRQ. This patch is a preparation patch to extend the driver for the PCI device support. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 34 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index de8c9894967c..636d3f39ddcb 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1817,6 +1817,29 @@ static const struct of_device_id etnaviv_gpu_match[] = { }; MODULE_DEVICE_TABLE(of, etnaviv_gpu_match); +static int etnaviv_gpu_register_irq(struct etnaviv_gpu *gpu, int irq) +{ + struct device *dev = gpu->dev; + int err; + + if (irq < 0) { + dev_err(dev, "failed to get irq: %d\n", irq); + return irq; + } + + err = devm_request_irq(dev, irq, irq_handler, 0, dev_name(dev), gpu); + if (err) { + dev_err(dev, "failed to request IRQ %u: %d\n", irq, err); + return err; + } + + gpu->irq = irq; + + dev_info(dev, "IRQ handler registered, irq = %d\n", irq); + + return 0; +} + static int etnaviv_gpu_platform_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1837,16 +1860,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) return PTR_ERR(gpu->mmio); /* Get Interrupt: */ - gpu->irq = platform_get_irq(pdev, 0); - if (gpu->irq < 0) - return gpu->irq; - - err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0, - dev_name(gpu->dev), gpu); - if (err) { - dev_err(dev, "failed to request IRQ%u: %d\n", gpu->irq, err); + err = etnaviv_gpu_register_irq(gpu, platform_get_irq(pdev, 0)); + if (err) return err; - } /* Get Clocks: */ gpu->clk_reg = devm_clk_get_optional(&pdev->dev, "reg");