Messages in this thread | | | From | Daniel Gutson <> | Date | Tue, 4 Aug 2020 10:50:13 -0300 | Subject | Re: [PATCH] Platform lockdown information in SYSFS |
| |
On Tue, Aug 4, 2020 at 3:41 AM Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote: > > On Mon, Aug 03, 2020 at 07:04:56PM -0300, Daniel Gutson wrote: > > > > > Think of this as an input device. You don't put the random input > > > > > attributes all in one place, you create a new device that represents the > > > > > input interface and register that. > > > > I'm having trouble with this. What's the dev_t for the child devices? > > I'm doing > > child_device = device_create(&my_class, &pdev->dev, MKDEV(0, 0), > > NULL, "child"); > > pdev is the pci_device (intel-spi-pci) > > dmesg shows > > > > sysfs: cannot create duplicate filename '/class/my-class' > > (call trace) > > kobject_add_internal failed for my-class with -EEXIST, don't try > > to register things with the same name in the same directory. > > Without seeing all of your code, I can't tell you what you are doing > wrong, but the kernel should be giving you a huge hint here... > > Don't create duplicate names in the same subdirectory.
I'm not doing that. One of my questions is if MKDEV(0, 0) is valid for create_device, which I inferred so from the documentation. Here is the listing
static ssize_t howareyou_show(struct class *class, struct class_attribute *attr, char *buf) { return sprintf(buf, "%s\n", "How are you?"); } static CLASS_ATTR_RO(howareyou);
static struct class my_class = { .name = "my-class", .owner = THIS_MODULE, };
struct device* child_device;
static int mypci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { int ret;
ret = pcim_enable_device(pdev); if (ret) return ret;
ret = class_register(&my_class); if (ret < 0) return ret;
pr_info("DFG: Recognized. DID: %lx\n", (unsigned long int)id->driver_data); pr_info("DFG: device DID: %lx\n", (unsigned long int)pdev->device);
ret = class_create_file(&my_class, &class_attr_howareyou); if (ret != 0) { pr_err("DFG class create file error: %d\n", ret); class_unregister(&my_class); return ret; }
child_device = device_create(&my_class, &pdev->dev, MKDEV(0, 0), NULL, "child"); if (child_device == NULL) { pr_err("DFG error child device NULL"); }
return ret; }
static void mypci_remove(struct pci_dev *pdev) { /* I tried enabling and disabling this code if (child_device != NULL) { put_device(child_device); device_unregister(child_device); } */
class_remove_file(&my_class, &class_attr_howareyou); class_unregister(&my_class); }
static const struct pci_device_id my_dids[] = { { PCI_VDEVICE(INTEL, 0xa30e), (unsigned long)0xa30e }, { PCI_VDEVICE(INTEL, 0xa324), (unsigned long)0xa324 }, { }, }; MODULE_DEVICE_TABLE(pci, my_dids);
static struct pci_driver my_pci_driver = { .name = "dfg-pci", .id_table = my_dids, .probe = mypci_probe, .remove = mypci_remove, };
module_pci_driver(my_pci_driver);
MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Daniel Gutson <daniel.gutson@eclypsium.com>");
> > thanks, > > greg k-h
-- Daniel Gutson Argentina Site Director Enginieering Director Eclypsium
Below The Surface: Get the latest threat research and insights on firmware and supply chain threats from the research team at Eclypsium. https://eclypsium.com/research/#threatreport
| |