Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1107442imm; Thu, 4 Oct 2018 08:17:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV63oWAa/PB5d3uZHC2m1nTu4st3+S9w22421kCVUftJwFU3OkzwIN6txD0DtBCoUQjLrypY5 X-Received: by 2002:a63:5f05:: with SMTP id t5-v6mr6029462pgb.352.1538666220732; Thu, 04 Oct 2018 08:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538666220; cv=none; d=google.com; s=arc-20160816; b=ucw4955NKAcoJbgdVymOSppc2wYzu6h/Yeo9zeJtVEy9pnSL7ttArLD5e89yX/bDBg H1+zHetUjphfn36dR0P6G1stgvQ3tSxxcsDmyNpKjQKZuI2sta8q3UWmQn5H9mvxpu6e 0VSLdbRUUujfhJK11bQ07J6pggRhXDDnuW5blBP1uLYrqEVyliSCUCMm1GoI0GKIJClP 5o5xF3XU59/otai97LsTsammymFy600idKI1YkplQOxehA9TM8Jwc8jms5lysegqEPqU hlEbZghfjJOW3nDvWOzDH788XPTa/zOq8+S3akO/g/8QHAhL7dORoV1dUvae4vBmonon /hKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rLXJLGLbUNC+wDOIeuKfWvWaWFSEJwlmKlHt/R3XqaI=; b=DCLzFGIHHHezaulo9xlU86iywLTK9EoXTG//sLFWT4NTQKZ1ZXrAppNox0mOvd6+Mt ihgdlDc/ko9blAlHxD24OMTpu3Uigq+9IKmC5dXhohgFoN529gSqe32muCIfKoJodf6s iD4qanvAzX64X3Hy6qbCw50s+CgCisKGca0CJbrt7y+0KK3oPw48sn+K1hzp1lDeYuwW caLkwNRYMyD9nPzK88gt7FFHHpH84/MwEzuq6ofEo2I5lb406rLj2nW3YQaYDHo4RSRu kQvlTuPnytKQCE88n76H8wKAtdRC5uEbA6nl0KYmkQLmJ+j8Qojpmvai+WrDnDfZ9dAz VEtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="DVz5Cea/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7-v6si4549768pgj.532.2018.10.04.08.16.44; Thu, 04 Oct 2018 08:17:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="DVz5Cea/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbeJDWKU (ORCPT + 99 others); Thu, 4 Oct 2018 18:10:20 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:53844 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727355AbeJDWKU (ORCPT ); Thu, 4 Oct 2018 18:10:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=rLXJLGLbUNC+wDOIeuKfWvWaWFSEJwlmKlHt/R3XqaI=; b=DVz5Cea/KBuzLzd87yePaFXKR1jb6A8yippQzA8LiucukLL9Z+MgnhKS1iYqg/gYxQUBG8BalaIdhRgQyb56HOKoMzK+FjCVM6a7yNJSb9WBTYVPoGniKy8NWZu5jyqvwP1GDiiBNJTWo+bxQ38B1eP5PNK6vlmJE1KhOOSMRC4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1g85Mc-0007EI-US; Thu, 04 Oct 2018 17:16:30 +0200 Date: Thu, 4 Oct 2018 17:16:30 +0200 From: Andrew Lunn To: Quentin Schulz Cc: davem@davemloft.net, f.fainelli@gmail.com, allan.nielsen@microchip.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, thomas.petazzoni@bootlin.com, alexandre.belloni@bootlin.com Subject: Re: [PATCH net-next v2 1/6] net: phy: mscc: migrate to phy_select/restore_page functions Message-ID: <20181004151630.GE4730@lunn.ch> References: <20181004124728.9821-1-quentin.schulz@bootlin.com> <20181004124728.9821-2-quentin.schulz@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181004124728.9821-2-quentin.schulz@bootlin.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 04, 2018 at 02:47:23PM +0200, Quentin Schulz wrote: > @@ -197,25 +199,30 @@ static int vsc85xx_mdix_set(struct phy_device *phydev, u8 mdix) > if (rc != 0) > return rc; > > - rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED); > - if (rc != 0) > - return rc; > + oldpage = phy_select_page(phydev, MSCC_PHY_PAGE_EXTENDED); > + if (oldpage < 0) { > + rc = oldpage; > + goto out; > + } > > - reg_val = phy_read(phydev, MSCC_PHY_EXT_MODE_CNTL); > + reg_val = __phy_read(phydev, MSCC_PHY_EXT_MODE_CNTL); > reg_val &= ~(FORCE_MDI_CROSSOVER_MASK); > if (mdix == ETH_TP_MDI) > reg_val |= FORCE_MDI_CROSSOVER_MDI; > else if (mdix == ETH_TP_MDI_X) > reg_val |= FORCE_MDI_CROSSOVER_MDIX; Hi Quentin Could you use phy_modify_paged() here? This function only accesses a single register, so using the wrapper should not have any disadvantages. The same should apply for any function modifying a single register. > - rc = phy_write(phydev, MSCC_PHY_EXT_MODE_CNTL, reg_val); > + rc = __phy_write(phydev, MSCC_PHY_EXT_MODE_CNTL, reg_val); > if (rc != 0) > - return rc; > + goto out; > > - rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD); > - if (rc != 0) > + rc = phy_restore_page(phydev, oldpage, rc); > + if (rc < 0) > return rc; > > return genphy_restart_aneg(phydev); > + > +out: > + return phy_restore_page(phydev, oldpage, rc); > } > > static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count) > @@ -223,25 +230,24 @@ static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count) > int rc; > u16 reg_val; > > - rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED); > - if (rc != 0) > + rc = phy_select_page(phydev, MSCC_PHY_PAGE_EXTENDED); > + if (rc < 0) > goto out; > > - reg_val = phy_read(phydev, MSCC_PHY_ACTIPHY_CNTL); > + reg_val = __phy_read(phydev, MSCC_PHY_ACTIPHY_CNTL); > reg_val &= DOWNSHIFT_CNTL_MASK; > if (!(reg_val & DOWNSHIFT_EN)) > *count = DOWNSHIFT_DEV_DISABLE; > else > *count = ((reg_val & ~DOWNSHIFT_EN) >> DOWNSHIFT_CNTL_POS) + 2; phy_read_paged()? Any function which just accesses a single register should try to use phy_read_paged(), phy_write_paged() or phy_modify_paged() to avoid a lot of boilerplate code. Andrew