Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11658930rwl; Tue, 3 Jan 2023 02:49:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXvT0OcKgsUyU0Uw0n26S+DS7xQ1EaJLvU6FDTkk3LjdXB/C6ozT2IewTeSiJjQE5/l11waR X-Received: by 2002:a17:907:c203:b0:7ad:84c7:503a with SMTP id ti3-20020a170907c20300b007ad84c7503amr36426443ejc.72.1672742949988; Tue, 03 Jan 2023 02:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672742949; cv=none; d=google.com; s=arc-20160816; b=JVP5yrneSC19bKYWdMKDAHG4dD91SzOhN9xH0jdhWjafLB3OuYnUdZn5a6vZ4rKXnx H15NCkYG8H6wZMekEjWshgUQg2T+7FHNJ/WsUO7ZlL694w602uIl28hB6nVciQjtNYQ0 EA6i48yatIqmjf35QpcH1vBFNoWYDnh19Zhdkz6x7qUHXoXcTRJ06C7endKg3z1bCWni 7+Qn3qnXPzonkrkjlGngJEPbzOv5xESaOQJl+2KtkbnfhDY09FzmRzBP6+EZ43v97r9f tYN/bEyv6u1FefP/TPpJg6BOOpXAIB6IjW6Gxu6Mx0bnO/bN5pcbRct6bF4SLp0f+J6a ID9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version :dkim-signature; bh=0NIrlOvbk7vZkei/UjaLevKnqZdjT8W2kPPgWX5gcEM=; b=rzVQBX2QAVklEEJOszWiN5QHJNN5k1UnzDFzJsR2M0OzPUPd1f9lkAbHJoXu8ZHrXJ g/xOGDLMlwq1z2lWm3fK8kYA1yO4ZzZDKawuvkSXm83a3r0UwL4KYQwCjYGOC7lVM1Gq yq6Se3Zn92FxDanIvrmaBpLJAtABESW2Ab+3Oo57hp+6vAIII5AFS2F8qo4L2o1MCMhf A95p+17BpLktfBwAT9/GWzcGbLWi/Pd/ThSfqiYkWcC8f+FK34rmAx+zuu85FY1qYo+m 88KAGaqICPa6EMz1QPt1Vby762R4CluMLO9KDJhEFbeSCeKw2C5WjELKwRG/Zob6XJrk 9j3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=RIvoOPSA; 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 i16-20020a1709064fd000b0073d8ccd37c2si29005353ejw.107.2023.01.03.02.48.55; Tue, 03 Jan 2023 02:49:09 -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=RIvoOPSA; 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 S237246AbjACKWI (ORCPT + 61 others); Tue, 3 Jan 2023 05:22:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237419AbjACKVR (ORCPT ); Tue, 3 Jan 2023 05:21:17 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B90DF28; Tue, 3 Jan 2023 02:21:10 -0800 (PST) Received: from 3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) (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 7021D126D; Tue, 3 Jan 2023 11:21:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1672741268; 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=0NIrlOvbk7vZkei/UjaLevKnqZdjT8W2kPPgWX5gcEM=; b=RIvoOPSAjkHkWRfLX6Q0K/aek6FQU3XreYN5YNfAte2T/48X3VC8QQcEpd8jPJCFiyZzWo YiNwIusJEscDbzhm+hLbf6HNICx53SmA+YBP6AkQJq43zwVjNQZv+E9+UWk/k+GVe5vHsB PpYh33/dKsFzSAcgjfwdUsLd5q72TbERdzSx/SCAm4zwGljRFXGGLdVqfy4IcIf2W5lAZO XjMLUaTiUPYAyq3PtzHwPIZ0R9tR/KsXvd4mja00tvj0OPMSluRJXfI+WgaY/465OcIWYl 25I7JQyqJw8aSZmYLqPK7a2CXyNMEgcEPOPRNCX0T6YnECO/Wo1QlrI2Qv3cuQ== MIME-Version: 1.0 Date: Tue, 03 Jan 2023 11:21:08 +0100 From: Michael Walle To: "Russell King (Oracle)" Cc: Heiner Kallweit , "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 , 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 Subject: Re: [PATCH RFC net-next v2 03/12] net: mdio: mdiobus_register: update validation test In-Reply-To: References: <20221227-v6-2-rc1-c45-seperation-v2-0-ddb37710e5a7@walle.cc> <20221227-v6-2-rc1-c45-seperation-v2-3-ddb37710e5a7@walle.cc> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <37247c17e5e555dddbc37c3c63a2cadb@walle.cc> X-Sender: michael@walle.cc Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit 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 Hi Russell, Am 2023-01-03 11:13, schrieb Russell King (Oracle): > On Wed, Dec 28, 2022 at 12:07:19AM +0100, Michael Walle wrote: >> + if (!bus || !bus->name) >> + return -EINVAL; >> + >> + /* An access method always needs both read and write operations */ >> + if ((bus->read && !bus->write) || >> + (!bus->read && bus->write) || >> + (bus->read_c45 && !bus->write_c45) || >> + (!bus->read_c45 && bus->write_c45)) > > I wonder whether the following would be even more readable: > > if (!bus->read != !bus->write || !bus->read_c45 != !bus->write_c45) That's what Andrew had originally. But there was a comment from Sergey [1] which I agree with. I had a hard time wrapping my head around that, so I just listed all the possible bad cases. I don't have a strong opinion, though. > which essentially asserts that the boolean of !method for the read and > write methods must match. Maybe with that as a comment? -michael [1] https://lore.kernel.org/netdev/ae79823f-3697-feee-32e6-645c6f4b4e93@omp.ru/