Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6158533rwl; Mon, 9 Jan 2023 05:04:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXvw1KtloXC+QpH2VNu1dXr1LjHAAlAzZqX4X1O8f/3k5eK8R+SQr9JAoGlPnO8edY8xc+bp X-Received: by 2002:a17:906:6402:b0:7c1:962e:cf24 with SMTP id d2-20020a170906640200b007c1962ecf24mr52661120ejm.50.1673269481624; Mon, 09 Jan 2023 05:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673269481; cv=none; d=google.com; s=arc-20160816; b=nUq/nnCA81Zdlo1eiLBoFhALKUad2QIyoNIdj+OXgltiZXLpWScRLvfODde7nvLhLN 2hx8108l/h73BUogoDptuLXVsxClkPB3kPSJ99meJLvOPjbkR36jJQY++4ezmEbLWe1y XbrxvovfaSmG8ARdbHMoLQ2aXplOkwr+7ux9CNRUQujZsGK+vd7PlNjwPldNDZ3sVrvr OVv+yYVtZeg5frHxa2M+h8dLDRI9ZFpn0K9J9+BL8lbByZua/D60bGq7+QgYRU/U1ykZ HZifeqpwBwgM1V+DCHHGBuVnHRK302usm+57q6A9zV7FlLIvXJc+dd14U65aLOn87TRa PL7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JGewXTLqSFz0s2fQ/uiqIpRGEfPE9NdhCOeAHQbwGQ4=; b=Tigd9BEklI4BTXzyzf7gZwBCMfqNWpUwbWU3slvGQv5YiRAsJcMjmjEj//xcNnBbgY 9taK/2jYU+ELEGuDyiYEPVzyF8mdOO4WJlHGxYyaW38PD3EIzFoIqWyigW7IUG42zRHl eTBxC173tY04QJrC4soeXLlarF2g5yCKnrfjLC8d+AXlNQqC7l4CzhQ+oaPy6WWfdOR+ AmmmpU1+aaDH7B3zbH7+oJmHIEpvEedUz/4i1aealWqkBuyOT8KJCfBDRkUlR6wJKvu2 t+URA+tYGRPh9MLzkV1GUZOZejdZSDgS1OFDbs3J4cya93fDcsVtc5pUhx8g/hfw0HYY Co+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=niw7LwOo; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wz7-20020a170906fe4700b00829cbd5f6f2si7717509ejb.498.2023.01.09.05.04.28; Mon, 09 Jan 2023 05:04:41 -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=@gmail.com header.s=20210112 header.b=niw7LwOo; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233629AbjAIMlZ (ORCPT + 54 others); Mon, 9 Jan 2023 07:41:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbjAIMlW (ORCPT ); Mon, 9 Jan 2023 07:41:22 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03C34DED8; Mon, 9 Jan 2023 04:41:21 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id c17so12263984edj.13; Mon, 09 Jan 2023 04:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=JGewXTLqSFz0s2fQ/uiqIpRGEfPE9NdhCOeAHQbwGQ4=; b=niw7LwOoXihZAh8slgQZqcziXoVi78Vi+LO4SGwAlxnMerGgKYyKrD7KNQ6i5NAmhM BGS4Z6cn31pJ6astgoj9Y3UwY0GdTwvwTBpNxSrW2N9UdXD+R/Sv1VTszs6TLG+q2gZd 0S+vZSl0qR7C6vpZhXvDk9hWPJJLITkm6aA0U6S6wQnP03t0vYb5y2QPilAz18Sr5zZU 5HEdF3cqTQ5SVv8GSqVb8TpcUw6KYbG8tUWh/aF52RGJ7gmHyAc1G3jpwlDTKQhHNkVt +GpGqybeJWI3IzbVIhdRfniC78iIe8dc2p5rNazLHzJfAuO0dkMJ+b1vBtbXAhHF/21g akiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JGewXTLqSFz0s2fQ/uiqIpRGEfPE9NdhCOeAHQbwGQ4=; b=tBcm8oW1ehgbe3JufCFMO4X76YIMscami/BnpEs4PaX0KofhGszsdWX+o4hjpvGVaa /2dRjbhL8xxW8CcgHMO8MprmzQFe6eV1/S4DsB8iAwlqMftAujx3XDZ8d7J/+OOo3+Yb dn860Ug3bPqUrG2W17c4PWSu16ZJMIZDDncWkjiIyaj3tVuO2tFem2pbo9ztgS2Y2wpL EuBwzGho9WyH2fX2LWFGbarGHonGQKQJaGV1kjS8OnAwSzJbV0ApEPzExgYR9NQbupZL SokMV4+oZMgs3IeLsyI4MQ4FwW+AX3qDjKajQIP//raQQhpoykvQa2JEeHZikY+EHJei TTnw== X-Gm-Message-State: AFqh2krC9psBl/ESU7dmdKOA0YQIDOWq+BGxrdc3/TPoKJ7PKgkwq1to KRRRbHuS+OK4ElqDVl57pcnF0AcA8rtCLg== X-Received: by 2002:a05:6402:3ce:b0:481:f14d:fda5 with SMTP id t14-20020a05640203ce00b00481f14dfda5mr51894230edw.39.1673268079446; Mon, 09 Jan 2023 04:41:19 -0800 (PST) Received: from skbuf ([188.27.185.38]) by smtp.gmail.com with ESMTPSA id j17-20020a17090623f100b00770812e2394sm1668190ejg.160.2023.01.09.04.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 04:41:18 -0800 (PST) Date: Mon, 9 Jan 2023 14:41:16 +0200 From: Vladimir Oltean To: Michael Walle Cc: "Russell King (Oracle)" , 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 , 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 Message-ID: <20230109124116.tqsnhh6xvg6e4m4l@skbuf> 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> <0584195b863b361a4f5c1e27e6c270b3@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0584195b863b361a4f5c1e27e6c270b3@walle.cc> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On Mon, Jan 09, 2023 at 01:35:29PM +0100, Michael Walle wrote: > 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. I think the double negation conveys the intention better than the simple one, actually (maybe even xor instead of != ?). In terms of readability I think I prefer the way the patch is written right now, but if you keep the comment, the double negation should be pretty easy to swallow too.