summaryrefslogtreecommitdiff
path: root/drivers/mfd/intel_soc_pmic_bxtwc.c
diff options
context:
space:
mode:
authorKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>2017-03-31 02:35:40 +0300
committerLee Jones <lee.jones@linaro.org>2017-04-27 11:25:06 +0300
commitb4ccc4d2e82f7c7f8304f44544bdefcd16234582 (patch)
tree419a6bc08090eb8023b16602a6bee57272adead0 /drivers/mfd/intel_soc_pmic_bxtwc.c
parent4407319d8fff93308c2afe40e7c2a7dc564ec122 (diff)
downloadlinux-b4ccc4d2e82f7c7f8304f44544bdefcd16234582.tar.xz
mfd: bxtwc: Remove unnecessary i2c_addr checks in ipc calls
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>
Diffstat (limited to 'drivers/mfd/intel_soc_pmic_bxtwc.c')
-rw-r--r--drivers/mfd/intel_soc_pmic_bxtwc.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index 1496a862baa6..8c3cbf63c6ad 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -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;