arm64: dts: qcom: sm8550: add TRNG node
[linux-modified.git] / sound / soc / intel / catpt / sysfs.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 //
3 // Copyright(c) 2020 Intel Corporation. All rights reserved.
4 //
5 // Author: Cezary Rojewski <cezary.rojewski@intel.com>
6 //
7
8 #include <linux/pm_runtime.h>
9 #include "core.h"
10
11 static ssize_t fw_version_show(struct device *dev,
12                                struct device_attribute *attr, char *buf)
13 {
14         struct catpt_dev *cdev = dev_get_drvdata(dev);
15         struct catpt_fw_version version;
16         int ret;
17
18         ret = pm_runtime_resume_and_get(cdev->dev);
19         if (ret < 0 && ret != -EACCES)
20                 return ret;
21
22         ret = catpt_ipc_get_fw_version(cdev, &version);
23
24         pm_runtime_mark_last_busy(cdev->dev);
25         pm_runtime_put_autosuspend(cdev->dev);
26
27         if (ret)
28                 return CATPT_IPC_ERROR(ret);
29
30         return sysfs_emit(buf, "%d.%d.%d.%d\n", version.type, version.major,
31                           version.minor, version.build);
32 }
33 static DEVICE_ATTR_RO(fw_version);
34
35 static ssize_t fw_info_show(struct device *dev,
36                             struct device_attribute *attr, char *buf)
37 {
38         struct catpt_dev *cdev = dev_get_drvdata(dev);
39
40         return sysfs_emit(buf, "%s\n", cdev->ipc.config.fw_info);
41 }
42 static DEVICE_ATTR_RO(fw_info);
43
44 static struct attribute *catpt_attrs[] = {
45         &dev_attr_fw_version.attr,
46         &dev_attr_fw_info.attr,
47         NULL
48 };
49
50 static const struct attribute_group catpt_attr_group = {
51         .attrs = catpt_attrs,
52 };
53
54 const struct attribute_group *catpt_attr_groups[] = {
55         &catpt_attr_group,
56         NULL
57 };