cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

sysfs.c (1277B)


      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
     11static 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	pm_runtime_get_sync(cdev->dev);
     19
     20	ret = catpt_ipc_get_fw_version(cdev, &version);
     21
     22	pm_runtime_mark_last_busy(cdev->dev);
     23	pm_runtime_put_autosuspend(cdev->dev);
     24
     25	if (ret)
     26		return CATPT_IPC_ERROR(ret);
     27
     28	return sprintf(buf, "%d.%d.%d.%d\n", version.type, version.major,
     29		       version.minor, version.build);
     30}
     31static DEVICE_ATTR_RO(fw_version);
     32
     33static ssize_t fw_info_show(struct device *dev,
     34			    struct device_attribute *attr, char *buf)
     35{
     36	struct catpt_dev *cdev = dev_get_drvdata(dev);
     37
     38	return sprintf(buf, "%s\n", cdev->ipc.config.fw_info);
     39}
     40static DEVICE_ATTR_RO(fw_info);
     41
     42static struct attribute *catpt_attrs[] = {
     43	&dev_attr_fw_version.attr,
     44	&dev_attr_fw_info.attr,
     45	NULL
     46};
     47
     48static const struct attribute_group catpt_attr_group = {
     49	.attrs = catpt_attrs,
     50};
     51
     52const struct attribute_group *catpt_attr_groups[] = {
     53	&catpt_attr_group,
     54	NULL
     55};