summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramy.shih <amy.shih@advantech.com.tw>2019-06-17 04:08:50 -0400
committerGuenter Roeck <linux@roeck-us.net>2019-07-08 21:11:29 -0400
commitb3e26067874700fb38aeddf2da9844afb36f1a94 (patch)
treef85c4b2003c6f63c8c5eb2b8822fb64427cc91bc
parent23297edbc15ae19917253064c81f91c4df240f93 (diff)
hwmon: (nct7904) Add error handling in probe function.
When register read and write operations return errors, needs to add error handling. Signed-off-by: amy.shih <amy.shih@advantech.com.tw> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/nct7904.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
index 5708171197e7..401ed4a4a576 100644
--- a/drivers/hwmon/nct7904.c
+++ b/drivers/hwmon/nct7904.c
@@ -506,6 +506,8 @@ static int nct7904_probe(struct i2c_client *client,
506 506
507 /* CPU_TEMP attributes */ 507 /* CPU_TEMP attributes */
508 ret = nct7904_read_reg(data, BANK_0, VT_ADC_CTRL0_REG); 508 ret = nct7904_read_reg(data, BANK_0, VT_ADC_CTRL0_REG);
509 if (ret < 0)
510 return ret;
509 511
510 if ((ret & 0x6) == 0x6) 512 if ((ret & 0x6) == 0x6)
511 data->tcpu_mask |= 1; /* TR1 */ 513 data->tcpu_mask |= 1; /* TR1 */
@@ -518,11 +520,15 @@ static int nct7904_probe(struct i2c_client *client,
518 520
519 /* LTD */ 521 /* LTD */
520 ret = nct7904_read_reg(data, BANK_0, VT_ADC_CTRL2_REG); 522 ret = nct7904_read_reg(data, BANK_0, VT_ADC_CTRL2_REG);
523 if (ret < 0)
524 return ret;
521 if ((ret & 0x02) == 0x02) 525 if ((ret & 0x02) == 0x02)
522 data->tcpu_mask |= 0x10; 526 data->tcpu_mask |= 0x10;
523 527
524 /* Multi-Function detecting for Volt and TR/TD */ 528 /* Multi-Function detecting for Volt and TR/TD */
525 ret = nct7904_read_reg(data, BANK_0, VT_ADC_MD_REG); 529 ret = nct7904_read_reg(data, BANK_0, VT_ADC_MD_REG);
530 if (ret < 0)
531 return ret;
526 532
527 for (i = 0; i < 4; i++) { 533 for (i = 0; i < 4; i++) {
528 val = (ret & (0x03 << i)) >> (i * 2); 534 val = (ret & (0x03 << i)) >> (i * 2);
@@ -533,22 +539,29 @@ static int nct7904_probe(struct i2c_client *client,
533 539
534 /* PECI */ 540 /* PECI */
535 ret = nct7904_read_reg(data, BANK_2, PFE_REG); 541 ret = nct7904_read_reg(data, BANK_2, PFE_REG);
542 if (ret < 0)
543 return ret;
536 if (ret & 0x80) { 544 if (ret & 0x80) {
537 data->enable_dts = 1; //Enable DTS & PECI 545 data->enable_dts = 1; //Enable DTS & PECI
538 } else { 546 } else {
539 ret = nct7904_read_reg(data, BANK_2, TSI_CTRL_REG); 547 ret = nct7904_read_reg(data, BANK_2, TSI_CTRL_REG);
548 if (ret < 0)
549 return ret;
540 if (ret & 0x80) 550 if (ret & 0x80)
541 data->enable_dts = 0x3; //Enable DTS & TSI 551 data->enable_dts = 0x3; //Enable DTS & TSI
542 } 552 }
543 553
544 /* Check DTS enable status */ 554 /* Check DTS enable status */
545 if (data->enable_dts) { 555 if (data->enable_dts) {
546 data->has_dts = 556 ret = nct7904_read_reg(data, BANK_0, DTS_T_CTRL0_REG);
547 nct7904_read_reg(data, BANK_0, DTS_T_CTRL0_REG) & 0xF; 557 if (ret < 0)
558 return ret;
559 data->has_dts = ret & 0xF;
548 if (data->enable_dts & 0x2) { 560 if (data->enable_dts & 0x2) {
549 data->has_dts |= 561 ret = nct7904_read_reg(data, BANK_0, DTS_T_CTRL1_REG);
550 (nct7904_read_reg(data, BANK_0, DTS_T_CTRL1_REG) & 0xF) 562 if (ret < 0)
551 << 4; 563 return ret;
564 data->has_dts |= (ret & 0xF) << 4;
552 } 565 }
553 } 566 }
554 567