From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37DEEC76196 for ; Thu, 23 Mar 2023 14:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231882AbjCWOtZ (ORCPT ); Thu, 23 Mar 2023 10:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbjCWOtR (ORCPT ); Thu, 23 Mar 2023 10:49:17 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F4C113C0; Thu, 23 Mar 2023 07:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kq/ue7wGgTFGUzW69Vf2Bw/C+gOE5WPwtv5TM9ErifE=; b=g+x3wPOcQBmEbr/fo+Ii280r+c a3wpLw1a3jiqC0cxpflxZXhqL0DbumsUQe5xktkglhPjV6OCzcQ6TQ22rmAlUU5AzJKujiKGR1v8M 16gbjuu7oP/ySSXvmJYBEysTkVBbZ8ehZRxKn4MeNTZbxdeYgUyogdFUn5ja3HGeCfdOzN++vPN+o U8nkZig0SA9qSelcKomk6jMGMTgu2zCH7oSo0hKY6sMl8BeWzyy/7VESZJIOeqqmUvQKKbGgQrBtg 2BX+nNs8VeI22EA4teVmWekNzEs9/pGwBNILtWUFIH8J1/r9fUVlrlOczrV2zRn92ujieX+lqfm6U L6CxiQHw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:45254) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pfMFT-0005IM-CQ; Thu, 23 Mar 2023 14:49:03 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pfMFR-0001T9-9Q; Thu, 23 Mar 2023 14:49:01 +0000 Date: Thu, 23 Mar 2023 14:49:01 +0000 From: "Russell King (Oracle)" To: Andy Shevchenko Cc: Andrew Lunn , Heiner Kallweit , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: Re: [PATCH RFC net-next 3/7] net: dsa: use fwnode_get_phy_mode() to get phy interface mode Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Mar 23, 2023 at 04:38:29PM +0200, Andy Shevchenko wrote: > On Thu, Mar 23, 2023 at 02:31:04PM +0000, Russell King (Oracle) wrote: > > On Thu, Mar 23, 2023 at 04:03:05PM +0200, Andy Shevchenko wrote: > > > On Wed, Mar 22, 2023 at 12:00:06PM +0000, Russell King (Oracle) wrote: > > ... > > > > > + struct fwnode_handle *fwnode; > > > > > > > + fwnode = of_fwnode_handle(dp->dn); > > > > > > const struct fwnode_handle *fwnode = of_fwnode_handle(dp->dn); > > > > > > ? > > > > Why const? > > Do you modify its content on the fly? Do you want to litter code with casts to get rid of the const? > For fwnode as a basic object type we want to reduce the scope of the possible > modifications. If you don't modify and APIs you call do not require non-const > object, use const for fwnode. Let's start here. We pass this fwnode to fwnode_get_phy_mode(): include/linux/property.h:int fwnode_get_phy_mode(struct fwnode_handle *fwnode); Does fwnode_get_phy_mode() alter the contents of the fwnode? Probably not, but it doesn't take a const pointer. Therefore, to declare my fwnode as const, I'd need to cast the const-ness away before calling this. Then there's phylink_create(). Same problem. So NAK to this const - until such time that we have a concerted effort to making functions we call which do not modify the "fwnode" argument constify that argument. Otherwise it's just rediculously crazy to declare a variable const only to then litter the code with casts to get rid of it at every call site. Please do a bit of research before making suggestions. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!