]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/hwmon/lm81.c
Fix bad return value checks (detected with Coccinelle)
[people/ms/u-boot.git] / drivers / hwmon / lm81.c
index 03bc53d58c421e631ffe01210b9b1fa848b25a4f..bcc8d3293b5639b6b6e97c21d6653127835a1410 100644 (file)
@@ -7,23 +7,7 @@
  * (C) Copyright 2001
  * Bill Hunter,  Wave 7 Optics, williamhunter@mediaone.net
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
  */
 
 #include <common.h>
-
-#ifdef CONFIG_DTT_LM81
-#if !defined(CFG_EEPROM_PAGE_WRITE_ENABLE) || \
-       (CFG_EEPROM_PAGE_WRITE_BITS < 1)
-# error "CFG_EEPROM_PAGE_WRITE_ENABLE must be defined and CFG_EEPROM_PAGE_WRITE_BITS must be greater than  1 to use CONFIG_DTT_LM81"
-#endif
-
 #include <i2c.h>
 #include <dtt.h>
 
  * Device code
  */
 #define DTT_I2C_DEV_CODE 0x2c                  /* ON Semi's LM81 device */
+#define DTT_READ_TEMP          0x27
+#define DTT_CONFIG_TEMP                0x4b
+#define DTT_TEMP_MAX           0x39
+#define DTT_TEMP_HYST          0x3a
+#define DTT_CONFIG             0x40
 
 int dtt_read(int sensor, int reg)
 {
@@ -91,7 +73,7 @@ int dtt_write(int sensor, int reg, int val)
 #define DTT_CONFIG     0x40
 #define DTT_ADR                0x48
 
-static int _dtt_init(int sensor)
+int dtt_init_one(int sensor)
 {
        int     man;
        int     adr;
@@ -108,31 +90,14 @@ static int _dtt_init(int sensor)
        if (adr < 0)
                return 1;
        rev = dtt_read (sensor, DTT_REV);
-       if (adr < 0)
+       if (rev < 0)
                return 1;
 
-       printf ("DTT:   Found LM81@%x Rev: %d\n", adr, rev);
+       debug ("DTT:   Found LM81@%x Rev: %d\n", adr, rev);
        return 0;
-} /* _dtt_init() */
+} /* dtt_init_one() */
 
 
-int dtt_init (void)
-{
-    int i;
-    unsigned char sensors[] = CONFIG_DTT_SENSORS;
-    const char *const header = "DTT:   ";
-
-    for (i = 0; i < sizeof(sensors); i++) {
-       if (_dtt_init(sensors[i]) != 0)
-           printf("%s%d FAILED INIT\n", header, i+1);
-       else
-           printf("%s%d is %i C\n", header, i+1,
-                  dtt_get_temp(sensors[i]));
-    }
-
-    return (0);
-} /* dtt_init() */
-
 #define TEMP_FROM_REG(temp) \
    ((temp)<256?((((temp)&0x1fe) >> 1) * 10)     + ((temp) & 1) * 5:  \
               ((((temp)&0x1fe) >> 1) -255) * 10 - ((temp) & 1) * 5)  \
@@ -144,5 +109,3 @@ int dtt_get_temp(int sensor)
 
        return (TEMP_FROM_REG((val << 1) + ((tmpcnf & 0x80) >> 7))) / 10;
 } /* dtt_get_temp() */
-
-#endif /* CONFIG_DTT_LM81 */