summaryrefslogtreecommitdiff
path: root/sound/soc/intel/catpt/sysfs.c
blob: 1bdbcc04dc71285199d0a06c843cafcbe25d306f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Cezary Rojewski <cezary.rojewski@intel.com>
//

#include <linux/pm_runtime.h>
#include "core.h"

static ssize_t fw_version_show(struct device *dev,
			       struct device_attribute *attr, char *buf)
{
	struct catpt_dev *cdev = dev_get_drvdata(dev);
	struct catpt_fw_version version;
	int ret;

	ret = pm_runtime_resume_and_get(cdev->dev);
	if (ret < 0 && ret != -EACCES)
		return ret;

	ret = catpt_ipc_get_fw_version(cdev, &version);

	pm_runtime_mark_last_busy(cdev->dev);
	pm_runtime_put_autosuspend(cdev->dev);

	if (ret)
		return CATPT_IPC_ERROR(ret);

	return sprintf(buf, "%d.%d.%d.%d\n", version.type, version.major,
		       version.minor, version.build);
}
static DEVICE_ATTR_RO(fw_version);

static ssize_t fw_info_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
{
	struct catpt_dev *cdev = dev_get_drvdata(dev);

	return sprintf(buf, "%s\n", cdev->ipc.config.fw_info);
}
static DEVICE_ATTR_RO(fw_info);

static struct attribute *catpt_attrs[] = {
	&dev_attr_fw_version.attr,
	&dev_attr_fw_info.attr,
	NULL
};

static const struct attribute_group catpt_attr_group = {
	.attrs = catpt_attrs,
};

const struct attribute_group *catpt_attr_groups[] = {
	&catpt_attr_group,
	NULL
};