lkml.org 
[lkml]   [2005]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH] I2C: ds1337: i2c_transfer() checking
    Date
    From
    [PATCH] I2C: ds1337: i2c_transfer() checking

    i2c_transfer returns number of sucessfully transfered messages. Change
    error checking to accordingly. (ds1337_set_datetime never returned
    sucess)

    Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
    Signed-off-by: James Chapman <jchapman@katalix.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

    ---
    commit 00588243053bb40d0406c7843833f8fae81294ab
    tree abf967a76d51f002a878ce6e6544c0b1c6cde62e
    parent 0b46e334d77b2d3b8b3aa665c81c4afbe9f1f458
    author Ladislav Michl <ladis@linux-mips.org> Wed, 04 May 2005 08:13:54 +0200
    committer Greg Kroah-Hartman <gregkh@suse.de> Tue, 21 Jun 2005 21:51:51 -0700

    drivers/i2c/chips/ds1337.c | 21 +++++++++------------
    1 files changed, 9 insertions(+), 12 deletions(-)

    diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
    --- a/drivers/i2c/chips/ds1337.c
    +++ b/drivers/i2c/chips/ds1337.c
    @@ -122,7 +122,7 @@ static int ds1337_get_datetime(struct i2
    __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3],
    buf[4], buf[5], buf[6]);

    - if (result >= 0) {
    + if (result == 2) {
    dt->tm_sec = BCD2BIN(buf[0]);
    dt->tm_min = BCD2BIN(buf[1]);
    val = buf[2] & 0x3f;
    @@ -140,12 +140,12 @@ static int ds1337_get_datetime(struct i2
    __FUNCTION__, dt->tm_sec, dt->tm_min,
    dt->tm_hour, dt->tm_mday,
    dt->tm_mon, dt->tm_year, dt->tm_wday);
    - } else {
    - dev_err(&client->dev, "error reading data! %d\n", result);
    - result = -EIO;
    +
    + return 0;
    }

    - return result;
    + dev_err(&client->dev, "error reading data! %d\n", result);
    + return -EIO;
    }

    static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
    @@ -185,14 +185,11 @@ static int ds1337_set_datetime(struct i2
    msg[0].buf = &buf[0];

    result = i2c_transfer(client->adapter, msg, 1);
    - if (result < 0) {
    - dev_err(&client->dev, "error writing data! %d\n", result);
    - result = -EIO;
    - } else {
    - result = 0;
    - }
    + if (result == 1)
    + return 0;

    - return result;
    + dev_err(&client->dev, "error writing data! %d\n", result);
    + return -EIO;
    }

    static int ds1337_command(struct i2c_client *client, unsigned int cmd,
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-06-22 09:00    [W:2.248 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site