Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/pci Add drm_pci_set_unique.



details:   https://anonhg.NetBSD.org/src/rev/dc46a89f21d7
branches:  trunk
changeset: 835212:dc46a89f21d7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 07:55:59 2018 +0000

description:
Add drm_pci_set_unique.

diffstat:

 sys/external/bsd/drm2/pci/drm_pci.c |  37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diffs (56 lines):

diff -r fa8e708d55a8 -r dc46a89f21d7 sys/external/bsd/drm2/pci/drm_pci.c
--- a/sys/external/bsd/drm2/pci/drm_pci.c       Mon Aug 27 07:55:49 2018 +0000
+++ b/sys/external/bsd/drm2/pci/drm_pci.c       Mon Aug 27 07:55:59 2018 +0000
@@ -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 @@
 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;
+}



Home | Main Index | Thread Index | Old Index