]> mj.ucw.cz Git - pciutils.git/blobdiff - ls-kernel.c
AmigaOS: Removed extraneous type cast
[pciutils.git] / ls-kernel.c
index c47dc8301bef11a97f6f2f8864581e1671163423..c939c52867e61ac76c67fddd12dcc7b043bc328f 100644 (file)
@@ -3,7 +3,9 @@
  *
  *     Copyright (c) 1997--2013 Martin Mares <mj@ucw.cz>
  *
  *
  *     Copyright (c) 1997--2013 Martin Mares <mj@ucw.cz>
  *
- *     Can be freely distributed and used under the terms of the GNU GPL.
+ *     Can be freely distributed and used under the terms of the GNU GPL v2+.
+ *
+ *     SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -173,16 +175,14 @@ static int
 match_pcimap(struct device *d, struct pcimap_entry *e)
 {
   struct pci_dev *dev = d->dev;
 match_pcimap(struct device *d, struct pcimap_entry *e)
 {
   struct pci_dev *dev = d->dev;
-  unsigned int class = get_conf_long(d, PCI_REVISION_ID) >> 8;
-  word subv, subd;
+  unsigned int class = (((unsigned int)dev->device_class << 8) | dev->prog_if);
 
 #define MATCH(x, y) ((y) > 0xffff || (x) == (y))
 
 #define MATCH(x, y) ((y) > 0xffff || (x) == (y))
-  get_subid(d, &subv, &subd);
   return
     MATCH(dev->vendor_id, e->vendor) &&
     MATCH(dev->device_id, e->device) &&
   return
     MATCH(dev->vendor_id, e->vendor) &&
     MATCH(dev->device_id, e->device) &&
-    MATCH(subv, e->subvendor) &&
-    MATCH(subd, e->subdevice) &&
+    MATCH(dev->subsys_vendor_id, e->subvendor) &&
+    MATCH(dev->subsys_id, e->subdevice) &&
     (class & e->class_mask) == e->class;
 #undef MATCH
 }
     (class & e->class_mask) == e->class;
 #undef MATCH
 }
@@ -213,40 +213,6 @@ show_kernel_cleanup(void)
 
 #endif
 
 
 #endif
 
-#define DRIVER_BUF_SIZE 1024
-
-static char *
-find_driver(struct device *d, char *buf)
-{
-  struct pci_dev *dev = d->dev;
-  char name[1024], *drv, *base;
-  int n;
-
-  if (dev->access->method != PCI_ACCESS_SYS_BUS_PCI)
-    return NULL;
-
-  base = pci_get_param(dev->access, "sysfs.path");
-  if (!base || !base[0])
-    return NULL;
-
-  n = snprintf(name, sizeof(name), "%s/devices/%04x:%02x:%02x.%d/driver",
-              base, dev->domain, dev->bus, dev->dev, dev->func);
-  if (n < 0 || n >= (int)sizeof(name))
-    die("show_driver: sysfs device name too long, why?");
-
-  n = readlink(name, buf, DRIVER_BUF_SIZE);
-  if (n < 0)
-    return NULL;
-  if (n >= DRIVER_BUF_SIZE)
-    return "<name-too-long>";
-  buf[n] = 0;
-
-  if (drv = strrchr(buf, '/'))
-    return drv+1;
-  else
-    return buf;
-}
-
 static const char *
 next_module_filtered(struct device *d)
 {
 static const char *
 next_module_filtered(struct device *d)
 {
@@ -269,10 +235,10 @@ next_module_filtered(struct device *d)
 void
 show_kernel(struct device *d)
 {
 void
 show_kernel(struct device *d)
 {
-  char buf[DRIVER_BUF_SIZE];
   const char *driver, *module;
 
   const char *driver, *module;
 
-  if (driver = find_driver(d, buf))
+  pci_fill_info(d->dev, PCI_FILL_DRIVER);
+  if (driver = pci_get_string_property(d->dev, PCI_FILL_DRIVER))
     printf("\tKernel driver in use: %s\n", driver);
 
   if (!show_kernel_init())
     printf("\tKernel driver in use: %s\n", driver);
 
   if (!show_kernel_init())
@@ -288,10 +254,10 @@ show_kernel(struct device *d)
 void
 show_kernel_machine(struct device *d)
 {
 void
 show_kernel_machine(struct device *d)
 {
-  char buf[DRIVER_BUF_SIZE];
   const char *driver, *module;
 
   const char *driver, *module;
 
-  if (driver = find_driver(d, buf))
+  pci_fill_info(d->dev, PCI_FILL_DRIVER);
+  if (driver = pci_get_string_property(d->dev, PCI_FILL_DRIVER))
     printf("Driver:\t%s\n", driver);
 
   if (!show_kernel_init())
     printf("Driver:\t%s\n", driver);
 
   if (!show_kernel_init())
@@ -304,13 +270,23 @@ show_kernel_machine(struct device *d)
 #else
 
 void
 #else
 
 void
-show_kernel(struct device *d UNUSED)
+show_kernel(struct device *d)
 {
 {
+  const char *driver;
+
+  pci_fill_info(d->dev, PCI_FILL_DRIVER);
+  if (driver = pci_get_string_property(d->dev, PCI_FILL_DRIVER))
+    printf("\tDriver in use: %s\n", driver);
 }
 
 void
 }
 
 void
-show_kernel_machine(struct device *d UNUSED)
+show_kernel_machine(struct device *d)
 {
 {
+  const char *driver;
+
+  pci_fill_info(d->dev, PCI_FILL_DRIVER);
+  if (driver = pci_get_string_property(d->dev, PCI_FILL_DRIVER))
+    printf("Driver:\t%s\n", driver);
 }
 
 void
 }
 
 void