Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp15270827rwb; Mon, 28 Nov 2022 09:38:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4qa27GjzvSkInwqn+YypV7CvkLxHOUgKwxdXFARD4vMr0Bf1A4w4K98VeEicxdwUz1qDIR X-Received: by 2002:a63:f34c:0:b0:477:b473:9693 with SMTP id t12-20020a63f34c000000b00477b4739693mr25627030pgj.471.1669657120924; Mon, 28 Nov 2022 09:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669657120; cv=none; d=google.com; s=arc-20160816; b=qEp8Dru1b0T+/8HO3hw6s5R2GsVRpZR1QpiWxUHL4f3IeuD5WozYSnJmmfVM/3i4/8 5BdhH06hVxKN37mAcTM9I1Ag2Z67fEostJm9qUkzBQ0gz5f7V5wtPDVdNr7ERZCc/sXy Zlev3nvAscKjWzMdWmp4JnitBbVAYZ6wei6iwQIM13gfmPF/HeZ5S8tzKvDSnZrfg4BE DKCtq81iwJMwSzLqd/6+yaSzCu99VCbDm1K2cg06dBpSX+5pJDq57dUwRZ+F8+0VeJfr xbZRJ2RmQTmsQTK5vm/XaKVSB8Tj+xVT5J2lGr9tWgq5Ff5AWbd0novo45VfPRAXiqRN 5l8A== 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=iBS9jKSqPURUHSlXNcwGPEOnu32AZ7W8U7XODb+/EtM=; b=zpc3AqcVGkuFnh3+Hg1E6YjeVShPzfjPjPWumbMK8834HeaBN6h0rYk4mzvV3IwQDw 86SERZIn3HXMBdgcxlwwLAVv59iQAYMpUDpKWMNsM+VUBXy8RErovcbjDATJgIeF0CLj sfSqaQYU6LgwiT8mGa15gQL9RifN3gSC4PxL2UvaTG2iDlnMz/8es4tbL7tNDjyYNEcL cjP6oPPUosIkiWvRXZ3a8F2FlvPHaYKTlMSv3+N7ZDBCWZ+JDSHDLEKLq/CklwJ/90gO XmOE00QTLnr7nRzX1KbBuuS5IWgCnYKfGPBg9eHILM3/RhSyumMDAGJKajgeay8Dm7Ai gdMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jklUVBk1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 d30-20020a634f1e000000b0046f729604fesi12989478pgb.170.2022.11.28.09.38.28; Mon, 28 Nov 2022 09:38:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-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=jklUVBk1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 S233035AbiK1RZe (ORCPT + 67 others); Mon, 28 Nov 2022 12:25:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbiK1RZR (ORCPT ); Mon, 28 Nov 2022 12:25:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D61B20349; Mon, 28 Nov 2022 09:25:14 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id B6D92B80E90; Mon, 28 Nov 2022 17:25:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 002F2C433D6; Mon, 28 Nov 2022 17:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669656311; bh=wZlmYJl8LMxMeefdCbrE5viQuX+AZVgF+lHUSAzV8mA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jklUVBk1mHdNx5UwNOVAyoL9FcfwZD4B7KDGLSBvRl5IAv16CCb++ynZ+TPs/2xnW Y09yfkYWX7Zusj8ufWXnQv3O5+iO2GnPgg5dqoMaQRFD7eFKipOag5+WZBxv2B/3hS npOJ5H5324elD5m0VsViiZtApWHVqoGlQ7+jDW9I= Date: Mon, 28 Nov 2022 18:25:09 +0100 From: Greg Kroah-Hartman To: Bart Van Assche Cc: linux-kernel@vger.kernel.org, Jens Axboe , Luis Chamberlain , Russ Weight , "Rafael J. Wysocki" , Jean Delvare , Johan Hovold , Jason Gunthorpe , Leon Romanovsky , Karsten Keil , Mauro Carvalho Chehab , Keith Busch , Christoph Hellwig , Sagi Grimberg , Dominik Brodowski , Sebastian Reichel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Johannes Berg , Wolfram Sang , Raed Salem , Chen Zhongjin , Tetsuo Handa , Avihai Horon , "Matthew Wilcox (Oracle)" , Alan Stern , Colin Ian King , Geert Uytterhoeven , Jakob Koschel , Antoine Tenart , Frederic Weisbecker , Wang Yufen , linux-block@vger.kernel.org, linux-media@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org, linux-rdma@vger.kernel.org, linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Message-ID: References: <20221123122523.1332370-1-gregkh@linuxfoundation.org> <5b14cdea-1bbe-1900-0004-a218ba97bbcb@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b14cdea-1bbe-1900-0004-a218ba97bbcb@acm.org> X-Spam-Status: No, score=-7.1 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-wireless@vger.kernel.org On Sun, Nov 27, 2022 at 06:38:39PM -0800, Bart Van Assche wrote: > On 11/27/22 05:45, Greg Kroah-Hartman wrote: > > On Fri, Nov 25, 2022 at 03:51:11PM -0800, Bart Van Assche wrote: > > > On 11/23/22 04:25, Greg Kroah-Hartman wrote: > > > > diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h > > > > index 7dd1f01ec4f9..7aab4a769736 100644 > > > > --- a/include/linux/mISDNif.h > > > > +++ b/include/linux/mISDNif.h > > > > @@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, > > > > void *); > > > > extern void mISDN_unregister_clock(struct mISDNclock *); > > > > -static inline struct mISDNdevice *dev_to_mISDN(struct device *dev) > > > > +static inline struct mISDNdevice *dev_to_mISDN(const struct device *dev) > > > > { > > > > if (dev) > > > > return dev_get_drvdata(dev); > > > > > > Why does the dev_to_mISDN() function drop constness? I haven't found an > > > explanation for this in the cover letter. > > > > I agree, this is going to be fixed up, see the thread starting here: > > https://lore.kernel.org/r/Y34+V2bCDdqujBDk@kroah.com > > > > I'll work on making a const / non const version for these so that we > > don't loose the marking. > > > > Oh wait, no, this function is fine, it's not modifying the device > > structure at all, and only returning the pointer in the private data > > stored in the device. There is no loss of const-ness here. > > Hi Greg, > > This is what I found in include/linux/mISDNif.h: > > struct mISDNdevice { > struct mISDNchannel D; > u_int id; > u_int Dprotocols; > u_int Bprotocols; > u_int nrbchan; > u_char channelmap[MISDN_CHMAP_SIZE]; > struct list_head bchannels; > struct mISDNchannel *teimgr; > struct device dev; > }; > > As one can see 'dev' is a member of struct mISDNdevice. I still think that > dev_to_mISDN() drops constness. Did I perhaps overlook something? I think you are missing that dev_to_mISDN() is doing something different than most dev_to_FOO() functions do (i.e. there is no container_of() call here at all): static inline struct mISDNdevice *dev_to_mISDN(struct device *dev) { if (dev) return dev_get_drvdata(dev); else return NULL; } See, no pointer mess or anything else here, all that happens is the driver data pointer in struct device is returned. If this was a "normal" dev_to_FOO() function, then yes, the const-ness of the pointer would be called into question as the thread I linked to discusses. thanks, greg k-h