mfd: bxtwc: Remove unnecessary i2c_addr checks in ipc calls
authorKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Thu, 30 Mar 2017 23:35:40 +0000 (16:35 -0700)
committerLee Jones <lee.jones@linaro.org>
Thu, 27 Apr 2017 08:25:06 +0000 (09:25 +0100)
In the following code block, BXTWC_DEVICE1_ADDR value is
already fixed and hence there no need to check for
if (!i2c_addr) in every ipc read/write calls. Even if this
check is required it can be moved to probe function.

i2c_addr = BXTWC_DEVICE1_ADDR;
if (!i2c_addr) {
dev_err(pmic->dev, "I2C address not set\n");
return -EINVAL;
}

This patch remove this extra check and adds some NULL
parameter checks.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/intel_soc_pmic_bxtwc.c

index 1496a862baa6ba5acc0a73f644973389eba28fe1..8c3cbf63c6ad0bdc117a9749824786389f6741ab 100644 (file)
@@ -238,15 +238,14 @@ static int regmap_ipc_byte_reg_read(void *context, unsigned int reg,
        u8 ipc_out[4];
        struct intel_soc_pmic *pmic = context;
 
+       if (!pmic)
+               return -EINVAL;
+
        if (reg & REG_ADDR_MASK)
                i2c_addr = (reg & REG_ADDR_MASK) >> REG_ADDR_SHIFT;
-       else {
+       else
                i2c_addr = BXTWC_DEVICE1_ADDR;
-               if (!i2c_addr) {
-                       dev_err(pmic->dev, "I2C address not set\n");
-                       return -EINVAL;
-               }
-       }
+
        reg &= REG_OFFSET_MASK;
 
        ipc_in[0] = reg;
@@ -271,15 +270,14 @@ static int regmap_ipc_byte_reg_write(void *context, unsigned int reg,
        u8 ipc_in[3];
        struct intel_soc_pmic *pmic = context;
 
+       if (!pmic)
+               return -EINVAL;
+
        if (reg & REG_ADDR_MASK)
                i2c_addr = (reg & REG_ADDR_MASK) >> REG_ADDR_SHIFT;
-       else {
+       else
                i2c_addr = BXTWC_DEVICE1_ADDR;
-               if (!i2c_addr) {
-                       dev_err(pmic->dev, "I2C address not set\n");
-                       return -EINVAL;
-               }
-       }
+
        reg &= REG_OFFSET_MASK;
 
        ipc_in[0] = reg;