Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1500150
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS |
| Date | 2016-10-13 12:40 +0200 |
| Message-ID | <srLAC-2i4-11@gated-at.bofh.it> (permalink) |
| References | <sqGMF-zG-3@gated-at.bofh.it> <srL7z-24J-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS Arnd Bergmann <arnd@arndb.de> - 2016-10-10 13:20 +0200
Re: [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS Nicolai Stange <nicstange@gmail.com> - 2016-10-13 12:10 +0200
Re: [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS Arnd Bergmann <arnd@arndb.de> - 2016-10-13 12:40 +0200
Re: [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS Nicolai Stange <nicstange@gmail.com> - 2016-10-13 12:50 +0200
[PATCH v2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUG_FS Nicolai Stange <nicstange@gmail.com> - 2016-10-20 22:10 +0200
Re: [PATCH v2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUG_FS Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-10-21 11:30 +0200
csiph-web