Module Name: src
Committed By: riastradh
Date: Mon Aug 27 07:55:59 UTC 2018
Modified Files:
src/sys/external/bsd/drm2/pci: drm_pci.c
Log Message:
Add drm_pci_set_unique.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/external/bsd/drm2/pci/drm_pci.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/pci/drm_pci.c
diff -u src/sys/external/bsd/drm2/pci/drm_pci.c:1.23 src/sys/external/bsd/drm2/pci/drm_pci.c:1.24
--- src/sys/external/bsd/drm2/pci/drm_pci.c:1.23 Mon Aug 27 07:54:54 2018
+++ src/sys/external/bsd/drm2/pci/drm_pci.c Mon Aug 27 07:55:59 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_pci.c,v 1.23 2018/08/27 07:54:54 riastradh Exp $ */
+/* $NetBSD: drm_pci.c,v 1.24 2018/08/27 07:55:59 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.23 2018/08/27 07:54:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.24 2018/08/27 07:55:59 riastradh Exp $");
#include <sys/types.h>
#include <sys/errno.h>
@@ -280,5 +280,36 @@ int
drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file)
{
- return -ENOSYS;
+ return -ENODEV;
+}
+
+int
+drm_pci_set_unique(struct drm_device *dev, struct drm_master *master,
+ struct drm_unique *unique)
+{
+ char kbuf[64], ubuf[64];
+ int ret;
+
+ /* Reject excessively long unique strings. */
+ if (unique->unique_len > sizeof(ubuf) - 1)
+ return -EINVAL;
+
+ /* Copy in the alleged unique string, NUL-terminated. */
+ ret = -copyin(unique->unique, ubuf, unique->unique_len);
+ if (ret)
+ return ret;
+ ubuf[unique->unique_len] = '\0';
+
+ /* Make sure it matches what we expect. */
+ snprintf(kbuf, sizeof kbuf, "PCI:%d:%ld:%ld", dev->pdev->bus->number,
+ PCI_SLOT(dev->pdev->devfn), PCI_FUNC(dev->pdev->devfn));
+ if (strncmp(kbuf, ubuf, sizeof(kbuf)) != 0)
+ return -EINVAL;
+
+ /* Remember it. */
+ master->unique = kstrdup(ubuf, GFP_KERNEL);
+ master->unique_len = strlen(master->unique);
+
+ /* Success! */
+ return 0;
}