Lines Matching refs:entry
52 struct intel_pmt_entry *entry = container_of(attr, in intel_pmt_read() local
59 if (off >= entry->size) in intel_pmt_read()
62 if (count > entry->size - off) in intel_pmt_read()
63 count = entry->size - off; in intel_pmt_read()
65 memcpy_fromio(buf, entry->base + off, count); in intel_pmt_read()
74 struct intel_pmt_entry *entry = container_of(attr, in intel_pmt_mmap() local
79 unsigned long phys = entry->base_addr; in intel_pmt_mmap()
86 psize = (PFN_UP(entry->base_addr + entry->size) - pfn) * PAGE_SIZE; in intel_pmt_mmap()
103 struct intel_pmt_entry *entry = dev_get_drvdata(dev); in guid_show() local
105 return sprintf(buf, "0x%x\n", entry->guid); in guid_show()
112 struct intel_pmt_entry *entry = dev_get_drvdata(dev); in size_show() local
114 return sprintf(buf, "%zu\n", entry->size); in size_show()
121 struct intel_pmt_entry *entry = dev_get_drvdata(dev); in offset_show() local
123 return sprintf(buf, "%lu\n", offset_in_page(entry->base_addr)); in offset_show()
141 static int intel_pmt_populate_entry(struct intel_pmt_entry *entry, in intel_pmt_populate_entry() argument
171 entry->base_addr = disc_res->end + 1 + header->base_offset; in intel_pmt_populate_entry()
184 entry->base_addr = 0; in intel_pmt_populate_entry()
188 entry->base_addr = pci_resource_start(pci_dev, i) + in intel_pmt_populate_entry()
192 if (!entry->base_addr) in intel_pmt_populate_entry()
203 entry->base_addr = pci_resource_start(pci_dev, bir) + in intel_pmt_populate_entry()
212 entry->guid = header->guid; in intel_pmt_populate_entry()
213 entry->size = header->size; in intel_pmt_populate_entry()
218 static int intel_pmt_dev_register(struct intel_pmt_entry *entry, in intel_pmt_dev_register() argument
226 ret = xa_alloc(ns->xa, &entry->devid, entry, PMT_XA_LIMIT, GFP_KERNEL); in intel_pmt_dev_register()
230 dev = device_create(&intel_pmt_class, parent, MKDEV(0, 0), entry, in intel_pmt_dev_register()
231 "%s%d", ns->name, entry->devid); in intel_pmt_dev_register()
235 ns->name, entry->devid); in intel_pmt_dev_register()
240 entry->kobj = &dev->kobj; in intel_pmt_dev_register()
243 ret = sysfs_create_group(entry->kobj, ns->attr_grp); in intel_pmt_dev_register()
249 if (!entry->size) in intel_pmt_dev_register()
252 res.start = entry->base_addr; in intel_pmt_dev_register()
253 res.end = res.start + entry->size - 1; in intel_pmt_dev_register()
256 entry->base = devm_ioremap_resource(dev, &res); in intel_pmt_dev_register()
257 if (IS_ERR(entry->base)) { in intel_pmt_dev_register()
258 ret = PTR_ERR(entry->base); in intel_pmt_dev_register()
262 sysfs_bin_attr_init(&entry->pmt_bin_attr); in intel_pmt_dev_register()
263 entry->pmt_bin_attr.attr.name = ns->name; in intel_pmt_dev_register()
264 entry->pmt_bin_attr.attr.mode = 0440; in intel_pmt_dev_register()
265 entry->pmt_bin_attr.mmap = intel_pmt_mmap; in intel_pmt_dev_register()
266 entry->pmt_bin_attr.read = intel_pmt_read; in intel_pmt_dev_register()
267 entry->pmt_bin_attr.size = entry->size; in intel_pmt_dev_register()
269 ret = sysfs_create_bin_file(&dev->kobj, &entry->pmt_bin_attr); in intel_pmt_dev_register()
275 sysfs_remove_group(entry->kobj, ns->attr_grp); in intel_pmt_dev_register()
279 xa_erase(ns->xa, entry->devid); in intel_pmt_dev_register()
284 int intel_pmt_dev_create(struct intel_pmt_entry *entry, in intel_pmt_dev_create() argument
296 entry->disc_table = devm_platform_ioremap_resource(pdev, idx); in intel_pmt_dev_create()
297 if (IS_ERR(entry->disc_table)) in intel_pmt_dev_create()
298 return PTR_ERR(entry->disc_table); in intel_pmt_dev_create()
300 ret = ns->pmt_header_decode(entry, &header, &pdev->dev); in intel_pmt_dev_create()
304 ret = intel_pmt_populate_entry(entry, &header, &pdev->dev, disc_res); in intel_pmt_dev_create()
308 return intel_pmt_dev_register(entry, ns, &pdev->dev); in intel_pmt_dev_create()
313 void intel_pmt_dev_destroy(struct intel_pmt_entry *entry, in intel_pmt_dev_destroy() argument
316 struct device *dev = kobj_to_dev(entry->kobj); in intel_pmt_dev_destroy()
318 if (entry->size) in intel_pmt_dev_destroy()
319 sysfs_remove_bin_file(entry->kobj, &entry->pmt_bin_attr); in intel_pmt_dev_destroy()
322 sysfs_remove_group(entry->kobj, ns->attr_grp); in intel_pmt_dev_destroy()
325 xa_erase(ns->xa, entry->devid); in intel_pmt_dev_destroy()