Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp663655ybt; Wed, 24 Jun 2020 08:17:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIau1xl3d71WpDES6+RiprMSigSgeXGAyzOQwsGeuqN9xrIsiXltPB3CCQFK2GT67shPjy X-Received: by 2002:aa7:ccc2:: with SMTP id y2mr26537771edt.97.1593011852112; Wed, 24 Jun 2020 08:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593011852; cv=none; d=google.com; s=arc-20160816; b=A5QkfU7z1un67IZVr17OMVJW+imU6MCttzB+g5pkFYf1kBUG2UMxKfd+wfIg71kqSb FL9kbl1d7WhWKcPP/WiARKKF9wrOkTUkGQCb7udnOd7NTyp1NkWzINkmChb3e+6n8OjV oiRx/CWqGplnjcjyI2gfdAbYiVEQh7u9Bx3BiSOnxw4naQW7lfaeKpU4fJZ5I3ogtcas F25Lc0HNrh+OTYyj4IFZBgw6aF7fF6qfuE3eSwx2l2/cpevPbY512xWw94ogqQjFO86/ XYIZW+Vro1njsMdlP/ht0wU9rDXypmXAk3/xaIaUIppIgMrvy8xDBA2Lan/rsN6hOiaF E2iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=YYHdUgJwcz6beLqSeN6z71BHZcjoFnTWzKo8Wv8ODGA=; b=jzGGgVpEQyRASL2w09lDHkU2YVkHT9+v/qc2X7j3MYJOkHn24/hMFlZLzBMdOZPyMs ys+82FRyuOXcN1k6N9EICqXblNd+GIna5UAcapko27uD5dttm/4a5XB9mKL1exGFC1mB H8TKjvbyBz9u5du7qH/YptEPJyuNF7it6HSGyTdjqmG8b9yrFfTIhxHYFsW9Da2OLP7D 5wlBQNfVpogC0hYFesIAZ2fKTlXOA07fCVxeqCTRiJN7DBausdKVG03VFpqnl43MG0F+ 0T45nbwrgxdY4Gpgh40pfrF/e7ZOYZUk+tV4LpAp02QOVWkDyGql97nKQnSaf//5yoyr l1hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pk14si14030578ejb.368.2020.06.24.08.17.08; Wed, 24 Jun 2020 08:17:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404548AbgFXPQ1 (ORCPT + 99 others); Wed, 24 Jun 2020 11:16:27 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:7318 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404523AbgFXPQI (ORCPT ); Wed, 24 Jun 2020 11:16:08 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05OEtLat019662; Wed, 24 Jun 2020 11:15:52 -0400 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 31uurjjgbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 Jun 2020 11:15:52 -0400 Received: from SCSQMBX10.ad.analog.com (scsqmbx10.ad.analog.com [10.77.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 05OFFoSU044808 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Wed, 24 Jun 2020 11:15:51 -0400 Received: from SCSQCASHYB7.ad.analog.com (10.77.17.133) by SCSQMBX10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Wed, 24 Jun 2020 08:15:49 -0700 Received: from SCSQMBX11.ad.analog.com (10.77.17.10) by SCSQCASHYB7.ad.analog.com (10.77.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Wed, 24 Jun 2020 08:15:49 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Wed, 24 Jun 2020 08:15:49 -0700 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 05OFFdRv023607; Wed, 24 Jun 2020 11:15:47 -0400 From: To: , , CC: , , Alexandru Tachici Subject: [PATCH v5 6/7] hwmon: pmbus: adm1266: debugfs for blackbox info Date: Wed, 24 Jun 2020 18:17:35 +0300 Message-ID: <20200624151736.95785-7-alexandru.tachici@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624151736.95785-1-alexandru.tachici@analog.com> References: <20200624151736.95785-1-alexandru.tachici@analog.com> MIME-Version: 1.0 Content-Type: text/plain X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-24_08:2020-06-24,2020-06-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 adultscore=0 mlxscore=0 spamscore=0 priorityscore=1501 cotscore=-2147483648 bulkscore=0 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006240107 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Tachici Add a debugfs file to print information in the BLACKBOX_INFORMATION register. Contains information about the number of stored records, logic index and id of the latest record. Signed-off-by: Alexandru Tachici --- drivers/hwmon/pmbus/adm1266.c | 56 ++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c index b9e92ab1e39a..ea2dc481094b 100644 --- a/drivers/hwmon/pmbus/adm1266.c +++ b/drivers/hwmon/pmbus/adm1266.c @@ -60,6 +60,7 @@ struct adm1266_data { const char *gpio_names[ADM1266_GPIO_NR + ADM1266_PDIO_NR]; struct i2c_client *client; struct mutex ioctl_mutex; /* lock ioctl access */ + struct dentry *debugfs_dir; struct nvmem_config nvmem_config; struct nvmem_device *nvmem; u8 *dev_mem; @@ -406,6 +407,28 @@ static const struct proc_ops adm1266_proc_ops = { .proc_ioctl = adm1266_ioctl, }; +static int adm1266_blackbox_information_read(struct seq_file *s, void *pdata) +{ + struct device *dev = s->private; + struct i2c_client *client = to_i2c_client(dev); + u8 read_buf[5]; + unsigned int latest_id; + int ret; + + ret = i2c_smbus_read_block_data(client, ADM1266_BLACKBOX_INFO, + read_buf); + if (ret < 0) + return ret; + + seq_puts(s, "BLACKBOX_INFORMATION:\n"); + latest_id = read_buf[0] + (read_buf[1] << 8); + seq_printf(s, "Black box ID: %u\n", latest_id); + seq_printf(s, "Logic index: %u\n", read_buf[2]); + seq_printf(s, "Record count: %u\n", read_buf[3]); + + return 0; +} + static int adm1266_init_procfs(struct adm1266_data *data) { struct proc_dir_entry *proc_dir; @@ -423,6 +446,29 @@ static int adm1266_init_procfs(struct adm1266_data *data) return 0; } +static int adm1266_init_debugfs(struct adm1266_data *data) +{ + struct dentry *entry; + struct dentry *root; + + root = pmbus_get_debugfs_dir(data->client); + if (!root) + return -ENOENT; + + data->debugfs_dir = debugfs_create_dir(data->client->name, root); + if (!data->debugfs_dir) + return -ENOENT; + + entry = debugfs_create_devm_seqfile(&data->client->dev, + "blackbox_information", + data->debugfs_dir, + adm1266_blackbox_information_read); + if (!entry) + return -ENOENT; + + return 0; +} + static int adm1266_nvmem_read_blackbox(struct adm1266_data *data, u8 *buf) { u8 read_buf[5]; @@ -571,7 +617,15 @@ static int adm1266_probe(struct i2c_client *client, for (i = 0; i < info->pages; i++) info->func[i] = funcs; - return pmbus_do_probe(client, id, info); + ret = pmbus_do_probe(client, id, info); + if (ret) + return ret; + + ret = adm1266_init_debugfs(data); + if (ret) + dev_warn(&client->dev, "Failed to register debugfs: %d\n", ret); + + return 0; } static const struct of_device_id adm1266_of_match[] = { -- 2.20.1