From patchwork Mon Oct 10 11:12:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101714 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1149582qge; Mon, 10 Oct 2016 04:13:52 -0700 (PDT) X-Received: by 10.66.160.72 with SMTP id xi8mr52912791pab.78.1476098032383; Mon, 10 Oct 2016 04:13:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hr2si30549557pad.44.2016.10.10.04.13.52; Mon, 10 Oct 2016 04:13:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751297AbcJJLNl (ORCPT + 27 others); Mon, 10 Oct 2016 07:13:41 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:52555 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750770AbcJJLNj (ORCPT ); Mon, 10 Oct 2016 07:13:39 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue001) with ESMTPA (Nemesis) id 0MIUYB-1brdEw0qkR-0047vo; Mon, 10 Oct 2016 13:13:17 +0200 From: Arnd Bergmann To: Greg Kroah-Hartman Cc: Andy Shevchenko , Rajneesh Bhardwaj , Darren Hart , Nicolai Stange , Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUGFS_FS Date: Mon, 10 Oct 2016 13:12:57 +0200 Message-Id: <20161010111313.119658-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:OZqN0/RCi+E2Q46wEi7EUeSuyI6ydRfWcAM11a+OtXuPP2JtzSa ssF1p2DLRxIy9OQzN0968cPz8/PK0hEeeaRHFee3GLr5dM9zIDLrtRUMH09jLjbBMKm2BEB /qtL5Ws1gA0BqnSxPC9aLSYnJKDaq4Pr/thgq+w+AVZowD+oEBrqsXNHaFiPjF0Sx+NDnRq kZK4uFvzA74htWihkYrxg== X-UI-Out-Filterresults: notjunk:1; V01:K0:cMuhRzoz1UY=:H2J+RpltJPoVq3pcf3aogF RGtixxkZ04fpgYifSo7U1qUUyfoGuQcHZM7u453RmM5PeSkziz/CIArHEtSwTb42QZp/hFTSG P/G/IUXrxBx0GIyF76FbXp3Ve3L6EPbMxbhC1bYPUtvZFMYGkHCEUyn7mf1ebuER3C4pfJFIo Kqec+xJD2VWpgOMqIoCV+eMy5zWI3XKAUT6hHQZNvxhS25T2Odvb88VWVRGsrnG+jmZZ/s9ED CHBATXc9Lk1l+oIAq8xoCUaWLsyJAG7Mtmj1SYiZDiu8RLwSkJ22rzlQFmMV3hAXCtvJUdc7Z g1RQfvwhQPZjIedLOWvM8wvlPySbCpwX8sal/Pl3FvKej8kTfNrtOoX2tMlxdocg+gKDz609F V0ZkFh07KaAjHW9KkH/O7iJobcxbLLgAU4UN1nkLJ6ldGCQ+k9jPCBJ4doFH5nHUEPdoL3Iei 7Awtvk2HBKYmwrUPZ0L6Wq/RVvevApFvM93xsSWzp7T7by9PhENmTwcm6w11PtFeI0QobFCik 8jL/hOQgR2Y20sbdhppIor3iVau+Zop7VKNUo5nUCrn+8udmfa13h22Fc14ilQmLXPb0gV8DX 80HpgNS6eTwNXl3vMgOeYCmfU5llUYvcrvcjyDo+J91cbF5LI9+oSJo1efYicrm1MT8/iGkVp +BDzIW6yUaXJo1s6g7aDj2aJCOgfxOaiyG25iMZ0CpBmlklyga+cLQXd/fyLmXJcScSTj/zOw BIQsZaQMUAE6AiSP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The slp_s0_residency_usec debugfs file currently uses DEFINE_DEBUGFS_ATTRIBUTE(), but that macro cannot really be used to define files outside of the debugfs code, as it has no reference to the get/set functions if CONFIG_DEBUGFS_FS is not defined: drivers/platform/x86/intel_pmc_core.c:80:12: error: ‘pmc_core_dev_state_get’ defined but not used [-Werror=unused-function] This fixes the macro to always contain the reference, and instead rely on the stubbed-out debugfs_create_file to not actually refer to its arguments so the compiler can still drop the reference. This works because the attribute definition is always 'static', and the dead-code removal silently drops all static symbols that are not used. Fixes: c64688081490 ("debugfs: add support for self-protecting attribute file fops") Fixes: df2294fb6428 ("intel_pmc_core: Convert to DEFINE_DEBUGFS_ATTRIBUTE") Signed-off-by: Arnd Bergmann --- include/linux/debugfs.h | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) -- 2.9.0 diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 4d3f0d1aec73..e94f5f8dced3 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -62,6 +62,26 @@ static inline const struct file_operations *debugfs_real_fops(struct file *filp) return filp->f_path.dentry->d_fsdata; } +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, \ + .llseek = generic_file_llseek, \ +} + #if defined(CONFIG_DEBUG_FS) struct dentry *debugfs_create_file(const char *name, umode_t mode, @@ -94,26 +114,6 @@ int debugfs_use_file_start(const struct dentry *dentry, int *srcu_idx) void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu); -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, \ - .llseek = generic_file_llseek, \ -} - struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, struct dentry *new_dir, const char *new_name); @@ -233,9 +233,6 @@ static inline void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu) { } -#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ - static const struct file_operations __fops = { 0 } - static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, struct dentry *new_dir, char *new_name) { From patchwork Mon Oct 10 11:12:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101713 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1149734qge; Mon, 10 Oct 2016 04:14:21 -0700 (PDT) X-Received: by 10.157.56.179 with SMTP id p48mr17003180otc.22.1476098061633; Mon, 10 Oct 2016 04:14:21 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j31si9102481ote.55.2016.10.10.04.14.21; Mon, 10 Oct 2016 04:14:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751640AbcJJLOL (ORCPT + 27 others); Mon, 10 Oct 2016 07:14:11 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:62468 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbcJJLOJ (ORCPT ); Mon, 10 Oct 2016 07:14:09 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue001) with ESMTPA (Nemesis) id 0MNyjT-1bm7Te0Fad-007RqS; Mon, 10 Oct 2016 13:13:37 +0200 From: Arnd Bergmann To: Darren Hart Cc: Greg Kroah-Hartman , Andy Shevchenko , Rajneesh Bhardwaj , Darren Hart , Nicolai Stange , Arnd Bergmann , Vishwanath Somayaji , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] intel_pmc_core: avoid boot time warning for !CONFIG_DEBUGFS_FS Date: Mon, 10 Oct 2016 13:12:58 +0200 Message-Id: <20161010111313.119658-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161010111313.119658-1-arnd@arndb.de> References: <20161010111313.119658-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K0:Opb8FXeH1o4bQc95vYomiGHMAX7v89aYNzAe421kXKsLykbNyl/ oBMczH4BysoEZk+LRCykcjgl4I7YyfhZebjE0D+daNdHDV7ZsaQGZNBHmNOMalLStP/Hvia XAxvaUJ88Z4iZP0QNjG11Q3KAZsz47Q7QOczM6LjfL/c/as+7/wI2k3IBSDnPMqJ4td9dq1 2ePjj1E9X6ARGTUdOu7gA== X-UI-Out-Filterresults: notjunk:1; V01:K0:vtiGckOYNDQ=:ag5wL3aguHn5dk8oKjlARx cDasNH7kjrCDdEUMBLDJTMSjvbS7ZHLAphPSg7BCd8pDGKcoPAbcyMMjnnWfis+uMUERZPpSr mtANXOst2uqWirMAev06bSasGfX3bcxZVHAwuf1nEF5GczTrvcAE/GbTKFAO0dfy7pF2qNGUF xJ3U1+V6iEkUZWOv5OzxsTzDBr9my7hpq8VPcBLjY7yaLClPJmyD97tooK6cDE3wehWUVOsX7 kRBrd/KPWdE4i1j4QkX4Q1nQsllZB6kkjmTZLNtLtUKK7Rzagmlv4VgWInnytZ76riZozEUOG sE3RO4NafYsm6G1quWao7XBFblDClXz8qSBTmBbnxCu0k8ItVwm6NRDABbPy82nIqb2lq5Peq VFZbRyHQ7Mn8tvMD+TEFX+jA5zHUL0g9aQUhm8kZqGRhY3fB5O8HR3VpinZexvmcWqM892B/y 4mCPdBytyZOCO1d1DOptPTtCMUvn4C+k97AqybPXEJs63aZRfOmOW1BYLqMq8nqiNGhcW9fav J3W7PQ3iTMO9FGYoA9tq6DUe7/FBfjYvgrTLr+WmzddK1d5WiVf+7TAbGMAWtEZOu5HndRtJl dc4X52ZH/cPQB/8GXkZQNrtr3upq+IG2k3d0/K92t0TCTv0lIGNb+oVBY1yLmOirC4NxRzx0K +YWDcUgNSzRZSObVHNdp4g+QNOEZTGuHhkBq+Jdew/e9lwFDTGfYRrFEpV7sIzUNfHlHDX4Et FFG3rSi1k6JxGMDF Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While looking at a patch that introduced a compile-time warning "‘pmc_core_dev_state_get’ defined but not used" (I sent a patch for debugfs to fix it), I noticed that the same patch caused it in intel_pmc_core also introduced a bogus run-time warning: "PMC Core: debugfs register failed". The problem is the IS_ERR_OR_NULL() check that as usual gets things wrong: when CONFIG_DEBUGFS_FS is disabled, debugfs_create_dir() fails with an error code, and we don't need to warn about it, unlike the case in which it returns NULL. This reverts the driver to the previous state of not warning about CONFIG_DEBUGFS_FS being disabled. I chose not to restore the driver to making a runtime error in debugfs fatal in pmc_core_probe(). Fixes: df2294fb6428 ("intel_pmc_core: Convert to DEFINE_DEBUGFS_ATTRIBUTE") Signed-off-by: Arnd Bergmann --- drivers/platform/x86/intel_pmc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index 520b58a04daa..e8b1b836ca2d 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -100,7 +100,7 @@ static int pmc_core_dbgfs_register(struct pmc_dev *pmcdev) struct dentry *dir, *file; dir = debugfs_create_dir("pmc_core", NULL); - if (IS_ERR_OR_NULL(dir)) + if (!dir) return -ENOMEM; pmcdev->dbgfs_dir = dir;