Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp307082pxx; Thu, 29 Oct 2020 03:11:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRYbCb9ryEBlG4ufsYTWeosc2meVwIm4UPFCCexDz+Ghv+DtdOsMkzXNyPBLnJhvb3cG2p X-Received: by 2002:a17:906:c0d8:: with SMTP id bn24mr3180433ejb.480.1603966312969; Thu, 29 Oct 2020 03:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603966312; cv=none; d=google.com; s=arc-20160816; b=YbNDXz5NTyzvKByPnG1YuORJQrMY7x1V1M01t4rUdSSesec5oXsJPnRuBSX/XBatkk cZLEsbBEwLsRjmctupHdySzshbGwDaPXeA8ZEG0gdqHSM+ctcDsbBpnjw7/sS33PbQy0 d1K7MjiXU3SfynC/IfKrwg84De1V5ovLEPinWXbBYt5p9eWxTm32codfFuoaYZwaRyIR x78YLfb05URqr4kCNIAXjDe3BSGxt6x7wXYZdrY14e8h19Uzf72Ab+XzcdjxAGWdAHKL N6eNc3wTdD24VfM74JSKKfTil1vlJSVjG5zqfv0oxWVt/J13LmyshKVghZmEGI5HzTqk 2Iiw== 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 :dkim-signature; bh=CqNUS7HcRPCCge3R03YlWR0VNXk0g9HQYTNptYIriU4=; b=cLTIRMU6u5dBFJ4ZfwUt0vogpfGibFQ8aNb8MQ64+Q8JHtVHO5I9uOJ0cJ5f08Xrh4 gQPA4u+sn/wbhWA24opSHtrjO7ozEhwdWGH8PXRWa9zA/lUdt1H3Zcod6nhPaHtG0K/5 wgiwnDRqNIE5ZzYJeNwQpfTKsHvohrc4XMfgVQOiGXFpssAzjo0hhnoltMR4P5z5RGmv 0V/86uJ2TeXKmSFKPMurCr9pklMgV7dj8osynkZ5ivUdJHyV/QZl68Y+IQbMmO3tZtA6 Ghc13tEEtIqofIFuMhp82RMZP0IA8QFpyQP14sPeKH48Oy51Zp35n39kC5sczg+jBZIf OUkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g8GfVQlS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si1333171eje.29.2020.10.29.03.11.30; Thu, 29 Oct 2020 03:11:52 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g8GfVQlS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726549AbgJ2KJ0 (ORCPT + 99 others); Thu, 29 Oct 2020 06:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgJ2KJE (ORCPT ); Thu, 29 Oct 2020 06:09:04 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED0BC0613CF; Thu, 29 Oct 2020 03:09:04 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id o18so2461006edq.4; Thu, 29 Oct 2020 03:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CqNUS7HcRPCCge3R03YlWR0VNXk0g9HQYTNptYIriU4=; b=g8GfVQlStWcB8JQ9WrTyXwfB6at9tKwefJK5QXB18khcv2zKYwyaSmU8tl5k6GIwoe sZjBr6y9g9Ese2VPgfPSz+CIi9v0KrmDWT0VooWnf7GEbN7yE3ZyNLZfm97xuPKpkiwn pKSj00qLRCYxcwjjuH1UvBbTx0AaV8PwnUjeUrYJl9dkSf5HfcTba7Xdqf9uLsDgq60t GjxJrfIPIcP986hIPdISdn4iP4bFjnE7YUF4nKdn30O/wpXoTmpFH/N9A9CmqT6/rXh8 e7/5hLWJGD7cTAvq0VB7e0eNsaiYucq8/rMBNzhufUK70ZhKcKHj6c64zoJKeEzzlfrn Q6Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CqNUS7HcRPCCge3R03YlWR0VNXk0g9HQYTNptYIriU4=; b=ItoJ68vk7o1++T0Y2eBgPPBb9ehUzbpKVOHZOUTMlKNWUg7vZrgLYgQ2++kM0uYeeP 74+QAxsu4EcxVnvT7gh5WF2fHKzODYsR6jYdtPVzeSrGPVYH//8Piqsq0ts8cygwWEfU dQcdXWkQCJroJ/C4IQbEeaFC2mbsDSuGlZmuR4pJRYa5lEDAyiQ3rzk17uL6cjgiDeb8 JJ2sAO3HBaD4rzM+YBZtxTNPohn3h93nYBCiZjU+NXJRqNMQDOhVhOM+N1rSKpjachsS HVXiSn3i6KTvn1zI6IhEFHwM7zdJMBndOQcwzCGste54Q+0Gd/f/HHyRA73tzfjr3My3 astQ== X-Gm-Message-State: AOAM530+DHuu0S9b+Ru1v4nLOH3QTOzosGeYTamLnh4EJkwHm5n21cBN dKP4I78xx3HHNzGTcZEER2k= X-Received: by 2002:a50:e149:: with SMTP id i9mr1373860edl.56.1603966143208; Thu, 29 Oct 2020 03:09:03 -0700 (PDT) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id m1sm1198650ejj.117.2020.10.29.03.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 03:09:02 -0700 (PDT) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Martin Blumenstingl , Willy Liu Subject: [PATCH net-next 18/19] net: phy: realtek: implement generic .handle_interrupt() callback Date: Thu, 29 Oct 2020 12:07:40 +0200 Message-Id: <20201029100741.462818-19-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029100741.462818-1-ciorneiioana@gmail.com> References: <20201029100741.462818-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Martin Blumenstingl Cc: Willy Liu Signed-off-by: Ioana Ciornei --- drivers/net/phy/realtek.c | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index fb1db713b7fb..dd77703af1be 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -149,6 +149,60 @@ static int rtl8211f_config_intr(struct phy_device *phydev) return phy_write_paged(phydev, 0xa42, RTL821x_INER, val); } +static irqreturn_t rtl8201_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, RTL8201F_ISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (irq_status == 0) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + +static irqreturn_t rtl821x_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, RTL821x_INSR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (irq_status == 0) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + +static irqreturn_t rtl8211f_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (irq_status == 0) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int rtl8211_config_aneg(struct phy_device *phydev) { int ret; @@ -556,6 +610,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8201F Fast Ethernet", .ack_interrupt = &rtl8201_ack_interrupt, .config_intr = &rtl8201_config_intr, + .handle_interrupt = rtl8201_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, .read_page = rtl821x_read_page, @@ -582,6 +637,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8211B Gigabit Ethernet", .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211b_config_intr, + .handle_interrupt = rtl821x_handle_interrupt, .read_mmd = &genphy_read_mmd_unsupported, .write_mmd = &genphy_write_mmd_unsupported, .suspend = rtl8211b_suspend, @@ -601,6 +657,7 @@ static struct phy_driver realtek_drvs[] = { .name = "RTL8211DN Gigabit Ethernet", .ack_interrupt = rtl821x_ack_interrupt, .config_intr = rtl8211e_config_intr, + .handle_interrupt = rtl821x_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, .read_page = rtl821x_read_page, @@ -611,6 +668,7 @@ static struct phy_driver realtek_drvs[] = { .config_init = &rtl8211e_config_init, .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211e_config_intr, + .handle_interrupt = rtl821x_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, .read_page = rtl821x_read_page, @@ -621,6 +679,7 @@ static struct phy_driver realtek_drvs[] = { .config_init = &rtl8211f_config_init, .ack_interrupt = &rtl8211f_ack_interrupt, .config_intr = &rtl8211f_config_intr, + .handle_interrupt = rtl8211f_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, .read_page = rtl821x_read_page, @@ -670,6 +729,7 @@ static struct phy_driver realtek_drvs[] = { */ .ack_interrupt = genphy_no_ack_interrupt, .config_intr = genphy_no_config_intr, + .handle_interrupt = genphy_handle_interrupt_no_ack, .suspend = genphy_suspend, .resume = genphy_resume, }, -- 2.28.0