* [PATCH v1 1/1] mfd: bxtwc: remove unnecessary i2c_addr checks in ipc calls
@ 2017-03-30 23:35 sathyanarayanan.kuppuswamy
2017-04-03 10:29 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: sathyanarayanan.kuppuswamy @ 2017-03-30 23:35 UTC (permalink / raw)
To: lee.jones; +Cc: sathyaosid, linux-kernel, Kuppuswamy Sathyanarayanan
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
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>
---
drivers/mfd/intel_soc_pmic_bxtwc.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index 699c8c7..583d17d 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -237,15 +237,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;
@@ -270,15 +269,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;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/1] mfd: bxtwc: remove unnecessary i2c_addr checks in ipc calls
2017-03-30 23:35 [PATCH v1 1/1] mfd: bxtwc: remove unnecessary i2c_addr checks in ipc calls sathyanarayanan.kuppuswamy
@ 2017-04-03 10:29 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2017-04-03 10:29 UTC (permalink / raw)
To: sathyanarayanan.kuppuswamy; +Cc: sathyaosid, linux-kernel
On Thu, 30 Mar 2017, sathyanarayanan.kuppuswamy@linux.intel.com wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> 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>
> ---
> drivers/mfd/intel_soc_pmic_bxtwc.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
Applied, thanks.
> diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
> index 699c8c7..583d17d 100644
> --- a/drivers/mfd/intel_soc_pmic_bxtwc.c
> +++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
> @@ -237,15 +237,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;
> @@ -270,15 +269,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;
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-03 10:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30 23:35 [PATCH v1 1/1] mfd: bxtwc: remove unnecessary i2c_addr checks in ipc calls sathyanarayanan.kuppuswamy
2017-04-03 10:29 ` Lee Jones
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.