diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d6d2d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/i2c-tools-3.1.0.tar.bz2 diff --git a/.i2c-tools.metadata b/.i2c-tools.metadata new file mode 100644 index 0000000..1365359 --- /dev/null +++ b/.i2c-tools.metadata @@ -0,0 +1 @@ +0756c9cffb7865d9815d44727de86973a28aba23 SOURCES/i2c-tools-3.1.0.tar.bz2 diff --git a/SOURCES/i2c-tools-3.1-man-decodeX.patch b/SOURCES/i2c-tools-3.1-man-decodeX.patch new file mode 100644 index 0000000..c3b35b0 --- /dev/null +++ b/SOURCES/i2c-tools-3.1-man-decodeX.patch @@ -0,0 +1,122 @@ +diff -Naur i2c-tools-3.1.0.orig/eeprom/decode-dimms.1 i2c-tools-3.1.0/eeprom/decode-dimms.1 +--- i2c-tools-3.1.0.orig/eeprom/decode-dimms.1 1970-01-01 01:00:00.000000000 +0100 ++++ i2c-tools-3.1.0/eeprom/decode-dimms.1 2013-10-03 18:01:35.396288464 +0200 +@@ -0,0 +1,77 @@ ++.\" ++.\" decode-dimms.1 - manpage for the i2c-tools/decode-dimms utility ++.\" Copyright (C) 2013 Jaromir Capik ++.\" ++.\" This program is free software; you can redistribute it and/or modify ++.\" it under the terms of the GNU General Public License as published by ++.\" the Free Software Foundation; either version 2 of the License, or ++.\" (at your option) any later version. ++.\" ++.\" This program is distributed in the hope that it will be useful, ++.\" but WITHOUT ANY WARRANTY; without even the implied warranty of ++.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++.\" GNU General Public License for more details. ++.\" ++.\" You should have received a copy of the GNU General Public License along ++.\" with this program; if not, write to the Free Software Foundation, Inc., ++.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++.\" ++.TH decode-dimms 1 "Oct 2013" "i2c-tools" "User Commands" ++.SH NAME ++decode-dimms \- Decode the information found in memory module SPD EEPROMs. ++.SH SYNOPSIS ++.B decode-dimms ++[-c] [-f [-b]] [-x|-X file [files..]] ++.br ++.B decode-dimms ++-h ++.SH DESCRIPTION ++ ++The purpose of the ++.B decode-dimms ++tool is to decode the information found in memory module SPD EEPROMs. ++The SPD data is read either from the running system or dump files. ++The tool requires the eeprom kernel module to be loaded. ++.SH PARAMETERS ++.TP ++.B \-f, --format ++Print nice html output ++.TP ++.B \-b, --bodyonly ++Don't print html header (useful for postprocessing the output) ++.TP ++.B \--side-by-side ++Display all DIMMs side-by-side if possible ++.TP ++.B \--merge-cells ++Merge neighbour cells with identical values (side-by-side output only) ++.TP ++.B \-c, --checksum ++Decode completely even if checksum fails ++.TP ++.B \-x ++Read data from hexdump files ++.TP ++.B \-X ++Same as -x except treat multibyte hex data as little endian ++.TP ++.B \-h, --help ++Display this usage summary ++.SH SEE ALSO ++.BR decode-vaio (1) ++.SH AUTHORS ++.UR phil@netroedge.com ++Philip Edelbrock ++.UE ++.br ++.UR zany@triq.net ++Christian Zuckschwerdt ++.UE ++.br ++.UR burkart@bollchen.de ++Burkart Lingner ++.UE ++.br ++.UR khali@linux-fr.org ++Jean Delvare ++.UE +diff -Naur i2c-tools-3.1.0.orig/eeprom/decode-vaio.1 i2c-tools-3.1.0/eeprom/decode-vaio.1 +--- i2c-tools-3.1.0.orig/eeprom/decode-vaio.1 1970-01-01 01:00:00.000000000 +0100 ++++ i2c-tools-3.1.0/eeprom/decode-vaio.1 2013-10-03 18:02:49.348720736 +0200 +@@ -0,0 +1,37 @@ ++.\" ++.\" decode-vaio.1 - manpage for the i2c-tools/decode-vaio utility ++.\" Copyright (C) 2013 Jaromir Capik ++.\" ++.\" This program is free software; you can redistribute it and/or modify ++.\" it under the terms of the GNU General Public License as published by ++.\" the Free Software Foundation; either version 2 of the License, or ++.\" (at your option) any later version. ++.\" ++.\" This program is distributed in the hope that it will be useful, ++.\" but WITHOUT ANY WARRANTY; without even the implied warranty of ++.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++.\" GNU General Public License for more details. ++.\" ++.\" You should have received a copy of the GNU General Public License along ++.\" with this program; if not, write to the Free Software Foundation, Inc., ++.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++.\" ++.TH decode-vaio 1 "Oct 2013" "i2c-tools" "User Commands" ++.SH NAME ++decode-vaio \- Decode the information found in the Sony Vaio laptop ++identification EEPROMs. ++.SH SYNOPSIS ++.B decode-vaio ++.SH DESCRIPTION ++ ++The purpose of the ++.B decode-vaio ++tool is to decode the information found in the Sony Vaio laptop ++identification EEPROMs. ++The tool requires the eeprom kernel module to be loaded. ++.SH SEE ALSO ++.BR decode-dimms (1) ++.SH AUTHOR ++.UR khali@linux-fr.org ++Jean Delvare ++.UE diff --git a/SOURCES/i2c-tools-3.1-man-eeproX.patch b/SOURCES/i2c-tools-3.1-man-eeproX.patch new file mode 100644 index 0000000..93730cd --- /dev/null +++ b/SOURCES/i2c-tools-3.1-man-eeproX.patch @@ -0,0 +1,261 @@ +diff -Naur i2c-tools-3.1.0.orig/eepromer/eeprog.8 i2c-tools-3.1.0/eepromer/eeprog.8 +--- i2c-tools-3.1.0.orig/eepromer/eeprog.8 1970-01-01 01:00:00.000000000 +0100 ++++ i2c-tools-3.1.0/eepromer/eeprog.8 2013-07-03 17:10:46.193787836 +0200 +@@ -0,0 +1,105 @@ ++.\" ++.\" eeprog.8 - manpage for the i2c-tools/eeprog utility ++.\" Copyright (C) 2013 Jaromir Capik ++.\" ++.\" This program is free software; you can redistribute it and/or modify ++.\" it under the terms of the GNU General Public License as published by ++.\" the Free Software Foundation; either version 2 of the License, or ++.\" (at your option) any later version. ++.\" ++.\" This program is distributed in the hope that it will be useful, ++.\" but WITHOUT ANY WARRANTY; without even the implied warranty of ++.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++.\" GNU General Public License for more details. ++.\" ++.\" You should have received a copy of the GNU General Public License along ++.\" with this program; if not, write to the Free Software Foundation, Inc., ++.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++.\" ++.TH eeprog "8" "Jul 2013" "i2c-tools" "System Administration" ++.SH NAME ++eeprog \- reads and writes 24Cxx EEPROMs connected to I2C serial bus. ++.SH SYNOPSIS ++.B eeprog ++[-fqxdh] [-16|-8] [-r addr[:count]|-w addr] ++.SH DESCRIPTION ++.B eeprog ++uses the SMBus protocol used by most of the recent chipsets. ++.SH NOTE ++Don't forget to load your i2c chipset and the i2c-dev drivers. ++.P ++The following environment variables could be set instead of the command line arguments: ++.P ++ EEPROG_DEV device ++.br ++ EEPROG_I2C_ADDR i2c-addr ++.SH PARAMETERS ++.I Address modes ++.TP ++.B \-8 ++Use 8bit address mode for 24c0x...24C16 [default] ++.TP ++.B \-16 ++Use 16bit address mode for 24c32...24C256 ++.TP ++.I Actions ++.TP ++.B \-r addr[:count] ++Read ++.B count ++(1 if omitted) bytes from ++.B addr ++and print them to the standard output ++.TP ++.B \-w addr ++Write input (stdin) at address ++.B addr ++of the EEPROM ++.TP ++.B \-h ++Print this help ++.TP ++.I Options ++.TP ++.B \-x ++Set hex output mode ++.TP ++.B \-d ++Dummy mode, display what *would* have been done ++.TP ++.B \-f ++Disable warnings and don't ask confirmation ++.TP ++.B \-q ++Quiet mode ++.TP ++.I Bus ++.TP ++.B device ++Device file representing the I2C bus (eg. /dev/i2c-0) ++.TP ++.B i2c-addr ++I2C bus address of the EEPROM (eg. 0x3A) ++.SH EXAMPLES ++Read 64 bytes from the EEPROM at address 0x54 on bus 0 starting at address 123 (decimal) ++.P ++.B eeprog ++/dev/i2c-0 0x54 -r 123:64 ++.P ++Print the hex codes of the first 32 bytes read from bus 1 at address 0x22 ++.P ++.B eeprog ++/dev/i2c-1 0x51 -x -r 0x22:0x20 ++.P ++Write the current timestamp at address 0x200 of the EEPROM on bus 0 at address 0x33 ++.P ++ date | ++.B eeprog ++/dev/i2c-0 0x33 -w 0x200 ++.SH SEE ALSO ++.BR eeprom (8) ++.BR eepromer (8) ++.SH AUTHOR ++.UR stefano@codesink.org ++Stefano Barbato ++.UE +diff -Naur i2c-tools-3.1.0.orig/eepromer/eepromer.8 i2c-tools-3.1.0/eepromer/eepromer.8 +--- i2c-tools-3.1.0.orig/eepromer/eepromer.8 1970-01-01 01:00:00.000000000 +0100 ++++ i2c-tools-3.1.0/eepromer/eepromer.8 2013-07-03 17:25:35.067487324 +0200 +@@ -0,0 +1,63 @@ ++.\" ++.\" eeprom.8 - manpage for the i2c-tools/eeprom utility ++.\" Copyright (C) 2013 Jaromir Capik ++.\" ++.\" This program is free software; you can redistribute it and/or modify ++.\" it under the terms of the GNU General Public License as published by ++.\" the Free Software Foundation; either version 2 of the License, or ++.\" (at your option) any later version. ++.\" ++.\" This program is distributed in the hope that it will be useful, ++.\" but WITHOUT ANY WARRANTY; without even the implied warranty of ++.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++.\" GNU General Public License for more details. ++.\" ++.\" You should have received a copy of the GNU General Public License along ++.\" with this program; if not, write to the Free Software Foundation, Inc., ++.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++.\" ++.TH eepromer "8" "Jul 2013" "i2c-tools" "System Administration" ++.SH NAME ++eepromer \- reads and writes 24Cxx EEPROMs connected to I2C serial bus. ++.SH SYNOPSIS ++.B eepromer ++[-r|-w|-e|-p] -f ++.SH DESCRIPTION ++The EEPROM must be a large EEPROM which uses a 2-byte address ++field (24C32 or larger). It will NOT WORK on small EEPROMs ++(24C01 - 24C16) such as those used on SDRAM DIMMs. ++.SH NOTE ++Don't forget to load your i2c chipset and the i2c-dev drivers. ++.P ++Tested only on 24C256. ++.P ++.SH PARAMETERS ++.TP ++.I Actions ++.TP ++.B \-r ++Read ++.TP ++.B \-w ++Write ++.TP ++.B \-e ++Erase ++.TP ++.B \-p ++Print header ++.TP ++.I Bus ++.TP ++.B \-f device ++Device file representing the I2C bus (eg. /dev/i2c-0) ++.TP ++.B i2c-addr ++I2C bus address of the EEPROM (eg. 0x3A) ++.SH SEE ALSO ++.BR eeprog (8) ++.BR eeprom (8) ++.SH AUTHOR ++.UR marvin@sitour.cz ++Daniel Smolik ++.UE +diff -Naur i2c-tools-3.1.0.orig/eepromer/eeprom.8 i2c-tools-3.1.0/eepromer/eeprom.8 +--- i2c-tools-3.1.0.orig/eepromer/eeprom.8 1970-01-01 01:00:00.000000000 +0100 ++++ i2c-tools-3.1.0/eepromer/eeprom.8 2013-07-03 17:14:22.852383941 +0200 +@@ -0,0 +1,64 @@ ++.\" ++.\" eeprom.8 - manpage for the i2c-tools/eeprom utility ++.\" Copyright (C) 2013 Jaromir Capik ++.\" ++.\" This program is free software; you can redistribute it and/or modify ++.\" it under the terms of the GNU General Public License as published by ++.\" the Free Software Foundation; either version 2 of the License, or ++.\" (at your option) any later version. ++.\" ++.\" This program is distributed in the hope that it will be useful, ++.\" but WITHOUT ANY WARRANTY; without even the implied warranty of ++.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++.\" GNU General Public License for more details. ++.\" ++.\" You should have received a copy of the GNU General Public License along ++.\" with this program; if not, write to the Free Software Foundation, Inc., ++.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++.\" ++.TH eeprom "8" "Jul 2013" "i2c-tools" "System Administration" ++.SH NAME ++eeprom \- reads and writes 24Cxx EEPROMs connected to I2C serial bus. ++.SH SYNOPSIS ++.B eeprom ++[-d dev] [-a adr] [-p pgs] [-w] [-y] [-f file] ++.SH DESCRIPTION ++.B eeprom ++can be used for reading from / writing to i2c-eeproms like the popular ++24C16, 24C08, 24C04, etc. ++In contrast to eeprommer which supports 24C256-type eeproms (24C16s) ++this tool works with 1-byte addresses! ++.SH NOTE ++Don't forget to load your i2c chipset and the i2c-dev drivers. ++.P ++Pages/addresses: ++ eeproms with more than 256 bytes appear as if they ++ were several eeproms with consecutive addresses on the bus ++ so we might as well address several separate eeproms with ++ increasing addresses ++.SH PARAMETERS ++.TP ++.B dev ++device, e.g. /dev/i2c-0 (def) ++.TP ++.B adr ++base address of eeprom, eg 0xA0 (def) ++.TP ++.B pgs ++number of pages to read, eg 8 (def) ++.TP ++.B \-w ++write to eeprom (default is reading!) ++.TP ++.B \-y ++suppress warning when writing (default is to warn!) ++.TP ++.B \-f file ++copy eeprom contents to/from file (default for read is test only; for write is all zeros) ++.SH SEE ALSO ++.BR eeprog (8) ++.BR eepromer (8) ++.SH AUTHOR ++.UR chris@hedonism.cx ++Christian Vogel ++.UE +diff -Naur i2c-tools-3.1.0.orig/tools/i2cset.c i2c-tools-3.1.0/tools/i2cset.c +--- i2c-tools-3.1.0.orig/tools/i2cset.c 2011-02-15 17:12:27.000000000 +0100 ++++ i2c-tools-3.1.0/tools/i2cset.c 2013-06-19 12:45:55.852490195 +0200 +@@ -35,7 +35,12 @@ + static void help(void) + { + fprintf(stderr, +- "Usage: i2cset [-f] [-y] [-m MASK] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n" ++ "Usage: i2cset [OPTIONS] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n" ++ " OPTIONS are\n" ++ " -f (force access when busy)\n" ++ " -y (disable interactive mode)\n" ++ " -m MASK (value write mask - bits set to 0 are preserved if possible)\n" ++ " -r (write verification by reading back)\n" + " I2CBUS is an integer or an I2C bus name\n" + " ADDRESS is an integer (0x03 - 0x77)\n" + " MODE is one of:\n" diff --git a/SOURCES/i2c-tools-3.1.0-load-i2cdev.patch b/SOURCES/i2c-tools-3.1.0-load-i2cdev.patch new file mode 100644 index 0000000..24901d2 --- /dev/null +++ b/SOURCES/i2c-tools-3.1.0-load-i2cdev.patch @@ -0,0 +1,277 @@ +diff -up i2c-tools-3.1.0/tools/i2cbusses.c.load-i2cdev i2c-tools-3.1.0/tools/i2cbusses.c +--- i2c-tools-3.1.0/tools/i2cbusses.c.load-i2cdev 2010-11-26 11:25:32.000000000 +0100 ++++ i2c-tools-3.1.0/tools/i2cbusses.c 2017-04-05 08:43:08.135938481 +0200 +@@ -37,9 +37,16 @@ + #include + #include + #include ++#ifdef USE_LIBKMOD ++ #include ++#endif + #include "i2cbusses.h" + #include + ++#define BUFLEN (NAME_MAX > 512 ? NAME_MAX : 512) ++#define I2C_DEV_MOD_NAME "i2c_dev" ++#define I2C_DEV_SUBPATH "/class/i2c-dev" ++ + enum adt { adt_dummy, adt_isa, adt_i2c, adt_smbus, adt_unknown }; + + struct adap_type { +@@ -60,6 +67,145 @@ static struct adap_type adap_types[5] = + .algo = "N/A", }, + }; + ++/* Get and cache sysfs mount point. */ ++static const char *get_sysfs_mount_point(void) { ++ static const char *mp = NULL; ++ ++ if (mp == NULL) { ++ char sysfs[NAME_MAX]; ++ char fstype[NAME_MAX]; ++ char line[BUFLEN]; ++ FILE *f; ++ ++ if ((f = fopen("/proc/mounts", "r")) == NULL) { ++ perror("failed to read /proc/mounts: "); ++ goto done; ++ } ++ while (fgets(line, BUFLEN, f)) { ++ sscanf(line, "%*[^ ] %[^ ] %[^ ] %*s\n", sysfs, fstype); ++ if (strcasecmp(fstype, "sysfs") == 0) { ++ mp = strdup(sysfs); ++ if (mp == NULL) ++ perror("strdup: "); ++ break; ++ } ++ } ++ fclose(f); ++ } ++done: ++ return mp; ++} ++ ++/* Get an absolute path of i2c device directory. Free the result when not ++ * needed. */ ++static char *get_i2c_dev_path(void) { ++ char *path = NULL; ++ int mplen, splen; ++ const char *mp = get_sysfs_mount_point(); ++ ++ if (mp != NULL) { ++ mplen = strlen(mp); ++ splen = strlen(I2C_DEV_SUBPATH); ++ path = malloc(mplen + splen + 1); ++ if (path == NULL) { ++ perror("malloc: "); ++ } else { ++ strncpy(path, mp, mplen); ++ strncpy(path + mplen, I2C_DEV_SUBPATH, splen); ++ path[mplen+splen] = '\0'; ++ } ++ } ++ return path; ++} ++ ++/** ++ * Try to load i2c_dev kernel mode. Do nothing if module is already loaded. ++ * Returns 1 on success, 0 otherwise. ++ */ ++static int try_load_i2c_dev_mod(void) { ++ int err = 0, loaded = 0; ++ char errbuf[BUFLEN] = { 0 }; ++#ifdef USE_LIBKMOD ++ int flags = 0; ++ struct kmod_ctx *ctx; ++ struct kmod_list *l, *list = NULL; ++ ++ ctx = kmod_new(NULL, NULL); ++ if (!ctx) { ++ snprintf(errbuf, BUFLEN, "kmod_new() failed!"); ++ goto done; ++ } ++ if (kmod_module_new_from_lookup(ctx, I2C_DEV_MOD_NAME, &list) < 0 || list == NULL) { ++ snprintf(errbuf, BUFLEN, I2C_DEV_MOD_NAME " module lookup failed"); ++ goto ctx_unref; ++ } ++ ++ flags |= KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY; ++ kmod_list_foreach(l, list) { ++ struct kmod_module *mod = kmod_module_get_module(l); ++ err = kmod_module_probe_insert_module(mod, flags, NULL, NULL, NULL, NULL); ++ if (err == -ENOENT) { ++ snprintf(errbuf, BUFLEN, ++ "unknown symbol in module \"%s\", or unknown parameter (see dmesg)", ++ kmod_module_get_name(mod)); ++ } else if (err < 0) { ++ snprintf(errbuf, BUFLEN, "(module %s): %s", ++ kmod_module_get_name(mod), strerror(-err)); ++ } else { ++ kmod_module_unref(mod); ++ ++loaded; ++ break; ++ } ++ kmod_module_unref(mod); ++ } ++ ++ kmod_module_unref_list(list); ++ctx_unref: ++ kmod_unref(ctx); ++#else /* Try to load the module with modprobe. */ ++ struct stat st; ++ char *dev_path = get_i2c_dev_path(); ++ ++ /* First check whether the module is already loaded or built-in. */ ++ if (dev_path == NULL) ++ goto done; ++ err = stat(dev_path, &st); ++ if (err < 0) { ++ if (errno != ENOENT) { ++ snprintf(errbuf, BUFLEN, "can not stat \"%s\": %s", dev_path, ++ strerror(errno)); ++ goto err; ++ } else { ++ err = 0; ++ } ++ } else { ++ ++loaded; ++ goto done; ++ } ++ ++ err = system("modprobe " I2C_DEV_MOD_NAME); ++ if (err < 0) { ++ snprintf(errbuf, BUFLEN, "failed to execute modprobe command"); ++ } else if (err > 0) { ++ snprintf(errbuf, BUFLEN, "modprobe command exited with code %d", ++ WEXITSTATUS(err)); ++ } else { ++ ++loaded; ++ goto done; ++ } ++ ++err: ++#endif ++ if (errbuf[0]) ++ fprintf(stderr, "Failed to load required " I2C_DEV_MOD_NAME ++ " kernel module: %s\n", errbuf); ++done: ++#ifndef USE_LIBKMOD ++ free(dev_path); ++#endif ++ return loaded; ++} ++ + static enum adt i2c_get_funcs(int i2cbus) + { + unsigned long funcs; +@@ -132,8 +278,7 @@ struct i2c_adap *gather_i2c_busses(void) + struct dirent *de, *dde; + DIR *dir, *ddir; + FILE *f; +- char fstype[NAME_MAX], sysfs[NAME_MAX], n[NAME_MAX]; +- int foundsysfs = 0; ++ char *sysfs = NULL, n[NAME_MAX]; + int count=0; + struct i2c_adap *adapters; + +@@ -185,29 +330,19 @@ struct i2c_adap *gather_i2c_busses(void) + goto done; + } + +- /* look in sysfs */ +- /* First figure out where sysfs was mounted */ +- if ((f = fopen("/proc/mounts", "r")) == NULL) { ++ sysfs = get_i2c_dev_path(); ++ if (sysfs == NULL) + goto done; +- } +- while (fgets(n, NAME_MAX, f)) { +- sscanf(n, "%*[^ ] %[^ ] %[^ ] %*s\n", sysfs, fstype); +- if (strcasecmp(fstype, "sysfs") == 0) { +- foundsysfs++; +- break; +- } +- } +- fclose(f); +- if (! foundsysfs) { +- goto done; +- } + + /* Bus numbers in i2c-adapter don't necessarily match those in + i2c-dev and what we really care about are the i2c-dev numbers. + Unfortunately the names are harder to get in i2c-dev */ +- strcat(sysfs, "/class/i2c-dev"); +- if(!(dir = opendir(sysfs))) +- goto done; ++ if(!(dir = opendir(sysfs))) { ++ if (!try_load_i2c_dev_mod()) ++ goto done; ++ if ((!(dir = opendir(sysfs)))) ++ goto done; ++ } + /* go through the busses */ + while ((de = readdir(dir)) != NULL) { + if (!strcmp(de->d_name, ".")) +@@ -272,14 +407,15 @@ found: + /* We need more space */ + adapters = more_adapters(adapters, count + 1); + if (!adapters) +- return NULL; ++ goto done; + } + + adapters[count].nr = i2cbus; + adapters[count].name = strdup(s); + if (adapters[count].name == NULL) { + free_adapters(adapters); +- return NULL; ++ adapters = NULL; ++ goto done; + } + adapters[count].funcs = adap_types[type].funcs; + adapters[count].algo = adap_types[type].algo; +@@ -289,6 +425,7 @@ found: + closedir(dir); + + done: ++ free(sysfs); + return adapters; + } + +@@ -380,8 +517,21 @@ int open_i2c_dev(int i2cbus, char *filen + file = open(filename, O_RDWR); + + if (file < 0 && (errno == ENOENT || errno == ENOTDIR)) { ++ if (!(try_load_i2c_dev_mod())) ++ fprintf(stderr, "Cannot load i2c-dev module.\n"); ++ else ++ file = open(filename, O_RDWR); ++ } ++ ++ if (file < 0 && (errno == ENOENT || errno == ENOTDIR)) { + sprintf(filename, "/dev/i2c-%d", i2cbus); + file = open(filename, O_RDWR); ++ if (file < 0 && (errno == ENOENT || errno == ENOTDIR)) { ++ if (!(try_load_i2c_dev_mod())) ++ fprintf(stderr, "Cannot load i2c-dev module.\n"); ++ else ++ file = open(filename, O_RDWR); ++ } + } + + if (file < 0 && !quiet) { +diff -up i2c-tools-3.1.0/tools/Module.mk.load-i2cdev i2c-tools-3.1.0/tools/Module.mk +--- i2c-tools-3.1.0/tools/Module.mk.load-i2cdev 2009-01-19 16:11:33.000000000 +0100 ++++ i2c-tools-3.1.0/tools/Module.mk 2017-04-05 08:41:10.554057368 +0200 +@@ -15,6 +15,11 @@ TOOLS_CFLAGS := -Wstrict-prototypes -Wsh + + TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget + ++ifeq ($(shell pkg-config --exists libkmod && echo 1), 1) ++ TOOLS_CFLAGS += $(shell pkg-config --cflags libkmod) -DUSE_LIBKMOD ++ LDFLAGS += $(shell pkg-config --libs libkmod) ++endif ++ + # + # Programs + # diff --git a/SPECS/i2c-tools.spec b/SPECS/i2c-tools.spec new file mode 100644 index 0000000..5f51883 --- /dev/null +++ b/SPECS/i2c-tools.spec @@ -0,0 +1,203 @@ +# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2007 Hans de Goede , the Fedora project. +# +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. + +%global _i2c_tools_libdir /usr/lib + +Name: i2c-tools +Version: 3.1.0 +Release: 13%{?dist} +Summary: A heterogeneous set of I2C tools for Linux +Group: Applications/System +License: GPLv2+ +URL: http://www.lm-sensors.org/wiki/I2CTools +Source0: http://dl.lm-sensors.org/i2c-tools/releases/%{name}-%{version}.tar.bz2 + +# Introducing man pages for binaries in the eepromer subpackage +# Introducing -r switch in the i2cset help +Patch0: i2c-tools-3.1-man-eeproX.patch +# Introducing man pages for decode-* binaries +Patch1: i2c-tools-3.1-man-decodeX.patch +# Load i2c-dev module when i2cdetect is executed (bug #1071397) +Patch2: i2c-tools-3.1.0-load-i2cdev.patch + +# for /etc/udev/makedev.d resp /etc/modprobe.d ownership +Requires: udev module-init-tools +BuildRequires: python-devel +ExcludeArch: s390 s390x + +%description +This package contains a heterogeneous set of I2C tools for Linux: a bus +probing tool, a chip dumper, register-level access helpers, EEPROM +decoding scripts, and more. + + +%package eepromer +Summary: Programs for reading / writing i2c / smbus eeproms +Group: Applications/System +# For the device nodes +Requires: %{name} = %{version}-%{release} + +%description eepromer +Programs for reading / writing i2c / smbus eeproms. Notice that writing the +eeproms in your system is very dangerous and is likely to render your system +unusable. Do not install, let alone use this, unless you really, _really_ know +what you are doing. + +%package python +Summary: Python bindings for Linux SMBus access through i2c-dev +Group: Applications/System + +%description python + +%prep +%setup -q + +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 -b .load-i2cdev + +%build +make CFLAGS="$RPM_OPT_FLAGS" +pushd eepromer +make CFLAGS="$RPM_OPT_FLAGS -I../include" +popd +pushd py-smbus +CFLAGS="$RPM_OPT_FLAGS -I../include" %{__python} setup.py build +popd + + +%install +make install DESTDIR=$RPM_BUILD_ROOT prefix=%{_prefix} +install -m 755 eepromer/{eepromer,eeprom,eeprog} \ + $RPM_BUILD_ROOT%{_sbindir} +install -m 644 eepromer/{eepromer,eeprom,eeprog}.8 \ + $RPM_BUILD_ROOT%{_mandir}/man8 +install -d 755 $RPM_BUILD_ROOT%{_mandir}/man1 +install -m 644 eeprom/{decode-dimms,decode-vaio}.1 \ + $RPM_BUILD_ROOT%{_mandir}/man1 +pushd py-smbus +%{__python} setup.py install --skip-build --root=$RPM_BUILD_ROOT +popd +# cleanup +rm -f $RPM_BUILD_ROOT%{_bindir}/decode-edid.pl +# Remove userland kernel headers, belong in glibc-kernheaders. +rm -rf $RPM_BUILD_ROOT%{_includedir}/linux +# Remove unpleasant DDC tools. KMS already exposes the EDID block in sysfs, +# and edid-decode is a more complete tool than decode-edid. +rm -f $RPM_BUILD_ROOT%{_bindir}/{ddcmon,decode-edid} +# for i2c-dev ondemand loading through kmod +mkdir -p $RPM_BUILD_ROOT%{_i2c_tools_libdir}/modprobe.d +echo "alias char-major-89-* i2c-dev" > \ + $RPM_BUILD_ROOT%{_i2c_tools_libdir}/modprobe.d/i2c-dev.conf +# for /dev/i2c-# creation (which are needed for kmod i2c-dev autoloading) +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/udev/makedev.d +for (( i = 0 ; i < 8 ; i++ )) do + echo "i2c-$i" >> $RPM_BUILD_ROOT%{_sysconfdir}/udev/makedev.d/99-i2c-dev.nodes +done + + +%files +%doc CHANGES COPYING README +%config(noreplace) %{_i2c_tools_libdir}/modprobe.d/i2c-dev.conf +%config(noreplace) %{_sysconfdir}/udev/makedev.d/99-i2c-dev.nodes +%{_bindir}/* +%{_sbindir}/* +%{_mandir}/man1/decode-*.1.gz +%exclude %{_sbindir}/eepro* +%{_mandir}/man8/*.8.gz +%exclude %{_mandir}/man8/eepro* + +%files eepromer +%doc eepromer/README* +%{_sbindir}/eepro* +%{_mandir}/man8/eepro*.8.gz + +%files python +%doc py-smbus/README +#/usr/lib64/python2.7/site-packages/smbus-1.1-py2.7.egg-info +#/usr/lib64/python2.7/site-packages/smbus.so +%{python_sitearch}/* + + + +%changelog +* Wed Apr 05 2017 Zdenek Dohnal - 3.1.0-13 +- added #ifndef for freeing dev_path in try_load_i2c_dev_mod function (rhbz#1071397) + +* Wed Mar 29 2017 Zdenek Dohnal - 3.1.0-12 +- fixing covscan errors for rhbz#1071397 + +* Wed Mar 29 2017 Zdenek Dohnal - 3.1.0-11 +- 1071397 - Load i2c-dev module when i2cdetect is executed +- 1195285 - Ship modprobe.d files in /usr/lib/modprobe.d + +* Fri Dec 27 2013 Daniel Mach - 3.1.0-10 +- Mass rebuild 2013-12-27 + +* Thu Oct 03 2013 Jaromir Capik - 3.1.0-9 +- Introducing man pages for decode-* binaries +- Cleaning the spec +- Resolves: rhbz#948819 + +* Sat Aug 03 2013 Fedora Release Engineering - 3.1.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Jul 17 2013 Petr Pisar - 3.1.0-7 +- Perl 5.18 rebuild + +* Wed Jul 03 2013 Jaromir Capik - 3.1.0-6 +- Installing the man pages and putting them in the files section + +* Wed Jul 03 2013 Jaromir Capik - 3.1.0-5 +- Introducing man pages for binaries in the eepromer subpackage +- Introducing -r switch in the i2cset help + +* Sat Jun 1 2013 Henrik Nordstrom - 3.1.0-4 +- Package python interface + +* Thu Feb 14 2013 Fedora Release Engineering - 3.1.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Thu Jul 19 2012 Fedora Release Engineering - 3.1.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Mon Feb 20 2012 Adam Jackson 3.1.0-1 +- i2c-tools 3.1.0 + +* Fri Jan 13 2012 Fedora Release Engineering - 3.0.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Jul 05 2011 Adam Jackson 3.0.3-1 +- i2c-tools 3.0.3 + +* Wed Feb 09 2011 Fedora Release Engineering - 3.0.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Fri Jul 24 2009 Fedora Release Engineering - 3.0.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Mon Apr 13 2009 Adam Jackson 3.0.2-3 +- mv /etc/modprobe.d/i2c-dev /etc/modprobe.d/i2c-dev.conf (#495455) + +* Tue Feb 24 2009 Fedora Release Engineering - 3.0.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Dec 11 2008 Adam Jackson 3.0.2-1 +- i2c-tools 3.0.2 + +* Wed Mar 5 2008 Hans de Goede 3.0.0-3 +- Change /dev/i2c-# creation from /lib/udev/devices to /etc/udev/makedev.d + usage +- Add an /etc/modprobe.d/i2c-dev file to work around bug 380971 + +* Tue Feb 19 2008 Fedora Release Engineering - 3.0.0-2 +- Autorebuild for GCC 4.3 + +* Tue Nov 13 2007 Hans de Goede 3.0.0-1 +- Initial Fedora package, based on Suse specfile + +* Mon Oct 15 2007 - jdelvare@suse.de +- Initial release.