Changeset 5885 for i2c-tools/trunk

Show
Ignore:
Timestamp:
11/26/10 11:25:32 (18 months ago)
Author:
khali
Message:

Use a 20-bit limit for the i2c bus number.
Use snprintf for the i2c dev node name.
Update copyright years.

Location:
i2c-tools/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • i2c-tools/trunk/CHANGES

    r5884 r5885  
    1717  eepromer: Fix array initialization overrun 
    1818  i2cdetect: Drop legacy reference to ISA bus 
    19              Drop arbitrary limit on I2C bus number 
    20   i2cdump: Drop arbitrary limit on I2C bus number 
    21   i2cget: Drop arbitrary limit on I2C bus number 
     19             Increase limit on I2C bus number 
     20  i2cdump: Increase limit on I2C bus number 
     21  i2cget: Increase limit on I2C bus number 
    2222  i2cset: Add support for short writes with PEC 
    23           Drop arbitrary limit on I2C bus number 
     23          Increase limit on I2C bus number 
    2424  i2c-stub-from-dump: Use udev settle to speed up initialization 
    2525                      Unload i2c-stub automatically if needed 
  • i2c-tools/trunk/tools/i2cbusses.c

    r5884 r5885  
    55    Copyright (c) 1999-2003  Frodo Looijaard <frodol@dds.nl> and 
    66                             Mark D. Studebaker <mdsxyz123@yahoo.com> 
    7     Copyright (C) 2008       Jean Delvare <khali@linux-fr.org> 
     7    Copyright (C) 2008-2010  Jean Delvare <khali@linux-fr.org> 
    88 
    99    This program is free software; you can redistribute it and/or modify 
     
    2323*/ 
    2424 
    25 /* For strdup */ 
     25/* For strdup and snprintf */ 
    2626#define _BSD_SOURCE 1 
    2727 
     
    6868        enum adt ret; 
    6969 
    70         file = open_i2c_dev(i2cbus, filename, 1); 
     70        file = open_i2c_dev(i2cbus, filename, sizeof(filename), 1); 
    7171        if (file < 0) 
    7272                return adt_unknown; 
     
    341341                return lookup_i2c_bus_by_name(i2cbus_arg); 
    342342        } 
    343         if (i2cbus > INT_MAX) { 
     343        if (i2cbus > 0xFFFFF) { 
    344344                fprintf(stderr, "Error: I2C bus out of range!\n"); 
    345345                return -2; 
     
    372372} 
    373373 
    374 int open_i2c_dev(const int i2cbus, char *filename, const int quiet) 
     374int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet) 
    375375{ 
    376376        int file; 
    377377 
    378         sprintf(filename, "/dev/i2c/%d", i2cbus); 
     378        snprintf(filename, size, "/dev/i2c/%d", i2cbus); 
     379        filename[size - 1] = '\0'; 
    379380        file = open(filename, O_RDWR); 
    380381 
  • i2c-tools/trunk/tools/i2cbusses.h

    r5241 r5885  
    22    i2cbusses.h - Part of the i2c-tools package 
    33 
    4     Copyright (C) 2004-2007  Jean Delvare <khali@linux-fr.org> 
     4    Copyright (C) 2004-2010  Jean Delvare <khali@linux-fr.org> 
    55 
    66    This program is free software; you can redistribute it and/or modify 
     
    2323#define _I2CBUSSES_H 
    2424 
     25#include <unistd.h> 
     26 
    2527struct i2c_adap { 
    2628        int nr; 
     
    3537int lookup_i2c_bus(const char *i2cbus_arg); 
    3638int parse_i2c_address(const char *address_arg); 
    37 int open_i2c_dev(const int i2cbus, char *filename, const int quiet); 
     39int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet); 
    3840int set_slave_addr(int file, int address, int force); 
    3941 
  • i2c-tools/trunk/tools/i2cdetect.c

    r5862 r5885  
    11/* 
    22    i2cdetect.c - a user-space program to scan for I2C devices 
    3     Copyright (C) 1999-2004  Frodo Looijaard <frodol@dds.nl>, 
    4                              Mark D. Studebaker <mdsxyz123@yahoo.com> and 
    5                              Jean Delvare <khali@linux-fr.org> 
     3    Copyright (C) 1999-2004  Frodo Looijaard <frodol@dds.nl>, and 
     4                             Mark D. Studebaker <mdsxyz123@yahoo.com> 
     5    Copyright (C) 2004-2010  Jean Delvare <khali@linux-fr.org> 
    66 
    77    This program is free software; you can redistribute it and/or modify 
     
    296296        } 
    297297 
    298         file = open_i2c_dev(i2cbus, filename, 0); 
     298        file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0); 
    299299        if (file < 0) { 
    300300                exit(1); 
  • i2c-tools/trunk/tools/i2cdump.c

    r5242 r5885  
    33    Copyright (C) 2002-2003  Frodo Looijaard <frodol@dds.nl>, and 
    44                             Mark D. Studebaker <mdsxyz123@yahoo.com> 
    5     Copyright (C) 2004-2008  Jean Delvare <khali@linux-fr.org> 
     5    Copyright (C) 2004-2010  Jean Delvare <khali@linux-fr.org> 
    66 
    77    This program is free software; you can redistribute it and/or modify 
     
    260260        } 
    261261 
    262         file = open_i2c_dev(i2cbus, filename, 0); 
     262        file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0); 
    263263        if (file < 0 
    264264         || check_funcs(file, size, pec) 
  • i2c-tools/trunk/tools/i2cget.c

    r5242 r5885  
    11/* 
    22    i2cget.c - A user-space program to read an I2C register. 
    3     Copyright (C) 2005-2008  Jean Delvare <khali@linux-fr.org> 
     3    Copyright (C) 2005-2010  Jean Delvare <khali@linux-fr.org> 
    44 
    55    Based on i2cset.c: 
     
    213213        } 
    214214 
    215         file = open_i2c_dev(i2cbus, filename, 0); 
     215        file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0); 
    216216        if (file < 0 
    217217         || check_funcs(file, size, daddress, pec) 
  • i2c-tools/trunk/tools/i2cset.c

    r5771 r5885  
    33    Copyright (C) 2001-2003  Frodo Looijaard <frodol@dds.nl>, and 
    44                             Mark D. Studebaker <mdsxyz123@yahoo.com> 
    5     Copyright (C) 2004-2009  Jean Delvare <khali@linux-fr.org> 
     5    Copyright (C) 2004-2010  Jean Delvare <khali@linux-fr.org> 
    66 
    77    This program is free software; you can redistribute it and/or modify 
     
    237237        } 
    238238 
    239         file = open_i2c_dev(i2cbus, filename, 0); 
     239        file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0); 
    240240        if (file < 0 
    241241         || check_funcs(file, size, pec)