Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp853363rwb; Fri, 23 Sep 2022 05:11:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VPb69V1OAjRTjmjpos/awoniXwoS9gskF8WTY6595weqg/nbLJejQqgDZUAT6JISJgxb4 X-Received: by 2002:a17:906:ee89:b0:73d:70c5:1a4e with SMTP id wt9-20020a170906ee8900b0073d70c51a4emr6459690ejb.683.1663935067034; Fri, 23 Sep 2022 05:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663935067; cv=none; d=google.com; s=arc-20160816; b=mFfeg0FSh4GwBgn7k8hKzXW+8l3x53WxJoIr+n3HQd0DDlD9Np0J+op/wsbWCWJiEz OvN7JCXsZlYTeT7JoubRaxCqwRfAkBjEgIiezLryIWhXhTGp5ixqiPbcm684V8lYYEzd fbCd26hdHpHFlapPeYhxGZqfnbqRdrU3keqDkcOqQzHElucHDSPlW5ZeVovcpwurnc9p Jcsc5TVy2mcdUNu81V5GuStF99OCQhA2NhcXcLw9qw/46idB0e00Z9L04pQK2/xXzQOv pj7vMhpyKO0JuThd5KGXJCYkpskbzQaMc8TqqNBcN+bFtvlolBrIQrski2GOnFN5iAFN okMw== 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=JF4yuCkxxFoILHgPHK2NckVf7jhusUPgOh/gjht97EY=; b=IPBBEXXp71BvJN5Wsb/tgEpQnxKjvgOPLQzPOlEO9FcYSXks/Wliosj1e3ZuECyF1+ PpDoPikKqlY2IS+6VZ1i5IMJ3LHJl7vGiSMx/a6nkIh1VDQ1+p1q6rOCEP2sPfQ6VnWo CRNZETfdo87C3cf4cCCpS1+LJRgFJL7WaDbJ4ei+ZBgf9EhyX6oHLxPympJIlxc65B3r IMWhMCrUFev196pPYomwCJ+g7NON+sKGXET5moYO0O2ozCLibvDeUpMZwB39hOifPbsK o7AKYQwBWBjcgm7da2/3Di3w46qy6bT+Fesm1rBe5hlkJFRcN80R74+ix0S5TZ/2V72/ qjrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G7m6sr6I; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a056402275300b004515bc0d76dsi9914720edd.44.2022.09.23.05.10.40; Fri, 23 Sep 2022 05:11:07 -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=@intel.com header.s=Intel header.b=G7m6sr6I; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbiIWL0N (ORCPT + 99 others); Fri, 23 Sep 2022 07:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231848AbiIWLZs (ORCPT ); Fri, 23 Sep 2022 07:25:48 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F3FE7429; Fri, 23 Sep 2022 04:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663932324; x=1695468324; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=uOvFZoazlmsabCykYjowvAOS8R6HTT99n3V0ABLDATg=; b=G7m6sr6ITRvQ6nePMltUXpejQ9sIXR0Ly0jDXP8dhaAMHUFpwe2gIIsf uz71DMd0ZtIOLXQKbeHawdxxtNVZPBdx04Af8VCWBuEVNBYe84D4aHYZU TxmE/Ac9s0Qh5O2r25oZXFFUaslnsWAY9L7IKi4mXQrV55A1J4EY80wOE LnuSS277knBXNnV747ZnQ7EaYengFHHqpTr8cw6itNa9J8XXgR98Kvm4s mymUAU7d/j0xNgmzmTSL7MU23HYzX03bEgQq2O2BNZ5WVcDsVz6UdupOx K5jqlOz3mSOdUkArfCvu5OYOdOGmUGL4tb+DaCILSUwLP8T0O7ot0ujVa A==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="298170640" X-IronPort-AV: E=Sophos;i="5.93,339,1654585200"; d="scan'208";a="298170640" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2022 04:25:24 -0700 X-IronPort-AV: E=Sophos;i="5.93,339,1654585200"; d="scan'208";a="682628053" Received: from punajuuri.fi.intel.com (HELO paasikivi.fi.intel.com) ([10.237.72.43]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2022 04:25:21 -0700 Received: from paasikivi.fi.intel.com (localhost [127.0.0.1]) by paasikivi.fi.intel.com (Postfix) with SMTP id C7DBA20124; Fri, 23 Sep 2022 14:25:19 +0300 (EEST) Date: Fri, 23 Sep 2022 11:25:19 +0000 From: Sakari Ailus To: Andy Shevchenko Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Scally , Heikki Krogerus , Greg Kroah-Hartman , "Rafael J. Wysocki" , kernel test robot Subject: Re: [PATCH v1 1/1] device property: Add const qualifier to device_get_match_data() parameter Message-ID: References: <20220922135410.49694-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE 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 Andy, On Fri, Sep 23, 2022 at 01:25:42PM +0300, Andy Shevchenko wrote: > On Thu, Sep 22, 2022 at 08:22:54PM +0000, Sakari Ailus wrote: > > On Thu, Sep 22, 2022 at 04:54:10PM +0300, Andy Shevchenko wrote: > > > Add const qualifier to the device_get_match_data() parameter. > > > Some of the future users may utilize this function without > > > forcing the type. > > > > From const to non-const? This is what this patch does, right? > > Right. > > > > All the same, dev_fwnode() may be used with a const qualifier. > > > > > > Reported-by: kernel test robot > > > Signed-off-by: Andy Shevchenko > > > > -struct fwnode_handle *dev_fwnode(struct device *dev) > > > +struct fwnode_handle *dev_fwnode(const struct device *dev) > > > > If you have const struct device pointer, then the embedded fwnode handle in > > that object sure is const, too. Isn't it? > > > > If you really have const struct device pointer (where do you?), then I'd > > device_get_match_data() expects the const parameter, but due to dev_fwnode() > it can't be satisfied. This has been reported by LKP when I tried to submit > a wrapper: > https://lore.kernel.org/linux-spi/20220921204520.23984-1-andriy.shevchenko@linux.intel.com/ > > Yes, I probably can drop const there, but it will be again awkward to see > almost all APIs beneath using const and upper one without it for unclear > (to the reader) reasons. dev could indeed be const there otherwise, I understand, but it's certainly not better to force it non-const elsewhere for that. > > > suggest to add another function, dev_fwnode_const() that is otherwise the > > same except the argument as well as the return value are const. > > Perhaps this is the case, but does it mean we need to duplicate APIs when > we know we don't modify data? Seems road to bloating the code for peanuts. > > > Or alternatively define it as a macro and use _Generic()? > > Yeah, I have the mixed feelings about _Generic for generic APIs because > it requires to convert some stuff to macros when type checking of the > parameters can be missed (if a target takes two or more of them). It's not uncommon to use wrapper functions in addition to get type checking done properly. > > It might work here (we have a single parameter), but in general... If it works here, why not to do it then? :-) -- Sakari Ailus