From: Arnd Bergmann <arnd@arndb.de>
To: Nicolai Stange <nicstange@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>,
Darren Hart <dvhart@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS
Date: Thu, 13 Oct 2016 12:29:44 +0200 [thread overview]
Message-ID: <5795991.0oAm3xDhR2@wuerfel> (raw)
In-Reply-To: <87vawwmuw5.fsf@gmail.com>
On Thursday, October 13, 2016 11:59:54 AM CEST Nicolai Stange wrote:
> >
> > +ssize_t debugfs_attr_read(struct file *file, char __user *buf,
> > + size_t len, loff_t *ppos);
> > +ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
> > + size_t len, loff_t *ppos);
> > +
> > +#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
> > +static int __fops ## _open(struct inode *inode, struct file *file) \
> > +{ \
> > + __simple_attr_check_format(__fmt, 0ull); \
> > + return simple_attr_open(inode, file, __get, __set, __fmt); \
> > +} \
> > +static const struct file_operations __fops = { \
> > + .owner = THIS_MODULE, \
> > + .open = __fops ## _open, \
> > + .release = simple_attr_release, \
> > + .read = debugfs_attr_read, \
> > + .write = debugfs_attr_write, \
>
> This depends on GCC dead code elimination to always work for this
> situation, otherwise we'd get undefined references to
> debugfs_attr_read/write(), right?
Correct.
> In order to avoid having to test your patch against all those older
> versions of GCC, can we have a safety net here and define some dummy
> debugfs_attr_read/write() for the !CONFIG_DEBUGFS case?
The question of dead-code elimination in older gcc versions comes up
occasionally, and I think all versions that are able to build the
kernel these days get this right all the time, otherwise any code
using IS_ENABLED() helpers to control the calling of external interfaces
would be broken.
We could probably use that macro here if you think that's better
and do:
static const struct file_operations __fops = {
.owner = THIS_MODULE,
.open = IS_ENABLED(CONFIG_DEBUGFS_FS) ? __fops ## _open : NULL,
...
> If nothing else, it would IMHO make the !CONFIG_DEBUGFS case more
> understandable because one had not to figure out that this actually
> relies on dead code elimination to work.
Sure, that's fine. Can you do the new version of that patch with
the change then?
Arnd
next prev parent reply other threads:[~2016-10-13 10:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-10 11:12 [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS Arnd Bergmann
2016-10-10 11:12 ` [PATCH 2/2] intel_pmc_core: avoid boot time warning " Arnd Bergmann
2016-10-10 12:29 ` Greg Kroah-Hartman
2016-10-12 8:13 ` Darren Hart
2016-10-13 9:59 ` [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE " Nicolai Stange
2016-10-13 10:29 ` Arnd Bergmann [this message]
2016-10-13 10:46 ` Nicolai Stange
2016-10-20 20:07 ` [PATCH v2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUG_FS Nicolai Stange
2016-10-21 9:22 ` Andy Shevchenko
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=5795991.0oAm3xDhR2@wuerfel \
--to=arnd@arndb.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dvhart@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicstange@gmail.com \
--cc=rajneesh.bhardwaj@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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