Lines Matching refs:entry
69 struct intel_pmt_entry *entry = container_of(attr, in intel_pmt_read() local
76 if (off >= entry->size) in intel_pmt_read()
79 if (count > entry->size - off) in intel_pmt_read()
80 count = entry->size - off; in intel_pmt_read()
82 if (entry->guid == GUID_SPR_PUNIT) in intel_pmt_read()
84 count = pmt_memcpy64_fromio(buf, entry->base + off, count); in intel_pmt_read()
86 memcpy_fromio(buf, entry->base + off, count); in intel_pmt_read()
95 struct intel_pmt_entry *entry = container_of(attr, in intel_pmt_mmap() local
100 unsigned long phys = entry->base_addr; in intel_pmt_mmap()
107 psize = (PFN_UP(entry->base_addr + entry->size) - pfn) * PAGE_SIZE; in intel_pmt_mmap()
124 struct intel_pmt_entry *entry = dev_get_drvdata(dev); in guid_show() local
126 return sprintf(buf, "0x%x\n", entry->guid); in guid_show()
133 struct intel_pmt_entry *entry = dev_get_drvdata(dev); in size_show() local
135 return sprintf(buf, "%zu\n", entry->size); in size_show()
142 struct intel_pmt_entry *entry = dev_get_drvdata(dev); in offset_show() local
144 return sprintf(buf, "%lu\n", offset_in_page(entry->base_addr)); in offset_show()
161 static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, in intel_pmt_populate_entry() argument
191 entry->base_addr = disc_res->end + 1 + header->base_offset; in intel_pmt_populate_entry()
204 entry->base_addr = 0; in intel_pmt_populate_entry()
208 entry->base_addr = pci_resource_start(pci_dev, i) + in intel_pmt_populate_entry()
212 if (!entry->base_addr) in intel_pmt_populate_entry()
223 entry->base_addr = pci_resource_start(pci_dev, bir) + in intel_pmt_populate_entry()
232 entry->guid = header->guid; in intel_pmt_populate_entry()
233 entry->size = header->size; in intel_pmt_populate_entry()
238 static int intel_pmt_dev_register(struct intel_pmt_entry *entry, in intel_pmt_dev_register() argument
246 ret = xa_alloc(ns->xa, &entry->devid, entry, PMT_XA_LIMIT, GFP_KERNEL); in intel_pmt_dev_register()
250 dev = device_create(&intel_pmt_class, parent, MKDEV(0, 0), entry, in intel_pmt_dev_register()
251 "%s%d", ns->name, entry->devid); in intel_pmt_dev_register()
255 ns->name, entry->devid); in intel_pmt_dev_register()
260 entry->kobj = &dev->kobj; in intel_pmt_dev_register()
263 ret = sysfs_create_group(entry->kobj, ns->attr_grp); in intel_pmt_dev_register()
269 if (!entry->size) in intel_pmt_dev_register()
272 res.start = entry->base_addr; in intel_pmt_dev_register()
273 res.end = res.start + entry->size - 1; in intel_pmt_dev_register()
276 entry->base = devm_ioremap_resource(dev, &res); in intel_pmt_dev_register()
277 if (IS_ERR(entry->base)) { in intel_pmt_dev_register()
278 ret = PTR_ERR(entry->base); in intel_pmt_dev_register()
282 sysfs_bin_attr_init(&entry->pmt_bin_attr); in intel_pmt_dev_register()
283 entry->pmt_bin_attr.attr.name = ns->name; in intel_pmt_dev_register()
284 entry->pmt_bin_attr.attr.mode = 0440; in intel_pmt_dev_register()
285 entry->pmt_bin_attr.mmap = intel_pmt_mmap; in intel_pmt_dev_register()
286 entry->pmt_bin_attr.read = intel_pmt_read; in intel_pmt_dev_register()
287 entry->pmt_bin_attr.size = entry->size; in intel_pmt_dev_register()
289 ret = sysfs_create_bin_file(&dev->kobj, &entry->pmt_bin_attr); in intel_pmt_dev_register()
295 sysfs_remove_group(entry->kobj, ns->attr_grp); in intel_pmt_dev_register()
299 xa_erase(ns->xa, entry->devid); in intel_pmt_dev_register()
304 int intel_pmt_dev_create(struct intel_pmt_entry *entry, struct intel_pmt_namespace *ns, in intel_pmt_dev_create() argument
314 entry->disc_table = devm_ioremap_resource(dev, disc_res); in intel_pmt_dev_create()
315 if (IS_ERR(entry->disc_table)) in intel_pmt_dev_create()
316 return PTR_ERR(entry->disc_table); in intel_pmt_dev_create()
318 ret = ns->pmt_header_decode(entry, &header, dev); in intel_pmt_dev_create()
322 ret = intel_pmt_populate_entry(entry, &header, dev, disc_res); in intel_pmt_dev_create()
326 return intel_pmt_dev_register(entry, ns, dev); in intel_pmt_dev_create()
331 void intel_pmt_dev_destroy(struct intel_pmt_entry *entry, in intel_pmt_dev_destroy() argument
334 struct device *dev = kobj_to_dev(entry->kobj); in intel_pmt_dev_destroy()
336 if (entry->size) in intel_pmt_dev_destroy()
337 sysfs_remove_bin_file(entry->kobj, &entry->pmt_bin_attr); in intel_pmt_dev_destroy()
340 sysfs_remove_group(entry->kobj, ns->attr_grp); in intel_pmt_dev_destroy()
343 xa_erase(ns->xa, entry->devid); in intel_pmt_dev_destroy()