From: Andrew Morton Cc: Raphael Assenat Cc: Alessandro Zummo Signed-off-by: Andrew Morton --- drivers/rtc/rtc-max6902.c | 37 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff -puN drivers/rtc/rtc-max6902.c~add-max6902-rtc-support-tidy drivers/rtc/rtc-max6902.c --- devel/drivers/rtc/rtc-max6902.c~add-max6902-rtc-support-tidy 2006-05-30 14:58:30.000000000 -0700 +++ devel-akpm/drivers/rtc/rtc-max6902.c 2006-05-30 14:58:30.000000000 -0700 @@ -29,8 +29,7 @@ #include #include #include - -#include +#include #define MAX6902_REG_SECONDS 0x01 #define MAX6902_REG_MINUTES 0x03 @@ -42,7 +41,6 @@ #define MAX6902_REG_CONTROL 0x0F #define MAX6902_REG_CENTURY 0x13 - #undef MAX6902_DEBUG struct max6902 { @@ -53,9 +51,9 @@ struct max6902 { }; static void max6902_set_reg(struct device *dev, unsigned char address, - unsigned char data) + unsigned char data) { - struct spi_device *spi = to_spi_device(dev); + struct spi_device *spi = to_spi_device(dev); unsigned char buf[2]; /* MSB must be '0' to write */ @@ -65,15 +63,17 @@ static void max6902_set_reg(struct devic spi_write(spi, buf, 2); } -static int max6902_get_reg(struct device *dev, unsigned char address, unsigned char *data) +static int max6902_get_reg(struct device *dev, unsigned char address, + unsigned char *data) { - struct spi_device *spi = to_spi_device(dev); + struct spi_device *spi = to_spi_device(dev); struct max6902 *chip = dev_get_drvdata(dev); struct spi_message message; struct spi_transfer xfer; int status; - if (!data) return -EINVAL; + if (!data) + return -EINVAL; /* Build our spi message */ spi_message_init(&message); @@ -90,9 +90,8 @@ static int max6902_get_reg(struct device /* do the i/o */ status = spi_sync(spi, &message); - if (status == 0) { + if (status == 0) status = message.status; - } else return status; @@ -106,8 +105,7 @@ static int max6902_get_datetime(struct d unsigned char tmp; int century; int err; - - struct spi_device *spi = to_spi_device(dev); + struct spi_device *spi = to_spi_device(dev); struct max6902 *chip = dev_get_drvdata(dev); struct spi_message message; struct spi_transfer xfer; @@ -120,17 +118,16 @@ static int max6902_get_datetime(struct d /* build the message */ spi_message_init(&message); memset(&xfer, 0, sizeof(xfer)); - xfer.len = 1 + 7; /* Burst read command + 7 registers */ + xfer.len = 1 + 7; /* Burst read command + 7 registers */ xfer.tx_buf = chip->buf; xfer.rx_buf = chip->buf; - chip->buf[0] = 0xbf; // Burst read + chip->buf[0] = 0xbf; /* Burst read */ spi_message_add_tail(&xfer, &message); /* do the i/o */ status = spi_sync(spi, &message); - if (status == 0) { + if (status == 0) status = message.status; - } else return status; @@ -144,7 +141,6 @@ static int max6902_get_datetime(struct d dt->tm_wday = BCD2BIN(chip->buf[6]); dt->tm_year = BCD2BIN(chip->buf[7]); - century = BCD2BIN(tmp) * 100; dt->tm_year += century; @@ -178,7 +174,7 @@ static int max6902_set_datetime(struct d printk("tm_year: %i\n",dt->tm_year); #endif - // Remove write protection + /* Remove write protection */ max6902_set_reg(dev, 0xF, 0); max6902_set_reg(dev, 0x01, BIN2BCD(dt->tm_sec)); @@ -195,7 +191,7 @@ static int max6902_set_datetime(struct d * does not mention a delay being required anywhere... */ /* delay(2000); */ - // Write protect + /* Write protect */ max6902_set_reg(dev, 0xF, 0x80); return 0; @@ -225,9 +221,8 @@ static int __devinit max6902_probe(struc rtc = rtc_device_register("max6902", &spi->dev, &max6902_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) { + if (IS_ERR(rtc)) return PTR_ERR(rtc); - } spi->mode = SPI_MODE_3; spi->bits_per_word = 8; _