| class.c (2fbe82037ab2513275b9d97fe4fd9947df26e960) | class.c (d9a0788093565c300f7c8dd034dbfa6ac4da9aa6) |
|---|---|
| 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Intel Platform Monitory Technology Telemetry driver 4 * 5 * Copyright (c) 2020, Intel Corporation. 6 * All Rights Reserved. 7 * 8 * Author: "Alexander Duyck" <alexander.h.duyck@linux.intel.com> 9 */ 10 11#include <linux/kernel.h> | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Intel Platform Monitory Technology Telemetry driver 4 * 5 * Copyright (c) 2020, Intel Corporation. 6 * All Rights Reserved. 7 * 8 * Author: "Alexander Duyck" <alexander.h.duyck@linux.intel.com> 9 */ 10 11#include <linux/kernel.h> |
| 12#include <linux/log2.h> |
|
| 12#include <linux/intel_vsec.h> 13#include <linux/io-64-nonatomic-lo-hi.h> 14#include <linux/module.h> 15#include <linux/mm.h> 16#include <linux/pci.h> | 13#include <linux/intel_vsec.h> 14#include <linux/io-64-nonatomic-lo-hi.h> 15#include <linux/module.h> 16#include <linux/mm.h> 17#include <linux/pci.h> |
| 18#include <linux/sysfs.h> |
|
| 17 18#include "class.h" 19 20#define PMT_XA_START 1 21#define PMT_XA_MAX INT_MAX 22#define PMT_XA_LIMIT XA_LIMIT(PMT_XA_START, PMT_XA_MAX) 23#define GUID_SPR_PUNIT 0x9956f43f 24 --- 136 unchanged lines hidden (view full) --- 161static DEVICE_ATTR_RO(offset); 162 163static struct attribute *intel_pmt_attrs[] = { 164 &dev_attr_guid.attr, 165 &dev_attr_size.attr, 166 &dev_attr_offset.attr, 167 NULL 168}; | 19 20#include "class.h" 21 22#define PMT_XA_START 1 23#define PMT_XA_MAX INT_MAX 24#define PMT_XA_LIMIT XA_LIMIT(PMT_XA_START, PMT_XA_MAX) 25#define GUID_SPR_PUNIT 0x9956f43f 26 --- 136 unchanged lines hidden (view full) --- 163static DEVICE_ATTR_RO(offset); 164 165static struct attribute *intel_pmt_attrs[] = { 166 &dev_attr_guid.attr, 167 &dev_attr_size.attr, 168 &dev_attr_offset.attr, 169 NULL 170}; |
| 169ATTRIBUTE_GROUPS(intel_pmt); | |
| 170 | 171 |
| 171static struct class intel_pmt_class = { | 172static umode_t intel_pmt_attr_visible(struct kobject *kobj, 173 struct attribute *attr, int n) 174{ 175 struct device *dev = container_of(kobj, struct device, kobj); 176 struct auxiliary_device *auxdev = to_auxiliary_dev(dev->parent); 177 struct intel_vsec_device *ivdev = auxdev_to_ivdev(auxdev); 178 179 /* 180 * Place the discovery features folder in /sys/class/intel_pmt, but 181 * exclude the common attributes as they are not applicable. 182 */ 183 if (ivdev->cap_id == ilog2(VSEC_CAP_DISCOVERY)) 184 return 0; 185 186 return attr->mode; 187} 188 189static bool intel_pmt_group_visible(struct kobject *kobj) 190{ 191 return true; 192} 193DEFINE_SYSFS_GROUP_VISIBLE(intel_pmt); 194 195static const struct attribute_group intel_pmt_group = { 196 .attrs = intel_pmt_attrs, 197 .is_visible = SYSFS_GROUP_VISIBLE(intel_pmt), 198}; 199__ATTRIBUTE_GROUPS(intel_pmt); 200 201struct class intel_pmt_class = { |
| 172 .name = "intel_pmt", 173 .dev_groups = intel_pmt_groups, 174}; | 202 .name = "intel_pmt", 203 .dev_groups = intel_pmt_groups, 204}; |
| 205EXPORT_SYMBOL_GPL(intel_pmt_class); |
|
| 175 176static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, 177 struct intel_vsec_device *ivdev, 178 struct resource *disc_res) 179{ 180 struct pci_dev *pci_dev = ivdev->pcidev; 181 struct device *dev = &ivdev->auxdev.dev; 182 struct intel_pmt_header *header = &entry->header; --- 120 unchanged lines hidden (view full) --- 303 ret = PTR_ERR(entry->base); 304 goto fail_ioremap; 305 } 306 307 sysfs_bin_attr_init(&entry->pmt_bin_attr); 308 entry->pmt_bin_attr.attr.name = ns->name; 309 entry->pmt_bin_attr.attr.mode = 0440; 310 entry->pmt_bin_attr.mmap = intel_pmt_mmap; | 206 207static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, 208 struct intel_vsec_device *ivdev, 209 struct resource *disc_res) 210{ 211 struct pci_dev *pci_dev = ivdev->pcidev; 212 struct device *dev = &ivdev->auxdev.dev; 213 struct intel_pmt_header *header = &entry->header; --- 120 unchanged lines hidden (view full) --- 334 ret = PTR_ERR(entry->base); 335 goto fail_ioremap; 336 } 337 338 sysfs_bin_attr_init(&entry->pmt_bin_attr); 339 entry->pmt_bin_attr.attr.name = ns->name; 340 entry->pmt_bin_attr.attr.mode = 0440; 341 entry->pmt_bin_attr.mmap = intel_pmt_mmap; |
| 311 entry->pmt_bin_attr.read = intel_pmt_read; | 342 entry->pmt_bin_attr.read_new = intel_pmt_read; |
| 312 entry->pmt_bin_attr.size = entry->size; 313 314 ret = sysfs_create_bin_file(&dev->kobj, &entry->pmt_bin_attr); 315 if (ret) 316 goto fail_ioremap; 317 318 if (ns->pmt_add_endpoint) { 319 ret = ns->pmt_add_endpoint(ivdev, entry); --- 76 unchanged lines hidden --- | 343 entry->pmt_bin_attr.size = entry->size; 344 345 ret = sysfs_create_bin_file(&dev->kobj, &entry->pmt_bin_attr); 346 if (ret) 347 goto fail_ioremap; 348 349 if (ns->pmt_add_endpoint) { 350 ret = ns->pmt_add_endpoint(ivdev, entry); --- 76 unchanged lines hidden --- |