Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp406643rwb; Wed, 28 Sep 2022 04:30:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5vezMChVoKyQIUy5zs0Wlzl3GeeCD7tt3jxDw9jMYlu0ie6mLFwCedwgwn86IzPPjkAK5k X-Received: by 2002:a17:906:cc5a:b0:77c:2df2:b78 with SMTP id mm26-20020a170906cc5a00b0077c2df20b78mr26172863ejb.95.1664364625018; Wed, 28 Sep 2022 04:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664364625; cv=none; d=google.com; s=arc-20160816; b=P6+kheuXK1eKHwA5nOy10KCBxmbg7vAYuN4Zc6A5EhNrGFVQIwkyP8c0AJ4+udvuAA MtXIfYr8ReW3d52zVpusSj5VPLWioa38SQEEO2i2Uf2gHHgokD4lrYxs3VLcRfKAELF3 Uzau0bdIAupzck0I18GnqDvbNw0JPKeAof6VRQvyVWrEFvZdRqoMccwWsbqhIEc6sfQH EoE+hB9RtypFr2Xq4+7XDk3O+H5vaiY8n2WqIxjN5RMgjdp941rCLRtNiJoVnzMR3v7e wfK2SgjJjbgixTIgPzpAVS9BUVWQXF9iNnlN4g3paDNw3W3TuIb7aFMjeXazfwE+dBPa SrOA== 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=nFqT/qPoFbYjEx33fybWSXhpIRduHZi7Yol1pzqGL+o=; b=Zdw+04X2gDb3OFxRSyRizpNtWY7qYEK6nxOgTt2nZbzXkijuoKIbMVysS3cIb2krju Dt4Mmf2/q95/sN/k8pcBx9WxEiSDOE9NC2aMLPBoG1l92/Oq5pD+ynfqCaDbelPNR4zA Cvx5K3ycoBizyjrkrcOhG99QmwrNLf0e5w9ehpBzMqZiqnoZruPEhO9YPjpkC4qBaZSs W3rhT7FG+6dnx2/Tk5kIdOahyWXRZ0awwX+N5dLDK0COvCteF/Dml9z0YWlevSlr6GC5 cIt+Zg+K57fvG5bO0Dro1VCVyVPhBaoTlHsRb3+aof6BgTuh9yTmazJDjfj4cHeJ/n+H Z3Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jts7knNV; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a056402279200b0044e848a603bsi5331813ede.79.2022.09.28.04.29.58; Wed, 28 Sep 2022 04:30:25 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Jts7knNV; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234196AbiI1LIZ (ORCPT + 99 others); Wed, 28 Sep 2022 07:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234029AbiI1LH4 (ORCPT ); Wed, 28 Sep 2022 07:07:56 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFF14101962; Wed, 28 Sep 2022 04:05:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1F0AECE1E0E; Wed, 28 Sep 2022 11:05:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84A9AC433C1; Wed, 28 Sep 2022 11:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664363123; bh=hjJNq8fnvzNa+xcgY2fbdv63qk0sriuoXr4L9LoZTA4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Jts7knNVMGAXXpFgv3N/rNxUiA7KZtNei74t90zWvg9uR+501l/R99wtdQ5qLxyBp VWWTnwwfGGar9eaUmoHGjgKMy0+zubfVu884PtbNVzPsfUJ7+pw0SBBpgcnGie9xBw +Fsjp4iOt8VzLrLJumsVOitjdom4jx4GpJto38j0= Date: Wed, 28 Sep 2022 13:05:20 +0200 From: Greg Kroah-Hartman To: Andy Shevchenko Cc: Sakari Ailus , Heikki Krogerus , Bjorn Andersson , Prashant Malani , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Daniel Scally , "Rafael J. Wysocki" Subject: Re: [PATCH v2 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Message-ID: References: <20220928105746.51208-1-andriy.shevchenko@linux.intel.com> <20220928105746.51208-2-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220928105746.51208-2-andriy.shevchenko@linux.intel.com> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Wed, Sep 28, 2022 at 01:57:42PM +0300, Andy Shevchenko wrote: > It's not fully correct to take a const parameter pointer to a struct > and return a non-const pointer to a member of that struct. > > Instead, introduce a const version of the dev_fwnode() API which takes > and returns const pointers and use it where it's applicable. > > Suggested-by: Sakari Ailus > Fixes: aade55c86033 ("device property: Add const qualifier to device_get_match_data() parameter") > Signed-off-by: Andy Shevchenko > Acked-by: Heikki Krogerus > Reviewed-by: Sakari Ailus > --- > drivers/base/property.c | 11 +++++++++-- > include/linux/property.h | 3 ++- > 2 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index 4d6278a84868..699f1b115e0a 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -17,13 +17,20 @@ > #include > #include > > -struct fwnode_handle *dev_fwnode(const struct device *dev) > +struct fwnode_handle *dev_fwnode(struct device *dev) > { > return IS_ENABLED(CONFIG_OF) && dev->of_node ? > of_fwnode_handle(dev->of_node) : dev->fwnode; > } > EXPORT_SYMBOL_GPL(dev_fwnode); > > +const struct fwnode_handle *dev_fwnode_const(const struct device *dev) > +{ > + return IS_ENABLED(CONFIG_OF) && dev->of_node ? > + of_fwnode_handle(dev->of_node) : dev->fwnode; > +} > +EXPORT_SYMBOL_GPL(dev_fwnode_const); Ick, no, this is a mess. Either always return a const pointer, or don't. Ideally always return a const pointer, so all we really need is: const struct fwnode_handle *dev_fwnode(const struct device *dev); right? Yes, it will take some unwinding backwards to get there, but please do that instead of having 2 different functions where the parameter type is part of the function name. This isn't the 1980's... thanks, greg k-h