From 434192995fdaa98004a45b8bb45362e4190c7b4b Mon Sep 17 00:00:00 2001 From: Jae-young Hwang Date: Mon, 21 Oct 2013 21:12:37 -0700 Subject: [PATCH] Downgrade from v3.2.0 to v3.1.10 Revert "pciutils version upgrade v3.1.10 -> v3.2.0" This reverts commit 7afe8c3fa3e8eee6063a831b216c0f32f938a58e. That commit was pushed and merged without reviewing, so revert that for verification to upgrade. Change-Id: I5ef1114342fa6e866b32a9e24661610dee515d07 Signed-off-by: Jae-young Hwang --- lib/access.c | 14 +-- lib/caps.c | 2 +- lib/configure | 38 +------- lib/filter.c | 2 +- lib/internal.h | 1 - lib/names-net.c | 3 +- lib/names-parse.c | 2 +- lib/pci.h | 6 +- lib/sysfs.c | 38 ++------ ls-kernel.c | 183 +++++-------------------------------- lspci.c | 1 - lspci.h | 1 - packaging/pciutils.changes | 4 +- packaging/pciutils.spec | 2 +- setpci.c | 4 +- 15 files changed, 51 insertions(+), 250 deletions(-) diff --git a/lib/access.c b/lib/access.c index 5112504..691df39 100644 --- a/lib/access.c +++ b/lib/access.c @@ -1,7 +1,7 @@ /* * The PCI Library -- User Access * - * Copyright (c) 1997--2013 Martin Mares + * Copyright (c) 1997--2008 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -59,7 +59,6 @@ void pci_free_dev(struct pci_dev *d) 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); } @@ -153,7 +152,7 @@ pci_write_block(struct pci_dev *d, int pos, byte *buf, int len) } 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) { @@ -167,13 +166,10 @@ pci_fill_info_v32(struct pci_dev *d, int flags) } /* 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) diff --git a/lib/caps.c b/lib/caps.c index 2378591..ff4d9c4 100644 --- a/lib/caps.c +++ b/lib/caps.c @@ -106,7 +106,7 @@ pci_find_cap(struct pci_dev *d, unsigned int id, unsigned int type) { 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; diff --git a/lib/configure b/lib/configure index 27388bc..4ae20d4 100755 --- a/lib/configure +++ b/lib/configure @@ -1,6 +1,6 @@ #!/bin/sh # Configuration script for the PCI library -# (c) 1998--2013 Martin Mares +# (c) 1998--2009 Martin Mares LC_ALL=C export LC_ALL @@ -86,7 +86,7 @@ case $sys in 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"' @@ -179,40 +179,6 @@ if [ "$DNS" = yes ] ; then 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' diff --git a/lib/filter.c b/lib/filter.c index f321b0f..0b7ce6e 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -114,7 +114,7 @@ pci_filter_match(struct pci_filter *f, struct pci_dev *d) 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; diff --git a/lib/internal.h b/lib/internal.h index 9718be6..0d95109 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -56,7 +56,6 @@ int pci_link_dev(struct pci_access *, struct pci_dev *); 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); diff --git a/lib/names-net.c b/lib/names-net.c index 1601030..a1a6e27 100644 --- a/lib/names-net.c +++ b/lib/names-net.c @@ -75,8 +75,7 @@ static int 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 */ diff --git a/lib/names-parse.c b/lib/names-parse.c index 9d979ad..cff410a 100644 --- a/lib/names-parse.c +++ b/lib/names-parse.c @@ -30,7 +30,7 @@ static pci_file pci_open(struct pci_access *a) 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); diff --git a/lib/pci.h b/lib/pci.h index 38e2e99..7a5a6b8 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -1,7 +1,7 @@ /* * The PCI Library * - * Copyright (c) 1997--2013 Martin Mares + * Copyright (c) 1997--2009 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -16,7 +16,7 @@ #include "header.h" #include "types.h" -#define PCI_LIB_VERSION 0x030200 +#define PCI_LIB_VERSION 0x030100 #ifndef PCI_ABI #define PCI_ABI @@ -130,7 +130,6 @@ struct pci_dev { 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; @@ -166,7 +165,6 @@ int pci_fill_info(struct pci_dev *, int flags) PCI_ABI; /* Fill in device inform #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; diff --git a/lib/sysfs.c b/lib/sysfs.c index 3b33a11..b3e411f 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -85,39 +85,24 @@ sysfs_obj_name(struct pci_dev *d, char *object, char *buf) 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); } @@ -259,7 +244,10 @@ sysfs_fill_slots(struct pci_access *a) { 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); } @@ -276,14 +264,6 @@ sysfs_fill_info(struct pci_dev *d, int flags) 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); } diff --git a/ls-kernel.c b/ls-kernel.c index 78b70f1..41afefe 100644 --- a/ls-kernel.c +++ b/ls-kernel.c @@ -1,7 +1,7 @@ /* * The PCI Utilities -- Show Kernel Drivers * - * Copyright (c) 1997--2013 Martin Mares + * Copyright (c) 1997--2008 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -16,94 +16,6 @@ #include -#ifdef PCI_USE_LIBKMOD - -#include - -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; @@ -114,8 +26,8 @@ struct pcimap_entry { static struct pcimap_entry *pcimap_head; -static int -show_kernel_init(void) +static void +load_pcimap(void) { static int tried_pcimap; struct utsname uts; @@ -123,7 +35,7 @@ show_kernel_init(void) FILE *f; if (tried_pcimap) - return 1; + return; tried_pcimap = 1; if (name = opt_pcimap) @@ -140,7 +52,7 @@ show_kernel_init(void) sprintf(name, "/lib/modules/%s/modules.pcimap", uts.release); f = fopen(name, "r"); if (!f) - return 1; + return; } while (fgets(line, sizeof(line), f)) @@ -172,8 +84,6 @@ show_kernel_init(void) strcpy(e->module, line); } fclose(f); - - return 1; } static int @@ -194,32 +104,6 @@ match_pcimap(struct device *d, struct pcimap_entry *e) #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 * @@ -254,41 +138,24 @@ find_driver(struct device *d, char *buf) 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'); } @@ -296,16 +163,19 @@ void 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 @@ -320,10 +190,5 @@ show_kernel_machine(struct device *d UNUSED) { } -void -show_kernel_cleanup(void) -{ -} - #endif diff --git a/lspci.c b/lspci.c index dbba678..2187894 100644 --- a/lspci.c +++ b/lspci.c @@ -1014,7 +1014,6 @@ main(int argc, char **argv) else show(); } - show_kernel_cleanup(); pci_cleanup(pacc); return (seen_errors ? 2 : 0); diff --git a/lspci.h b/lspci.h index 86429b2..4edaf6f 100644 --- a/lspci.h +++ b/lspci.h @@ -74,7 +74,6 @@ void show_ext_caps(struct device *d); void show_kernel_machine(struct device *d UNUSED); void show_kernel(struct device *d UNUSED); -void show_kernel_cleanup(void); /* ls-tree.c */ diff --git a/packaging/pciutils.changes b/packaging/pciutils.changes index 8b7706e..c0812c0 100644 --- a/packaging/pciutils.changes +++ b/packaging/pciutils.changes @@ -1,5 +1,5 @@ -* Tue Oct 15 2013 Jae-young Hwang accepted/tizen/20130912.195043@df41534 -- pciutils version upgrade v3.1.10 -> v3.2.0 +* Thu Oct 24 2013 Jae-young Hwang accepted/tizen/20130912.195043@993d6a5 +- Downgrade from v3.2.0 to v3.1.10 * Mon Mar 18 2013 Anas Nashif submit/trunk/20130305.105339@d088459 - Update package groups diff --git a/packaging/pciutils.spec b/packaging/pciutils.spec index 4e087d2..3c10e04 100644 --- a/packaging/pciutils.spec +++ b/packaging/pciutils.spec @@ -1,5 +1,5 @@ Name: pciutils -Version: 3.2.0 +Version: 3.1.10 Release: 0 License: GPL-2.0+ Summary: PCI utilities for Kernel version 2 diff --git a/setpci.c b/setpci.c index acf7689..731c612 100644 --- a/setpci.c +++ b/setpci.c @@ -637,14 +637,14 @@ static void parse_op(char *c, struct pci_dev **selected_devices) 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; -- 2.34.1