From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753907AbcJMKgq (ORCPT ); Thu, 13 Oct 2016 06:36:46 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:56854 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752940AbcJMKgj (ORCPT ); Thu, 13 Oct 2016 06:36:39 -0400 From: Arnd Bergmann To: Nicolai Stange Cc: Greg Kroah-Hartman , Andy Shevchenko , Rajneesh Bhardwaj , Darren Hart , 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 Message-ID: <5795991.0oAm3xDhR2@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <87vawwmuw5.fsf@gmail.com> References: <20161010111313.119658-1-arnd@arndb.de> <87vawwmuw5.fsf@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:DQH5U7QHlNOQZALIexxgIqeUO5DwzUjJSqB4RBaY5ZFpZryS4d9 gDI/W3IXF0VhokquVM6yMl/Ab0YWub7QBH0KootOOSRhcYeaPmqVgc1Ot7bsTuneMoLKVQC 2IKGcuyTjOj8U04FPZLchb9KVoem8a32euKvHK6UqsqR0GDV0M9e57WwyyA9IHj2lFOquRo vbaigmJ2Av/G6TApXUwXg== X-UI-Out-Filterresults: notjunk:1;V01:K0:G15t1nwg/U8=:yG9jUX1SNPtyQirGNKBTWh YORFQvQOvpHazA7KV6i4leJQ9aBinm4LnyCaVTSUkkAIZ2rXBBwQaNEECfN0gd+F7RN2qK0tg MBKuuBylMn64VYxKYNpJSUv12OITTbSbEMV+68VvOxmaK6pHZ8qMK749v1fL4P2P0joBmbXvq CsEMD6ASP3K1mxRebZX4FuC5N7AK8Dtnz6uj3BYP4eR07Dne4J+Rw3jaQCF6j3hopkqfgra6K z9fkJI+zSt8aLhPzIk1kiLKbs+cOcNDnXaFXeZZf0cT1fFs5UTP1DRYZlCYyA0Pj1bHoVsZ+u iRnG/bbrnPoCBAHY1UFSUtJyy9nv8jCtjmDRJdPPR7hIEXqLqlZ1SptMKmEyc5C6zrl2Idzrb NUOPFpZSqe0Z9gmmVCyRYXUx4XrgOkCz9Db3XPahqTQmn2dzD+KCwskvvnrCiDYvEBj3RXtzq SbUCnVIKC0uI7nLtQrra3r7+GFMBKKU7vR5rtG1eXPn0hvGymbVamxPsBV06dwPDMEwjpjCYH w4z446JmpUBKbSbtBScNofz080vEKk9HGpgEJBvbpdBwQNLZAFzmIq19vgU6xn2XyZwSghKQc hO0PxJ1mkpkB/XSdrZmqKrgbwQFUjCjMWZ/vW0TN2AKnAouFODhFspQYdeQxg4XtG0f/Ssghi MCFqZrIKlWmU32TNrWsLkgpAQ0eIuhyrLQlviBaSM+akUJl4wizA86Vcp0yT9UgiZkdSe9GU4 OGNk0+jc7hDlHCkT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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