From: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
To: Bart Van Assche <bvanassche@acm•org>
Cc: linux-kernel@vger•kernel.org, Jens Axboe <axboe@kernel•dk>,
Luis Chamberlain <mcgrof@kernel•org>,
Russ Weight <russell.h.weight@intel•com>,
"Rafael J. Wysocki" <rafael@kernel•org>,
Jean Delvare <jdelvare@suse•com>, Johan Hovold <johan@kernel•org>,
Jason Gunthorpe <jgg@ziepe•ca>, Leon Romanovsky <leon@kernel•org>,
Karsten Keil <isdn@linux-pingi•de>,
Mauro Carvalho Chehab <mchehab@kernel•org>,
Keith Busch <kbusch@kernel•org>, Christoph Hellwig <hch@lst•de>,
Sagi Grimberg <sagi@grimberg•me>,
Dominik Brodowski <linux@dominikbrodowski•net>,
Sebastian Reichel <sre@kernel•org>,
"David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
Johannes Berg <johannes@sipsolutions•net>,
Wolfram Sang <wsa+renesas@sang-engineering•com>,
Raed Salem <raeds@nvidia•com>,
Chen Zhongjin <chenzhongjin@huawei•com>,
Tetsuo Handa <penguin-kernel@i-love•sakura.ne.jp>,
Avihai Horon <avihaih@nvidia•com>,
"Matthew Wilcox (Oracle)" <willy@infradead•org>,
Alan Stern <stern@rowland•harvard.edu>,
Colin Ian King <colin.i.king@gmail•com>,
Geert Uytterhoeven <geert+renesas@glider•be>,
Jakob Koschel <jakobkoschel@gmail•com>,
Antoine Tenart <atenart@kernel•org>,
Frederic Weisbecker <frederic@kernel•org>,
Wang Yufen <wangyufen@huawei•com>,
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 *
Date: Mon, 28 Nov 2022 18:25:09 +0100 [thread overview]
Message-ID: <Y4Tu9UUGGiEdFcVw@kroah.com> (raw)
In-Reply-To: <5b14cdea-1bbe-1900-0004-a218ba97bbcb@acm.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
prev parent reply other threads:[~2022-11-28 17:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
2022-11-23 12:38 ` Rafael J. Wysocki
2022-11-24 15:03 ` Sebastian Reichel
2022-11-25 11:54 ` Mauro Carvalho Chehab
2022-11-25 23:51 ` Bart Van Assche
2022-11-27 13:45 ` Greg Kroah-Hartman
2022-11-28 2:38 ` Bart Van Assche
2022-11-28 17:25 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y4Tu9UUGGiEdFcVw@kroah.com \
--to=gregkh@linuxfoundation$(echo .)org \
--cc=atenart@kernel$(echo .)org \
--cc=avihaih@nvidia$(echo .)com \
--cc=axboe@kernel$(echo .)dk \
--cc=bvanassche@acm$(echo .)org \
--cc=chenzhongjin@huawei$(echo .)com \
--cc=colin.i.king@gmail$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=frederic@kernel$(echo .)org \
--cc=geert+renesas@glider$(echo .)be \
--cc=hch@lst$(echo .)de \
--cc=isdn@linux-pingi$(echo .)de \
--cc=jakobkoschel@gmail$(echo .)com \
--cc=jdelvare@suse$(echo .)com \
--cc=jgg@ziepe$(echo .)ca \
--cc=johan@kernel$(echo .)org \
--cc=johannes@sipsolutions$(echo .)net \
--cc=kbusch@kernel$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=leon@kernel$(echo .)org \
--cc=linux-block@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-media@vger$(echo .)kernel.org \
--cc=linux-nvme@lists$(echo .)infradead.org \
--cc=linux-pm@vger$(echo .)kernel.org \
--cc=linux-rdma@vger$(echo .)kernel.org \
--cc=linux-usb@vger$(echo .)kernel.org \
--cc=linux-wireless@vger$(echo .)kernel.org \
--cc=linux@dominikbrodowski$(echo .)net \
--cc=mcgrof@kernel$(echo .)org \
--cc=mchehab@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=penguin-kernel@i-love$(echo .)sakura.ne.jp \
--cc=raeds@nvidia$(echo .)com \
--cc=rafael@kernel$(echo .)org \
--cc=russell.h.weight@intel$(echo .)com \
--cc=sagi@grimberg$(echo .)me \
--cc=sre@kernel$(echo .)org \
--cc=stern@rowland$(echo .)harvard.edu \
--cc=wangyufen@huawei$(echo .)com \
--cc=willy@infradead$(echo .)org \
--cc=wsa+renesas@sang-engineering$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox