mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 19:47:08 +02:00
soc: qti_battery_debug: Move qbg_context to device bin file
Replace the "qbg_context" debugfs blob with a binary file associated
with the battery_debug device that provides the same functionality as
the existing debugfs blob for getting QBG context.
Usage:
# cd /sys/devices/platform/soc/soc:qcom,pmic_glink_log/\
soc:qcom,pmic_glink_log:qcom,battery_debug
# echo 1 > qbg_context
# cat qbg_context > file.bin
Change-Id: I59cfea2880362a95d8c87c02b4d823bfdca4e1e2
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
This commit is contained in:
parent
e4ea2b8741
commit
d9197e1de2
|
|
@ -275,9 +275,6 @@ static int get_qbg_context_write(void *data, u64 val)
|
|||
return battery_dbg_write(bd, &req_msg, sizeof(req_msg));
|
||||
}
|
||||
|
||||
DEFINE_DEBUGFS_ATTRIBUTE(get_qbg_context_debugfs_ops, NULL,
|
||||
get_qbg_context_write, "%llu\n");
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
static int battery_dbg_request_read_votable(struct battery_dbg_dev *bd,
|
||||
u32 id)
|
||||
|
|
@ -629,34 +626,16 @@ static int battery_dbg_create_votables(struct battery_dbg_dev *bd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int battery_dbg_add_debugfs(struct battery_dbg_dev *bd)
|
||||
static void battery_dbg_add_debugfs(struct battery_dbg_dev *bd)
|
||||
{
|
||||
int rc;
|
||||
struct dentry *bd_dir, *file;
|
||||
struct dentry *bd_dir;
|
||||
|
||||
bd_dir = debugfs_create_dir("battery_debug", NULL);
|
||||
if (IS_ERR(bd_dir)) {
|
||||
rc = PTR_ERR(bd_dir);
|
||||
pr_err("Failed to create battery debugfs directory: %d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
file = debugfs_create_file_unsafe("get_qbg_context", 0200, bd_dir, bd,
|
||||
&get_qbg_context_debugfs_ops);
|
||||
if (IS_ERR(file)) {
|
||||
rc = PTR_ERR(file);
|
||||
pr_err("Failed to create get_qbg_context debugfs file: %d\n",
|
||||
rc);
|
||||
goto error;
|
||||
}
|
||||
|
||||
bd->qbg_blob.data = bd->qbg_dump.buf;
|
||||
bd->qbg_blob.size = 0;
|
||||
file = debugfs_create_blob("qbg_context", 0444, bd_dir, &bd->qbg_blob);
|
||||
if (IS_ERR(file)) {
|
||||
rc = PTR_ERR(file);
|
||||
pr_err("Failed to create qbg_context debugfs file: %d\n", rc);
|
||||
goto error;
|
||||
return;
|
||||
}
|
||||
|
||||
rc = battery_dbg_create_votables(bd, bd_dir);
|
||||
|
|
@ -667,18 +646,68 @@ static int battery_dbg_add_debugfs(struct battery_dbg_dev *bd)
|
|||
|
||||
bd->debugfs_dir = bd_dir;
|
||||
|
||||
return 0;
|
||||
return;
|
||||
error:
|
||||
debugfs_remove_recursive(bd_dir);
|
||||
return rc;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
static int battery_dbg_add_debugfs(struct battery_dbg_dev *bd)
|
||||
static void battery_dbg_add_debugfs(struct battery_dbg_dev *bd)
|
||||
{
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
static ssize_t qbg_blob_write(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf,
|
||||
loff_t pos, size_t count)
|
||||
{
|
||||
int rc;
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
struct battery_dbg_dev *bd = dev_get_drvdata(dev);
|
||||
|
||||
rc = get_qbg_context_write(bd, 0); /* second arg is ignored */
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t qbg_blob_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *attr, char *buf,
|
||||
loff_t pos, size_t count)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
struct battery_dbg_dev *bd = dev_get_drvdata(dev);
|
||||
|
||||
return memory_read_from_buffer(buf, count, &pos, bd->qbg_blob.data,
|
||||
bd->qbg_blob.size);
|
||||
}
|
||||
|
||||
static struct bin_attribute qbg_blob = {
|
||||
.attr = {
|
||||
.name = "qbg_context",
|
||||
.mode = 0600,
|
||||
},
|
||||
.read = qbg_blob_read,
|
||||
.write = qbg_blob_write,
|
||||
};
|
||||
|
||||
static int battery_dbg_add_dev_attr(struct battery_dbg_dev *bd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
bd->qbg_blob.data = bd->qbg_dump.buf;
|
||||
bd->qbg_blob.size = 0;
|
||||
|
||||
rc = device_create_bin_file(bd->dev, &qbg_blob);
|
||||
if (rc)
|
||||
dev_err(bd->dev, "Failed to create qbg_context bin file: %d\n",
|
||||
rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int battery_dbg_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct battery_dbg_dev *bd;
|
||||
|
|
@ -708,10 +737,12 @@ static int battery_dbg_probe(struct platform_device *pdev)
|
|||
init_completion(&bd->ack);
|
||||
platform_set_drvdata(pdev, bd);
|
||||
|
||||
rc = battery_dbg_add_debugfs(bd);
|
||||
rc = battery_dbg_add_dev_attr(bd);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
battery_dbg_add_debugfs(bd);
|
||||
|
||||
return 0;
|
||||
out:
|
||||
pmic_glink_unregister_client(bd->client);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user