/*
* The PCI Library -- User Access
*
- * Copyright (c) 1997--2013 Martin Mares <mj@ucw.cz>
+ * Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
if (d->methods->cleanup_dev)
d->methods->cleanup_dev(d);
pci_free_caps(d);
- pci_mfree(d->module_alias);
pci_mfree(d->phy_slot);
pci_mfree(d);
}
}
int
-pci_fill_info_v32(struct pci_dev *d, int flags)
+pci_fill_info_v31(struct pci_dev *d, int flags)
{
if (flags & PCI_FILL_RESCAN)
{
}
/* In version 3.1, pci_fill_info got new flags => versioned alias */
-/* In version 3.2, the same has happened */
-STATIC_ALIAS(int pci_fill_info(struct pci_dev *d, int flags), pci_fill_info_v32(d, flags));
-DEFINE_ALIAS(int pci_fill_info_v30(struct pci_dev *d, int flags), pci_fill_info_v32);
-DEFINE_ALIAS(int pci_fill_info_v31(struct pci_dev *d, int flags), pci_fill_info_v32);
+STATIC_ALIAS(int pci_fill_info(struct pci_dev *d, int flags), pci_fill_info_v31(d,flags));
+DEFINE_ALIAS(int pci_fill_info_v30(struct pci_dev *d, int flags), pci_fill_info_v31);
SYMBOL_VERSION(pci_fill_info_v30, pci_fill_info@LIBPCI_3.0);
-SYMBOL_VERSION(pci_fill_info_v31, pci_fill_info@LIBPCI_3.1);
-SYMBOL_VERSION(pci_fill_info_v32, pci_fill_info@@LIBPCI_3.2);
+SYMBOL_VERSION(pci_fill_info_v31, pci_fill_info@@LIBPCI_3.1);
void
pci_setup_cache(struct pci_dev *d, byte *cache, int len)
{
struct pci_cap *c;
- pci_fill_info_v32(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS));
+ pci_fill_info_v31(d, ((type == PCI_CAP_NORMAL) ? PCI_FILL_CAPS : PCI_FILL_EXT_CAPS));
for (c=d->first_cap; c; c=c->next)
if (c->type == type && c->id == id)
return c;
#!/bin/sh
# Configuration script for the PCI library
-# (c) 1998--2013 Martin Mares <mj@ucw.cz>
+# (c) 1998--2009 Martin Mares <mj@ucw.cz>
LC_ALL=C
export LC_ALL
esac
echo >>$c '#define PCI_HAVE_STDINT_H'
;;
- freebsd*)
+ freebsd)
echo_n " fbsd-device"
echo >>$c '#define PCI_HAVE_PM_FBSD_DEVICE'
echo >>$c '#define PCI_PATH_FBSD_DEVICE "/dev/pci"'
echo >>$m "WITH_LIBS+=$LIBRESOLV"
fi
-if [ "$sys" = linux ] ; then
- echo_n "Checking for libkmod... "
- LIBKMOD_DETECTED=
- if [ -z "$PKG_CONFIG" ] ; then
- PKG_CONFIG=pkg-config
- fi
- if [ "$LIBKMOD" != no ] ; then
- if ! which $PKG_CONFIG >/dev/null ; then
- echo_n "($PKG_CONFIG not found) "
- elif $PKG_CONFIG libkmod ; then
- LIBKMOD_DETECTED=1
- fi
- fi
- if [ "$LIBKMOD" = yes -o "$LIBKMOD" = no ] ; then
- echo "$LIBKMOD (set manually)"
- if [ "$LIBKMOD" = yes -a -z "$LIBKMOD_DETECTED" ] ; then
- echo "Requested use of libkmod, but it is not available. Giving up."
- exit 1
- fi
- else
- if [ -n "$LIBKMOD_DETECTED" ] ; then
- LIBKMOD=yes
- else
- LIBKMOD=no
- fi
- echo "$LIBKMOD (auto-detected)"
- fi
- if [ "$LIBKMOD" = yes ] ; then
- echo >>$c "#define PCI_USE_LIBKMOD"
- echo >>$m "LIBKMOD_CFLAGS=$($PKG_CONFIG --cflags libkmod)"
- echo >>$m "LIBKMOD_LIBS=$($PKG_CONFIG --libs libkmod)"
- fi
-fi
-
echo "Checking whether to build a shared library... $SHARED (set manually)"
if [ "$SHARED" = no ] ; then
echo >>$m 'PCILIB=$(LIBNAME).a'
return 0;
if (f->device >= 0 || f->vendor >= 0)
{
- pci_fill_info_v32(d, PCI_FILL_IDENT);
+ pci_fill_info_v31(d, PCI_FILL_IDENT);
if ((f->device >= 0 && f->device != d->device_id) ||
(f->vendor >= 0 && f->vendor != d->vendor_id))
return 0;
int pci_fill_info_v30(struct pci_dev *, int flags) PCI_ABI;
int pci_fill_info_v31(struct pci_dev *, int flags) PCI_ABI;
-int pci_fill_info_v32(struct pci_dev *, int flags) PCI_ABI;
/* params.c */
void pci_define_param(struct pci_access *acc, char *param, char *val, char *help);
dns_parse_packet(struct dns_state *s, byte *p, unsigned int plen)
{
byte *end = p + plen;
- unsigned int i, j, len;
- unsigned int UNUSED x;
+ unsigned int i, j, x, len;
#if 0
/* Dump the packet */
if (result)
return result;
len = strlen(a->id_file_name);
- if (len < 3 || memcmp(a->id_file_name + len - 3, ".gz", 3) != 0)
+ if (len >= 3 && memcmp(a->id_file_name + len - 3, ".gz", 3) != 0)
return result;
new_name = malloc(len - 2);
memcpy(new_name, a->id_file_name, len - 3);
/*
* The PCI Library
*
- * Copyright (c) 1997--2013 Martin Mares <mj@ucw.cz>
+ * Copyright (c) 1997--2009 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "header.h"
#include "types.h"
-#define PCI_LIB_VERSION 0x030200
+#define PCI_LIB_VERSION 0x030100
#ifndef PCI_ABI
#define PCI_ABI
pciaddr_t rom_size; /* Expansion ROM size */
struct pci_cap *first_cap; /* List of capabilities */
char *phy_slot; /* Physical slot */
- char *module_alias; /* Linux kernel module alias */
/* Fields used internally: */
struct pci_access *access;
#define PCI_FILL_CAPS 64
#define PCI_FILL_EXT_CAPS 128
#define PCI_FILL_PHYS_SLOT 256
-#define PCI_FILL_MODULE_ALIAS 512
#define PCI_FILL_RESCAN 0x10000
void pci_setup_cache(struct pci_dev *, u8 *cache, int len) PCI_ABI;
d->access->error("File name too long");
}
-#define OBJBUFSIZE 1024
-
static int
-sysfs_get_string(struct pci_dev *d, char *object, char *buf, int mandatory)
+sysfs_get_value(struct pci_dev *d, char *object)
{
struct pci_access *a = d->access;
int fd, n;
- char namebuf[OBJNAMELEN];
+ char namebuf[OBJNAMELEN], buf[256];
sysfs_obj_name(d, object, namebuf);
fd = open(namebuf, O_RDONLY|O_CLOEXEC);
if (fd < 0)
- {
- if (mandatory)
- a->error("Cannot open %s: %s", namebuf, strerror(errno));
- return 0;
- }
- n = read(fd, buf, OBJBUFSIZE);
+ a->error("Cannot open %s: %s", namebuf, strerror(errno));
+ n = read(fd, buf, sizeof(buf));
close(fd);
if (n < 0)
a->error("Error reading %s: %s", namebuf, strerror(errno));
- if (n >= OBJBUFSIZE)
+ if (n >= (int) sizeof(buf))
a->error("Value in %s too long", namebuf);
buf[n] = 0;
- return 1;
-}
-
-static int
-sysfs_get_value(struct pci_dev *d, char *object)
-{
- char buf[OBJBUFSIZE];
-
- sysfs_get_string(d, object, buf, 1);
return strtol(buf, NULL, 0);
}
{
for (d = a->devices; d; d = d->next)
if (dom == d->domain && bus == d->bus && dev == d->dev && !d->phy_slot)
- d->phy_slot = pci_strdup(a, entry->d_name);
+ {
+ d->phy_slot = pci_malloc(a, strlen(entry->d_name) + 1);
+ strcpy(d->phy_slot, entry->d_name);
+ }
}
fclose(file);
}
for (pd = d->access->devices; pd; pd = pd->next)
pd->known_fields |= PCI_FILL_PHYS_SLOT;
}
-
- if ((flags & PCI_FILL_MODULE_ALIAS) && !(d->known_fields & PCI_FILL_MODULE_ALIAS))
- {
- char buf[OBJBUFSIZE];
- if (sysfs_get_string(d, "modalias", buf, 0))
- d->module_alias = pci_strdup(d->access, buf);
- }
-
return pci_generic_fill_info(d, flags);
}
/*
* The PCI Utilities -- Show Kernel Drivers
*
- * Copyright (c) 1997--2013 Martin Mares <mj@ucw.cz>
+ * Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include <sys/utsname.h>
-#ifdef PCI_USE_LIBKMOD
-
-#include <libkmod.h>
-
-static struct kmod_ctx *kmod_ctx;
-
-static int
-show_kernel_init(void)
-{
- static int show_kernel_inited = -1;
- if (show_kernel_inited >= 0)
- return show_kernel_inited;
-
- struct utsname uts;
- if (uname(&uts) < 0)
- die("uname() failed: %m");
- char *name = alloca(64 + strlen(uts.release));
- sprintf(name, "/lib/modules/%s", uts.release);
-
- kmod_ctx = kmod_new(name, NULL);
- if (!kmod_ctx)
- {
- fprintf(stderr, "lspci: Unable to initialize libkmod context\n");
- goto failed;
- }
-
- int err;
- if ((err = kmod_load_resources(kmod_ctx)) < 0)
- {
- fprintf(stderr, "lspci: Unable to load libkmod resources: error %d\n", err);
- goto failed;
- }
-
- show_kernel_inited = 1;
- return 1;
-
-failed:
- show_kernel_inited = 0;
- return 0;
-}
-
-void
-show_kernel_cleanup(void)
-{
- if (kmod_ctx)
- kmod_unref(kmod_ctx);
-}
-
-static const char *next_module(struct device *d)
-{
- static struct kmod_list *klist, *kcurrent;
- static struct kmod_module *kmodule;
-
- if (kmodule)
- {
- kmod_module_unref(kmodule);
- kmodule = NULL;
- }
-
- if (!klist)
- {
- pci_fill_info(d->dev, PCI_FILL_MODULE_ALIAS);
- if (!d->dev->module_alias)
- return NULL;
- int err = kmod_module_new_from_lookup(kmod_ctx, d->dev->module_alias, &klist);
- if (err < 0)
- {
- fprintf(stderr, "lspci: libkmod lookup failed: error %d\n", err);
- return NULL;
- }
- kcurrent = klist;
- }
- else
- kcurrent = kmod_list_next(klist, kcurrent);
-
- if (kcurrent)
- {
- kmodule = kmod_module_get_module(kcurrent);
- return kmod_module_get_name(kmodule);
- }
-
- kmod_module_unref_list(klist);
- klist = NULL;
- return NULL;
-}
-
-#else
-
struct pcimap_entry {
struct pcimap_entry *next;
unsigned int vendor, device;
static struct pcimap_entry *pcimap_head;
-static int
-show_kernel_init(void)
+static void
+load_pcimap(void)
{
static int tried_pcimap;
struct utsname uts;
FILE *f;
if (tried_pcimap)
- return 1;
+ return;
tried_pcimap = 1;
if (name = opt_pcimap)
sprintf(name, "/lib/modules/%s/modules.pcimap", uts.release);
f = fopen(name, "r");
if (!f)
- return 1;
+ return;
}
while (fgets(line, sizeof(line), f))
strcpy(e->module, line);
}
fclose(f);
-
- return 1;
}
static int
#undef MATCH
}
-static const char *next_module(struct device *d)
-{
- static struct pcimap_entry *current;
-
- if (!current)
- current = pcimap_head;
- else
- current = current->next;
-
- while (current)
- {
- if (match_pcimap(d, current))
- return current->module;
- current = current->next;
- }
-
- return NULL;
-}
-
-void
-show_kernel_cleanup(void)
-{
-}
-
-#endif
-
#define DRIVER_BUF_SIZE 1024
static char *
return buf;
}
-static const char *
-next_module_filtered(struct device *d)
-{
- static char prev_module[256];
- const char *module;
-
- while (module = next_module(d))
- {
- if (strcmp(module, prev_module))
- {
- strncpy(prev_module, module, sizeof(prev_module));
- prev_module[sizeof(prev_module) - 1] = 0;
- return module;
- }
- }
- prev_module[0] = 0;
- return NULL;
-}
-
void
show_kernel(struct device *d)
{
char buf[DRIVER_BUF_SIZE];
- const char *driver, *module;
+ char *driver;
+ struct pcimap_entry *e, *last = NULL;
if (driver = find_driver(d, buf))
printf("\tKernel driver in use: %s\n", driver);
- if (!show_kernel_init())
- return;
-
- int cnt = 0;
- while (module = next_module_filtered(d))
- printf("%s %s", (cnt++ ? "," : "\tKernel modules:"), module);
- if (cnt)
+ load_pcimap();
+ for (e=pcimap_head; e; e=e->next)
+ if (match_pcimap(d, e) && (!last || strcmp(last->module, e->module)))
+ {
+ printf("%s %s", (last ? "," : "\tKernel modules:"), e->module);
+ last = e;
+ }
+ if (last)
putchar('\n');
}
show_kernel_machine(struct device *d)
{
char buf[DRIVER_BUF_SIZE];
- const char *driver, *module;
+ char *driver;
+ struct pcimap_entry *e, *last = NULL;
if (driver = find_driver(d, buf))
printf("Driver:\t%s\n", driver);
- if (!show_kernel_init())
- return;
-
- while (module = next_module_filtered(d))
- printf("Module:\t%s\n", module);
+ load_pcimap();
+ for (e=pcimap_head; e; e=e->next)
+ if (match_pcimap(d, e) && (!last || strcmp(last->module, e->module)))
+ {
+ printf("Module:\t%s\n", e->module);
+ last = e;
+ }
}
#else
{
}
-void
-show_kernel_cleanup(void)
-{
-}
-
#endif
else
show();
}
- show_kernel_cleanup();
pci_cleanup(pacc);
return (seen_errors ? 2 : 0);
void show_kernel_machine(struct device *d UNUSED);
void show_kernel(struct device *d UNUSED);
-void show_kernel_cleanup(void);
/* ls-tree.c */
-* Tue Oct 15 2013 Jae-young Hwang <j-zero.hwang@samsung.com> accepted/tizen/20130912.195043@df41534
-- pciutils version upgrade v3.1.10 -> v3.2.0
+* Thu Oct 24 2013 Jae-young Hwang <j-zero.hwang@samsung.com> accepted/tizen/20130912.195043@993d6a5
+- Downgrade from v3.2.0 to v3.1.10
* Mon Mar 18 2013 Anas Nashif <anas.nashif@intel.com> submit/trunk/20130305.105339@d088459
- Update package groups
Name: pciutils
-Version: 3.2.0
+Version: 3.1.10
Release: 0
License: GPL-2.0+
Summary: PCI utilities for Kernel version 2
if (parse_x32(value, &f, &ll) < 0 || f && *f != ':')
parse_err("Invalid value \"%s\"", value);
lim = max_values[op->width];
- if (ll > lim && ll < ~0U - lim)
+ if (ll > lim && ll < ~0UL - lim)
parse_err("Value \"%s\" is out of range", value);
op->values[j].value = ll;
if (f && *f == ':')
{
if (parse_x32(f+1, NULL, &ll) <= 0)
parse_err("Invalid mask \"%s\"", f+1);
- if (ll > lim && ll < ~0U - lim)
+ if (ll > lim && ll < ~0UL - lim)
parse_err("Mask \"%s\" is out of range", f+1);
op->values[j].mask = ll;
op->values[j].value &= ll;