Received: by 10.223.164.202 with SMTP id h10csp611847wrb; Thu, 30 Nov 2017 04:50:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ0VTmkXD4tD5/ajBD6TrAHPI87yhqEBY+UYz4JMNrFPqyVBDEgYH5jxc/H4tNB2aRZirz4 X-Received: by 10.99.164.81 with SMTP id c17mr2269531pgp.206.1512046251106; Thu, 30 Nov 2017 04:50:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512046251; cv=none; d=google.com; s=arc-20160816; b=bDyhAytdjdnaq29r71Tdb6yUFQW3yueWqzPdrl734SQ1aOnn0dXXpQD3hxa4GlLFCi O0MIwa2GgAjz7Igf5p3Kr0YFJkItimEw8JjiTwE9PIKTXcU/a3GpOIAGAKfe0FcvGlWh UcIUKfrhilQYQu25lDdXG94rqDlTE66ws4lbSx/EcU1bqO0/+ZdIcFvqe8pGr2iPwqEs 7lCRRAa1u7koi0iNdJEuWR9lsljLE1f6pYdfUINKvtdgK6AGwDPKo0SUM4Fx6YThSttb JqJxSdHr83wv0ysxvdoW6oA10eHbX2pGagUkFd05sbk/vIR2iEmd4JBJ5Xq28+gKvHOS 2PzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=ZVfnF7O3Mf+W2d6AfilgzrYkl9q6RBmvqBR9bS6AWSs=; b=JIO9fh3+f7w3fETgKy7r8hrXyQ7eIcS9cKsXygu9dAIor9dMbxlyPsKk6A0Q8blKJ0 UI5tgGFV11SnZBvgLpRuZgjbApNUR8rW+4K9x2cU0/UZ+cl+vsj/VVpo/0oNMF7PRu3r efL8r12kKaLir/22uLFxLEdQvHoVdF1Bi7PVJ3IlEdmADBInPhuxVle1DZTX7cC7rppx CyIVp6hGXDft0aFLHMWgv1bnaPDnNQoqpfXJk/v748Fy3EGd4c+xPCTq/vrPJBegr7rt mC3UNRc6nnkP7vvp3Vcafgbzy8mnjmcGt0TszP2qMxVcdbMDXR4ceckRy3VLRMDeWdcn sHlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TFSQAm/i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c30si2213688pgn.38.2017.11.30.04.50.37; Thu, 30 Nov 2017 04:50:51 -0800 (PST) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TFSQAm/i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752428AbdK3MtL (ORCPT + 99 others); Thu, 30 Nov 2017 07:49:11 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55050 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751783AbdK3MtJ (ORCPT ); Thu, 30 Nov 2017 07:49:09 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171130124907euoutp01efe400599725252b3ae80e92a0d2884b~73fW58oUW2212022120euoutp01O; Thu, 30 Nov 2017 12:49:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171130124907euoutp01efe400599725252b3ae80e92a0d2884b~73fW58oUW2212022120euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1512046147; bh=ZVfnF7O3Mf+W2d6AfilgzrYkl9q6RBmvqBR9bS6AWSs=; h=From:To:Cc:Subject:Date:References:From; b=TFSQAm/iS70ArJFu4+/46CIbXi8IdszYMmDTgSQqgSDdPDP0pn04qMm89FatlFDl3 8/WEl0k16xi66OuWXUrxeeu17aTEx+wn4gCsDpzJ6i+3dIk1/E8kJuLoAj2XXUOHE+ NE1cPmUjh15NOmBIbTj2khH6J2Py7trORJhbpnME= Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171130124906eucas1p135268b59319f560c8e8a728c72c250c7~73fWdehUb0692706927eucas1p1d; Thu, 30 Nov 2017 12:49:06 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 79.DA.12743.24EFF1A5; Thu, 30 Nov 2017 12:49:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171130124906eucas1p2a671ee7d62ddebe9fde3a5def2d97f44~73fVzPN-C1144011440eucas1p2D; Thu, 30 Nov 2017 12:49:06 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d0000031c7-96-5a1ffe427d8a Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5E.08.20118.24EFF1A5; Thu, 30 Nov 2017 12:49:06 +0000 (GMT) Received: from AMDC2075.DIGITAL.local ([106.120.51.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P0800IZ2E9NVI00@eusync1.samsung.com>; Thu, 30 Nov 2017 12:49:06 +0000 (GMT) From: Maciej Purski To: Greg Kroah-Hartman Cc: Marek Szyprowski , Russell King , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, Maciej Purski Subject: [PATCH v4] component: add debugfs support Date: Thu, 30 Nov 2017 13:48:32 +0100 Message-id: <1512046112-9474-1-git-send-email-m.purski@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRmVeSWpSXmKPExsWy7djPc7pO/+SjDKa1qVlsnLGe1aJ58Xo2 i8u75rBZLHh5i8Vi7ZG77BaX+icyObB5XL52kdlj/9w17B59W1YxenzeJBfAEsVlk5Kak1mW WqRvl8CV8ej1YZaCL4oVP9f2MDUwdsl0MXJySAiYSOx9vZENwhaTuHBvPZDNxSEksJRR4ubU 3ewQzmdGiXM7tzLBdMye8w6qahmjxIF7XxkhnP+MEqcbmoAcDg42AS2JNe3xIA0iAsYS/Wdn gU1iFrjFKPH0+gNGkISwgJHE6r372EFsFgFViUkLOsFsXgFnic7OXVDb5CRunutkBmmWEHjK KrFsXxdUwkXie1c3C4QtLPHq+BZ2CFtG4vJkmHi1xMWvu6Ceq5FovL0BqsZa4vOkLcwgNrMA n8SkbdOZQY6WEOCV6GgTgjA9JOZvjoWodpTY+OQKO0hYSCBW4tvVkAmMUgsYGVYxiqSWFuem pxab6hUn5haX5qXrJefnbmIERt7pf8e/7mBceszqEKMAB6MSD+8NNfkoIdbEsuLK3EOMEhzM SiK8yieAQrwpiZVVqUX58UWlOanFhxilOViUxHlto9oihQTSE0tSs1NTC1KLYLJMHJxSDYxN UQr7Uv5d0Fr04kCkKavzkTKRuZwi64QcC2NCLVgTPu9YsOFoqHRo2IfVC6OPCn+7w+Sde+2n jNr/mpv6PZf7Pgct0IxJ5Pxpufq7cXNQza+1kosPn4yw4mPrY9n7tVrZvnmOo9fDf82vr8kw Gs+WmWcUcj9hNRff/YjS7Sv/KPJ+e57/ylWJpTgj0VCLuag4EQDimVQDuAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIJMWRmVeSWpSXmKPExsVy+t/xy7pO/+SjDJ4+4LTYOGM9q0Xz4vVs Fpd3zWGzWPDyFovF2iN32S0u9U9kcmDzuHztIrPH/rlr2D36tqxi9Pi8SS6AJYrLJiU1J7Ms tUjfLoEr49HrwywFXxQrfq7tYWpg7JLpYuTkkBAwkZg95x0bhC0mceHeeiCbi0NIYAmjxIyt 56CcRiaJt196gBwODjYBLYk17fEgDSICxhL9Z2exg9QwC9xilDi79CEjSEJYwEhi9d597CA2 i4CqxKQFnWA2r4CzRGfnLiaIbXISN891Mk9g5F7AyLCKUSS1tDg3PbfYSK84Mbe4NC9dLzk/ dxMjMCC2Hfu5ZQdj17vgQ4wCHIxKPLw31OSjhFgTy4orcw8xSnAwK4nwKp8ACvGmJFZWpRbl xxeV5qQWH2KU5mBREuft3bM6UkggPbEkNTs1tSC1CCbLxMEp1cC4sO+/rdGnyoXpUnYO2q37 fvPt1Oo8/5zlFoedYbK77Gv2RdveZ/a9CWyd+ietfoZt2QWj6n8vntpncVnM1K9Zl73qwT8d uw+auwLkArKKz+06IfmhT0LosqkkmwCX2K0H0l958rc1PbIrS2m/tEnrmZdNk7K+NNsSNT+F aZ8+6SunTPT4d1WJpTgj0VCLuag4EQDOmnNsBAIAAA== X-CMS-MailID: 20171130124906eucas1p2a671ee7d62ddebe9fde3a5def2d97f44 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171130124906eucas1p2a671ee7d62ddebe9fde3a5def2d97f44 X-RootMTR: 20171130124906eucas1p2a671ee7d62ddebe9fde3a5def2d97f44 References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently there is no information in any vfs about which devices a master component consists of, what makes debugging hard if one of the component devices fails to register. Add 'device_component' directory to debugfs. Create a new file for each component master, when it has been added. Remove it on a master deletion. Show a list of devices required by the given master and their status (registered or not). This provides an easy way to check, which device has failed to register if the given master device is not available in the system. Signed-off-by: Maciej Purski --- Changes in v4: - fix and expand commit message - inline no-op functions Changes in v3: - get rid of useless check - change directory name to "device_component" 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 | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/base/component.c b/drivers/base/component.c index 89b032f..5adbfb8 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,80 @@ 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("device_component", NULL); + + 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); +} + +static void component_master_debugfs_del(struct master *m) +{ + debugfs_remove(m->dentry); + m->dentry = NULL; +} + +#else + +static inline void component_master_debugfs_add(struct master *m) +{ } + +static inline void component_master_debugfs_del(struct master *m) +{ } + +#endif + static struct master *__master_find(struct device *dev, const struct component_master_ops *ops) { @@ -290,6 +366,7 @@ static void free_master(struct master *master) struct component_match *match = master->match; int i; + component_master_debugfs_del(master); list_del(&master->node); if (match) { @@ -323,6 +400,7 @@ int component_master_add_with_match(struct device *dev, master->ops = ops; master->match = match; + component_master_debugfs_add(master); /* Add to the list of available masters. */ mutex_lock(&component_mutex); list_add(&master->node, &masters); -- 2.7.4 From 1585450148951187972@xxx Thu Nov 30 00:51:26 +0000 2017 X-GM-THRID: 1585450148951187972 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread