Merge tag 'powerpc-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[linux/fpc-iii.git] / sound / soc / intel / catpt / sysfs.c
blob9579e233a15db4d851148ab16124d541ff54d281
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 //
8 #include <linux/pm_runtime.h>
9 #include "core.h"
11 static ssize_t fw_version_show(struct device *dev,
12 struct device_attribute *attr, char *buf)
14 struct catpt_dev *cdev = dev_get_drvdata(dev);
15 struct catpt_fw_version version;
16 int ret;
18 pm_runtime_get_sync(cdev->dev);
20 ret = catpt_ipc_get_fw_version(cdev, &version);
22 pm_runtime_mark_last_busy(cdev->dev);
23 pm_runtime_put_autosuspend(cdev->dev);
25 if (ret)
26 return CATPT_IPC_ERROR(ret);
28 return sprintf(buf, "%d.%d.%d.%d\n", version.type, version.major,
29 version.minor, version.build);
31 static DEVICE_ATTR_RO(fw_version);
33 static ssize_t fw_info_show(struct device *dev,
34 struct device_attribute *attr, char *buf)
36 struct catpt_dev *cdev = dev_get_drvdata(dev);
38 return sprintf(buf, "%s\n", cdev->ipc.config.fw_info);
40 static DEVICE_ATTR_RO(fw_info);
42 static struct attribute *catpt_attrs[] = {
43 &dev_attr_fw_version.attr,
44 &dev_attr_fw_info.attr,
45 NULL
48 static const struct attribute_group catpt_attr_group = {
49 .attrs = catpt_attrs,
52 const struct attribute_group *catpt_attr_groups[] = {
53 &catpt_attr_group,
54 NULL