Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3783564rwl; Tue, 27 Dec 2022 15:19:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXsd55zdDutsKhqp4ag6lvpPAnZ+mCJklk88AConLVslP1MRtqnc4++ax/AnkNI/+jV1aPWK X-Received: by 2002:aa7:de15:0:b0:483:30d7:f9ac with SMTP id h21-20020aa7de15000000b0048330d7f9acmr10695259edv.19.1672183169149; Tue, 27 Dec 2022 15:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672183169; cv=none; d=google.com; s=arc-20160816; b=vO1o3304tkbG+sDyLjqd44t8kfJXcaKeqSw572lYoAMjWaZ+Twgg1YxlKCG2JNe0rs /PLugCkuX9XDVCLiOEsnFji6KBtzdv7FBTYSAQYUA3R4+ex/kT/Z0mJeapqDDngCenZR R36lC3ljiwEfJU610jDKbZQl495Q8pSIYwYu4/bgUh0VEiIt7QCEe27Kegm1WV5sTMAa yTRVPQfUNU8NNXnMyF17olLoc7gKbTNeVdmjkVP7DblcxygfQNXxwvQHr1/lx0uJlq+V wlCEdXRsnPQSkqaaJcLhFQ63LT4rfZzdGABgz47nasK6sLWnMSLwXjPAuU7/WgauUQkA Iu1Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020a05640226c100b0046cad997ceasi13365715edd.455.2022.12.27.15.19.13; Tue, 27 Dec 2022 15:19:29 -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 + 66 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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); -- 2.30.2