diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2015-08-20 14:54:11 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2015-08-28 12:37:32 +1000 |
commit | 6b5ad9285fef62f1e0c379c3777288d7bc8b14da (patch) | |
tree | 393544a290d9c02bc385ad3c5cd0c1e3d0f193c0 /lib/main.c | |
parent | a17e10dfa3bde89e7a17b1d6f697cfcf7d3ce6ff (diff) | |
download | nouveau-6b5ad9285fef62f1e0c379c3777288d7bc8b14da.tar.gz |
core: type-safe printk macros
These require an explicit pointers to nvkm_object/nvkm_subdev/nvkm_device,
depending on which macros are used. This is unlike the previous macros
which take a void *, and work for anything derived from nvkm_object (by
way of some awful heuristics).
The output will be a bit confused until everything has been transitioned,
as the logging format used is a more standard style that previously.
In addition, usage of pr_cont(), which doesn't work correctly with the
dev_*() printk functions (and was potentially racy to begin with), will
be replaced.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'lib/main.c')
-rw-r--r-- | lib/main.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/main.c b/lib/main.c index 6201c3ca3..d1a57a85e 100644 --- a/lib/main.c +++ b/lib/main.c @@ -139,7 +139,6 @@ os_init_device(struct pci_device *pdev, u64 handle, const char *cfg, const char { struct os_device *odev; struct pci_dev *ldev; - char *name, _name[64]; int ret; ret = pci_device_probe(pdev); @@ -148,31 +147,28 @@ os_init_device(struct pci_device *pdev, u64 handle, const char *cfg, const char return ret; } - snprintf(_name, sizeof(_name), "%04x:%02x:%02x.%1x", - pdev->domain, pdev->bus, pdev->dev, pdev->func); - list_for_each_entry(odev, &os_device_list, head) { if (odev->base.handle == handle) return -EEXIST; } - ldev = calloc(1, sizeof(*ldev)); + ldev = malloc(sizeof(*ldev)); + snprintf(ldev->dev.name, sizeof(ldev->dev.name), "%04x:%02x:%02x.%1x", + pdev->domain, pdev->bus, pdev->dev, pdev->func); ldev->pdev = pdev; ldev->device = pdev->dev; ldev->subsystem_vendor = pdev->subvendor_id; ldev->subsystem_device = pdev->subdevice_id; - name = strdup(_name); - ret = nvkm_device_create(ldev, NVKM_BUS_PCI, handle, name, + ret = nvkm_device_create(ldev, NVKM_BUS_PCI, handle, ldev->dev.name, cfg, dbg, &odev); if (ret) { fprintf(stderr, "failed to create device, %d\n", ret); - free(name); + free(ldev); return ret; } list_add_tail(&odev->head, &os_device_list); - odev->name = name; return 0; } @@ -221,10 +217,9 @@ os_fini(void) list_for_each_entry_safe(odev, temp, &os_device_list, head) { struct pci_dev *ldev = odev->base.pdev; - char *name = odev->name; list_del(&odev->head); nvkm_object_ref(NULL, (struct nvkm_object **)&odev); - free(name); free(ldev); + free(ldev); } nvkm_object_debug(); |