From patchwork Mon Nov 23 15:38:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 331983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70957C63697 for ; Mon, 23 Nov 2020 15:39:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33CD92080A for ; Mon, 23 Nov 2020 15:39:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IurMSwYn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389705AbgKWPjE (ORCPT ); Mon, 23 Nov 2020 10:39:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389649AbgKWPjC (ORCPT ); Mon, 23 Nov 2020 10:39:02 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D486C061A4D; Mon, 23 Nov 2020 07:39:02 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id a16so23935599ejj.5; Mon, 23 Nov 2020 07:39:02 -0800 (PST) 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=+FeXibTuIgwGfVQRfzn1QNcdeuVRN4zL8aR37xT1P1E=; b=IurMSwYnPKLYb4Iqmtc/C5bWUGna4RmdWi5lMn3oj6+TZM4aoCTJOatM+LSEcqAfc5 5+OU7an60iO34LKtloCoKslhW4st8kvXA5OsUrxRUxWEA92gwFBymUS9GsdWaWW3Wgpm gvru1ESD0UGXOlOPSTK3IqIdLEAL4FJAQv+FFq/W9dk5p5VtDAkay8mm7NvL4ltDHTu5 Tp34i13xf5oxXL8PSikjD2EmuESLBqkfSBZCbcflL17LwLjTVAdzcMKdkpo3EPzYo6xn lI+9KhosO4mGrMrg1furqV/We6lxHj95syomMT2fGggoyFltUu9WORRsatht7Y7awke0 x1pw== 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=+FeXibTuIgwGfVQRfzn1QNcdeuVRN4zL8aR37xT1P1E=; b=cmnUDFsDJEA0ZZWRMmdFlYDKcrYKlV/DJFK4TBcK3UCSTgn9KHyEJAcZGVVOYufPFE SXUh5XpC2/ojiYOR5mPDXLCcZya2+8wBw9zluBhfc5kXNgBNYVITpVVUrFLZTP11+jHO iTDCwldoXvF2laTT5VfZ4J4Nx1d/d5gS0/0qWhXs5zmWmq64ohx/QatBtG0ON3IbEVLv j3cWkma/mmEi9u7aBtmT8tZR+V4sZ9RXxmlLMHsjgXJWOKb4U3X5l0bLc2+QP5r/BOW6 bkn9CmA/U+K6XO221XJ1pQ7UOJ5kuRHSLjIsScsmQGgplRMW4ZGj9DLNgCcS+WpoyZgp bnMg== X-Gm-Message-State: AOAM530/GlpvPZBXgweNDToVJ3aVt/UU9kFeY+4eShaaLK7yWuSA5JyD lOZftWNBWnsD2OnGv8DZqho= X-Google-Smtp-Source: ABdhPJzbXW1OKamSInKqoX74QDVRyyD9wIGtXiZ+468HVMMYCEfeb5bXfTxii9EAgtnswat5868SQw== X-Received: by 2002:a17:906:f186:: with SMTP id gs6mr162629ejb.171.1606145940827; Mon, 23 Nov 2020 07:39:00 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:39:00 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei Subject: [PATCH net-next 14/15] net: phy: qsemi: remove the use of .ack_interrupt() Date: Mon, 23 Nov 2020 17:38:16 +0200 Message-Id: <20201123153817.1616814-15-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Also, add a comment describing the multiple step interrupt acknoledgement process. Signed-off-by: Ioana Ciornei --- drivers/net/phy/qsemi.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c index 97f29ed2f0ca..d5c1aaa8236a 100644 --- a/drivers/net/phy/qsemi.c +++ b/drivers/net/phy/qsemi.c @@ -75,6 +75,10 @@ static int qs6612_ack_interrupt(struct phy_device *phydev) { int err; + /* The Interrupt Source register is not self-clearing, bits 4 and 5 are + * cleared when MII_BMSR is read and bits 1 and 3 are cleared when + * MII_EXPANSION is read + */ err = phy_read(phydev, MII_QS6612_ISR); if (err < 0) @@ -96,11 +100,22 @@ static int qs6612_ack_interrupt(struct phy_device *phydev) static int qs6612_config_intr(struct phy_device *phydev) { int err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + /* clear any interrupts before enabling them */ + err = qs6612_ack_interrupt(phydev); + if (err) + return err; + err = phy_write(phydev, MII_QS6612_IMR, MII_QS6612_IMR_INIT); - else + } else { err = phy_write(phydev, MII_QS6612_IMR, 0); + if (err) + return err; + + /* clear any leftover interrupts */ + err = qs6612_ack_interrupt(phydev); + } return err; @@ -133,7 +148,6 @@ static struct phy_driver qs6612_driver[] = { { .phy_id_mask = 0xfffffff0, /* PHY_BASIC_FEATURES */ .config_init = qs6612_config_init, - .ack_interrupt = qs6612_ack_interrupt, .config_intr = qs6612_config_intr, .handle_interrupt = qs6612_handle_interrupt, } };