From: Alexandru Tachici <[email protected]>
Add a debugfs entry which prints the current state
of the adm1266 sequencer.
Signed-off-by: Alexandru Tachici <[email protected]>
---
drivers/hwmon/pmbus/adm1266.c | 42 ++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
index be911de02cf6..dbffc6d12e87 100644
--- a/drivers/hwmon/pmbus/adm1266.c
+++ b/drivers/hwmon/pmbus/adm1266.c
@@ -19,6 +19,7 @@
#include <linux/slab.h>
#define ADM1266_PDIO_CONFIG 0xD4
+#define ADM1266_READ_STATE 0xD9
#define ADM1266_GPIO_CONFIG 0xE1
#define ADM1266_PDIO_STATUS 0xE9
#define ADM1266_GPIO_STATUS 0xEA
@@ -43,6 +44,7 @@ struct adm1266_data {
struct gpio_chip gc;
const char *gpio_names[ADM1266_GPIO_NR + ADM1266_PDIO_NR];
struct i2c_client *client;
+ struct dentry *debugfs_dir;
struct mutex buf_mutex;
u8 write_buf[ADM1266_PMBUS_BLOCK_MAX + 1] ____cacheline_aligned;
u8 read_buf[ADM1266_PMBUS_BLOCK_MAX + 1] ____cacheline_aligned;
@@ -287,6 +289,38 @@ static int adm1266_config_gpio(struct adm1266_data *data)
return ret;
}
+static int adm1266_state_read(struct seq_file *s, void *pdata)
+{
+ struct device *dev = s->private;
+ struct i2c_client *client = to_i2c_client(dev);
+ int ret;
+
+ ret = i2c_smbus_read_word_data(client, ADM1266_READ_STATE);
+ if (ret < 0)
+ return ret;
+
+ seq_printf(s, "%d\n", ret);
+
+ return 0;
+}
+
+static void adm1266_init_debugfs(struct adm1266_data *data)
+{
+ struct dentry *entry;
+ struct dentry *root;
+
+ root = pmbus_get_debugfs_dir(data->client);
+ if (!root)
+ return;
+
+ data->debugfs_dir = debugfs_create_dir(data->client->name, root);
+ if (!data->debugfs_dir)
+ return;
+
+ entry = debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state",
+ data->debugfs_dir, adm1266_state_read);
+}
+
static int adm1266_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct adm1266_data *data;
@@ -310,7 +344,13 @@ static int adm1266_probe(struct i2c_client *client, const struct i2c_device_id *
if (ret < 0)
return ret;
- return pmbus_do_probe(client, id, &data->info);
+ ret = pmbus_do_probe(client, id, &data->info);
+ if (ret)
+ return ret;
+
+ adm1266_init_debugfs(data);
+
+ return 0;
}
static const struct of_device_id adm1266_of_match[] = {
--
2.20.1
Hi,
I love your patch! Perhaps something to improve:
[auto build test WARNING on hwmon/hwmon-next]
[also build test WARNING on linux/master robh/for-next linus/master v5.8-rc7 next-20200724]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/alexandru-tachici-analog-com/hwmon-pmbus-adm1266-add-support/20200727-133122
base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
drivers/hwmon/pmbus/adm1266.c: In function 'adm1266_init_debugfs':
>> drivers/hwmon/pmbus/adm1266.c:309:17: warning: variable 'entry' set but not used [-Wunused-but-set-variable]
309 | struct dentry *entry;
| ^~~~~
vim +/entry +309 drivers/hwmon/pmbus/adm1266.c
306
307 static void adm1266_init_debugfs(struct adm1266_data *data)
308 {
> 309 struct dentry *entry;
310 struct dentry *root;
311
312 root = pmbus_get_debugfs_dir(data->client);
313 if (!root)
314 return;
315
316 data->debugfs_dir = debugfs_create_dir(data->client->name, root);
317 if (!data->debugfs_dir)
318 return;
319
320 entry = debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state",
321 data->debugfs_dir, adm1266_state_read);
322 }
323
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]