diff options
Diffstat (limited to 'drivers/hwmon/dme1737.c')
-rw-r--r-- | drivers/hwmon/dme1737.c | 189 |
1 files changed, 126 insertions, 63 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index e9a610bfd0c..d9c59271391 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c | |||
@@ -77,12 +77,14 @@ enum chips { dme1737, sch5027, sch311x, sch5127 }; | |||
77 | * in4 +12V | 77 | * in4 +12V |
78 | * in5 VTR (+3.3V stby) | 78 | * in5 VTR (+3.3V stby) |
79 | * in6 Vbat | 79 | * in6 Vbat |
80 | * in7 Vtrip (sch5127 only) | ||
80 | * | 81 | * |
81 | * --------------------------------------------------------------------- */ | 82 | * --------------------------------------------------------------------- */ |
82 | 83 | ||
83 | /* Voltages (in) numbered 0-6 (ix) */ | 84 | /* Voltages (in) numbered 0-7 (ix) */ |
84 | #define DME1737_REG_IN(ix) ((ix) < 5 ? 0x20 + (ix) \ | 85 | #define DME1737_REG_IN(ix) ((ix) < 5 ? 0x20 + (ix) : \ |
85 | : 0x94 + (ix)) | 86 | (ix) < 7 ? 0x94 + (ix) : \ |
87 | 0x1f) | ||
86 | #define DME1737_REG_IN_MIN(ix) ((ix) < 5 ? 0x44 + (ix) * 2 \ | 88 | #define DME1737_REG_IN_MIN(ix) ((ix) < 5 ? 0x44 + (ix) * 2 \ |
87 | : 0x91 + (ix) * 2) | 89 | : 0x91 + (ix) * 2) |
88 | #define DME1737_REG_IN_MAX(ix) ((ix) < 5 ? 0x45 + (ix) * 2 \ | 90 | #define DME1737_REG_IN_MAX(ix) ((ix) < 5 ? 0x45 + (ix) * 2 \ |
@@ -101,10 +103,11 @@ enum chips { dme1737, sch5027, sch311x, sch5127 }; | |||
101 | * IN_TEMP_LSB(1) = [temp3, temp1] | 103 | * IN_TEMP_LSB(1) = [temp3, temp1] |
102 | * IN_TEMP_LSB(2) = [in4, temp2] | 104 | * IN_TEMP_LSB(2) = [in4, temp2] |
103 | * IN_TEMP_LSB(3) = [in3, in0] | 105 | * IN_TEMP_LSB(3) = [in3, in0] |
104 | * IN_TEMP_LSB(4) = [in2, in1] */ | 106 | * IN_TEMP_LSB(4) = [in2, in1] |
107 | * IN_TEMP_LSB(5) = [res, in7] */ | ||
105 | #define DME1737_REG_IN_TEMP_LSB(ix) (0x84 + (ix)) | 108 | #define DME1737_REG_IN_TEMP_LSB(ix) (0x84 + (ix)) |
106 | static const u8 DME1737_REG_IN_LSB[] = {3, 4, 4, 3, 2, 0, 0}; | 109 | static const u8 DME1737_REG_IN_LSB[] = {3, 4, 4, 3, 2, 0, 0, 5}; |
107 | static const u8 DME1737_REG_IN_LSB_SHL[] = {4, 4, 0, 0, 0, 0, 4}; | 110 | static const u8 DME1737_REG_IN_LSB_SHL[] = {4, 4, 0, 0, 0, 0, 4, 4}; |
108 | static const u8 DME1737_REG_TEMP_LSB[] = {1, 2, 1}; | 111 | static const u8 DME1737_REG_TEMP_LSB[] = {1, 2, 1}; |
109 | static const u8 DME1737_REG_TEMP_LSB_SHL[] = {4, 4, 0}; | 112 | static const u8 DME1737_REG_TEMP_LSB_SHL[] = {4, 4, 0}; |
110 | 113 | ||
@@ -145,7 +148,7 @@ static const u8 DME1737_REG_TEMP_LSB_SHL[] = {4, 4, 0}; | |||
145 | #define DME1737_REG_ALARM1 0x41 | 148 | #define DME1737_REG_ALARM1 0x41 |
146 | #define DME1737_REG_ALARM2 0x42 | 149 | #define DME1737_REG_ALARM2 0x42 |
147 | #define DME1737_REG_ALARM3 0x83 | 150 | #define DME1737_REG_ALARM3 0x83 |
148 | static const u8 DME1737_BIT_ALARM_IN[] = {0, 1, 2, 3, 8, 16, 17}; | 151 | static const u8 DME1737_BIT_ALARM_IN[] = {0, 1, 2, 3, 8, 16, 17, 18}; |
149 | static const u8 DME1737_BIT_ALARM_TEMP[] = {4, 5, 6}; | 152 | static const u8 DME1737_BIT_ALARM_TEMP[] = {4, 5, 6}; |
150 | static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; | 153 | static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; |
151 | 154 | ||
@@ -190,6 +193,7 @@ static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; | |||
190 | #define HAS_PWM_MIN (1 << 4) /* bit 4 */ | 193 | #define HAS_PWM_MIN (1 << 4) /* bit 4 */ |
191 | #define HAS_FAN(ix) (1 << ((ix) + 5)) /* bits 5-10 */ | 194 | #define HAS_FAN(ix) (1 << ((ix) + 5)) /* bits 5-10 */ |
192 | #define HAS_PWM(ix) (1 << ((ix) + 11)) /* bits 11-16 */ | 195 | #define HAS_PWM(ix) (1 << ((ix) + 11)) /* bits 11-16 */ |
196 | #define HAS_IN7 (1 << 17) /* bit 17 */ | ||
193 | 197 | ||
194 | /* --------------------------------------------------------------------- | 198 | /* --------------------------------------------------------------------- |
195 | * Data structures and manipulation thereof | 199 | * Data structures and manipulation thereof |
@@ -213,9 +217,9 @@ struct dme1737_data { | |||
213 | u32 has_features; | 217 | u32 has_features; |
214 | 218 | ||
215 | /* Register values */ | 219 | /* Register values */ |
216 | u16 in[7]; | 220 | u16 in[8]; |
217 | u8 in_min[7]; | 221 | u8 in_min[8]; |
218 | u8 in_max[7]; | 222 | u8 in_max[8]; |
219 | s16 temp[3]; | 223 | s16 temp[3]; |
220 | s8 temp_min[3]; | 224 | s8 temp_min[3]; |
221 | s8 temp_max[3]; | 225 | s8 temp_max[3]; |
@@ -247,7 +251,7 @@ static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300, | |||
247 | static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300, | 251 | static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300, |
248 | 3300}; | 252 | 3300}; |
249 | static const int IN_NOMINAL_SCH5127[] = {2500, 2250, 3300, 1125, 1125, 3300, | 253 | static const int IN_NOMINAL_SCH5127[] = {2500, 2250, 3300, 1125, 1125, 3300, |
250 | 3300}; | 254 | 3300, 1500}; |
251 | #define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \ | 255 | #define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \ |
252 | (type) == sch5027 ? IN_NOMINAL_SCH5027 : \ | 256 | (type) == sch5027 ? IN_NOMINAL_SCH5027 : \ |
253 | (type) == sch5127 ? IN_NOMINAL_SCH5127 : \ | 257 | (type) == sch5127 ? IN_NOMINAL_SCH5127 : \ |
@@ -580,7 +584,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
580 | { | 584 | { |
581 | struct dme1737_data *data = dev_get_drvdata(dev); | 585 | struct dme1737_data *data = dev_get_drvdata(dev); |
582 | int ix; | 586 | int ix; |
583 | u8 lsb[5]; | 587 | u8 lsb[6]; |
584 | 588 | ||
585 | mutex_lock(&data->update_lock); | 589 | mutex_lock(&data->update_lock); |
586 | 590 | ||
@@ -603,6 +607,9 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
603 | /* Voltage inputs are stored as 16 bit values even | 607 | /* Voltage inputs are stored as 16 bit values even |
604 | * though they have only 12 bits resolution. This is | 608 | * though they have only 12 bits resolution. This is |
605 | * to make it consistent with the temp inputs. */ | 609 | * to make it consistent with the temp inputs. */ |
610 | if (ix == 7 && !(data->has_features & HAS_IN7)) { | ||
611 | continue; | ||
612 | } | ||
606 | data->in[ix] = dme1737_read(data, | 613 | data->in[ix] = dme1737_read(data, |
607 | DME1737_REG_IN(ix)) << 8; | 614 | DME1737_REG_IN(ix)) << 8; |
608 | data->in_min[ix] = dme1737_read(data, | 615 | data->in_min[ix] = dme1737_read(data, |
@@ -635,10 +642,16 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
635 | * which the registers are read (MSB first, then LSB) is | 642 | * which the registers are read (MSB first, then LSB) is |
636 | * important! */ | 643 | * important! */ |
637 | for (ix = 0; ix < ARRAY_SIZE(lsb); ix++) { | 644 | for (ix = 0; ix < ARRAY_SIZE(lsb); ix++) { |
645 | if (ix == 5 && !(data->has_features & HAS_IN7)) { | ||
646 | continue; | ||
647 | } | ||
638 | lsb[ix] = dme1737_read(data, | 648 | lsb[ix] = dme1737_read(data, |
639 | DME1737_REG_IN_TEMP_LSB(ix)); | 649 | DME1737_REG_IN_TEMP_LSB(ix)); |
640 | } | 650 | } |
641 | for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { | 651 | for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { |
652 | if (ix == 7 && !(data->has_features & HAS_IN7)) { | ||
653 | continue; | ||
654 | } | ||
642 | data->in[ix] |= (lsb[DME1737_REG_IN_LSB[ix]] << | 655 | data->in[ix] |= (lsb[DME1737_REG_IN_LSB[ix]] << |
643 | DME1737_REG_IN_LSB_SHL[ix]) & 0xf0; | 656 | DME1737_REG_IN_LSB_SHL[ix]) & 0xf0; |
644 | } | 657 | } |
@@ -762,7 +775,7 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
762 | 775 | ||
763 | /* --------------------------------------------------------------------- | 776 | /* --------------------------------------------------------------------- |
764 | * Voltage sysfs attributes | 777 | * Voltage sysfs attributes |
765 | * ix = [0-5] | 778 | * ix = [0-7] |
766 | * --------------------------------------------------------------------- */ | 779 | * --------------------------------------------------------------------- */ |
767 | 780 | ||
768 | #define SYS_IN_INPUT 0 | 781 | #define SYS_IN_INPUT 0 |
@@ -1439,7 +1452,7 @@ static ssize_t show_name(struct device *dev, struct device_attribute *attr, | |||
1439 | * Sysfs device attribute defines and structs | 1452 | * Sysfs device attribute defines and structs |
1440 | * --------------------------------------------------------------------- */ | 1453 | * --------------------------------------------------------------------- */ |
1441 | 1454 | ||
1442 | /* Voltages 0-6 */ | 1455 | /* Voltages 0-7 */ |
1443 | 1456 | ||
1444 | #define SENSOR_DEVICE_ATTR_IN(ix) \ | 1457 | #define SENSOR_DEVICE_ATTR_IN(ix) \ |
1445 | static SENSOR_DEVICE_ATTR_2(in##ix##_input, S_IRUGO, \ | 1458 | static SENSOR_DEVICE_ATTR_2(in##ix##_input, S_IRUGO, \ |
@@ -1458,6 +1471,7 @@ SENSOR_DEVICE_ATTR_IN(3); | |||
1458 | SENSOR_DEVICE_ATTR_IN(4); | 1471 | SENSOR_DEVICE_ATTR_IN(4); |
1459 | SENSOR_DEVICE_ATTR_IN(5); | 1472 | SENSOR_DEVICE_ATTR_IN(5); |
1460 | SENSOR_DEVICE_ATTR_IN(6); | 1473 | SENSOR_DEVICE_ATTR_IN(6); |
1474 | SENSOR_DEVICE_ATTR_IN(7); | ||
1461 | 1475 | ||
1462 | /* Temperatures 1-3 */ | 1476 | /* Temperatures 1-3 */ |
1463 | 1477 | ||
@@ -1576,7 +1590,7 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); /* for ISA devices */ | |||
1576 | * created unconditionally. The attributes that need modification of their | 1590 | * created unconditionally. The attributes that need modification of their |
1577 | * permissions are created read-only and write permissions are added or removed | 1591 | * permissions are created read-only and write permissions are added or removed |
1578 | * on the fly when required */ | 1592 | * on the fly when required */ |
1579 | static struct attribute *dme1737_attr[] ={ | 1593 | static struct attribute *dme1737_attr[] = { |
1580 | /* Voltages */ | 1594 | /* Voltages */ |
1581 | &sensor_dev_attr_in0_input.dev_attr.attr, | 1595 | &sensor_dev_attr_in0_input.dev_attr.attr, |
1582 | &sensor_dev_attr_in0_min.dev_attr.attr, | 1596 | &sensor_dev_attr_in0_min.dev_attr.attr, |
@@ -1681,7 +1695,7 @@ static const struct attribute_group dme1737_zone3_group = { | |||
1681 | }; | 1695 | }; |
1682 | 1696 | ||
1683 | 1697 | ||
1684 | /* The following struct holds temp zone hysteresis related attributes, which | 1698 | /* The following struct holds temp zone hysteresis related attributes, which |
1685 | * are not available in all chips. The following chips support them: | 1699 | * are not available in all chips. The following chips support them: |
1686 | * DME1737, SCH311x */ | 1700 | * DME1737, SCH311x */ |
1687 | static struct attribute *dme1737_zone_hyst_attr[] = { | 1701 | static struct attribute *dme1737_zone_hyst_attr[] = { |
@@ -1695,6 +1709,21 @@ static const struct attribute_group dme1737_zone_hyst_group = { | |||
1695 | .attrs = dme1737_zone_hyst_attr, | 1709 | .attrs = dme1737_zone_hyst_attr, |
1696 | }; | 1710 | }; |
1697 | 1711 | ||
1712 | /* The following struct holds voltage in7 related attributes, which | ||
1713 | * are not available in all chips. The following chips support them: | ||
1714 | * SCH5127 */ | ||
1715 | static struct attribute *dme1737_in7_attr[] = { | ||
1716 | &sensor_dev_attr_in7_input.dev_attr.attr, | ||
1717 | &sensor_dev_attr_in7_min.dev_attr.attr, | ||
1718 | &sensor_dev_attr_in7_max.dev_attr.attr, | ||
1719 | &sensor_dev_attr_in7_alarm.dev_attr.attr, | ||
1720 | NULL | ||
1721 | }; | ||
1722 | |||
1723 | static const struct attribute_group dme1737_in7_group = { | ||
1724 | .attrs = dme1737_in7_attr, | ||
1725 | }; | ||
1726 | |||
1698 | /* The following structs hold the PWM attributes, some of which are optional. | 1727 | /* The following structs hold the PWM attributes, some of which are optional. |
1699 | * Their creation depends on the chip configuration which is determined during | 1728 | * Their creation depends on the chip configuration which is determined during |
1700 | * module load. */ | 1729 | * module load. */ |
@@ -1986,6 +2015,9 @@ static void dme1737_remove_files(struct device *dev) | |||
1986 | if (data->has_features & HAS_ZONE_HYST) { | 2015 | if (data->has_features & HAS_ZONE_HYST) { |
1987 | sysfs_remove_group(&dev->kobj, &dme1737_zone_hyst_group); | 2016 | sysfs_remove_group(&dev->kobj, &dme1737_zone_hyst_group); |
1988 | } | 2017 | } |
2018 | if (data->has_features & HAS_IN7) { | ||
2019 | sysfs_remove_group(&dev->kobj, &dme1737_in7_group); | ||
2020 | } | ||
1989 | sysfs_remove_group(&dev->kobj, &dme1737_group); | 2021 | sysfs_remove_group(&dev->kobj, &dme1737_group); |
1990 | 2022 | ||
1991 | if (!data->client) { | 2023 | if (!data->client) { |
@@ -1999,43 +2031,58 @@ static int dme1737_create_files(struct device *dev) | |||
1999 | int err, ix; | 2031 | int err, ix; |
2000 | 2032 | ||
2001 | /* Create a name attribute for ISA devices */ | 2033 | /* Create a name attribute for ISA devices */ |
2002 | if (!data->client && | 2034 | if (!data->client) { |
2003 | (err = sysfs_create_file(&dev->kobj, &dev_attr_name.attr))) { | 2035 | err = sysfs_create_file(&dev->kobj, &dev_attr_name.attr); |
2004 | goto exit; | 2036 | if (err) { |
2037 | goto exit; | ||
2038 | } | ||
2005 | } | 2039 | } |
2006 | 2040 | ||
2007 | /* Create standard sysfs attributes */ | 2041 | /* Create standard sysfs attributes */ |
2008 | if ((err = sysfs_create_group(&dev->kobj, &dme1737_group))) { | 2042 | err = sysfs_create_group(&dev->kobj, &dme1737_group); |
2043 | if (err) { | ||
2009 | goto exit_remove; | 2044 | goto exit_remove; |
2010 | } | 2045 | } |
2011 | 2046 | ||
2012 | /* Create chip-dependent sysfs attributes */ | 2047 | /* Create chip-dependent sysfs attributes */ |
2013 | if ((data->has_features & HAS_TEMP_OFFSET) && | 2048 | if (data->has_features & HAS_TEMP_OFFSET) { |
2014 | (err = sysfs_create_group(&dev->kobj, | 2049 | err = sysfs_create_group(&dev->kobj, |
2015 | &dme1737_temp_offset_group))) { | 2050 | &dme1737_temp_offset_group); |
2016 | goto exit_remove; | 2051 | if (err) { |
2052 | goto exit_remove; | ||
2053 | } | ||
2017 | } | 2054 | } |
2018 | if ((data->has_features & HAS_VID) && | 2055 | if (data->has_features & HAS_VID) { |
2019 | (err = sysfs_create_group(&dev->kobj, | 2056 | err = sysfs_create_group(&dev->kobj, &dme1737_vid_group); |
2020 | &dme1737_vid_group))) { | 2057 | if (err) { |
2021 | goto exit_remove; | 2058 | goto exit_remove; |
2059 | } | ||
2022 | } | 2060 | } |
2023 | if ((data->has_features & HAS_ZONE3) && | 2061 | if (data->has_features & HAS_ZONE3) { |
2024 | (err = sysfs_create_group(&dev->kobj, | 2062 | err = sysfs_create_group(&dev->kobj, &dme1737_zone3_group); |
2025 | &dme1737_zone3_group))) { | 2063 | if (err) { |
2026 | goto exit_remove; | 2064 | goto exit_remove; |
2065 | } | ||
2027 | } | 2066 | } |
2028 | if ((data->has_features & HAS_ZONE_HYST) && | 2067 | if (data->has_features & HAS_ZONE_HYST) { |
2029 | (err = sysfs_create_group(&dev->kobj, | 2068 | err = sysfs_create_group(&dev->kobj, &dme1737_zone_hyst_group); |
2030 | &dme1737_zone_hyst_group))) { | 2069 | if (err) { |
2031 | goto exit_remove; | 2070 | goto exit_remove; |
2071 | } | ||
2072 | } | ||
2073 | if (data->has_features & HAS_IN7) { | ||
2074 | err = sysfs_create_group(&dev->kobj, &dme1737_in7_group); | ||
2075 | if (err) { | ||
2076 | goto exit_remove; | ||
2077 | } | ||
2032 | } | 2078 | } |
2033 | 2079 | ||
2034 | /* Create fan sysfs attributes */ | 2080 | /* Create fan sysfs attributes */ |
2035 | for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { | 2081 | for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { |
2036 | if (data->has_features & HAS_FAN(ix)) { | 2082 | if (data->has_features & HAS_FAN(ix)) { |
2037 | if ((err = sysfs_create_group(&dev->kobj, | 2083 | err = sysfs_create_group(&dev->kobj, |
2038 | &dme1737_fan_group[ix]))) { | 2084 | &dme1737_fan_group[ix]); |
2085 | if (err) { | ||
2039 | goto exit_remove; | 2086 | goto exit_remove; |
2040 | } | 2087 | } |
2041 | } | 2088 | } |
@@ -2044,14 +2091,17 @@ static int dme1737_create_files(struct device *dev) | |||
2044 | /* Create PWM sysfs attributes */ | 2091 | /* Create PWM sysfs attributes */ |
2045 | for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) { | 2092 | for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) { |
2046 | if (data->has_features & HAS_PWM(ix)) { | 2093 | if (data->has_features & HAS_PWM(ix)) { |
2047 | if ((err = sysfs_create_group(&dev->kobj, | 2094 | err = sysfs_create_group(&dev->kobj, |
2048 | &dme1737_pwm_group[ix]))) { | 2095 | &dme1737_pwm_group[ix]); |
2096 | if (err) { | ||
2049 | goto exit_remove; | 2097 | goto exit_remove; |
2050 | } | 2098 | } |
2051 | if ((data->has_features & HAS_PWM_MIN) && ix < 3 && | 2099 | if ((data->has_features & HAS_PWM_MIN) && (ix < 3)) { |
2052 | (err = sysfs_create_file(&dev->kobj, | 2100 | err = sysfs_create_file(&dev->kobj, |
2053 | dme1737_auto_pwm_min_attr[ix]))) { | 2101 | dme1737_auto_pwm_min_attr[ix]); |
2054 | goto exit_remove; | 2102 | if (err) { |
2103 | goto exit_remove; | ||
2104 | } | ||
2055 | } | 2105 | } |
2056 | } | 2106 | } |
2057 | } | 2107 | } |
@@ -2188,7 +2238,7 @@ static int dme1737_init_device(struct device *dev) | |||
2188 | data->has_features |= HAS_ZONE3; | 2238 | data->has_features |= HAS_ZONE3; |
2189 | break; | 2239 | break; |
2190 | case sch5127: | 2240 | case sch5127: |
2191 | data->has_features |= HAS_FAN(2) | HAS_PWM(2); | 2241 | data->has_features |= HAS_FAN(2) | HAS_PWM(2) | HAS_IN7; |
2192 | break; | 2242 | break; |
2193 | default: | 2243 | default: |
2194 | break; | 2244 | break; |
@@ -2281,8 +2331,9 @@ static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data) | |||
2281 | dme1737_sio_outb(sio_cip, 0x07, 0x0a); | 2331 | dme1737_sio_outb(sio_cip, 0x07, 0x0a); |
2282 | 2332 | ||
2283 | /* Get the base address of the runtime registers */ | 2333 | /* Get the base address of the runtime registers */ |
2284 | if (!(addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | | 2334 | addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | |
2285 | dme1737_sio_inb(sio_cip, 0x61))) { | 2335 | dme1737_sio_inb(sio_cip, 0x61); |
2336 | if (!addr) { | ||
2286 | err = -ENODEV; | 2337 | err = -ENODEV; |
2287 | goto exit; | 2338 | goto exit; |
2288 | } | 2339 | } |
@@ -2363,13 +2414,15 @@ static int dme1737_i2c_probe(struct i2c_client *client, | |||
2363 | mutex_init(&data->update_lock); | 2414 | mutex_init(&data->update_lock); |
2364 | 2415 | ||
2365 | /* Initialize the DME1737 chip */ | 2416 | /* Initialize the DME1737 chip */ |
2366 | if ((err = dme1737_init_device(dev))) { | 2417 | err = dme1737_init_device(dev); |
2418 | if (err) { | ||
2367 | dev_err(dev, "Failed to initialize device.\n"); | 2419 | dev_err(dev, "Failed to initialize device.\n"); |
2368 | goto exit_kfree; | 2420 | goto exit_kfree; |
2369 | } | 2421 | } |
2370 | 2422 | ||
2371 | /* Create sysfs files */ | 2423 | /* Create sysfs files */ |
2372 | if ((err = dme1737_create_files(dev))) { | 2424 | err = dme1737_create_files(dev); |
2425 | if (err) { | ||
2373 | dev_err(dev, "Failed to create sysfs files.\n"); | 2426 | dev_err(dev, "Failed to create sysfs files.\n"); |
2374 | goto exit_kfree; | 2427 | goto exit_kfree; |
2375 | } | 2428 | } |
@@ -2446,8 +2499,9 @@ static int __init dme1737_isa_detect(int sio_cip, unsigned short *addr) | |||
2446 | dme1737_sio_outb(sio_cip, 0x07, 0x0a); | 2499 | dme1737_sio_outb(sio_cip, 0x07, 0x0a); |
2447 | 2500 | ||
2448 | /* Get the base address of the runtime registers */ | 2501 | /* Get the base address of the runtime registers */ |
2449 | if (!(base_addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | | 2502 | base_addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | |
2450 | dme1737_sio_inb(sio_cip, 0x61))) { | 2503 | dme1737_sio_inb(sio_cip, 0x61); |
2504 | if (!base_addr) { | ||
2451 | pr_err("Base address not set\n"); | 2505 | pr_err("Base address not set\n"); |
2452 | err = -ENODEV; | 2506 | err = -ENODEV; |
2453 | goto exit; | 2507 | goto exit; |
@@ -2476,18 +2530,21 @@ static int __init dme1737_isa_device_add(unsigned short addr) | |||
2476 | if (err) | 2530 | if (err) |
2477 | goto exit; | 2531 | goto exit; |
2478 | 2532 | ||
2479 | if (!(pdev = platform_device_alloc("dme1737", addr))) { | 2533 | pdev = platform_device_alloc("dme1737", addr); |
2534 | if (!pdev) { | ||
2480 | pr_err("Failed to allocate device\n"); | 2535 | pr_err("Failed to allocate device\n"); |
2481 | err = -ENOMEM; | 2536 | err = -ENOMEM; |
2482 | goto exit; | 2537 | goto exit; |
2483 | } | 2538 | } |
2484 | 2539 | ||
2485 | if ((err = platform_device_add_resources(pdev, &res, 1))) { | 2540 | err = platform_device_add_resources(pdev, &res, 1); |
2541 | if (err) { | ||
2486 | pr_err("Failed to add device resource (err = %d)\n", err); | 2542 | pr_err("Failed to add device resource (err = %d)\n", err); |
2487 | goto exit_device_put; | 2543 | goto exit_device_put; |
2488 | } | 2544 | } |
2489 | 2545 | ||
2490 | if ((err = platform_device_add(pdev))) { | 2546 | err = platform_device_add(pdev); |
2547 | if (err) { | ||
2491 | pr_err("Failed to add device (err = %d)\n", err); | 2548 | pr_err("Failed to add device (err = %d)\n", err); |
2492 | goto exit_device_put; | 2549 | goto exit_device_put; |
2493 | } | 2550 | } |
@@ -2514,11 +2571,12 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev) | |||
2514 | dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", | 2571 | dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", |
2515 | (unsigned short)res->start, | 2572 | (unsigned short)res->start, |
2516 | (unsigned short)res->start + DME1737_EXTENT - 1); | 2573 | (unsigned short)res->start + DME1737_EXTENT - 1); |
2517 | err = -EBUSY; | 2574 | err = -EBUSY; |
2518 | goto exit; | 2575 | goto exit; |
2519 | } | 2576 | } |
2520 | 2577 | ||
2521 | if (!(data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL))) { | 2578 | data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL); |
2579 | if (!data) { | ||
2522 | err = -ENOMEM; | 2580 | err = -ENOMEM; |
2523 | goto exit_release_region; | 2581 | goto exit_release_region; |
2524 | } | 2582 | } |
@@ -2565,13 +2623,15 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev) | |||
2565 | data->type == sch5127 ? "SCH5127" : "SCH311x", data->addr); | 2623 | data->type == sch5127 ? "SCH5127" : "SCH311x", data->addr); |
2566 | 2624 | ||
2567 | /* Initialize the chip */ | 2625 | /* Initialize the chip */ |
2568 | if ((err = dme1737_init_device(dev))) { | 2626 | err = dme1737_init_device(dev); |
2627 | if (err) { | ||
2569 | dev_err(dev, "Failed to initialize device.\n"); | 2628 | dev_err(dev, "Failed to initialize device.\n"); |
2570 | goto exit_kfree; | 2629 | goto exit_kfree; |
2571 | } | 2630 | } |
2572 | 2631 | ||
2573 | /* Create sysfs files */ | 2632 | /* Create sysfs files */ |
2574 | if ((err = dme1737_create_files(dev))) { | 2633 | err = dme1737_create_files(dev); |
2634 | if (err) { | ||
2575 | dev_err(dev, "Failed to create sysfs files.\n"); | 2635 | dev_err(dev, "Failed to create sysfs files.\n"); |
2576 | goto exit_kfree; | 2636 | goto exit_kfree; |
2577 | } | 2637 | } |
@@ -2628,7 +2688,8 @@ static int __init dme1737_init(void) | |||
2628 | int err; | 2688 | int err; |
2629 | unsigned short addr; | 2689 | unsigned short addr; |
2630 | 2690 | ||
2631 | if ((err = i2c_add_driver(&dme1737_i2c_driver))) { | 2691 | err = i2c_add_driver(&dme1737_i2c_driver); |
2692 | if (err) { | ||
2632 | goto exit; | 2693 | goto exit; |
2633 | } | 2694 | } |
2634 | 2695 | ||
@@ -2641,12 +2702,14 @@ static int __init dme1737_init(void) | |||
2641 | return 0; | 2702 | return 0; |
2642 | } | 2703 | } |
2643 | 2704 | ||
2644 | if ((err = platform_driver_register(&dme1737_isa_driver))) { | 2705 | err = platform_driver_register(&dme1737_isa_driver); |
2706 | if (err) { | ||
2645 | goto exit_del_i2c_driver; | 2707 | goto exit_del_i2c_driver; |
2646 | } | 2708 | } |
2647 | 2709 | ||
2648 | /* Sets global pdev as a side effect */ | 2710 | /* Sets global pdev as a side effect */ |
2649 | if ((err = dme1737_isa_device_add(addr))) { | 2711 | err = dme1737_isa_device_add(addr); |
2712 | if (err) { | ||
2650 | goto exit_del_isa_driver; | 2713 | goto exit_del_isa_driver; |
2651 | } | 2714 | } |
2652 | 2715 | ||