diff mbox

[RFC,2/2] i2c: sh_mobile: drop needless check for of_node

Message ID 20170518211140.12023-3-wsa+renesas@sang-engineering.com
State Accepted
Headers show

Commit Message

Wolfram Sang May 18, 2017, 9:11 p.m. UTC
After removal of platform_data support, we can simplify OF handling.
of_match_device() evaluates to NULL if !CONFIG_OF or if there is no node
pointer for that device, so we can remove the check for the node ptr.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-sh_mobile.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Comments

Geert Uytterhoeven May 19, 2017, 7:46 a.m. UTC | #1
On Thu, May 18, 2017 at 11:11 PM, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> After removal of platform_data support, we can simplify OF handling.
> of_match_device() evaluates to NULL if !CONFIG_OF or if there is no node
> pointer for that device, so we can remove the check for the node ptr.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/drivers/i2c/busses/i2c-sh_mobile.c
> +++ b/drivers/i2c/busses/i2c-sh_mobile.c

> +       if (match) {
> +               const struct sh_mobile_dt_config *config;
>
> -                       config = match->data;
> -                       pd->clks_per_count = config->clks_per_count;
> +               config = match->data;

You could have combined the assignment with the variable declaration.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
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
Wolfram Sang June 2, 2017, 8:53 p.m. UTC | #2
On Thu, May 18, 2017 at 11:11:40PM +0200, Wolfram Sang wrote:
> After removal of platform_data support, we can simplify OF handling.
> of_match_device() evaluates to NULL if !CONFIG_OF or if there is no node
> pointer for that device, so we can remove the check for the node ptr.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Fixed the assignment as mentioned by Geert (thanks!) and applied to
for-next, thanks!
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index d5e39eccae9b97..92c002c5bb0abe 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -881,6 +881,7 @@  static int sh_mobile_i2c_probe(struct platform_device *dev)
 	struct sh_mobile_i2c_data *pd;
 	struct i2c_adapter *adap;
 	struct resource *res;
+	const struct of_device_id *match;
 	int ret;
 	u32 bus_speed;
 
@@ -910,22 +911,17 @@  static int sh_mobile_i2c_probe(struct platform_device *dev)
 
 	ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed);
 	pd->bus_speed = ret ? STANDARD_MODE : bus_speed;
-
 	pd->clks_per_count = 1;
 
-	if (dev->dev.of_node) {
-		const struct of_device_id *match;
-
-		match = of_match_device(sh_mobile_i2c_dt_ids, &dev->dev);
-		if (match) {
-			const struct sh_mobile_dt_config *config;
+	match = of_match_device(sh_mobile_i2c_dt_ids, &dev->dev);
+	if (match) {
+		const struct sh_mobile_dt_config *config;
 
-			config = match->data;
-			pd->clks_per_count = config->clks_per_count;
+		config = match->data;
+		pd->clks_per_count = config->clks_per_count;
 
-			if (config->setup)
-				config->setup(pd);
-		}
+		if (config->setup)
+			config->setup(pd);
 	}
 
 	/* The IIC blocks on SH-Mobile ARM processors