summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-08-20 14:54:11 +1000
committerBen Skeggs <bskeggs@redhat.com>2015-08-28 12:37:32 +1000
commit6b5ad9285fef62f1e0c379c3777288d7bc8b14da (patch)
tree393544a290d9c02bc385ad3c5cd0c1e3d0f193c0 /lib
parenta17e10dfa3bde89e7a17b1d6f697cfcf7d3ce6ff (diff)
downloadnouveau-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')
-rw-r--r--lib/include/nvif/os.h10
-rw-r--r--lib/main.c17
-rw-r--r--lib/null.c3
-rw-r--r--lib/priv.h1
4 files changed, 15 insertions, 16 deletions
diff --git a/lib/include/nvif/os.h b/lib/include/nvif/os.h
index 3ed79cc12..84817babc 100644
--- a/lib/include/nvif/os.h
+++ b/lib/include/nvif/os.h
@@ -634,12 +634,14 @@ struct device_driver {
struct device {
struct device_driver *driver;
+ char name[64];
};
-#define dev_crit(d,f,a...) printf("nouveau: "f, ##a)
-#define dev_err(d,f,a...) dev_crit((d), f, ##a)
-#define dev_warn(d,f,a...) dev_crit((d), f, ##a)
-#define dev_info(d,f,a...) dev_crit((d), f, ##a)
+#define dev_crit(d,f,a...) printf("nouveau %s: "f, (d)->name, ##a)
+#define dev_err(d,f,a...) dev_crit((d), f, ##a)
+#define dev_warn(d,f,a...) dev_crit((d), f, ##a)
+#define dev_notice(d,f,a...) dev_crit((d), f, ##a)
+#define dev_info(d,f,a...) dev_crit((d), f, ##a)
/******************************************************************************
* PM runtime
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();
diff --git a/lib/null.c b/lib/null.c
index 8f35b944b..910f95d2c 100644
--- a/lib/null.c
+++ b/lib/null.c
@@ -38,6 +38,9 @@ static int null_client_nr = 0;
static struct nvkm_device *null_device;
static struct pci_dev
null_pci_dev = {
+ .dev = {
+ .name = "0000:00:00.0",
+ },
.pdev = &(struct pci_device) {
},
};
diff --git a/lib/priv.h b/lib/priv.h
index 00e304680..cae0acd75 100644
--- a/lib/priv.h
+++ b/lib/priv.h
@@ -9,7 +9,6 @@
struct os_device {
struct nvkm_device base;
struct list_head head;
- char *name;
char *cfg;
char *dbg;
};