From patchwork Tue Dec 27 23:07:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 37018 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1622087wrt; Tue, 27 Dec 2022 15:08:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQIzMTgystGS0TJ9TATV2U//8p41PCVjp1ZaDaz1+scM3lrzs+K/9Ruf+BNvC46pZFt8wH X-Received: by 2002:a17:902:f34a:b0:192:75b8:b461 with SMTP id q10-20020a170902f34a00b0019275b8b461mr8019809ple.37.1672182539024; Tue, 27 Dec 2022 15:08:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672182539; cv=none; d=google.com; s=arc-20160816; b=vJximUKi8JlYGR+/xWUrma2qTpH0gfDsJUKqsl2UJEf7z0TdP98Is+hMqDExdE31bL nUST6+O3+dbzYl/Wb5SLGCP7vjkfm8N/DoF9TialeqycZX3uEpCPuLgb4mBOJzp8Yh/y E0KpJlYbokh4IYJhjvP1ZQtLtPxTSR9pNNqxyBaVePNyr198sXgVIsYEr7GlghM1lN3T eTkQJ5P2JkrO9uQ/O3EGWh+OEGVvVrhW0BOU1VJh5QPXvbVELPrwDTrCxMcpYYdM7NjL iHJaXDrXGESqaAdX+AGYi4wZUKGw52Qfo02lzo16upgc+DmDKoZvoX3LCYHlt3sA4EVT injQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Q+FQH7xKg3mu7py/TKhsNiqXLlNql6R3XEpSBYuofsU=; b=vy1VfJAdHaMP8baMIE29+ms5Vw4WRCo1RBTwnvYzgO2Xm33gQ2wv1Pma4nnG2jcvZi 8MCOKf5NUvMQs60ezPjV+2bzkRv1VF/cLtC+ofG52N2aJmAXFms+wWKuzv2zHercbXD0 ixZmUhKr8nvyLXzW9qnUel0FUTHUbo7mjfrDi/7+OJO+X3mJNFyp8/1CWvowTplX/P/C nDS3V+QlMUVuWP/7QqSKHC6sbZdfcXUn55dNPFhcxZ6AGSA6Y0nyKAzI2zxAmce3rh96 iKMsYI2xd43vhzQI0gr8UukWwj8JMT0AMil18br1/TfQFp0dk6h9MG3aS6+LWkap+Ibq Rryw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b="K9x/Tqb5"; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a65490c000000b00489a4cba354si15811361pgs.453.2022.12.27.15.08.47; Tue, 27 Dec 2022 15:08:58 -0800 (PST) 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=mail2022082101 header.b="K9x/Tqb5"; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232585AbiL0XI0 (ORCPT + 99 others); Tue, 27 Dec 2022 18:08:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232183AbiL0XHp (ORCPT ); Tue, 27 Dec 2022 18:07:45 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F3063E7; Tue, 27 Dec 2022 15:07:28 -0800 (PST) Received: from mwalle01.sab.local (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 0AD3516DC; Wed, 28 Dec 2022 00:07:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1672182447; 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=Q+FQH7xKg3mu7py/TKhsNiqXLlNql6R3XEpSBYuofsU=; b=K9x/Tqb5P1nRpEongrUKmS2tFJkrt6WI0YbaSK1bz3NUJ4GNh7M1ZUAbjLrvZ7n187EBM+ xCtBIsPzLPn/fn/9WpgcwKEE/L9sqzy2+1Y7AmCU+R1j3AINHElvHam2GtAW9ewKWWgl1s 10r06HbkFOGtjubpeTsptw03a2i7f1n7UMmIluykbzQC6pag2sOznEsJva9QQv3Dr72z8f FJQF+bbcqkApXokAI61LjbxTBOCbjKwsP4wQiA7bm5YPb1nNfEf6ru7UjjI172Ie/H0tmF Kax7544yq9brnJLLt5ASPsgCptbMLbcpKK2gAW3a989X27X3CTSe/+BGMlk0Pg== From: Michael Walle Date: Wed, 28 Dec 2022 00:07:20 +0100 Subject: [PATCH RFC net-next v2 04/12] net: mdio: C22 is now optional, EOPNOTSUPP if not provided MIME-Version: 1.0 Message-Id: <20221227-v6-2-rc1-c45-seperation-v2-4-ddb37710e5a7@walle.cc> References: <20221227-v6-2-rc1-c45-seperation-v2-0-ddb37710e5a7@walle.cc> In-Reply-To: <20221227-v6-2-rc1-c45-seperation-v2-0-ddb37710e5a7@walle.cc> To: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jose Abreu , Sergey Shtylyov , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , Sean Wang , Landen Chao , DENG Qingfang , Florian Fainelli , Vladimir Oltean , Matthias Brugger Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Andrew Lunn , Geert Uytterhoeven , Michael Walle X-Mailer: b4 0.11.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753410478036946516?= X-GMAIL-MSGID: =?utf-8?q?1753410478036946516?= From: Andrew Lunn When performing a C22 operation, check that the bus driver actually provides the methods, and return -EOPNOTSUPP if not. C45 only busses do exist, and in future their C22 methods will be NULL. Signed-off-by: Andrew Lunn Signed-off-by: Michael Walle --- drivers/net/phy/mdio_bus.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index d14d7704e895..20ba38a346fe 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -769,7 +769,10 @@ int __mdiobus_read(struct mii_bus *bus, int addr, u32 regnum) lockdep_assert_held_once(&bus->mdio_lock); - retval = bus->read(bus, addr, regnum); + if (bus->read) + retval = bus->read(bus, addr, regnum); + else + retval = -EOPNOTSUPP; trace_mdio_access(bus, 1, addr, regnum, retval, retval); mdiobus_stats_acct(&bus->stats[addr], true, retval); @@ -795,7 +798,10 @@ int __mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val) lockdep_assert_held_once(&bus->mdio_lock); - err = bus->write(bus, addr, regnum, val); + if (bus->write) + err = bus->write(bus, addr, regnum, val); + else + err = -EOPNOTSUPP; trace_mdio_access(bus, 0, addr, regnum, val, err); mdiobus_stats_acct(&bus->stats[addr], false, err);