All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: mux: reg: simplify register size checking
@ 2015-08-20 21:40 Wolfram Sang
       [not found] ` <1440106846-4484-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2015-08-20 21:40 UTC (permalink / raw
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: Wolfram Sang, York Sun

Checking was done at three different locations, just do it once and
properly at probing time.

Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Cc: York Sun <yorksun-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---

York Sun: Can you test this patch? I can only build test.

 drivers/i2c/muxes/i2c-mux-reg.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

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);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] i2c: mux: reg: simplify register size checking
       [not found] ` <1440106846-4484-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2015-08-21  3:26   ` York Sun
       [not found]     ` <BLUPR03MB15192BDC38DC0DE8D28395FBE650-GeMU99GfrrutHeM+ReIpiOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
  2015-08-31 22:07   ` York Sun
  2015-09-03  9:56   ` Wolfram Sang
  2 siblings, 1 reply; 7+ messages in thread
From: York Sun @ 2015-08-21  3:26 UTC (permalink / raw
  To: Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

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


________________________________________
From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Sent: Thursday, August 20, 2015 2:40 PM
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Wolfram Sang; Sun York-R58495
Subject: [PATCH] i2c: mux: reg: simplify register size checking

Checking was done at three different locations, just do it once and
properly at probing time.

Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Cc: York Sun <yorksun-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---

York Sun: Can you test this patch? I can only build test.

 drivers/i2c/muxes/i2c-mux-reg.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

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);
--
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] i2c: mux: reg: simplify register size checking
       [not found]     ` <BLUPR03MB15192BDC38DC0DE8D28395FBE650-GeMU99GfrrutHeM+ReIpiOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
@ 2015-08-21  6:46       ` Wolfram Sang
  2015-08-31 20:24       ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2015-08-21  6:46 UTC (permalink / raw
  To: York Sun; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

[-- Attachment #1: Type: text/plain, Size: 96 bytes --]


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

That will do. Thank you!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] i2c: mux: reg: simplify register size checking
       [not found]     ` <BLUPR03MB15192BDC38DC0DE8D28395FBE650-GeMU99GfrrutHeM+ReIpiOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
  2015-08-21  6:46       ` Wolfram Sang
@ 2015-08-31 20:24       ` Wolfram Sang
  2015-08-31 21:08         ` York Sun
  1 sibling, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2015-08-31 20:24 UTC (permalink / raw
  To: York Sun; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

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


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] i2c: mux: reg: simplify register size checking
  2015-08-31 20:24       ` Wolfram Sang
@ 2015-08-31 21:08         ` York Sun
  0 siblings, 0 replies; 7+ messages in thread
From: York Sun @ 2015-08-31 21:08 UTC (permalink / raw
  To: Wolfram Sang; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org



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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] i2c: mux: reg: simplify register size checking
       [not found] ` <1440106846-4484-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  2015-08-21  3:26   ` York Sun
@ 2015-08-31 22:07   ` York Sun
  2015-09-03  9:56   ` Wolfram Sang
  2 siblings, 0 replies; 7+ messages in thread
From: York Sun @ 2015-08-31 22:07 UTC (permalink / raw
  To: Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA



On 08/20/2015 04:40 PM, Wolfram Sang wrote:
> Checking was done at three different locations, just do it once and
> properly at probing time.
> 
> Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
> Cc: York Sun <yorksun-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
> 
> York Sun: Can you test this patch? I can only build test.

Patch is OK. Verified on hardware with good and intentional bad values.

Acked-by: York Sun <yorksun-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] i2c: mux: reg: simplify register size checking
       [not found] ` <1440106846-4484-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  2015-08-21  3:26   ` York Sun
  2015-08-31 22:07   ` York Sun
@ 2015-09-03  9:56   ` Wolfram Sang
  2 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2015-09-03  9:56 UTC (permalink / raw
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: York Sun

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

On Thu, Aug 20, 2015 at 11:40:46PM +0200, Wolfram Sang wrote:
> Checking was done at three different locations, just do it once and
> properly at probing time.
> 
> Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
> Cc: York Sun <yorksun-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-03  9:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 21:40 [PATCH] i2c: mux: reg: simplify register size checking Wolfram Sang
     [not found] ` <1440106846-4484-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2015-08-21  3:26   ` York Sun
     [not found]     ` <BLUPR03MB15192BDC38DC0DE8D28395FBE650-GeMU99GfrrutHeM+ReIpiOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
2015-08-21  6:46       ` Wolfram Sang
2015-08-31 20:24       ` Wolfram Sang
2015-08-31 21:08         ` York Sun
2015-08-31 22:07   ` York Sun
2015-09-03  9:56   ` Wolfram Sang

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.