Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp301529pxb; Thu, 31 Mar 2022 05:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIOfpbS+97AR8hLvCW+X0ogp95jiDYxLJl2+2BlKKpp5Sb+PL5C9a3u6HAtQwBP+8pdEwn X-Received: by 2002:a17:903:124a:b0:154:c7a4:9375 with SMTP id u10-20020a170903124a00b00154c7a49375mr4922592plh.0.1648731426941; Thu, 31 Mar 2022 05:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648731426; cv=none; d=google.com; s=arc-20160816; b=iz/mELS6/YdXNzabAUGDcHzD2K9VuBj/w5EN2Ki88T5U/tYttIGzwEAjLtGIssd+9h ICI/3faUcTgWhGwh56ZbOSoFPN4dAa+7h1zW7TjcRYKpcRNGvGxrdTLlb7ZsGKRhCBPC E7+fr2602QmxzXYHK3pMhk305sSClEmFvt7LQITT5jguMK3hHy60o2QFc63O//tzfbr+ EN1VTygqtAYEInaTd0iFZ4YbpDZzbeJVOiUFtZNA57wplpdz+J6bf6Qg9uxz8ckyZP1Q 51jZE+d/cg9yhl2V/pwuT4ML7aS9rS/jNNm2jrKbLV9pFh9ZIwmDk9ri6ULNbOmAz3II csiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=xLBmDR105PDmmrWw4p/m3U41pcGdvFhEUw0TeW5bDNE=; b=qb88bvh2QsfMeR7iSIN4KPkiFOqGTNynchin4iRoQOWXtmrIWf5F/lSUMLhCJg54Fr XsIwO2J7mZDrnJ3FSr9vjLr1MpnvdXNFx3ymHJfW+FUGDkwCyLdzHW7bWSnUr1FzFCEN 9Y8OPlgu4AAZWfvHy1/+DCfIUF+PztAh4t++YzfoV2jKjqRhPMXy6PyCo0Bxk78CLqF8 UEqocu82MBa5QXN4ND/mFzsTcf6GZF0bb+VVX7g5EDm3Z7zN5p3PxN8S3RFzwo636/G3 P54JWm670iC1F1ok0eF7m17yxuNz8q1LIFND0XSwwLbahhov4pvkkt95W1z5anEDgaN5 QJpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=W1xRlWIq; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902724600b00153b2d1665esi22163226pll.614.2022.03.31.05.56.51; Thu, 31 Mar 2022 05:57:06 -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; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=W1xRlWIq; 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 S232801AbiCaI34 (ORCPT + 99 others); Thu, 31 Mar 2022 04:29:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232797AbiCaI3y (ORCPT ); Thu, 31 Mar 2022 04:29:54 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5DA1C9B6A; Thu, 31 Mar 2022 01:28:07 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id DC76222246; Thu, 31 Mar 2022 10:28:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648715285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xLBmDR105PDmmrWw4p/m3U41pcGdvFhEUw0TeW5bDNE=; b=W1xRlWIqee+MF+MuWb7M1g0mk/kRz4fGc0y59p8rQAEjNFvMXG24hkNHs9nd7/thGGp02q e7RPyvg19Ua1iSeEUneD7nDWwOvFOH4a3pDe5CTnCRxGiUkmvdQdlzkKoJGvomw2HrnpNY mdFwr11MrtNYI0MXUTJ8xXn0t8DOAxw= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 31 Mar 2022 10:28:04 +0200 From: Michael Walle To: "Russell King (Oracle)" Cc: Andrew Lunn , Heiner Kallweit , Jakub Kicinski , Paolo Abeni , "David S . Miller" , Xu Liang , Alexandre Belloni , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC net-next 2/5] net: phy: support indirect c45 access in get_phy_c45_ids() In-Reply-To: References: <20220323183419.2278676-1-michael@walle.cc> <20220323183419.2278676-3-michael@walle.cc> <43227d27d938fad8a2441363d175106e@walle.cc> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: michael@walle.cc X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Am 2022-03-30 18:18, schrieb Russell King (Oracle): > On Wed, Mar 23, 2022 at 11:14:11PM +0100, Michael Walle wrote: >> I actually had that. But mmd_phy_indirect() doesn't check >> the return code and neither does the __phy_write_mmd() it >> actually deliberatly sets "ret = 0". So I wasn't sure. If you >> are fine with a changed code flow in the error case, then sure. >> I.e. mmd_phy_indirect() always (try to) do three accesses; with >> error checks it might end after the first. If you are fine >> with the error checks, should __phy_write_mmd() also check the >> last mdiobus_write()? > > The reason for that goes back to > commit a59a4d1921664da63d801ba477950114c71c88c9 > phy: add the EEE support and the way to access to the MMD > registers. > > and to maintain compatibility with that; if we start checking for > errors now, we might trigger a kernel regression sadly. I see that this is the commit which introduced the mmd_phy_indirect() function, but I don't see why there is no return code checking. Unlike now, there is a check for the last read (the one who reads MII_MMD_DATA). That read which might return garbage if any write has failed before - or if the bus is completely dead, return an error. Current code will just return 0. In any case, I don't have a strong opinion here. I just don't see how that function could be reused while adding error checks and without making it ugly, so I've just duplicated it. Maybe something like this: static int __phy_mmd_indirect_common(struct mii_bus *bus, int prtad, int devad, int addr, bool check_rc) { int ret; /* Write the desired MMD Devad */ ret = __mdiobus_write(bus, phy_addr, MII_MMD_CTRL, devad); if (check_rc && ret) return ret; /* Write the desired MMD register address */ ret = __mdiobus_write(bus, phy_addr, MII_MMD_DATA, regnum); if (check_rc && ret) return ret; /* Select the Function : DATA with no post increment */ ret = __mdiobus_write(bus, phy_addr, MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR); if (check_rc && ret) return ret; return 0; } int __phy_mmd_indirect(struct mii_bus *bus, int prtad, int devad, int addr) { return __phy_mmd_indirect_common(bus, prtad, devad, addr, true); } /* some function doc about deliberatly no error checking.. */ void __phy_mmd_indirect_legacy(struct mii_bus *bus, int prtad, int devad, int addr) { __phy_mmd_indirect_common(bus, prtad, devad, addr, false); } should the last two functions be static inline? -michael