aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>2016-04-21 12:23:21 -0400
committerMark Brown <broonie@kernel.org>2016-04-22 05:28:52 -0400
commit2d80a91b2f2a96f38877bc328dac135d69564911 (patch)
treebc85bdad22397adddb16e177385a8aa1f73245fd /drivers/regulator
parentf55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff)
regulator: core: Add debugfs to show constraint flags
There are debugfs entries for voltage and current, but not for the constraint flags. It's useful for debugging to be able to see what these flags are so this patch adds a new debugfs file. We can't use debugfs_create_bool for this because the flags are bitfields, so as this needs a special read callback they have been collected into a single file that lists all the flags. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e0b764284773..73381752ff78 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1272,6 +1272,55 @@ static void unset_regulator_supplies(struct regulator_dev *rdev)
1272 } 1272 }
1273} 1273}
1274 1274
1275#ifdef CONFIG_DEBUG_FS
1276static ssize_t constraint_flags_read_file(struct file *file,
1277 char __user *user_buf,
1278 size_t count, loff_t *ppos)
1279{
1280 const struct regulator *regulator = file->private_data;
1281 const struct regulation_constraints *c = regulator->rdev->constraints;
1282 char *buf;
1283 ssize_t ret;
1284
1285 if (!c)
1286 return 0;
1287
1288 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
1289 if (!buf)
1290 return -ENOMEM;
1291
1292 ret = snprintf(buf, PAGE_SIZE,
1293 "always_on: %u\n"
1294 "boot_on: %u\n"
1295 "apply_uV: %u\n"
1296 "ramp_disable: %u\n"
1297 "soft_start: %u\n"
1298 "pull_down: %u\n"
1299 "over_current_protection: %u\n",
1300 c->always_on,
1301 c->boot_on,
1302 c->apply_uV,
1303 c->ramp_disable,
1304 c->soft_start,
1305 c->pull_down,
1306 c->over_current_protection);
1307
1308 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
1309 kfree(buf);
1310
1311 return ret;
1312}
1313
1314#endif
1315
1316static const struct file_operations constraint_flags_fops = {
1317#ifdef CONFIG_DEBUG_FS
1318 .open = simple_open,
1319 .read = constraint_flags_read_file,
1320 .llseek = default_llseek,
1321#endif
1322};
1323
1275#define REG_STR_SIZE 64 1324#define REG_STR_SIZE 64
1276 1325
1277static struct regulator *create_regulator(struct regulator_dev *rdev, 1326static struct regulator *create_regulator(struct regulator_dev *rdev,
@@ -1327,6 +1376,9 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1327 &regulator->min_uV); 1376 &regulator->min_uV);
1328 debugfs_create_u32("max_uV", 0444, regulator->debugfs, 1377 debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1329 &regulator->max_uV); 1378 &regulator->max_uV);
1379 debugfs_create_file("constraint_flags", 0444,
1380 regulator->debugfs, regulator,
1381 &constraint_flags_fops);
1330 } 1382 }
1331 1383
1332 /* 1384 /*