From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934739AbdKPMkH (ORCPT ); Thu, 16 Nov 2017 07:40:07 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:46827 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934484AbdKPMj6 (ORCPT ); Thu, 16 Nov 2017 07:39:58 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20171116123956euoutp02f1ffa0ed8f9a60105ee982392d12dbe0~3kVV_5ip40659606596euoutp02D X-AuditID: cbfec7f4-f79ab6d000003290-4c-5a0d871b3c02 Subject: Re: [PATCH v2] component: add debugfs support To: Greg Kroah-Hartman , Russell King Cc: linux-kernel@vger.kernel.org, Marek Szyprowski From: Maciej Purski Message-id: <7642de97-981f-643c-bdff-b4be5c0effc5@samsung.com> Date: Thu, 16 Nov 2017 13:39:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-version: 1.0 In-reply-to: <20171115140131.GB21840@kroah.com> Content-type: text/plain; charset="utf-8"; format="flowed" Content-language: en-US Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnleLIzCtJLcpLzFFi42LZduznOV3pdt4ogxlfhCyaF69ns7i8aw6b xdojd9ktLvVPZHJg8bh87SKzx/65a9g9+rasYvT4vEkugCWKyyYlNSezLLVI3y6BK+P110cs BTMUKy52rWduYLwl1cXIySEhYCLxuP8RM4QtJnHh3no2EFtIYCmjxM55MV2MXED2Z0aJpd1r mGEaTvycyQKRWMYo8ffLD2YI5xmjxIWVa4DaOTiEBcwkLm+tB2kQEUiQmNIyixXEZhbwl1j2 vYsJpIRNQEtiTXs8SJhXwE7iwrSbYCUsAqoSj7p/g9miAhESxw8vZ4SoEZT4MfkeC4jNKaAv MfPMJ6iRVhLP/rVC2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ZHCgmkJ5akZqemFqQWwWSZODilGhjzsvbeW2D6m6+TWTjs ybLYHxcyBR94f7kQpBm+VPju5kd1v81V2piiMgoWyn/excR0elZfgsvZvHs/f3bVr2Hal9vM V6EQf3j/6UsbL7B/zhL0TJw+30RqK8f/8maG6B9bJs96/9sg4HrMD5cLXpFS22VrNN7NnX8+ 3H3+22l8WyZMud1Zzr1FiaU4I9FQi7moOBEAPWqOjXECAAA= X-CMS-MailID: 20171116123954eucas1p188df045df68dcb26b2115d7894fd928d X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171115120534eucas1p25315c9e71abea9b7be93d66f97406523 X-RootMTR: 20171115120534eucas1p25315c9e71abea9b7be93d66f97406523 References: <1510747526-24831-1-git-send-email-m.purski@samsung.com> <20171115140131.GB21840@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/15/2017 03:01 PM, Greg Kroah-Hartman wrote: > On Wed, Nov 15, 2017 at 01:05:26PM +0100, Maciej Purski wrote: >> Add 'component' directory to debugfs. Create a new file for each master, >> when a master is added. Remove it on a master deletion. >> >> Show a list of devices matched with master and indicate if >> master's components were successfully added and if the whole master is >> bound. >> >> Signed-off-by: Maciej Purski >> --- >> Changes in v2: >> - use seq_printf() instead of seq_puts() when printing headers >> - move whole debugfs code to the file beginning in order to avoid >> forward declarations or using multiple ifdefs >> --- >> drivers/base/component.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 83 insertions(+) >> >> diff --git a/drivers/base/component.c b/drivers/base/component.c >> index 89b032f..8745ad9 100644 >> --- a/drivers/base/component.c >> +++ b/drivers/base/component.c >> @@ -17,6 +17,7 @@ >> #include >> #include >> #include >> +#include >> >> struct component; >> >> @@ -41,6 +42,7 @@ struct master { >> const struct component_master_ops *ops; >> struct device *dev; >> struct component_match *match; >> + struct dentry *dentry; >> }; >> >> struct component { >> @@ -56,6 +58,85 @@ static DEFINE_MUTEX(component_mutex); >> static LIST_HEAD(component_list); >> static LIST_HEAD(masters); >> >> +#ifdef CONFIG_DEBUG_FS >> + >> +static struct dentry *component_debugfs_dir; >> + >> +static int component_devices_show(struct seq_file *s, void *data) >> +{ >> + struct master *m = s->private; >> + struct component_match *match = m->match; >> + size_t i; >> + >> + mutex_lock(&component_mutex); >> + seq_printf(s, "%-40s %20s\n", "master name", "status"); >> + seq_puts(s, "-------------------------------------------------------------\n"); >> + seq_printf(s, "%-40s %20s\n\n", >> + dev_name(m->dev), m->bound ? "bound" : "not bound"); >> + >> + seq_printf(s, "%-40s %20s\n", "device name", "status"); >> + seq_puts(s, "-------------------------------------------------------------\n"); >> + for (i = 0; i < match->num; i++) { >> + struct device *d = (struct device *)match->compare[i].data; >> + >> + seq_printf(s, "%-40s %20s\n", dev_name(d), >> + match->compare[i].component ? >> + "registered" : "not registered"); >> + } >> + mutex_unlock(&component_mutex); >> + >> + return 0; >> +} >> + >> +static int component_devices_open(struct inode *inode, struct file *file) >> +{ >> + return single_open(file, component_devices_show, inode->i_private); >> +} >> + >> +static const struct file_operations component_devices_fops = { >> + .open = component_devices_open, >> + .read = seq_read, >> + .llseek = seq_lseek, >> + .release = single_release, >> +}; >> + >> +static int __init component_debug_init(void) >> +{ >> + component_debugfs_dir = debugfs_create_dir("component", NULL); >> + >> + if (!component_debugfs_dir) >> + return -ENOMEM; > > No need to test this at all, you should never fail anything if debugfs > is not working properly, just continue and move on. The result of any > debugfs call can be fed back into any other debugfs call without any > problems. > >> + >> + return 0; >> +} >> + >> +core_initcall(component_debug_init); >> + >> +static void component_master_debugfs_add(struct master *m) >> +{ >> + m->dentry = debugfs_create_file(dev_name(m->dev), 0444, >> + component_debugfs_dir, >> + m, &component_devices_fops); > > See, you do it well here, do the same thing when you create the initial > debugfs directory. I'll to this the way you suggest. Thanks. > > Also, "component" is very vague, can you think of a better term for > this? "device_component"? "dev_component"? Something else? But I > don't care, if you really like "component", that's fine. > I'm not really attached to that name, so I can change it to one that you suggested. Maybe Russell King has some preference on that? Best regards, Maciej Purski > thanks, > > greg k-h > > >