Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6133074rwl; Mon, 9 Jan 2023 04:44:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXvyUZ72tt5WPsxS2r6ajVmUeC6W96q0SJ/esD1dAsf3mGlmuHqFD2BQS/0sJ0K++dPLy6zK X-Received: by 2002:a05:6a21:e384:b0:af:9539:9fc9 with SMTP id cc4-20020a056a21e38400b000af95399fc9mr87138061pzc.47.1673268289244; Mon, 09 Jan 2023 04:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673268289; cv=none; d=google.com; s=arc-20160816; b=ic+2yV7MUFbMZPzVCF522cbmZrv7/HoVUmDd7do0j4zmO4VEbrMMxR5ICD6SQrsx0q lteKYQWuZPWzQ5a0WZJ9SuywMNvgJf7Uns5k0Y/2JXxRbrhN3sZJ53AlCNgQqyoUQ2Rb IpEBUA3gMiPSBFwp6VDGaact+dIHSBYuDZjFYk0RFJEKyzh7pHagHduSnOWVvUYZSz0f OlQKjLGEsoonRXqieWsgNaFRZ2U3xsUeGt8weUxyplEX1KM2XlZoJLAY4lx0iYJHQ+rF TTJo+zvj/AZFSF1oWewN4JwZnGJHF1fo4aTvFDVcsi2uG5PXLI9o72Ya23Znimoc0Bbl Bo/Q== 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=JQKaBY79GF+RPE6e93Lg/pYFuxmQLdWNgR8P0RjYoXg=; b=L7wqHn3SAhmL+NtldsWKrpp4slXuGclhsTnj+yh8af9sxXny09fz3ZfyfkikkdkIew Uo6Aoha+IbFGyx+/ck6wXEhddyYKHEnqJ8JMLPEtJBcG/Ydh9AcRbu8yHN625JdzMsI4 l9UQ/dfsKTyAGw9rSBbFCcgy7EMV91YbnJHBVgRSaWUhF2RW4XSiMwwXL7O2prG2IRgI rOOP+IQf+7sXLK/sWSgOSBaKDbPrDME8nLfbdW9T4VQat73Iktd0wg77SvIoxPaZpd1T feBmUq1sM/e9WXfJKzh7Xxe+2Nlwfq8Hg+S6baJg75tzfFxZgEgt4d4aTyTMufy043DC G2CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b="YNe7fL7/"; 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 28-20020a630f5c000000b004769f0faab8si9076903pgp.740.2023.01.09.04.44.41; Mon, 09 Jan 2023 04:44:49 -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="YNe7fL7/"; 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 S234365AbjAIMfk (ORCPT + 52 others); Mon, 9 Jan 2023 07:35:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233434AbjAIMfc (ORCPT ); Mon, 9 Jan 2023 07:35:32 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456F064FA; Mon, 9 Jan 2023 04:35:31 -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 8B6369FB; Mon, 9 Jan 2023 13:35:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1673267729; 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=JQKaBY79GF+RPE6e93Lg/pYFuxmQLdWNgR8P0RjYoXg=; b=YNe7fL7/NvBT9L6Xe/XKhfiU4deYF+rMcnn0PVQjmP8JXnWJnnkS3k45Axw3ZrVlF835dG mLQILtHhuY/HO+jJTzAgjUYhpeNtQpcwWN3MfskBvly/QmSEDqqw4/g7+wlSqEgBvOWchV r5PnpMP2Ns6mUH0K7HHTxw2Iq3PkYc2/rWu0/FbdurUrmvBL+HOvPeVKDO6aEXB9Rr9GpL AqwASKCUxfm5ylURZ2inKalD18ZZ3BBDbJ2Z/NXdJFJhxakGyaQc0F0cDijDQON8ESHwMG bE99WMg1fhqML2j2+JM6JoPXwjLGUIbtjFqNGWVIEh3KD4iV/aJ4aYBSEOdx9A== MIME-Version: 1.0 Date: Mon, 09 Jan 2023 13:35:29 +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> <37247c17e5e555dddbc37c3c63a2cadb@walle.cc> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <0584195b863b361a4f5c1e27e6c270b3@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 23:19, schrieb Russell King (Oracle): > On Tue, Jan 03, 2023 at 11:21:08AM +0100, Michael Walle wrote: >> 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. > > The only reason I suggested it was because when looked at your code, > it also took several reads to work out what it was trying to do! > > Would using !!bus->read != !!bus->write would help or make it worse, > !!ptr being the more normal way to convert something to a boolean? IMHO that makes it even harder. But I doubt we will find an expression that will work for everyone. I'll go with your suggestion/Andrew's first version in the next iteration. -michael