diff mbox

i2c: mux: reg: simplify register size checking

Message ID BLUPR03MB15192BDC38DC0DE8D28395FBE650@BLUPR03MB151.namprd03.prod.outlook.com
State Accepted
Headers show

Commit Message

York Sun Aug. 21, 2015, 3:26 a.m. UTC
Sorry for top posting, I am out and replying using web access.

This patch looks OK. I cannot test it until earliest next Friday.

York

Comments

Wolfram Sang Aug. 21, 2015, 6:46 a.m. UTC | #1
> This patch looks OK. I cannot test it until earliest next Friday.

That will do. Thank you!
Wolfram Sang Aug. 31, 2015, 8:24 p.m. UTC | #2
On Fri, Aug 21, 2015 at 03:26:23AM +0000, York Sun wrote:
> Sorry for top posting, I am out and replying using web access.
> 
> This patch looks OK. I cannot test it until earliest next Friday.

Did you have the chance to test it?

Thanks,

   Wolfram
York Sun Aug. 31, 2015, 9:08 p.m. UTC | #3
On 08/31/2015 03:24 PM, Wolfram Sang wrote:
> On Fri, Aug 21, 2015 at 03:26:23AM +0000, York Sun wrote:
>> Sorry for top posting, I am out and replying using web access.
>>
>> This patch looks OK. I cannot test it until earliest next Friday.
> 
> Did you have the chance to test it?
> 

I am working on it. My hardware was replaced with a new version. I am running my
driver now. Will try your patch and confirm.

York

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c
index 86d41d36a78340..da8926d816c8cc 100644
--- a/drivers/i2c/muxes/i2c-mux-reg.c
+++ b/drivers/i2c/muxes/i2c-mux-reg.c
@@ -59,9 +59,6 @@  static int i2c_mux_reg_set(const struct regmux *mux, unsigned int chan_id)
                if (!mux->data.write_only)
                        ioread8(mux->data.reg);
                break;
-       default:
-               pr_err("Invalid register size\n");
-               return -EINVAL;
        }

        return 0;
@@ -154,10 +151,6 @@  static int i2c_mux_reg_probe_dt(struct regmux *mux,
        /* map address from "reg" if exists */
        if (of_address_to_resource(np, 0, &res)) {
                mux->data.reg_size = resource_size(&res);
-               if (mux->data.reg_size > 4) {
-                       dev_err(&pdev->dev, "Invalid address size\n");
-                       return -EINVAL;
-               }
                mux->data.reg = devm_ioremap_resource(&pdev->dev, &res);
                if (IS_ERR(mux->data.reg))
                        return PTR_ERR(mux->data.reg);
@@ -210,15 +203,17 @@  static int i2c_mux_reg_probe(struct platform_device *pdev)
                        "Register not set, using platform resource\n");
                res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                mux->data.reg_size = resource_size(res);
-               if (mux->data.reg_size > 4) {
-                       dev_err(&pdev->dev, "Invalid resource size\n");
-                       return -EINVAL;
-               }
                mux->data.reg = devm_ioremap_resource(&pdev->dev, res);
                if (IS_ERR(mux->data.reg))
                        return PTR_ERR(mux->data.reg);
        }

+       if (mux->data.reg_size != 4 && mux->data.reg_size != 2 &&
+           mux->data.reg_size != 1) {
+               dev_err(&pdev->dev, "Invalid register size\n");
+               return -EINVAL;
+       }
+
        mux->adap = devm_kzalloc(&pdev->dev,
                                 sizeof(*mux->adap) * mux->data.n_values,
                                 GFP_KERNEL);