Re: [PATCH v2 08/21] clk: bcm2835: use match_string() helper
Quoting Yisheng Xie (2018-05-31 04:11:13) > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > > Reviewed-by: Eric Anholt > Cc: Michael Turquette > Cc: Stephen Boyd > Cc: Eric Anholt > Cc: Stefan Wahren > Cc: linux-...@vger.kernel.org > Cc: linux-rpi-ker...@lists.infradead.org > Cc: linux-arm-ker...@lists.infradead.org > Signed-off-by: Yisheng Xie > --- Applied to clk-next
Re: [PATCH v2 08/21] clk: bcm2835: use match_string() helper
Quoting Yisheng Xie (2018-05-31 04:11:13) > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > > Reviewed-by: Eric Anholt > Cc: Michael Turquette > Cc: Stephen Boyd > Cc: Eric Anholt > Cc: Stefan Wahren > Cc: linux-...@vger.kernel.org > Cc: linux-rpi-ker...@lists.infradead.org > Cc: linux-arm-ker...@lists.infradead.org > Signed-off-by: Yisheng Xie > --- Applied to clk-next
[PATCH v2 08/21] clk: bcm2835: use match_string() helper
match_string() returns the index of an array for a matching string, which can be used instead of open coded variant. Reviewed-by: Eric Anholt Cc: Michael Turquette Cc: Stephen Boyd Cc: Eric Anholt Cc: Stefan Wahren Cc: linux-...@vger.kernel.org Cc: linux-rpi-ker...@lists.infradead.org Cc: linux-arm-ker...@lists.infradead.org Signed-off-by: Yisheng Xie --- v2: - donot change the type of i - per Andy drivers/clk/bcm/clk-bcm2835.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index fa0d5c8..5e18433 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1395,7 +1395,7 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, struct bcm2835_clock *clock; struct clk_init_data init; const char *parents[1 << CM_SRC_BITS]; - size_t i, j; + size_t i; int ret; /* @@ -1405,12 +1405,11 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, for (i = 0; i < data->num_mux_parents; i++) { parents[i] = data->parents[i]; - for (j = 0; j < ARRAY_SIZE(cprman_parent_names); j++) { - if (strcmp(parents[i], cprman_parent_names[j]) == 0) { - parents[i] = cprman->real_parent_names[j]; - break; - } - } + ret = match_string(cprman_parent_names, + ARRAY_SIZE(cprman_parent_names), + parents[i]); + if (ret >= 0) + parents[i] = cprman->real_parent_names[ret]; } memset(, 0, sizeof(init)); -- 1.7.12.4
[PATCH v2 08/21] clk: bcm2835: use match_string() helper
match_string() returns the index of an array for a matching string, which can be used instead of open coded variant. Reviewed-by: Eric Anholt Cc: Michael Turquette Cc: Stephen Boyd Cc: Eric Anholt Cc: Stefan Wahren Cc: linux-...@vger.kernel.org Cc: linux-rpi-ker...@lists.infradead.org Cc: linux-arm-ker...@lists.infradead.org Signed-off-by: Yisheng Xie --- v2: - donot change the type of i - per Andy drivers/clk/bcm/clk-bcm2835.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index fa0d5c8..5e18433 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1395,7 +1395,7 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, struct bcm2835_clock *clock; struct clk_init_data init; const char *parents[1 << CM_SRC_BITS]; - size_t i, j; + size_t i; int ret; /* @@ -1405,12 +1405,11 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman, for (i = 0; i < data->num_mux_parents; i++) { parents[i] = data->parents[i]; - for (j = 0; j < ARRAY_SIZE(cprman_parent_names); j++) { - if (strcmp(parents[i], cprman_parent_names[j]) == 0) { - parents[i] = cprman->real_parent_names[j]; - break; - } - } + ret = match_string(cprman_parent_names, + ARRAY_SIZE(cprman_parent_names), + parents[i]); + if (ret >= 0) + parents[i] = cprman->real_parent_names[ret]; } memset(, 0, sizeof(init)); -- 1.7.12.4