From eac46a64c0c78d87c51330809b196b3e92c92c9e Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Tue, 3 May 2016 15:05:28 -0700 Subject: gpu: nvgpu: Add PCIe id to device node name Use device name to distinguish between different instances of PCIe devices. JIRA DNVGPU-7 Change-Id: Ice0a9dae41396c8faada1815afd1237907896036 Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1140685 Reviewed-by: Sami Kiminki GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/pci.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/pci.c') diff --git a/drivers/gpu/nvgpu/pci.c b/drivers/gpu/nvgpu/pci.c index bc8cb510..38a4ad10 100644 --- a/drivers/gpu/nvgpu/pci.c +++ b/drivers/gpu/nvgpu/pci.c @@ -21,7 +21,7 @@ #include "gk20a/gk20a.h" #include "gk20a/platform_gk20a.h" -#define PCI_INTERFACE_NAME "nvgpu-pci%s" +#define PCI_INTERFACE_NAME "nvgpu-pci-%s%%s" static int nvgpu_pci_tegra_probe(struct device *dev) { @@ -138,6 +138,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, struct gk20a_platform *platform = &nvgpu_pci_device; struct gk20a *g; int err; + char *nodefmt; pci_set_drvdata(pdev, platform); @@ -174,7 +175,18 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, } disable_irq(g->irq_stall); - err = gk20a_user_init(&pdev->dev, PCI_INTERFACE_NAME); + if (strchr(dev_name(&pdev->dev), '%')) { + gk20a_err(&pdev->dev, "illegal character in device name"); + return -EINVAL; + } + + nodefmt = kasprintf(GFP_KERNEL, PCI_INTERFACE_NAME, dev_name(&pdev->dev)); + if (!nodefmt) + return -ENOMEM; + + err = gk20a_user_init(&pdev->dev, nodefmt); + kfree(nodefmt); + nodefmt = NULL; if (err) return err; -- cgit v1.2.2