LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 00/33] use match_string() helper
@ 2018-05-21 11:57 Yisheng Xie
  2018-05-21 11:57 ` [PATCH 01/33] usb: phy: " Yisheng Xie
                   ` (33 more replies)
  0 siblings, 34 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie

Andy introduce helper function match_string() which can be used to return
the index of array for a matching string. so we can use it in many places
intead of open coded variant.

I just try to make this API be used more commonly, sorry if this makes
too much big patchset.

Yisheng Xie (33):
  usb: phy: use match_string() helper
  mfd: omap-usb-host: use match_string() helper
  Staging: gdm724x: use match_string() helper
  gpiolib-of: use match_string() helper
  cxgb4: use match_string() helper
  hp100: use match_string() helper
  iwlwifi: mvm: use match_string() helper
  vfio: use match_string() helper
  phy: tegra: use match_string() helper
  pata_hpt37x: use match_string() helper
  bus: fsl-mc: use match_string() helper
  clk: bcm2835: use match_string() helper
  clk: rockchip: use match_string() helper
  clk: use match_string() helper
  cpufreq: intel_pstate: use match_string() helper
  mmc: sdhci-xenon: use match_string() helper
  pinctrl: armada-37xx: use match_string() helper
  power: supply: use match_string() helper
  thermal: db8500: use match_string() helper
  video: fbdev: pxafb: use match_string() helper
  drm/nouveau: use match_string() helper
  drm/i915: use match_string() helper
  drm: i2c: ch7006: use match_string() helper
  drm: use match_string() helper
  ima: use match_string() helper
  apparmor: use match_string() helper
  sched/debug: use match_string() helper
  ALSA: dice use match_string() helper
  ALSA: oxfw: use match_string() helper
  ALSA: oxygen: use match_string() helper
  ASoC: max98088: use match_string() helper
  ASoC: max98095: use match_string() helper
  ASoC: dapm: use match_string() helper

 drivers/ata/pata_hpt37x.c                        | 13 +++++-------
 drivers/bus/fsl-mc/fsl-mc-allocator.c            | 24 +++++------------------
 drivers/clk/bcm/clk-bcm2835.c                    | 14 ++++++-------
 drivers/clk/clk.c                                |  8 ++------
 drivers/clk/rockchip/clk.c                       | 16 +++++----------
 drivers/cpufreq/intel_pstate.c                   | 15 ++++++--------
 drivers/gpio/gpiolib-of.c                        |  7 +------
 drivers/gpu/drm/drm_panel_orientation_quirks.c   |  7 ++-----
 drivers/gpu/drm/i2c/ch7006_drv.c                 | 13 +++++-------
 drivers/gpu/drm/i915/intel_pipe_crc.c            | 22 ++++++++++-----------
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c        | 13 +++++-------
 drivers/mfd/omap-usb-host.c                      | 24 ++---------------------
 drivers/mmc/host/sdhci-xenon-phy.c               | 11 +++--------
 drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c   | 14 ++++---------
 drivers/net/ethernet/hp/hp100.c                  |  9 +--------
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 11 +++--------
 drivers/phy/tegra/xusb.c                         | 15 +-------------
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c      | 16 ++-------------
 drivers/power/supply/power_supply_core.c         | 16 ++++++---------
 drivers/staging/gdm724x/gdm_tty.c                | 16 ++++-----------
 drivers/thermal/db8500_thermal.c                 |  8 +++-----
 drivers/usb/phy/of.c                             | 12 +++++-------
 drivers/vfio/vfio.c                              | 11 +++--------
 drivers/video/fbdev/pxafb.c                      |  6 ++----
 kernel/sched/debug.c                             | 20 +++++++++----------
 security/apparmor/lsm.c                          | 25 +++++++++++-------------
 security/integrity/ima/ima_main.c                | 11 ++++-------
 sound/firewire/dice/dice.c                       |  8 +-------
 sound/firewire/oxfw/oxfw.c                       |  8 +-------
 sound/pci/oxygen/oxygen_mixer.c                  | 13 ++++++------
 sound/soc/codecs/max98088.c                      |  9 +++------
 sound/soc/codecs/max98095.c                      | 11 ++++-------
 sound/soc/soc-dapm.c                             | 18 +++++++----------
 33 files changed, 137 insertions(+), 307 deletions(-)

-- 
1.7.12.4

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

* [PATCH 01/33] usb: phy: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 22:20   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 02/33] mfd: omap-usb-host: " Yisheng Xie
                   ` (32 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, linux-usb, Felipe Balbi, Greg Kroah-Hartman

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: linux-usb@vger.kernel.org
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/usb/phy/of.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
index 1ab134f..5777c9f 100644
--- a/drivers/usb/phy/of.c
+++ b/drivers/usb/phy/of.c
@@ -28,16 +28,14 @@
 enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
 {
 	const char *phy_type;
-	int err, i;
+	int ret;
 
-	err = of_property_read_string(np, "phy_type", &phy_type);
-	if (err < 0)
+	ret = of_property_read_string(np, "phy_type", &phy_type);
+	if (ret < 0)
 		return USBPHY_INTERFACE_MODE_UNKNOWN;
 
-	for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
-		if (!strcmp(phy_type, usbphy_modes[i]))
-			return i;
+	ret = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type);
 
-	return USBPHY_INTERFACE_MODE_UNKNOWN;
+	return (ret < 0) ? USBPHY_INTERFACE_MODE_UNKNOWN : ret;
 }
 EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
-- 
1.7.12.4

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

* [PATCH 02/33] mfd: omap-usb-host: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
  2018-05-21 11:57 ` [PATCH 01/33] usb: phy: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 17:41   ` Tony Lindgren
  2018-06-04  6:15   ` Lee Jones
  2018-05-21 11:57 ` [PATCH 03/33] Staging: gdm724x: " Yisheng Xie
                   ` (31 subsequent siblings)
  33 siblings, 2 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Tony Lindgren, Lee Jones, linux-omap

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/mfd/omap-usb-host.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 7aab376..e11ab12 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -153,27 +153,6 @@ static inline u32 usbhs_read(void __iomem *base, u32 reg)
 	[OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM]	= "ohci-tll-2pin-dpdm",
 };
 
-/**
- * omap_usbhs_get_dt_port_mode - Get the 'enum usbhs_omap_port_mode'
- * from the port mode string.
- * @mode: The port mode string, usually obtained from device tree.
- *
- * The function returns the 'enum usbhs_omap_port_mode' that matches the
- * provided port mode string as per the port_modes table.
- * If no match is found it returns -ENODEV
- */
-static int omap_usbhs_get_dt_port_mode(const char *mode)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(port_modes); i++) {
-		if (!strcmp(mode, port_modes[i]))
-			return i;
-	}
-
-	return -ENODEV;
-}
-
 static struct platform_device *omap_usbhs_alloc_child(const char *name,
 			struct resource	*res, int num_resources, void *pdata,
 			size_t pdata_size, struct device *dev)
@@ -529,7 +508,8 @@ static int usbhs_omap_get_dt_pdata(struct device *dev,
 		if (ret < 0)
 			continue;
 
-		ret = omap_usbhs_get_dt_port_mode(mode);
+		/* get 'enum usbhs_omap_port_mode' from port mode string */
+		ret = match_string(port_modes, ARRAY_SIZE(port_modes), mode);
 		if (ret < 0) {
 			dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n",
 					i, mode);
-- 
1.7.12.4

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

* [PATCH 03/33] Staging: gdm724x: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
  2018-05-21 11:57 ` [PATCH 01/33] usb: phy: " Yisheng Xie
  2018-05-21 11:57 ` [PATCH 02/33] mfd: omap-usb-host: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:35   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 04/33] gpiolib-of: " Yisheng Xie
                   ` (30 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Greg Kroah-Hartman, Quytelda Kahja, devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Quytelda Kahja <quytelda@tamalin.org>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/staging/gdm724x/gdm_tty.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index 3cdebb8..ba53a06 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -65,22 +65,14 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
 {
 	struct gdm *gdm = NULL;
 	int ret;
-	int i;
-	int j;
-
-	j = GDM_TTY_MINOR;
-	for (i = 0; i < TTY_MAX_COUNT; i++) {
-		if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) {
-			j = tty->index;
-			break;
-		}
-	}
 
-	if (j == GDM_TTY_MINOR)
+	ret = match_string((const char **)DRIVER_STRING,
+			   TTY_MAX_COUNT, tty->driver->driver_name);
+	if (ret < 0 || tty->index == GDM_TTY_MINOR)
 		return -ENODEV;
 
 	mutex_lock(&gdm_table_lock);
-	gdm = gdm_table[i][j];
+	gdm = gdm_table[ret][tty->index];
 	if (!gdm) {
 		mutex_unlock(&gdm_table_lock);
 		return -ENODEV;
-- 
1.7.12.4

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

* [PATCH 04/33] gpiolib-of: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (2 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 03/33] Staging: gdm724x: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:36   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 05/33] cxgb4: " Yisheng Xie
                   ` (29 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Linus Walleij, linux-gpio

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/gpio/gpiolib-of.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 586d151..9cbc898 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -202,7 +202,6 @@ static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *
 	};
 	struct device_node *np = dev->of_node;
 	struct gpio_desc *desc;
-	int i;
 
 	if (!IS_ENABLED(CONFIG_REGULATOR))
 		return ERR_PTR(-ENOENT);
@@ -210,11 +209,7 @@ static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *
 	if (!con_id)
 		return ERR_PTR(-ENOENT);
 
-	for (i = 0; i < ARRAY_SIZE(whitelist); i++)
-		if (!strcmp(con_id, whitelist[i]))
-			break;
-
-	if (i == ARRAY_SIZE(whitelist))
+	if (match_string(whitelist, ARRAY_SIZE(whitelist), con_id) < 0)
 		return ERR_PTR(-ENOENT);
 
 	desc = of_get_named_gpiod_flags(np, con_id, 0, of_flags);
-- 
1.7.12.4

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

* [PATCH 05/33] cxgb4: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (3 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 04/33] gpiolib-of: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:39   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 06/33] hp100: " Yisheng Xie
                   ` (28 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Ganesh Goudar, netdev

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Ganesh Goudar <ganeshgr@chelsio.com>
Cc: netdev@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
index 9da6f57..bd61610 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
@@ -782,17 +782,11 @@ static int cudbg_get_mem_region(struct adapter *padap,
 	if (rc)
 		return rc;
 
-	for (i = 0; i < ARRAY_SIZE(cudbg_region); i++) {
-		if (!strcmp(cudbg_region[i], region_name)) {
-			found = 1;
-			idx = i;
-			break;
-		}
-	}
-	if (!found)
-		return -EINVAL;
+	rc = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name);
+	if (rc < 0)
+		return rc;
 
-	found = 0;
+	idx = rc;
 	for (i = 0; i < meminfo->mem_c; i++) {
 		if (meminfo->mem[i].idx >= ARRAY_SIZE(cudbg_region))
 			continue; /* Skip holes */
-- 
1.7.12.4

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

* [PATCH 06/33] hp100: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (4 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 05/33] cxgb4: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 11:57 ` [PATCH 07/33] iwlwifi: mvm: " Yisheng Xie
                   ` (27 subsequent siblings)
  33 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Jaroslav Kysela, netdev

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: netdev@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/net/ethernet/hp/hp100.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c
index c8c7ad2..84501b3 100644
--- a/drivers/net/ethernet/hp/hp100.c
+++ b/drivers/net/ethernet/hp/hp100.c
@@ -335,7 +335,6 @@ static const char *hp100_read_id(int ioaddr)
 static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr)
 {
 	const char *sig;
-	int i;
 
 	if (!request_region(ioaddr, HP100_REGION_SIZE, "hp100"))
 		goto err;
@@ -351,13 +350,7 @@ static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr)
 	if (sig == NULL)
 		goto err;
 
-	for (i = 0; i < ARRAY_SIZE(hp100_isa_tbl); i++) {
-		if (!strcmp(hp100_isa_tbl[i], sig))
-			break;
-
-	}
-
-	if (i < ARRAY_SIZE(hp100_isa_tbl))
+	if (match_string(hp100_isa_tbl, ARRAY_SIZE(hp100_isa_tbl), sig) >= 0)
 		return hp100_probe1(dev, ioaddr, HP100_BUS_ISA, NULL);
  err:
 	return -ENODEV;
-- 
1.7.12.4

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

* [PATCH 07/33] iwlwifi: mvm: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (5 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 06/33] hp100: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 20:12   ` Luca Coelho
  2018-05-21 21:43   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 08/33] vfio: " Yisheng Xie
                   ` (26 subsequent siblings)
  33 siblings, 2 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Kalle Valo, Intel Linux Wireless, Johannes Berg,
	Emmanuel Grumbach, linux-wireless, netdev

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: Intel Linux Wireless <linuxwifi@intel.com>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 0e6401c..e8249a6 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -671,14 +671,9 @@ static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
 	};
 	int ret, bt_force_ant_mode;
 
-	for (bt_force_ant_mode = 0;
-	     bt_force_ant_mode < ARRAY_SIZE(modes_str);
-	     bt_force_ant_mode++) {
-		if (!strcmp(buf, modes_str[bt_force_ant_mode]))
-			break;
-	}
-
-	if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
+	bt_force_ant_mode = match_string(modes_str,
+					 ARRAY_SIZE(modes_str), buf);
+	if (bt_force_ant_mode < 0)
 		return -EINVAL;
 
 	ret = 0;
-- 
1.7.12.4

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

* [PATCH 08/33] vfio: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (6 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 07/33] iwlwifi: mvm: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-25 20:55   ` Alex Williamson
  2018-05-21 11:57 ` [PATCH 09/33] phy: tegra: " Yisheng Xie
                   ` (25 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Alex Williamson, kvm

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/vfio/vfio.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 721f97f..6483387 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -630,8 +630,6 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group,
 
 static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv)
 {
-	int i;
-
 	if (dev_is_pci(dev)) {
 		struct pci_dev *pdev = to_pci_dev(dev);
 
@@ -639,12 +637,9 @@ static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv)
 			return true;
 	}
 
-	for (i = 0; i < ARRAY_SIZE(vfio_driver_whitelist); i++) {
-		if (!strcmp(drv->name, vfio_driver_whitelist[i]))
-			return true;
-	}
-
-	return false;
+	return match_string(vfio_driver_whitelist,
+			    ARRAY_SIZE(vfio_driver_whitelist),
+			    drv->name) >= 0;
 }
 
 /*
-- 
1.7.12.4

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

* [PATCH 09/33] phy: tegra: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (7 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 08/33] vfio: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:45   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 10/33] pata_hpt37x: " Yisheng Xie
                   ` (24 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Kishon Vijay Abraham I, Thierry Reding, Jonathan Hunter

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/phy/tegra/xusb.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 11aa590..de1b4eb 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -102,19 +102,6 @@ static struct phy *tegra_xusb_pad_of_xlate(struct device *dev,
 	return np;
 }
 
-static int
-tegra_xusb_lane_lookup_function(struct tegra_xusb_lane *lane,
-				    const char *function)
-{
-	unsigned int i;
-
-	for (i = 0; i < lane->soc->num_funcs; i++)
-		if (strcmp(function, lane->soc->funcs[i]) == 0)
-			return i;
-
-	return -EINVAL;
-}
-
 int tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane,
 			     struct device_node *np)
 {
@@ -126,7 +113,7 @@ int tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane,
 	if (err < 0)
 		return err;
 
-	err = tegra_xusb_lane_lookup_function(lane, function);
+	err = match_string(lane->soc->funcs, lane->soc->num_funcs, function);
 	if (err < 0) {
 		dev_err(dev, "invalid function \"%s\" for lane \"%s\"\n",
 			function, np->name);
-- 
1.7.12.4

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

* [PATCH 10/33] pata_hpt37x: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (8 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 09/33] phy: tegra: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:46   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 11/33] bus: fsl-mc: " Yisheng Xie
                   ` (23 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Bartlomiej Zolnierkiewicz, Tejun Heo, linux-ide

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: linux-ide@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/ata/pata_hpt37x.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 3ba843f..ef8aaeb 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -224,17 +224,14 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
 			       const char * const list[])
 {
 	unsigned char model_num[ATA_ID_PROD_LEN + 1];
-	int i = 0;
+	int i;
 
 	ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
 
-	while (list[i] != NULL) {
-		if (!strcmp(list[i], model_num)) {
-			pr_warn("%s is not supported for %s\n",
-				modestr, list[i]);
-			return 1;
-		}
-		i++;
+	i = match_string(list, -1, model_num);
+	if (i >= 0) {
+		pr_warn("%s is not supported for %s\n", modestr, list[i]);
+		return 1;
 	}
 	return 0;
 }
-- 
1.7.12.4

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

* [PATCH 11/33] bus: fsl-mc: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (9 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 10/33] pata_hpt37x: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 11:57 ` [PATCH 12/33] clk: bcm2835: " Yisheng Xie
                   ` (22 subsequent siblings)
  33 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Stuart Yoder, Laurentiu Tudor

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Stuart Yoder <stuyoder@gmail.com>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/bus/fsl-mc/fsl-mc-allocator.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index fb1442b..63c4735 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -156,22 +156,6 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
 	[FSL_MC_POOL_IRQ] = "irq",
 };
 
-static int __must_check object_type_to_pool_type(const char *object_type,
-						 enum fsl_mc_pool_type
-								*pool_type)
-{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(fsl_mc_pool_type_strings); i++) {
-		if (strcmp(object_type, fsl_mc_pool_type_strings[i]) == 0) {
-			*pool_type = i;
-			return 0;
-		}
-	}
-
-	return -EINVAL;
-}
-
 int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
 					  enum fsl_mc_pool_type pool_type,
 					  struct fsl_mc_resource **new_resource)
@@ -581,9 +565,11 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev)
 		return -EINVAL;
 
 	mc_bus = to_fsl_mc_bus(mc_bus_dev);
-	error = object_type_to_pool_type(mc_dev->obj_desc.type, &pool_type);
-	if (error < 0)
-		return error;
+	pool_type = match_string(fsl_mc_pool_type_strings,
+				 ARRAY_SIZE(fsl_mc_pool_type_strings),
+				 mc_dev->obj_desc.type);
+	if (pool_type < 0)
+		return pool_type;
 
 	error = fsl_mc_resource_pool_add_device(mc_bus, pool_type, mc_dev);
 	if (error < 0)
-- 
1.7.12.4

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

* [PATCH 12/33] clk: bcm2835: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (10 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 11/33] bus: fsl-mc: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 17:48   ` Eric Anholt
  2018-05-21 21:50   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 13/33] clk: rockchip: " Yisheng Xie
                   ` (21 subsequent siblings)
  33 siblings, 2 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Michael Turquette, Stephen Boyd, Eric Anholt,
	Stefan Wahren, linux-clk, linux-rpi-kernel, linux-arm-kernel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: linux-clk@vger.kernel.org
Cc: linux-rpi-kernel@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/clk/bcm/clk-bcm2835.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index fa0d5c8..a27c0d2 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1395,8 +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;
-	int ret;
+	int i, ret;
 
 	/*
 	 * Replace our strings referencing parent clocks with the
@@ -1405,12 +1404,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(&init, 0, sizeof(init));
-- 
1.7.12.4

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

* [PATCH 13/33] clk: rockchip: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (11 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 12/33] clk: bcm2835: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-22 13:56   ` Heiko Stuebner
  2018-05-21 11:57 ` [PATCH 14/33] clk: " Yisheng Xie
                   ` (20 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Michael Turquette, Stephen Boyd, Heiko Stuebner,
	linux-clk, linux-arm-kernel, linux-rockchip

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-clk@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/clk/rockchip/clk.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index 3cd8ad5..514032d 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -274,18 +274,10 @@ static struct clk *rockchip_clk_register_frac_branch(
 		struct clk_mux *frac_mux = &frac->mux;
 		struct clk_init_data init;
 		struct clk *mux_clk;
-		int i, ret;
-
-		frac->mux_frac_idx = -1;
-		for (i = 0; i < child->num_parents; i++) {
-			if (!strcmp(name, child->parent_names[i])) {
-				pr_debug("%s: found fractional parent in mux at pos %d\n",
-					 __func__, i);
-				frac->mux_frac_idx = i;
-				break;
-			}
-		}
+		int ret;
 
+		frac->mux_frac_idx = match_string(child->parent_names,
+						  child->num_parents, name);
 		frac->mux_ops = &clk_mux_ops;
 		frac->clk_nb.notifier_call = rockchip_clk_frac_notifier_cb;
 
@@ -312,6 +304,8 @@ static struct clk *rockchip_clk_register_frac_branch(
 
 		/* notifier on the fraction divider to catch rate changes */
 		if (frac->mux_frac_idx >= 0) {
+			pr_debug("%s: find fractional parent in mux at pos %d\n",
+				 __func__, frac->mux_frac_idx);
 			ret = clk_notifier_register(clk, &frac->clk_nb);
 			if (ret)
 				pr_err("%s: failed to register clock notifier for %s\n",
-- 
1.7.12.4

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

* [PATCH 14/33] clk: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (12 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 13/33] clk: rockchip: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:53   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 15/33] cpufreq: intel_pstate: " Yisheng Xie
                   ` (19 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Michael Turquette, Stephen Boyd, linux-clk

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/clk/clk.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7af555f..4469eca 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2171,7 +2171,6 @@ void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent)
 bool clk_has_parent(struct clk *clk, struct clk *parent)
 {
 	struct clk_core *core, *parent_core;
-	unsigned int i;
 
 	/* NULL clocks should be nops, so return success if either is NULL. */
 	if (!clk || !parent)
@@ -2184,11 +2183,8 @@ bool clk_has_parent(struct clk *clk, struct clk *parent)
 	if (core->parent == parent_core)
 		return true;
 
-	for (i = 0; i < core->num_parents; i++)
-		if (strcmp(core->parent_names[i], parent_core->name) == 0)
-			return true;
-
-	return false;
+	return match_string(core->parent_names,
+			    core->num_parents, parent_core->name) >= 0;
 }
 EXPORT_SYMBOL_GPL(clk_has_parent);
 
-- 
1.7.12.4

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

* [PATCH 15/33] cpufreq: intel_pstate: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (13 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 14/33] clk: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 11:57 ` [PATCH 16/33] mmc: sdhci-xenon: " Yisheng Xie
                   ` (18 subsequent siblings)
  33 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Srinivas Pandruvada, Len Brown, Rafael J. Wysocki,
	Viresh Kumar, linux-pm

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/cpufreq/intel_pstate.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 17e566af..d701e26 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -645,21 +645,18 @@ static ssize_t store_energy_performance_preference(
 {
 	struct cpudata *cpu_data = all_cpu_data[policy->cpu];
 	char str_preference[21];
-	int ret, i = 0;
+	int ret;
 
 	ret = sscanf(buf, "%20s", str_preference);
 	if (ret != 1)
 		return -EINVAL;
 
-	while (energy_perf_strings[i] != NULL) {
-		if (!strcmp(str_preference, energy_perf_strings[i])) {
-			intel_pstate_set_energy_pref_index(cpu_data, i);
-			return count;
-		}
-		++i;
-	}
+	ret = match_string(energy_perf_strings, -1, str_preference);
+	if (ret < 0)
+		return ret;
 
-	return -EINVAL;
+	intel_pstate_set_energy_pref_index(cpu_data, ret);
+	return count;
 }
 
 static ssize_t show_energy_performance_preference(
-- 
1.7.12.4

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

* [PATCH 16/33] mmc: sdhci-xenon: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (14 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 15/33] cpufreq: intel_pstate: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-24  7:58   ` Adrian Hunter
  2018-05-28 11:27   ` Ulf Hansson
  2018-05-21 11:57 ` [PATCH 17/33] pinctrl: armada-37xx: " Yisheng Xie
                   ` (17 subsequent siblings)
  33 siblings, 2 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Adrian Hunter, Hu Ziji, Ulf Hansson, linux-mmc

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Hu Ziji <huziji@marvell.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/mmc/host/sdhci-xenon-phy.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c
index ec87943..a35804b 100644
--- a/drivers/mmc/host/sdhci-xenon-phy.c
+++ b/drivers/mmc/host/sdhci-xenon-phy.c
@@ -814,15 +814,10 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
-	int i, ret;
+	int ret;
 
-	for (i = 0; i < NR_PHY_TYPES; i++) {
-		if (!strcmp(phy_name, phy_types[i])) {
-			priv->phy_type = i;
-			break;
-		}
-	}
-	if (i == NR_PHY_TYPES) {
+	priv->phy_type = match_string(phy_types, NR_PHY_TYPES, phy_name);
+	if (priv->phy_type < 0) {
 		dev_err(mmc_dev(host->mmc),
 			"Unable to determine PHY name %s. Use default eMMC 5.1 PHY\n",
 			phy_name);
-- 
1.7.12.4

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

* [PATCH 17/33] pinctrl: armada-37xx: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (15 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 16/33] mmc: sdhci-xenon: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:55   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 18/33] power: supply: " Yisheng Xie
                   ` (16 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Jason Cooper, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Linus Walleij, linux-arm-kernel,
	linux-gpio

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 5b63248..e338327 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -214,18 +214,6 @@ static inline void armada_37xx_update_reg(unsigned int *reg,
 	}
 }
 
-static int armada_37xx_get_func_reg(struct armada_37xx_pin_group *grp,
-				    const char *func)
-{
-	int f;
-
-	for (f = 0; (f < NB_FUNCS) && grp->funcs[f]; f++)
-		if (!strcmp(grp->funcs[f], func))
-			return f;
-
-	return -ENOTSUPP;
-}
-
 static struct armada_37xx_pin_group *armada_37xx_find_next_grp_by_pin(
 	struct armada_37xx_pinctrl *info, int pin, int *grp)
 {
@@ -344,10 +332,10 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev,
 	dev_dbg(info->dev, "enable function %s group %s\n",
 		name, grp->name);
 
-	func = armada_37xx_get_func_reg(grp, name);
+	func = match_string(grp->funcs, NB_FUNCS, name);
 
 	if (func < 0)
-		return func;
+		return -ENOTSUPP;
 
 	val = grp->val[func];
 
-- 
1.7.12.4

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

* [PATCH 18/33] power: supply: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (16 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 17/33] pinctrl: armada-37xx: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 21:58   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 19/33] thermal: db8500: " Yisheng Xie
                   ` (15 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Sebastian Reichel, linux-pm

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/power/supply/power_supply_core.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index feac7b0..84da3a2 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -36,8 +36,6 @@
 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
 					 struct power_supply *supply)
 {
-	int i;
-
 	if (!supply->supplied_from && !supplier->supplied_to)
 		return false;
 
@@ -45,18 +43,16 @@ static bool __power_supply_is_supplied_by(struct power_supply *supplier,
 	if (supply->supplied_from) {
 		if (!supplier->desc->name)
 			return false;
-		for (i = 0; i < supply->num_supplies; i++)
-			if (!strcmp(supplier->desc->name, supply->supplied_from[i]))
-				return true;
+		return match_string((const char **)supply->supplied_from,
+				    supply->num_supplies,
+				    supplier->desc->name) >= 0;
 	} else {
 		if (!supply->desc->name)
 			return false;
-		for (i = 0; i < supplier->num_supplicants; i++)
-			if (!strcmp(supplier->supplied_to[i], supply->desc->name))
-				return true;
+		return match_string((const char **)supplier->supplied_to,
+				    supplier->num_supplicants,
+				    supply->desc->name) >= 0;
 	}
-
-	return false;
 }
 
 static int __power_supply_changed_work(struct device *dev, void *data)
-- 
1.7.12.4

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

* [PATCH 19/33] thermal: db8500: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (17 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 18/33] power: supply: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 22:00   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 20/33] video: fbdev: pxafb: " Yisheng Xie
                   ` (14 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Zhang Rui, Eduardo Valentin, linux-pm

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/thermal/db8500_thermal.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c
index f491faf..dd83614 100644
--- a/drivers/thermal/db8500_thermal.c
+++ b/drivers/thermal/db8500_thermal.c
@@ -50,12 +50,10 @@ static int db8500_thermal_match_cdev(struct thermal_cooling_device *cdev,
 	if (!strlen(cdev->type))
 		return -EINVAL;
 
-	for (i = 0; i < COOLING_DEV_MAX; i++) {
-		if (!strcmp(trip_point->cdev_name[i], cdev->type))
-			return 0;
-	}
+	i = match_string((const char **)trip_point->cdev_name,
+			 COOLING_DEV_MAX, cdev->type);
 
-	return -ENODEV;
+	return (i < 0) ? -ENODEV : 0;
 }
 
 /* Callback to bind cooling device to thermal zone */
-- 
1.7.12.4

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

* [PATCH 20/33] video: fbdev: pxafb: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (18 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 19/33] thermal: db8500: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 22:01   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 21/33] drm/nouveau: " Yisheng Xie
                   ` (13 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Bartlomiej Zolnierkiewicz, Arvind Yadav, dri-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: dri-devel@lists.freedesktop.org
linux-fbdev@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/video/fbdev/pxafb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index c3d49e1..702193d 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -2115,10 +2115,8 @@ static int of_get_pxafb_display(struct device *dev, struct device_node *disp,
 	if (ret)
 		s = "color-tft";
 
-	for (i = 0; lcd_types[i]; i++)
-		if (!strcmp(s, lcd_types[i]))
-			break;
-	if (!i || !lcd_types[i]) {
+	i = match_string(lcd_types, -1, s);
+	if (i <= 0) {
 		dev_err(dev, "lcd-type %s is unknown\n", s);
 		return -EINVAL;
 	}
-- 
1.7.12.4

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

* [PATCH 21/33] drm/nouveau: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (19 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 20/33] video: fbdev: pxafb: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 22:03   ` Andy Shevchenko
  2018-05-21 11:57 ` [PATCH 22/33] drm/i915: " Yisheng Xie
                   ` (12 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Ben Skeggs, David Airlie, dri-devel, nouveau

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
index 6d99f11..a6b4c4a 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
@@ -644,14 +644,11 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder,
 	int i;
 
 	if (nouveau_tv_norm) {
-		for (i = 0; i < num_tv_norms; i++) {
-			if (!strcmp(nv17_tv_norm_names[i], nouveau_tv_norm)) {
-				tv_enc->tv_norm = i;
-				break;
-			}
-		}
-
-		if (i == num_tv_norms)
+		i = match_string(nv17_tv_norm_names,
+				 num_tv_norms, nouveau_tv_norm);
+		if (i >= 0)
+			tv_enc->tv_norm = i;
+		else
 			NV_WARN(drm, "Invalid TV norm setting \"%s\"\n",
 				nouveau_tv_norm);
 	}
-- 
1.7.12.4

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

* [PATCH 22/33] drm/i915: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (20 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 21/33] drm/nouveau: " Yisheng Xie
@ 2018-05-21 11:57 ` Yisheng Xie
  2018-05-21 22:04   ` Andy Shevchenko
  2018-05-21 11:58 ` [PATCH 23/33] drm: i2c: ch7006: " Yisheng Xie
                   ` (11 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	David Airlie, intel-gfx, dri-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: David Airlie <airlied@linux.ie>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/gpu/drm/i915/intel_pipe_crc.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_pipe_crc.c b/drivers/gpu/drm/i915/intel_pipe_crc.c
index 1f5cd57..f6b1335 100644
--- a/drivers/gpu/drm/i915/intel_pipe_crc.c
+++ b/drivers/gpu/drm/i915/intel_pipe_crc.c
@@ -764,13 +764,12 @@ enum intel_pipe_crc_object {
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(pipe_crc_objects); i++)
-		if (!strcmp(buf, pipe_crc_objects[i])) {
-			*o = i;
-			return 0;
-		}
+	i = match_string(pipe_crc_objects, ARRAY_SIZE(pipe_crc_objects), buf);
+	if (i < 0)
+		return -EINVAL;
 
-	return -EINVAL;
+	*o = i;
+	return 0;
 }
 
 static int display_crc_ctl_parse_pipe(struct drm_i915_private *dev_priv,
@@ -796,13 +795,12 @@ static int display_crc_ctl_parse_pipe(struct drm_i915_private *dev_priv,
 		return 0;
 	}
 
-	for (i = 0; i < ARRAY_SIZE(pipe_crc_sources); i++)
-		if (!strcmp(buf, pipe_crc_sources[i])) {
-			*s = i;
-			return 0;
-		}
+	i = match_string(pipe_crc_sources, ARRAY_SIZE(pipe_crc_sources), buf);
+	if (i < 0)
+		return -EINVAL;
 
-	return -EINVAL;
+	*s = i;
+	return 0;
 }
 
 static int display_crc_ctl_parse(struct drm_i915_private *dev_priv,
-- 
1.7.12.4

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

* [PATCH 23/33] drm: i2c: ch7006: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (21 preceding siblings ...)
  2018-05-21 11:57 ` [PATCH 22/33] drm/i915: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 11:58 ` [PATCH 24/33] drm: " Yisheng Xie
                   ` (10 subsequent siblings)
  33 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, David Airlie, Daniel Vetter, Arvind Yadav, dri-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: David Airlie <airlied@linux.ie>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/gpu/drm/i2c/ch7006_drv.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c
index 544a8a2..405c7fb 100644
--- a/drivers/gpu/drm/i2c/ch7006_drv.c
+++ b/drivers/gpu/drm/i2c/ch7006_drv.c
@@ -464,14 +464,11 @@ static int ch7006_encoder_init(struct i2c_client *client,
 	priv->chip_version = ch7006_read(client, CH7006_VERSION_ID);
 
 	if (ch7006_tv_norm) {
-		for (i = 0; i < NUM_TV_NORMS; i++) {
-			if (!strcmp(ch7006_tv_norm_names[i], ch7006_tv_norm)) {
-				priv->norm = i;
-				break;
-			}
-		}
-
-		if (i == NUM_TV_NORMS)
+		i = match_string(ch7006_tv_norm_names,
+				 NUM_TV_NORMS, ch7006_tv_norm);
+		if (i >= 0)
+			priv->norm = i;
+		else
 			ch7006_err(client, "Invalid TV norm setting \"%s\".\n",
 				   ch7006_tv_norm);
 	}
-- 
1.7.12.4

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

* [PATCH 24/33] drm: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (22 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 23/33] drm: i2c: ch7006: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 22:06   ` Andy Shevchenko
  2018-05-21 11:58 ` [PATCH 25/33] ima: " Yisheng Xie
                   ` (9 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Gustavo Padovan, Maarten Lankhorst, Sean Paul,
	David Airlie, dri-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 drivers/gpu/drm/drm_panel_orientation_quirks.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index 902cc1a..3367c36 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -136,7 +136,6 @@ int drm_get_panel_orientation_quirk(int width, int height)
 	const struct dmi_system_id *match;
 	const struct drm_dmi_panel_orientation_data *data;
 	const char *bios_date;
-	int i;
 
 	for (match = dmi_first_match(orientation_data);
 	     match;
@@ -154,10 +153,8 @@ int drm_get_panel_orientation_quirk(int width, int height)
 		if (!bios_date)
 			continue;
 
-		for (i = 0; data->bios_dates[i]; i++) {
-			if (!strcmp(data->bios_dates[i], bios_date))
-				return data->orientation;
-		}
+		if (match_string(data->bios_dates, -1, bios_date) >= 0)
+			return data->orientation;
 	}
 
 	return DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
-- 
1.7.12.4

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

* [PATCH 25/33] ima: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (23 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 24/33] drm: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-23 14:42   ` Mimi Zohar
  2018-05-21 11:58 ` [PATCH 26/33] apparmor: " Yisheng Xie
                   ` (8 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Mimi Zohar, Dmitry Kasatkin, James Morris,
	Serge E. Hallyn, linux-integrity, linux-security-module

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-integrity@vger.kernel.org
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 security/integrity/ima/ima_main.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 74d0bd7..f807093 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -61,14 +61,11 @@ static int __init hash_setup(char *str)
 		goto out;
 	}
 
-	for (i = 0; i < HASH_ALGO__LAST; i++) {
-		if (strcmp(str, hash_algo_name[i]) == 0) {
-			ima_hash_algo = i;
-			break;
-		}
-	}
-	if (i == HASH_ALGO__LAST)
+	i = match_string(hash_algo_name, HASH_ALGO__LAST, str);
+	if (i < 0)
 		return 1;
+
+	ima_hash_algo = i;
 out:
 	hash_setup_done = 1;
 	return 1;
-- 
1.7.12.4


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

* [PATCH 26/33] apparmor: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (24 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 25/33] ima: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 15:33   ` John Johansen
  2018-05-21 22:10   ` Andy Shevchenko
  2018-05-21 11:58 ` [PATCH 27/33] sched/debug: " Yisheng Xie
                   ` (7 subsequent siblings)
  33 siblings, 2 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, John Johansen, James Morris, Serge E. Hallyn,
	linux-security-module

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: John Johansen <john.johansen@canonical.com>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 security/apparmor/lsm.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index ce2b89e..9b5904f 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -1378,14 +1378,12 @@ static int param_set_audit(const char *val, const struct kernel_param *kp)
 	if (apparmor_initialized && !policy_admin_capable(NULL))
 		return -EPERM;
 
-	for (i = 0; i < AUDIT_MAX_INDEX; i++) {
-		if (strcmp(val, audit_mode_names[i]) == 0) {
-			aa_g_audit = i;
-			return 0;
-		}
-	}
+	i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
+	if (i < 0)
+		return -EINVAL;
 
-	return -EINVAL;
+	aa_g_audit = i;
+	return 0;
 }
 
 static int param_get_mode(char *buffer, const struct kernel_param *kp)
@@ -1409,14 +1407,13 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
 	if (apparmor_initialized && !policy_admin_capable(NULL))
 		return -EPERM;
 
-	for (i = 0; i < APPARMOR_MODE_NAMES_MAX_INDEX; i++) {
-		if (strcmp(val, aa_profile_mode_names[i]) == 0) {
-			aa_g_profile_mode = i;
-			return 0;
-		}
-	}
+	i = match_string(aa_profile_mode_names,
+			 APPARMOR_MODE_NAMES_MAX_INDEX, val);
+	if (i)
+		return -EINVAL;
 
-	return -EINVAL;
+	aa_g_profile_mode = i;
+	return 0;
 }
 
 /*
-- 
1.7.12.4


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

* [PATCH 27/33] sched/debug: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (25 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 26/33] apparmor: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 22:13   ` Andy Shevchenko
  2018-05-21 11:58 ` [PATCH 28/33] ALSA: dice " Yisheng Xie
                   ` (6 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Yisheng Xie, Ingo Molnar, Peter Zijlstra

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 kernel/sched/debug.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 15b10e2..9e34499 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -111,16 +111,14 @@ static int sched_feat_set(char *cmp)
 		cmp += 3;
 	}
 
-	for (i = 0; i < __SCHED_FEAT_NR; i++) {
-		if (strcmp(cmp, sched_feat_names[i]) == 0) {
-			if (neg) {
-				sysctl_sched_features &= ~(1UL << i);
-				sched_feat_disable(i);
-			} else {
-				sysctl_sched_features |= (1UL << i);
-				sched_feat_enable(i);
-			}
-			break;
+	i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
+	if (i >= 0) {
+		if (neg) {
+			sysctl_sched_features &= ~(1UL << i);
+			sched_feat_disable(i);
+		} else {
+			sysctl_sched_features |= (1UL << i);
+			sched_feat_enable(i);
 		}
 	}
 
@@ -150,7 +148,7 @@ static int sched_feat_set(char *cmp)
 	inode_lock(inode);
 	i = sched_feat_set(cmp);
 	inode_unlock(inode);
-	if (i == __SCHED_FEAT_NR)
+	if (i < 0)
 		return -EINVAL;
 
 	*ppos += cnt;
-- 
1.7.12.4

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

* [PATCH 28/33] ALSA: dice use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (26 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 27/33] sched/debug: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 22:31   ` Takashi Sakamoto
  2018-05-21 11:58 ` [PATCH 29/33] ALSA: oxfw: " Yisheng Xie
                   ` (5 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Clemens Ladisch, Jaroslav Kysela, Takashi Iwai,
	Takashi Sakamoto, alsa-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 sound/firewire/dice/dice.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
index 96bb01b..0639074 100644
--- a/sound/firewire/dice/dice.c
+++ b/sound/firewire/dice/dice.c
@@ -35,19 +35,13 @@ static bool force_two_pcm_support(struct fw_unit *unit)
 		"SAFFIRE_PRO_40_1",
 	};
 	char model[32];
-	unsigned int i;
 	int err;
 
 	err = fw_csr_string(unit->directory, CSR_MODEL, model, sizeof(model));
 	if (err < 0)
 		return false;
 
-	for (i = 0; i < ARRAY_SIZE(models); i++) {
-		if (strcmp(models[i], model) == 0)
-			break;
-	}
-
-	return i < ARRAY_SIZE(models);
+	return match_string(models, ARRAY_SIZE(models), model) >= 0;
 }
 
 static int check_dice_category(struct fw_unit *unit)
-- 
1.7.12.4

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

* [PATCH 29/33] ALSA: oxfw: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (27 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 28/33] ALSA: dice " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 22:26   ` [alsa-devel] " Takashi Sakamoto
  2018-05-21 11:58 ` [PATCH 30/33] ALSA: oxygen: " Yisheng Xie
                   ` (4 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Clemens Ladisch, Jaroslav Kysela, Takashi Iwai, alsa-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 sound/firewire/oxfw/oxfw.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
index 413ab63..1e5b2c8 100644
--- a/sound/firewire/oxfw/oxfw.c
+++ b/sound/firewire/oxfw/oxfw.c
@@ -49,7 +49,6 @@ static bool detect_loud_models(struct fw_unit *unit)
 		"Tapco LINK.firewire 4x6",
 		"U.420"};
 	char model[32];
-	unsigned int i;
 	int err;
 
 	err = fw_csr_string(unit->directory, CSR_MODEL,
@@ -57,12 +56,7 @@ static bool detect_loud_models(struct fw_unit *unit)
 	if (err < 0)
 		return false;
 
-	for (i = 0; i < ARRAY_SIZE(models); i++) {
-		if (strcmp(models[i], model) == 0)
-			break;
-	}
-
-	return (i < ARRAY_SIZE(models));
+	return match_string(models, ARRAY_SIZE(models), model) >= 0;
 }
 
 static int name_card(struct snd_oxfw *oxfw)
-- 
1.7.12.4

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

* [PATCH 30/33] ALSA: oxygen: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (28 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 29/33] ALSA: oxfw: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 22:23   ` Andy Shevchenko
  2018-05-21 11:58 ` [PATCH 31/33] ASoC: max98088: " Yisheng Xie
                   ` (3 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Clemens Ladisch, Jaroslav Kysela, Takashi Iwai, alsa-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 sound/pci/oxygen/oxygen_mixer.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 4ca1266..fbd8f5e 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -1052,10 +1052,9 @@ static int add_controls(struct oxygen *chip,
 		[CONTROL_CD_CAPTURE_SWITCH] = "CD Capture Switch",
 		[CONTROL_AUX_CAPTURE_SWITCH] = "Aux Capture Switch",
 	};
-	unsigned int i, j;
 	struct snd_kcontrol_new template;
 	struct snd_kcontrol *ctl;
-	int err;
+	int i, j, err;
 
 	for (i = 0; i < count; ++i) {
 		template = controls[i];
@@ -1086,11 +1085,11 @@ static int add_controls(struct oxygen *chip,
 		err = snd_ctl_add(chip->card, ctl);
 		if (err < 0)
 			return err;
-		for (j = 0; j < CONTROL_COUNT; ++j)
-			if (!strcmp(ctl->id.name, known_ctl_names[j])) {
-				chip->controls[j] = ctl;
-				ctl->private_free = oxygen_any_ctl_free;
-			}
+		j = match_string(known_ctl_names, CONTROL_COUNT, ctl->id.name);
+		if (j >= 0) {
+			chip->controls[j] = ctl;
+			ctl->private_free = oxygen_any_ctl_free;
+		}
 	}
 	return 0;
 }
-- 
1.7.12.4

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

* [PATCH 31/33] ASoC: max98088: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (29 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 30/33] ALSA: oxygen: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 22:24   ` Andy Shevchenko
  2018-05-21 11:58 ` [PATCH 32/33] ASoC: max98095: " Yisheng Xie
                   ` (2 subsequent siblings)
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 sound/soc/codecs/max98088.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index 865f64c..7383f90 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -1382,14 +1382,11 @@ static int max98088_set_bias_level(struct snd_soc_component *component,
 
 static int max98088_get_channel(struct snd_soc_component *component, const char *name)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(eq_mode_name); i++)
-		if (strcmp(name, eq_mode_name[i]) == 0)
-			return i;
+	int ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name);
 
 	/* Shouldn't happen */
-	dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
+	if (ret < 0)
+		dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
 	return -EINVAL;
 }
 
-- 
1.7.12.4

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

* [PATCH 32/33] ASoC: max98095: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (30 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 31/33] ASoC: max98088: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-21 22:25   ` Andy Shevchenko
  2018-05-21 11:58 ` [PATCH 33/33] ASoC: dapm: " Yisheng Xie
  2018-05-21 22:27 ` [PATCH 00/33] use match_string() helper Andy Shevchenko
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 sound/soc/codecs/max98095.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 6bf2d0b..0ef42dc 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -1634,15 +1634,12 @@ static void max98095_handle_eq_pdata(struct snd_soc_component *component)
 static int max98095_get_bq_channel(struct snd_soc_component *component,
 				   const char *name)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(bq_mode_name); i++)
-		if (strcmp(name, bq_mode_name[i]) == 0)
-			return i;
+	int ret = match_string(bq_mode_name, ARRAY_SIZE(bq_mode_name), name);
 
 	/* Shouldn't happen */
-	dev_err(component->dev, "Bad biquad channel name '%s'\n", name);
-	return -EINVAL;
+	if (ret < 0)
+		dev_err(component->dev, "Bad biquad channel name '%s'\n", name);
+	return ret;
 }
 
 static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
-- 
1.7.12.4

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

* [PATCH 33/33] ASoC: dapm: use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (31 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 32/33] ASoC: max98095: " Yisheng Xie
@ 2018-05-21 11:58 ` Yisheng Xie
  2018-05-31 16:09   ` Applied "ASoC: dapm: use match_string() helper" to the asoc tree Mark Brown
  2018-05-21 22:27 ` [PATCH 00/33] use match_string() helper Andy Shevchenko
  33 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yisheng Xie, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel

match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 sound/soc/soc-dapm.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2d97091..1e9a363 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -724,18 +724,14 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
 		item = 0;
 	}
 
-	for (i = 0; i < e->items; i++) {
-		if (!(strcmp(control_name, e->texts[i]))) {
-			path->name = e->texts[i];
-			if (i == item)
-				path->connect = 1;
-			else
-				path->connect = 0;
-			return 0;
-		}
-	}
+	i = match_string(e->texts, e->items, control_name);
+	if (i < 0)
+		return -ENODEV;
+
+	path->name = e->texts[i];
+	path->connect = (i == item);
+	return 0;
 
-	return -ENODEV;
 }
 
 /* set up initial codec paths */
-- 
1.7.12.4

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

* Re: [PATCH 26/33] apparmor: use match_string() helper
  2018-05-21 11:58 ` [PATCH 26/33] apparmor: " Yisheng Xie
@ 2018-05-21 15:33   ` John Johansen
  2018-05-22  1:25     ` Yisheng Xie
  2018-05-21 22:10   ` Andy Shevchenko
  1 sibling, 1 reply; 88+ messages in thread
From: John Johansen @ 2018-05-21 15:33 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel
  Cc: James Morris, Serge E. Hallyn, linux-security-module

On 05/21/2018 04:58 AM, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 

Andy Shevchenko patch to do the same thing is already in apparmor-next

> Cc: John Johansen <john.johansen@canonical.com>
> Cc: James Morris <jmorris@namei.org>
> Cc: "Serge E. Hallyn" <serge@hallyn.com>
> Cc: linux-security-module@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  security/apparmor/lsm.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> index ce2b89e..9b5904f 100644
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
> @@ -1378,14 +1378,12 @@ static int param_set_audit(const char *val, const struct kernel_param *kp)
>  	if (apparmor_initialized && !policy_admin_capable(NULL))
>  		return -EPERM;
>  
> -	for (i = 0; i < AUDIT_MAX_INDEX; i++) {
> -		if (strcmp(val, audit_mode_names[i]) == 0) {
> -			aa_g_audit = i;
> -			return 0;
> -		}
> -	}
> +	i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
> +	if (i < 0)
> +		return -EINVAL;
>  
> -	return -EINVAL;
> +	aa_g_audit = i;
> +	return 0;
>  }
>  
>  static int param_get_mode(char *buffer, const struct kernel_param *kp)
> @@ -1409,14 +1407,13 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
>  	if (apparmor_initialized && !policy_admin_capable(NULL))
>  		return -EPERM;
>  
> -	for (i = 0; i < APPARMOR_MODE_NAMES_MAX_INDEX; i++) {
> -		if (strcmp(val, aa_profile_mode_names[i]) == 0) {
> -			aa_g_profile_mode = i;
> -			return 0;
> -		}
> -	}
> +	i = match_string(aa_profile_mode_names,
> +			 APPARMOR_MODE_NAMES_MAX_INDEX, val);
> +	if (i)
> +		return -EINVAL;
>  
> -	return -EINVAL;
> +	aa_g_profile_mode = i;
> +	return 0;
>  }
>  
>  /*
> 


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

* Re: [PATCH 02/33] mfd: omap-usb-host: use match_string() helper
  2018-05-21 11:57 ` [PATCH 02/33] mfd: omap-usb-host: " Yisheng Xie
@ 2018-05-21 17:41   ` Tony Lindgren
  2018-06-04  6:15   ` Lee Jones
  1 sibling, 0 replies; 88+ messages in thread
From: Tony Lindgren @ 2018-05-21 17:41 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: linux-kernel, Lee Jones, linux-omap

* Yisheng Xie <xieyisheng1@huawei.com> [180521 12:11]:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

Looks OK to me:

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 12/33] clk: bcm2835: use match_string() helper
  2018-05-21 11:57 ` [PATCH 12/33] clk: bcm2835: " Yisheng Xie
@ 2018-05-21 17:48   ` Eric Anholt
  2018-05-21 21:50   ` Andy Shevchenko
  1 sibling, 0 replies; 88+ messages in thread
From: Eric Anholt @ 2018-05-21 17:48 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel
  Cc: Yisheng Xie, Michael Turquette, Stephen Boyd, Stefan Wahren,
	linux-clk, linux-rpi-kernel, linux-arm-kernel

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

Yisheng Xie <xieyisheng1@huawei.com> writes:

> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: Eric Anholt <eric@anholt.net>
> Cc: Stefan Wahren <stefan.wahren@i2se.com>
> Cc: linux-clk@vger.kernel.org
> Cc: linux-rpi-kernel@lists.infradead.org
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  drivers/clk/bcm/clk-bcm2835.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
> index fa0d5c8..a27c0d2 100644
> --- a/drivers/clk/bcm/clk-bcm2835.c
> +++ b/drivers/clk/bcm/clk-bcm2835.c
> @@ -1395,8 +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;
> -	int ret;
> +	int i, ret;
>  
>  	/*
>  	 * Replace our strings referencing parent clocks with the
> @@ -1405,12 +1404,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];

Reviewed-by: Eric Anholt <eric@anholt.net>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper
  2018-05-21 11:57 ` [PATCH 07/33] iwlwifi: mvm: " Yisheng Xie
@ 2018-05-21 20:12   ` Luca Coelho
  2018-05-21 21:43   ` Andy Shevchenko
  1 sibling, 0 replies; 88+ messages in thread
From: Luca Coelho @ 2018-05-21 20:12 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel
  Cc: Kalle Valo, Intel Linux Wireless, Johannes Berg,
	Emmanuel Grumbach, linux-wireless, netdev

On Mon, 2018-05-21 at 19:57 +0800, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Kalle Valo <kvalo@codeaurora.org>
> Cc: Intel Linux Wireless <linuxwifi@intel.com>
> Cc: Johannes Berg <johannes.berg@intel.com>
> Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
> b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
> index 0e6401c..e8249a6 100644
> --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
> +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
> @@ -671,14 +671,9 @@ static ssize_t iwl_dbgfs_bt_cmd_read(struct file
> *file, char __user *user_buf,
>  	};
>  	int ret, bt_force_ant_mode;
>  
> -	for (bt_force_ant_mode = 0;
> -	     bt_force_ant_mode < ARRAY_SIZE(modes_str);
> -	     bt_force_ant_mode++) {
> -		if (!strcmp(buf, modes_str[bt_force_ant_mode]))
> -			break;
> -	}
> -
> -	if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
> +	bt_force_ant_mode = match_string(modes_str,
> +					 ARRAY_SIZE(modes_str),
> buf);
> +	if (bt_force_ant_mode < 0)
>  		return -EINVAL;
>  
>  	ret = 0;

Looks fine, I'll push this to our internal tree for review and take a
closer look at what the match_string() function does exactly.

Thanks for the patch.

--
Cheers,
Luca.

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

* Re: [PATCH 03/33] Staging: gdm724x: use match_string() helper
  2018-05-21 11:57 ` [PATCH 03/33] Staging: gdm724x: " Yisheng Xie
@ 2018-05-21 21:35   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:35 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Greg Kroah-Hartman, Quytelda Kahja, devel

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.


> +       ret = match_string((const char **)DRIVER_STRING,
> +                          TTY_MAX_COUNT, tty->driver->driver_name);

It looks like DRIVER_STRING should be converted to const * const.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 04/33] gpiolib-of: use match_string() helper
  2018-05-21 11:57 ` [PATCH 04/33] gpiolib-of: " Yisheng Xie
@ 2018-05-21 21:36   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:36 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Linus Walleij, open list:GPIO SUBSYSTEM

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>

https://patchwork.ozlabs.org/patch/908134/

> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: linux-gpio@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 05/33] cxgb4: use match_string() helper
  2018-05-21 11:57 ` [PATCH 05/33] cxgb4: " Yisheng Xie
@ 2018-05-21 21:39   ` Andy Shevchenko
  2018-05-22  0:55     ` Yisheng Xie
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:39 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: Linux Kernel Mailing List, Ganesh Goudar, netdev

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

> -       for (i = 0; i < ARRAY_SIZE(cudbg_region); i++) {
> -               if (!strcmp(cudbg_region[i], region_name)) {
> -                       found = 1;
> -                       idx = i;
> -                       break;
> -               }
> -       }
> -       if (!found)
> -               return -EINVAL;
> +       rc = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name);
> +       if (rc < 0)
> +               return rc;
>
> -       found = 0;
> +       idx = rc;

Is found still in use after this?
If so, is it initialized properly now?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper
  2018-05-21 11:57 ` [PATCH 07/33] iwlwifi: mvm: " Yisheng Xie
  2018-05-21 20:12   ` Luca Coelho
@ 2018-05-21 21:43   ` Andy Shevchenko
  2018-05-22  3:30     ` Yisheng Xie
  1 sibling, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:43 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Kalle Valo, Intel Linux Wireless,
	Johannes Berg, Emmanuel Grumbach, open list:TI WILINK WIRELES...,
	netdev

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

>         int ret, bt_force_ant_mode;
>
> -       for (bt_force_ant_mode = 0;
> -            bt_force_ant_mode < ARRAY_SIZE(modes_str);
> -            bt_force_ant_mode++) {
> -               if (!strcmp(buf, modes_str[bt_force_ant_mode]))
> -                       break;
> -       }
> -
> -       if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))

> +       bt_force_ant_mode = match_string(modes_str,
> +                                        ARRAY_SIZE(modes_str), buf);

One line?

> +       if (bt_force_ant_mode < 0)
>                 return -EINVAL;

I would rather use

ret = match_string();
if (ret < 0)
 return ret;

bt_force_... = ret;

But it's up tu Loca.

>
>         ret = 0;



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 09/33] phy: tegra: use match_string() helper
  2018-05-21 11:57 ` [PATCH 09/33] phy: tegra: " Yisheng Xie
@ 2018-05-21 21:45   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:45 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Kishon Vijay Abraham I,
	Thierry Reding, Jonathan Hunter

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>

https://patchwork.ozlabs.org/patch/908133/

> Cc: Kishon Vijay Abraham I <kishon@ti.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Jonathan Hunter <jonathanh@nvidia.com>
> Cc: linux-kernel@vger.kernel.org


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 10/33] pata_hpt37x: use match_string() helper
  2018-05-21 11:57 ` [PATCH 10/33] pata_hpt37x: " Yisheng Xie
@ 2018-05-21 21:46   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:46 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Bartlomiej Zolnierkiewicz, Tejun Heo,
	linux-ide

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>

https://www.spinics.net/lists/linux-ide/msg55658.html

> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: linux-ide@vger.kernel.org


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 12/33] clk: bcm2835: use match_string() helper
  2018-05-21 11:57 ` [PATCH 12/33] clk: bcm2835: " Yisheng Xie
  2018-05-21 17:48   ` Eric Anholt
@ 2018-05-21 21:50   ` Andy Shevchenko
  2018-05-22  3:42     ` Yisheng Xie
  1 sibling, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:50 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Michael Turquette, Stephen Boyd,
	Eric Anholt, Stefan Wahren, linux-clk, linux-rpi-kernel,
	linux-arm Mailing List

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: Eric Anholt <eric@anholt.net>
> Cc: Stefan Wahren <stefan.wahren@i2se.com>
> Cc: linux-clk@vger.kernel.org
> Cc: linux-rpi-kernel@lists.infradead.org
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>

> -       size_t i, j;
> -       int ret;
> +       int i, ret;

I do not see any need to change type for i.

> +               ret = match_string(cprman_parent_names,
> +                                  ARRAY_SIZE(cprman_parent_names),
> +                                  parents[i]);
> +               if (ret >= 0)
> +                       parents[i] = cprman->real_parent_names[ret];


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 14/33] clk: use match_string() helper
  2018-05-21 11:57 ` [PATCH 14/33] clk: " Yisheng Xie
@ 2018-05-21 21:53   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:53 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Michael Turquette, Stephen Boyd, linux-clk

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

> +       return match_string(core->parent_names,
> +                           core->num_parents, parent_core->name) >= 0;

More logical split is to leave second parameter on the first line.

P.S. I would rather to put everything to one line even if takes ~83 characters.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 17/33] pinctrl: armada-37xx: use match_string() helper
  2018-05-21 11:57 ` [PATCH 17/33] pinctrl: armada-37xx: " Yisheng Xie
@ 2018-05-21 21:55   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:55 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Jason Cooper, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Linus Walleij,
	linux-arm Mailing List, open list:GPIO SUBSYSTEM

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

https://patchwork.kernel.org/patch/10378781/

> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-gpio@vger.kernel.org

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 18/33] power: supply: use match_string() helper
  2018-05-21 11:57 ` [PATCH 18/33] power: supply: " Yisheng Xie
@ 2018-05-21 21:58   ` Andy Shevchenko
  2018-05-22 16:16     ` Sebastian Reichel
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 21:58 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: Linux Kernel Mailing List, Sebastian Reichel, Linux PM

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>

This doesn't make code looks better anyhow. I even think it makes it
worse to read.
That's why I dropped my version of the change (and yes, I missed the
type conversion which looks here just ugly).

Sebastian, if my opinion makes any difference here, I would say NAK to this one.

> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  drivers/power/supply/power_supply_core.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index feac7b0..84da3a2 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -36,8 +36,6 @@
>  static bool __power_supply_is_supplied_by(struct power_supply *supplier,
>                                          struct power_supply *supply)
>  {
> -       int i;
> -
>         if (!supply->supplied_from && !supplier->supplied_to)
>                 return false;
>
> @@ -45,18 +43,16 @@ static bool __power_supply_is_supplied_by(struct power_supply *supplier,
>         if (supply->supplied_from) {
>                 if (!supplier->desc->name)
>                         return false;
> -               for (i = 0; i < supply->num_supplies; i++)
> -                       if (!strcmp(supplier->desc->name, supply->supplied_from[i]))
> -                               return true;
> +               return match_string((const char **)supply->supplied_from,
> +                                   supply->num_supplies,
> +                                   supplier->desc->name) >= 0;
>         } else {
>                 if (!supply->desc->name)
>                         return false;
> -               for (i = 0; i < supplier->num_supplicants; i++)
> -                       if (!strcmp(supplier->supplied_to[i], supply->desc->name))
> -                               return true;
> +               return match_string((const char **)supplier->supplied_to,
> +                                   supplier->num_supplicants,
> +                                   supply->desc->name) >= 0;
>         }
> -
> -       return false;
>  }
>
>  static int __power_supply_changed_work(struct device *dev, void *data)
> --
> 1.7.12.4
>



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 19/33] thermal: db8500: use match_string() helper
  2018-05-21 11:57 ` [PATCH 19/33] thermal: db8500: " Yisheng Xie
@ 2018-05-21 22:00   ` Andy Shevchenko
  2018-05-23  7:47     ` Yisheng Xie
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:00 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Zhang Rui, Eduardo Valentin, Linux PM

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

> +       i = match_string((const char **)trip_point->cdev_name,

Casting looks ugly. You need to constify the variable itself.

> +                        COOLING_DEV_MAX, cdev->type);
>
> -       return -ENODEV;
> +       return (i < 0) ? -ENODEV : 0;

I would rather go with

if (ret < 0)
 return -ENODEV;

return 0;

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 20/33] video: fbdev: pxafb: use match_string() helper
  2018-05-21 11:57 ` [PATCH 20/33] video: fbdev: pxafb: " Yisheng Xie
@ 2018-05-21 22:01   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:01 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Bartlomiej Zolnierkiewicz,
	Arvind Yadav, dri-devel

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

https://patchwork.kernel.org/patch/10378815/

> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
> Cc: dri-devel@lists.freedesktop.org
> linux-fbdev@vger.kernel.org

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 21/33] drm/nouveau: use match_string() helper
  2018-05-21 11:57 ` [PATCH 21/33] drm/nouveau: " Yisheng Xie
@ 2018-05-21 22:03   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:03 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Ben Skeggs, David Airlie, dri-devel, nouveau

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

>         if (nouveau_tv_norm) {

> +               i = match_string(nv17_tv_norm_names,
> +                                num_tv_norms, nouveau_tv_norm);

Same comment for logical split, 2nd parameter looks better on the previous line.

> +               if (i >= 0)
> +                       tv_enc->tv_norm = i;
> +               else
>                         NV_WARN(drm, "Invalid TV norm setting \"%s\"\n",
>                                 nouveau_tv_norm);

I would rather go with

if (i < 0)
 NV_WARN
else
 ...

>         }


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 22/33] drm/i915: use match_string() helper
  2018-05-21 11:57 ` [PATCH 22/33] drm/i915: " Yisheng Xie
@ 2018-05-21 22:04   ` Andy Shevchenko
  2018-05-22  8:36     ` Jani Nikula
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:04 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Jani Nikula, Joonas Lahtinen,
	Rodrigo Vivi, David Airlie, intel-gfx, dri-devel

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

https://patchwork.kernel.org/patch/10382323/

> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 24/33] drm: use match_string() helper
  2018-05-21 11:58 ` [PATCH 24/33] drm: " Yisheng Xie
@ 2018-05-21 22:06   ` Andy Shevchenko
  2018-05-22  8:39     ` Jani Nikula
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:06 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Gustavo Padovan, Maarten Lankhorst,
	Sean Paul, David Airlie, dri-devel

On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

https://patchwork.kernel.org/patch/10382377/

> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: dri-devel@lists.freedesktop.org

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 26/33] apparmor: use match_string() helper
  2018-05-21 11:58 ` [PATCH 26/33] apparmor: " Yisheng Xie
  2018-05-21 15:33   ` John Johansen
@ 2018-05-21 22:10   ` Andy Shevchenko
  1 sibling, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:10 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, John Johansen, James Morris,
	Serge E. Hallyn, linux-security-module

On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

http://kernsec.org/pipermail/linux-security-module-archi

> Cc: John Johansen <john.johansen@canonical.com>
> Cc: James Morris <jmorris@namei.org>
> Cc: "Serge E. Hallyn" <serge@hallyn.com>
> Cc: linux-security-module@vger.kernel.org

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 27/33] sched/debug: use match_string() helper
  2018-05-21 11:58 ` [PATCH 27/33] sched/debug: " Yisheng Xie
@ 2018-05-21 22:13   ` Andy Shevchenko
  2018-05-22 12:10     ` Yisheng Xie
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:13 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: Linux Kernel Mailing List, Ingo Molnar, Peter Zijlstra

On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  kernel/sched/debug.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index 15b10e2..9e34499 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -111,16 +111,14 @@ static int sched_feat_set(char *cmp)
>                 cmp += 3;
>         }
>
> -       for (i = 0; i < __SCHED_FEAT_NR; i++) {
> -               if (strcmp(cmp, sched_feat_names[i]) == 0) {
> -                       if (neg) {
> -                               sysctl_sched_features &= ~(1UL << i);
> -                               sched_feat_disable(i);
> -                       } else {
> -                               sysctl_sched_features |= (1UL << i);
> -                               sched_feat_enable(i);
> -                       }
> -                       break;
> +       i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);

> +       if (i >= 0) {

Why not

if (i < 0)
 return i;

?

> +               if (neg) {
> +                       sysctl_sched_features &= ~(1UL << i);
> +                       sched_feat_disable(i);
> +               } else {
> +                       sysctl_sched_features |= (1UL << i);
> +                       sched_feat_enable(i);
>                 }
>         }
>
> @@ -150,7 +148,7 @@ static int sched_feat_set(char *cmp)
>         inode_lock(inode);
>         i = sched_feat_set(cmp);
>         inode_unlock(inode);

> -       if (i == __SCHED_FEAT_NR)
> +       if (i < 0)
>                 return -EINVAL;

Now it would be

if (i < 0)
 return i;

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 01/33] usb: phy: use match_string() helper
  2018-05-21 11:57 ` [PATCH 01/33] usb: phy: " Yisheng Xie
@ 2018-05-21 22:20   ` Andy Shevchenko
  2018-05-22 10:02     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:20 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, USB, Felipe Balbi, Greg Kroah-Hartman

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

> -       int err, i;
> +       int ret;

int err;

would still work.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 30/33] ALSA: oxygen: use match_string() helper
  2018-05-21 11:58 ` [PATCH 30/33] ALSA: oxygen: " Yisheng Xie
@ 2018-05-21 22:23   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:23 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Clemens Ladisch, Jaroslav Kysela,
	Takashi Iwai, ALSA Development Mailing List

On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>
> Cc: Clemens Ladisch <clemens@ladisch.de>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: alsa-devel@alsa-project.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  sound/pci/oxygen/oxygen_mixer.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
> index 4ca1266..fbd8f5e 100644
> --- a/sound/pci/oxygen/oxygen_mixer.c
> +++ b/sound/pci/oxygen/oxygen_mixer.c
> @@ -1052,10 +1052,9 @@ static int add_controls(struct oxygen *chip,
>                 [CONTROL_CD_CAPTURE_SWITCH] = "CD Capture Switch",
>                 [CONTROL_AUX_CAPTURE_SWITCH] = "Aux Capture Switch",
>         };
> -       unsigned int i, j;
>         struct snd_kcontrol_new template;
>         struct snd_kcontrol *ctl;
> -       int err;
> +       int i, j, err;

What's wrong with

unsigned int i;

?

>
>         for (i = 0; i < count; ++i) {
>                 template = controls[i];
> @@ -1086,11 +1085,11 @@ static int add_controls(struct oxygen *chip,
>                 err = snd_ctl_add(chip->card, ctl);
>                 if (err < 0)
>                         return err;
> -               for (j = 0; j < CONTROL_COUNT; ++j)
> -                       if (!strcmp(ctl->id.name, known_ctl_names[j])) {
> -                               chip->controls[j] = ctl;
> -                               ctl->private_free = oxygen_any_ctl_free;
> -                       }
> +               j = match_string(known_ctl_names, CONTROL_COUNT, ctl->id.name);
> +               if (j >= 0) {
> +                       chip->controls[j] = ctl;
> +                       ctl->private_free = oxygen_any_ctl_free;
> +               }
>         }
>         return 0;
>  }
> --
> 1.7.12.4
>



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 31/33] ASoC: max98088: use match_string() helper
  2018-05-21 11:58 ` [PATCH 31/33] ASoC: max98088: " Yisheng Xie
@ 2018-05-21 22:24   ` Andy Shevchenko
  2018-05-22 12:30     ` Yisheng Xie
  0 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:24 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, ALSA Development Mailing List

On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

>  static int max98088_get_channel(struct snd_soc_component *component, const char *name)
>  {

> +       int ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name);
I would rather split this and move an assignment to the line before 'if'

>
>         /* Shouldn't happen */

> +       if (ret < 0)
> +               dev_err(component->dev, "Bad EQ channel name '%s'\n", name);

>         return -EINVAL;

return ret;

?

>  }
>
> --
> 1.7.12.4
>



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 32/33] ASoC: max98095: use match_string() helper
  2018-05-21 11:58 ` [PATCH 32/33] ASoC: max98095: " Yisheng Xie
@ 2018-05-21 22:25   ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:25 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, ALSA Development Mailing List

On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.


> +       int ret = match_string(bq_mode_name, ARRAY_SIZE(bq_mode_name), name);

Rather split and move an assignment to the line before 'if'.

>
>         /* Shouldn't happen */

> +       if (ret < 0)
> +               dev_err(component->dev, "Bad biquad channel name '%s'\n", name);
> +       return ret;
>  }

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [alsa-devel] [PATCH 29/33] ALSA: oxfw: use match_string() helper
  2018-05-21 11:58 ` [PATCH 29/33] ALSA: oxfw: " Yisheng Xie
@ 2018-05-21 22:26   ` Takashi Sakamoto
  2018-05-22  7:26     ` Takashi Iwai
  0 siblings, 1 reply; 88+ messages in thread
From: Takashi Sakamoto @ 2018-05-21 22:26 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel; +Cc: alsa-devel, Clemens Ladisch, Takashi Iwai

Hi,

On May 21 2018 20:58, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Clemens Ladisch <clemens@ladisch.de>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: alsa-devel@alsa-project.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>   sound/firewire/oxfw/oxfw.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

For my information, use_match_string() helper was firstly introduced to
v4.6 kernel by a commit 56b060814e2d ('lib/string: introduce 
match_string() helper').

> diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
> index 413ab63..1e5b2c8 100644
> --- a/sound/firewire/oxfw/oxfw.c
> +++ b/sound/firewire/oxfw/oxfw.c
> @@ -49,7 +49,6 @@ static bool detect_loud_models(struct fw_unit *unit)
>   		"Tapco LINK.firewire 4x6",
>   		"U.420"};
>   	char model[32];
> -	unsigned int i;
>   	int err;
>   
>   	err = fw_csr_string(unit->directory, CSR_MODEL,
> @@ -57,12 +56,7 @@ static bool detect_loud_models(struct fw_unit *unit)
>   	if (err < 0)
>   		return false;
>   
> -	for (i = 0; i < ARRAY_SIZE(models); i++) {
> -		if (strcmp(models[i], model) == 0)
> -			break;
> -	}
> -
> -	return (i < ARRAY_SIZE(models));
> +	return match_string(models, ARRAY_SIZE(models), model) >= 0;
>   }
>   
>   static int name_card(struct snd_oxfw *oxfw)

Thanks

Takashi Sakamoto

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

* Re: [PATCH 00/33] use match_string() helper
  2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
                   ` (32 preceding siblings ...)
  2018-05-21 11:58 ` [PATCH 33/33] ASoC: dapm: " Yisheng Xie
@ 2018-05-21 22:27 ` Andy Shevchenko
  2018-05-22  0:52   ` Yisheng Xie
  33 siblings, 1 reply; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-21 22:27 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: Linux Kernel Mailing List

On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> Andy introduce helper function match_string() which can be used to return
> the index of array for a matching string. so we can use it in many places
> intead of open coded variant.

You forgot to Cc that Andy.

For the patches I didn't comment, LGTM

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> I just try to make this API be used more commonly, sorry if this makes
> too much big patchset.
>
> Yisheng Xie (33):
>   usb: phy: use match_string() helper
>   mfd: omap-usb-host: use match_string() helper
>   Staging: gdm724x: use match_string() helper
>   gpiolib-of: use match_string() helper
>   cxgb4: use match_string() helper
>   hp100: use match_string() helper
>   iwlwifi: mvm: use match_string() helper
>   vfio: use match_string() helper
>   phy: tegra: use match_string() helper
>   pata_hpt37x: use match_string() helper
>   bus: fsl-mc: use match_string() helper
>   clk: bcm2835: use match_string() helper
>   clk: rockchip: use match_string() helper
>   clk: use match_string() helper
>   cpufreq: intel_pstate: use match_string() helper
>   mmc: sdhci-xenon: use match_string() helper
>   pinctrl: armada-37xx: use match_string() helper
>   power: supply: use match_string() helper
>   thermal: db8500: use match_string() helper
>   video: fbdev: pxafb: use match_string() helper
>   drm/nouveau: use match_string() helper
>   drm/i915: use match_string() helper
>   drm: i2c: ch7006: use match_string() helper
>   drm: use match_string() helper
>   ima: use match_string() helper
>   apparmor: use match_string() helper
>   sched/debug: use match_string() helper
>   ALSA: dice use match_string() helper
>   ALSA: oxfw: use match_string() helper
>   ALSA: oxygen: use match_string() helper
>   ASoC: max98088: use match_string() helper
>   ASoC: max98095: use match_string() helper
>   ASoC: dapm: use match_string() helper
>
>  drivers/ata/pata_hpt37x.c                        | 13 +++++-------
>  drivers/bus/fsl-mc/fsl-mc-allocator.c            | 24 +++++------------------
>  drivers/clk/bcm/clk-bcm2835.c                    | 14 ++++++-------
>  drivers/clk/clk.c                                |  8 ++------
>  drivers/clk/rockchip/clk.c                       | 16 +++++----------
>  drivers/cpufreq/intel_pstate.c                   | 15 ++++++--------
>  drivers/gpio/gpiolib-of.c                        |  7 +------
>  drivers/gpu/drm/drm_panel_orientation_quirks.c   |  7 ++-----
>  drivers/gpu/drm/i2c/ch7006_drv.c                 | 13 +++++-------
>  drivers/gpu/drm/i915/intel_pipe_crc.c            | 22 ++++++++++-----------
>  drivers/gpu/drm/nouveau/dispnv04/tvnv17.c        | 13 +++++-------
>  drivers/mfd/omap-usb-host.c                      | 24 ++---------------------
>  drivers/mmc/host/sdhci-xenon-phy.c               | 11 +++--------
>  drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c   | 14 ++++---------
>  drivers/net/ethernet/hp/hp100.c                  |  9 +--------
>  drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 11 +++--------
>  drivers/phy/tegra/xusb.c                         | 15 +-------------
>  drivers/pinctrl/mvebu/pinctrl-armada-37xx.c      | 16 ++-------------
>  drivers/power/supply/power_supply_core.c         | 16 ++++++---------
>  drivers/staging/gdm724x/gdm_tty.c                | 16 ++++-----------
>  drivers/thermal/db8500_thermal.c                 |  8 +++-----
>  drivers/usb/phy/of.c                             | 12 +++++-------
>  drivers/vfio/vfio.c                              | 11 +++--------
>  drivers/video/fbdev/pxafb.c                      |  6 ++----
>  kernel/sched/debug.c                             | 20 +++++++++----------
>  security/apparmor/lsm.c                          | 25 +++++++++++-------------
>  security/integrity/ima/ima_main.c                | 11 ++++-------
>  sound/firewire/dice/dice.c                       |  8 +-------
>  sound/firewire/oxfw/oxfw.c                       |  8 +-------
>  sound/pci/oxygen/oxygen_mixer.c                  | 13 ++++++------
>  sound/soc/codecs/max98088.c                      |  9 +++------
>  sound/soc/codecs/max98095.c                      | 11 ++++-------
>  sound/soc/soc-dapm.c                             | 18 +++++++----------
>  33 files changed, 137 insertions(+), 307 deletions(-)
>
> --
> 1.7.12.4
>



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 28/33] ALSA: dice use match_string() helper
  2018-05-21 11:58 ` [PATCH 28/33] ALSA: dice " Yisheng Xie
@ 2018-05-21 22:31   ` Takashi Sakamoto
  0 siblings, 0 replies; 88+ messages in thread
From: Takashi Sakamoto @ 2018-05-21 22:31 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel; +Cc: alsa-devel, Clemens Ladisch, Takashi Iwai

Hi,

On May 21 2018 20:58, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Clemens Ladisch <clemens@ladisch.de>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> Cc: alsa-devel@alsa-project.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>   sound/firewire/dice/dice.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)

I'm welcome to this change, while in the latest subsystem tree for v4.18
the 'force_to_pcm_support()' local function was removed by my patch[1].
Your patch can be abandon.

> diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
> index 96bb01b..0639074 100644
> --- a/sound/firewire/dice/dice.c
> +++ b/sound/firewire/dice/dice.c
> @@ -35,19 +35,13 @@ static bool force_two_pcm_support(struct fw_unit *unit)
>   		"SAFFIRE_PRO_40_1",
>   	};
>   	char model[32];
> -	unsigned int i;
>   	int err;
>   
>   	err = fw_csr_string(unit->directory, CSR_MODEL, model, sizeof(model));
>   	if (err < 0)
>   		return false;
>   
> -	for (i = 0; i < ARRAY_SIZE(models); i++) {
> -		if (strcmp(models[i], model) == 0)
> -			break;
> -	}
> -
> -	return i < ARRAY_SIZE(models);
> +	return match_string(models, ARRAY_SIZE(models), model) >= 0;
>   }
>   
>   static int check_dice_category(struct fw_unit *unit)

[1] ALSA: dice: remove local frag of force_two_pcms
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?h=for-next&id=9c367c01d3d5


Thanks

Takashi Sakamoto

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

* Re: [PATCH 00/33] use match_string() helper
  2018-05-21 22:27 ` [PATCH 00/33] use match_string() helper Andy Shevchenko
@ 2018-05-22  0:52   ` Yisheng Xie
  0 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22  0:52 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linux Kernel Mailing List

Hi Andy,

On 2018/5/22 6:27, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> Andy introduce helper function match_string() which can be used to return
>> the index of array for a matching string. so we can use it in many places
>> intead of open coded variant.
> 
> You forgot to Cc that Andy.

Yeah, I just forgot it when send them out.
> 
> For the patches I didn't comment, LGTM
> 
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Thanks, and I will drop the ones you already sent out, and make a v2 as your comment!

Thanks
Yisheng

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

* Re: [PATCH 05/33] cxgb4: use match_string() helper
  2018-05-21 21:39   ` Andy Shevchenko
@ 2018-05-22  0:55     ` Yisheng Xie
  0 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22  0:55 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linux Kernel Mailing List, Ganesh Goudar, netdev

Hi Andy,

On 2018/5/22 5:39, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
> 
>> -       for (i = 0; i < ARRAY_SIZE(cudbg_region); i++) {
>> -               if (!strcmp(cudbg_region[i], region_name)) {
>> -                       found = 1;
>> -                       idx = i;
>> -                       break;
>> -               }
>> -       }
>> -       if (!found)
>> -               return -EINVAL;
>> +       rc = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name);
>> +       if (rc < 0)
>> +               return rc;
>>
>> -       found = 0;
>> +       idx = rc;
> 
> Is found still in use after this?
> If so, is it initialized properly now?
it is initialized  when define 'found', so no need to be initialized once more.

Thanks
Yisheng

> 

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

* Re: [PATCH 26/33] apparmor: use match_string() helper
  2018-05-21 15:33   ` John Johansen
@ 2018-05-22  1:25     ` Yisheng Xie
  0 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22  1:25 UTC (permalink / raw)
  To: John Johansen, linux-kernel
  Cc: James Morris, Serge E. Hallyn, linux-security-module

Hi John,

On 2018/5/21 23:33, John Johansen wrote:
> On 05/21/2018 04:58 AM, Yisheng Xie wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
>>
> 
> Andy Shevchenko patch to do the same thing is already in apparmor-next

Sorry, I will drop this one.

Thanks
Yisheng
> 
>> Cc: John Johansen <john.johansen@canonical.com>
>> Cc: James Morris <jmorris@namei.org>
>> Cc: "Serge E. Hallyn" <serge@hallyn.com>
>> Cc: linux-security-module@vger.kernel.org
>> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
>> ---
>>  security/apparmor/lsm.c | 25 +++++++++++--------------
>>  1 file changed, 11 insertions(+), 14 deletions(-)
>>
>> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
>> index ce2b89e..9b5904f 100644
>> --- a/security/apparmor/lsm.c
>> +++ b/security/apparmor/lsm.c
>> @@ -1378,14 +1378,12 @@ static int param_set_audit(const char *val, const struct kernel_param *kp)
>>  	if (apparmor_initialized && !policy_admin_capable(NULL))
>>  		return -EPERM;
>>  
>> -	for (i = 0; i < AUDIT_MAX_INDEX; i++) {
>> -		if (strcmp(val, audit_mode_names[i]) == 0) {
>> -			aa_g_audit = i;
>> -			return 0;
>> -		}
>> -	}
>> +	i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
>> +	if (i < 0)
>> +		return -EINVAL;
>>  
>> -	return -EINVAL;
>> +	aa_g_audit = i;
>> +	return 0;
>>  }
>>  
>>  static int param_get_mode(char *buffer, const struct kernel_param *kp)
>> @@ -1409,14 +1407,13 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
>>  	if (apparmor_initialized && !policy_admin_capable(NULL))
>>  		return -EPERM;
>>  
>> -	for (i = 0; i < APPARMOR_MODE_NAMES_MAX_INDEX; i++) {
>> -		if (strcmp(val, aa_profile_mode_names[i]) == 0) {
>> -			aa_g_profile_mode = i;
>> -			return 0;
>> -		}
>> -	}
>> +	i = match_string(aa_profile_mode_names,
>> +			 APPARMOR_MODE_NAMES_MAX_INDEX, val);
>> +	if (i)
>> +		return -EINVAL;
>>  
>> -	return -EINVAL;
>> +	aa_g_profile_mode = i;
>> +	return 0;
>>  }
>>  
>>  /*
>>
> 
> 
> 


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

* Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper
  2018-05-21 21:43   ` Andy Shevchenko
@ 2018-05-22  3:30     ` Yisheng Xie
  2018-05-22 20:41       ` Andy Shevchenko
  0 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22  3:30 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linux Kernel Mailing List, Kalle Valo, Intel Linux Wireless,
	Johannes Berg, Emmanuel Grumbach, open list:TI WILINK WIRELES...,
	netdev

Hi Andy,

On 2018/5/22 5:43, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
> 
>>         int ret, bt_force_ant_mode;
>>
>> -       for (bt_force_ant_mode = 0;
>> -            bt_force_ant_mode < ARRAY_SIZE(modes_str);
>> -            bt_force_ant_mode++) {
>> -               if (!strcmp(buf, modes_str[bt_force_ant_mode]))
>> -                       break;
>> -       }
>> -
>> -       if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
> 
>> +       bt_force_ant_mode = match_string(modes_str,
>> +                                        ARRAY_SIZE(modes_str), buf);
> 
> One line?

hmm, if use ret instead it will no over 80 chars.

> 
>> +       if (bt_force_ant_mode < 0)
>>                 return -EINVAL;
> 
> I would rather use
> 
> ret = match_string();
> if (ret < 0)
>  return ret;
> 
> bt_force_... = ret;
> 
> But it's up tu Loca.

OK, I will change it if Loca agree your opinion.

Thanks
Yisheng
> 
>>
>>         ret = 0;
> 
> 
> 

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

* Re: [PATCH 12/33] clk: bcm2835: use match_string() helper
  2018-05-21 21:50   ` Andy Shevchenko
@ 2018-05-22  3:42     ` Yisheng Xie
  0 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22  3:42 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linux Kernel Mailing List, Michael Turquette, Stephen Boyd,
	Eric Anholt, Stefan Wahren, linux-clk, linux-rpi-kernel,
	linux-arm Mailing List

Hi Andy,

On 2018/5/22 5:50, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
>>
>> Cc: Michael Turquette <mturquette@baylibre.com>
>> Cc: Stephen Boyd <sboyd@kernel.org>
>> Cc: Eric Anholt <eric@anholt.net>
>> Cc: Stefan Wahren <stefan.wahren@i2se.com>
>> Cc: linux-clk@vger.kernel.org
>> Cc: linux-rpi-kernel@lists.infradead.org
>> Cc: linux-arm-kernel@lists.infradead.org
>> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> 
>> -       size_t i, j;
>> -       int ret;
>> +       int i, ret;
> 
> I do not see any need to change type for i.

Right, I just want to smaller the line of code, for unsinged int is also OK for i.
Anyway, I can change it as your suggestion in next version.

Thanks
Yisheng

> 
>> +               ret = match_string(cprman_parent_names,
>> +                                  ARRAY_SIZE(cprman_parent_names),
>> +                                  parents[i]);
>> +               if (ret >= 0)
>> +                       parents[i] = cprman->real_parent_names[ret];
> 
> 

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

* Re: [alsa-devel] [PATCH 29/33] ALSA: oxfw: use match_string() helper
  2018-05-21 22:26   ` [alsa-devel] " Takashi Sakamoto
@ 2018-05-22  7:26     ` Takashi Iwai
  0 siblings, 0 replies; 88+ messages in thread
From: Takashi Iwai @ 2018-05-22  7:26 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: Yisheng Xie, linux-kernel, alsa-devel, Clemens Ladisch

On Tue, 22 May 2018 00:26:53 +0200,
Takashi Sakamoto wrote:
> 
> Hi,
> 
> On May 21 2018 20:58, Yisheng Xie wrote:
> > match_string() returns the index of an array for a matching string,
> > which can be used intead of open coded variant.
> >
> > Cc: Clemens Ladisch <clemens@ladisch.de>
> > Cc: Jaroslav Kysela <perex@perex.cz>
> > Cc: Takashi Iwai <tiwai@suse.com>
> > Cc: alsa-devel@alsa-project.org
> > Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> > ---
> >   sound/firewire/oxfw/oxfw.c | 8 +-------
> >   1 file changed, 1 insertion(+), 7 deletions(-)
> 
> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> 
> For my information, use_match_string() helper was firstly introduced to
> v4.6 kernel by a commit 56b060814e2d ('lib/string: introduce
> match_string() helper').

OK, applied now.  Thanks.


Takashi

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

* Re: [PATCH 22/33] drm/i915: use match_string() helper
  2018-05-21 22:04   ` Andy Shevchenko
@ 2018-05-22  8:36     ` Jani Nikula
  2018-05-22  9:22       ` Yisheng Xie
  0 siblings, 1 reply; 88+ messages in thread
From: Jani Nikula @ 2018-05-22  8:36 UTC (permalink / raw)
  To: Andy Shevchenko, Yisheng Xie
  Cc: Linux Kernel Mailing List, Joonas Lahtinen, Rodrigo Vivi,
	David Airlie, intel-gfx, dri-devel

On Tue, 22 May 2018, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
>
> https://patchwork.kernel.org/patch/10382323/

Even more convincingly,

47d4cb8ae8e7 ("i915: Convert to use match_string() helper")

BR,
Jani.

>
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> Cc: David Airlie <airlied@linux.ie>
>> Cc: intel-gfx@lists.freedesktop.org
>> Cc: dri-devel@lists.freedesktop.org

-- 
Jani Nikula, Intel Open Source Graphics Center

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

* Re: [PATCH 24/33] drm: use match_string() helper
  2018-05-21 22:06   ` Andy Shevchenko
@ 2018-05-22  8:39     ` Jani Nikula
  0 siblings, 0 replies; 88+ messages in thread
From: Jani Nikula @ 2018-05-22  8:39 UTC (permalink / raw)
  To: Andy Shevchenko, Yisheng Xie
  Cc: David Airlie, Linux Kernel Mailing List, dri-devel

On Tue, 22 May 2018, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
>
> https://patchwork.kernel.org/patch/10382377/

818c05d8e267 ("drm: panel-orientation-quirks: Convert to use match_string() helper")

BR,
Jani.

>
>> Cc: Gustavo Padovan <gustavo@padovan.org>
>> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Cc: Sean Paul <seanpaul@chromium.org>
>> Cc: David Airlie <airlied@linux.ie>
>> Cc: dri-devel@lists.freedesktop.org

-- 
Jani Nikula, Intel Open Source Graphics Center

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

* Re: [PATCH 22/33] drm/i915: use match_string() helper
  2018-05-22  8:36     ` Jani Nikula
@ 2018-05-22  9:22       ` Yisheng Xie
  0 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22  9:22 UTC (permalink / raw)
  To: Jani Nikula, Andy Shevchenko
  Cc: Linux Kernel Mailing List, Joonas Lahtinen, Rodrigo Vivi,
	David Airlie, intel-gfx, dri-devel

Hi Jani,

On 2018/5/22 16:36, Jani Nikula wrote:
> On Tue, 22 May 2018, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>>> match_string() returns the index of an array for a matching string,
>>> which can be used intead of open coded variant.
>>
>> https://patchwork.kernel.org/patch/10382323/
> 
> Even more convincingly,
> 
> 47d4cb8ae8e7 ("i915: Convert to use match_string() helper")

Sorry, but I will definitely remove them in next version, I just miss these.

Thanks
Yisheng
> 
> BR,
> Jani.
> 
>>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>>> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>>> Cc: David Airlie <airlied@linux.ie>
>>> Cc: intel-gfx@lists.freedesktop.org
>>> Cc: dri-devel@lists.freedesktop.org
> 

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

* Re: [PATCH 01/33] usb: phy: use match_string() helper
  2018-05-21 22:20   ` Andy Shevchenko
@ 2018-05-22 10:02     ` Greg Kroah-Hartman
  2018-05-22 11:12       ` Yisheng Xie
  0 siblings, 1 reply; 88+ messages in thread
From: Greg Kroah-Hartman @ 2018-05-22 10:02 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Yisheng Xie, Linux Kernel Mailing List, USB, Felipe Balbi

On Tue, May 22, 2018 at 01:20:01AM +0300, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> > match_string() returns the index of an array for a matching string,
> > which can be used intead of open coded variant.
> 
> > -       int err, i;
> > +       int ret;
> 
> int err;
> 
> would still work.

And it reduces churn.

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

* Re: [PATCH 01/33] usb: phy: use match_string() helper
  2018-05-22 10:02     ` Greg Kroah-Hartman
@ 2018-05-22 11:12       ` Yisheng Xie
  0 siblings, 0 replies; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22 11:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko
  Cc: Linux Kernel Mailing List, USB, Felipe Balbi

Hi,

On 2018/5/22 18:02, Greg Kroah-Hartman wrote:
> On Tue, May 22, 2018 at 01:20:01AM +0300, Andy Shevchenko wrote:
>> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>>> match_string() returns the index of an array for a matching string,
>>> which can be used intead of open coded variant.
>>
>>> -       int err, i;
>>> +       int ret;
>>
>> int err;
>>
>> would still work.
> 
> And it reduces churn.

I will keep it as err in next version.

Thanks
Yisheng
> 
> 


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

* Re: [PATCH 27/33] sched/debug: use match_string() helper
  2018-05-21 22:13   ` Andy Shevchenko
@ 2018-05-22 12:10     ` Yisheng Xie
  2018-05-22 20:29       ` Andy Shevchenko
  0 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22 12:10 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linux Kernel Mailing List, Ingo Molnar, Peter Zijlstra

Hi Andy,

On 2018/5/22 6:13, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
>>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
>> ---
>>  kernel/sched/debug.c | 20 +++++++++-----------
>>  1 file changed, 9 insertions(+), 11 deletions(-)
>>
>> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
>> index 15b10e2..9e34499 100644
>> --- a/kernel/sched/debug.c
>> +++ b/kernel/sched/debug.c
>> @@ -111,16 +111,14 @@ static int sched_feat_set(char *cmp)
>>                 cmp += 3;
>>         }
>>
>> -       for (i = 0; i < __SCHED_FEAT_NR; i++) {
>> -               if (strcmp(cmp, sched_feat_names[i]) == 0) {
>> -                       if (neg) {
>> -                               sysctl_sched_features &= ~(1UL << i);
>> -                               sched_feat_disable(i);
>> -                       } else {
>> -                               sysctl_sched_features |= (1UL << i);
>> -                               sched_feat_enable(i);
>> -                       }
>> -                       break;
>> +       i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
> 
>> +       if (i >= 0) {
> 
> Why not
> 
> if (i < 0)
>  return i;

if i >=0 it will also return i. so need return i just if (i < 0), right ?

> 
> ?
> 
>> +               if (neg) {
>> +                       sysctl_sched_features &= ~(1UL << i);
>> +                       sched_feat_disable(i);
>> +               } else {
>> +                       sysctl_sched_features |= (1UL << i);
>> +                       sched_feat_enable(i);
>>                 }
>>         }
>>
>> @@ -150,7 +148,7 @@ static int sched_feat_set(char *cmp)
>>         inode_lock(inode);
>>         i = sched_feat_set(cmp);
>>         inode_unlock(inode);
> 
>> -       if (i == __SCHED_FEAT_NR)
>> +       if (i < 0)
>>                 return -EINVAL;
> 
> Now it would be
> 
> if (i < 0)
>  return i;

Right, will change it in next version

Thanks
Yisheng Xie
> 

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

* Re: [PATCH 31/33] ASoC: max98088: use match_string() helper
  2018-05-21 22:24   ` Andy Shevchenko
@ 2018-05-22 12:30     ` Yisheng Xie
  2018-05-22 17:23       ` Andy Shevchenko
  0 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-22 12:30 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linux Kernel Mailing List, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, ALSA Development Mailing List

Hi Andy,

On 2018/5/22 6:24, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:58 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
> 
>>  static int max98088_get_channel(struct snd_soc_component *component, const char *name)
>>  {
> 
>> +       int ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name);
> I would rather split this and move an assignment to the line before 'if'

hmm, you mean something like:

	int ret;

	ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name);
	if (ret < 0) /* Shouldn't happen */
		dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
	return ret;
>>
>>         /* Shouldn't happen */
> 
>> +       if (ret < 0)
>> +               dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
> 
>>         return -EINVAL;
> 
> return ret;
Right, sorry for this big mistake.

Thanks
Yisheng
> 
> ?
> 
>>  }
>>
>> --
>> 1.7.12.4
>>
> 
> 
> 

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

* Re: [PATCH 13/33] clk: rockchip: use match_string() helper
  2018-05-21 11:57 ` [PATCH 13/33] clk: rockchip: " Yisheng Xie
@ 2018-05-22 13:56   ` Heiko Stuebner
  0 siblings, 0 replies; 88+ messages in thread
From: Heiko Stuebner @ 2018-05-22 13:56 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: linux-kernel, Michael Turquette, Stephen Boyd, linux-clk,
	linux-arm-kernel, linux-rockchip

Am Montag, 21. Mai 2018, 13:57:50 CEST schrieb Yisheng Xie:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: linux-clk@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-rockchip@lists.infradead.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>

> @@ -312,6 +304,8 @@ static struct clk *rockchip_clk_register_frac_branch(
>  
>  		/* notifier on the fraction divider to catch rate changes */
>  		if (frac->mux_frac_idx >= 0) {
> +			pr_debug("%s: find fractional parent in mux at pos %d\n",
> +				 __func__, frac->mux_frac_idx);

applied to my Rockchip clk branch for 4.18 after changing the "find" above
to "found" again ;-) .


Thanks for the nice cleanup
Heiko

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

* Re: [PATCH 18/33] power: supply: use match_string() helper
  2018-05-21 21:58   ` Andy Shevchenko
@ 2018-05-22 16:16     ` Sebastian Reichel
  0 siblings, 0 replies; 88+ messages in thread
From: Sebastian Reichel @ 2018-05-22 16:16 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Yisheng Xie, Linux Kernel Mailing List, Linux PM

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

Hi Andy,

On Tue, May 22, 2018 at 12:58:14AM +0300, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> > match_string() returns the index of an array for a matching string,
> > which can be used intead of open coded variant.
> >
> 
> This doesn't make code looks better anyhow. I even think it makes it
> worse to read. That's why I dropped my version of the change (and yes,
> I missed the type conversion which looks here just ugly).
> 
> Sebastian, if my opinion makes any difference here, I would say
> NAK to this one.

I agree.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 31/33] ASoC: max98088: use match_string() helper
  2018-05-22 12:30     ` Yisheng Xie
@ 2018-05-22 17:23       ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-22 17:23 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, ALSA Development Mailing List

On Tue, May 22, 2018 at 3:30 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:

> hmm, you mean something like:
>
>         int ret;
>
>         ret = match_string(eq_mode_name, ARRAY_SIZE(eq_mode_name), name);
>         if (ret < 0) /* Shouldn't happen */
>                 dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
>         return ret;

Yes. (But remove that useless comment).

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 27/33] sched/debug: use match_string() helper
  2018-05-22 12:10     ` Yisheng Xie
@ 2018-05-22 20:29       ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-22 20:29 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: Linux Kernel Mailing List, Ingo Molnar, Peter Zijlstra

On Tue, May 22, 2018 at 3:10 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:

>>> +       i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
>>> +       if (i >= 0) {
>>
>> Why not
>>
>> if (i < 0)
>>  return i;
>
> if i >=0 it will also return i. so need return i just if (i < 0), right ?

Looking to the only (modified) caller, I think yes, either you return
error code or just 0.

>>> -       if (i == __SCHED_FEAT_NR)
>>> +       if (i < 0)
>>>                 return -EINVAL;
>>
>> Now it would be
>>

>> if (i < 0)

...even if (i) and rename i to ret to show the change in returned value meaning.

>>  return i;
>
> Right, will change it in next version

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper
  2018-05-22  3:30     ` Yisheng Xie
@ 2018-05-22 20:41       ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-05-22 20:41 UTC (permalink / raw)
  To: Yisheng Xie, Luca Coelho
  Cc: Linux Kernel Mailing List, Kalle Valo, Intel Linux Wireless,
	Johannes Berg, Emmanuel Grumbach, open list:TI WILINK WIRELES...,
	netdev

On Tue, May 22, 2018 at 6:30 AM, Yisheng Xie <xieyisheng1@huawei.com> wrote:

>> But it's up tu Loca.

Shame on me. I meant Luca, of course!
Luca, sorry.

> OK, I will change it if Loca agree your opinion.


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 19/33] thermal: db8500: use match_string() helper
  2018-05-21 22:00   ` Andy Shevchenko
@ 2018-05-23  7:47     ` Yisheng Xie
  2018-06-05 16:14       ` Andy Shevchenko
  0 siblings, 1 reply; 88+ messages in thread
From: Yisheng Xie @ 2018-05-23  7:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linux Kernel Mailing List, Zhang Rui, Eduardo Valentin, Linux PM

Hi Andy,

On 2018/5/22 6:00, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used intead of open coded variant.
> 
>> +       i = match_string((const char **)trip_point->cdev_name,
> 
> Casting looks ugly. You need to constify the variable itself.
When I tried to const cdev_name like:
+++ b/include/linux/platform_data/db8500_thermal.h
@@ -27,7 +27,7 @@
 struct db8500_trip_point {
        unsigned long temp;
        enum thermal_trip_type type;
-       char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH];
+       char const cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH]; // const char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH] will also the same
 };

The compiler will also warning:
drivers/thermal/db8500_thermal.c: In function ‘db8500_thermal_match_cdev’:
drivers/thermal/db8500_thermal.c:53:2: warning: passing argument 1 of ‘match_string’ from incompatible pointer type [enabled by default]
  i = match_string(trip_point->cdev_name, COOLING_DEV_MAX, cdev->type);
  ^
In file included from include/linux/bitmap.h:9:0,
                 from include/linux/cpumask.h:12,
                 from include/linux/rcupdate.h:44,
                 from include/linux/radix-tree.h:28,
                 from include/linux/idr.h:15,
                 from include/linux/kernfs.h:14,
                 from include/linux/sysfs.h:16,
                 from kernel/include/linux/kobject.h:20,
                 from kernel/include/linux/of.h:17,
                 from include/linux/cpu_cooling.h:27,
                 from drivers/thermal/db8500_thermal.c:20:
include/linux/string.h:184:5: note: expected ‘const char * const*’ but argument is of type ‘const char (*)[20]’

Any idea?

Thanks
Yisheng
> 
>> +                        COOLING_DEV_MAX, cdev->type);
>>
>> -       return -ENODEV;
>> +       return (i < 0) ? -ENODEV : 0;
> 
> I would rather go with
> 
> if (ret < 0)
>  return -ENODEV;
> 
> return 0;
> 

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

* Re: [PATCH 25/33] ima: use match_string() helper
  2018-05-21 11:58 ` [PATCH 25/33] ima: " Yisheng Xie
@ 2018-05-23 14:42   ` Mimi Zohar
  0 siblings, 0 replies; 88+ messages in thread
From: Mimi Zohar @ 2018-05-23 14:42 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel
  Cc: Dmitry Kasatkin, James Morris, Serge E. Hallyn, linux-integrity,
	linux-security-module

On Mon, 2018-05-21 at 19:58 +0800, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
> Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
> Cc: James Morris <jmorris@namei.org>
> Cc: "Serge E. Hallyn" <serge@hallyn.com>
> Cc: linux-integrity@vger.kernel.org
> Cc: linux-security-module@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>

Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>

> ---
>  security/integrity/ima/ima_main.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 74d0bd7..f807093 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -61,14 +61,11 @@ static int __init hash_setup(char *str)
>  		goto out;
>  	}
> 
> -	for (i = 0; i < HASH_ALGO__LAST; i++) {
> -		if (strcmp(str, hash_algo_name[i]) == 0) {
> -			ima_hash_algo = i;
> -			break;
> -		}
> -	}
> -	if (i == HASH_ALGO__LAST)
> +	i = match_string(hash_algo_name, HASH_ALGO__LAST, str);
> +	if (i < 0)
>  		return 1;
> +
> +	ima_hash_algo = i;
>  out:
>  	hash_setup_done = 1;
>  	return 1;


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

* Re: [PATCH 16/33] mmc: sdhci-xenon: use match_string() helper
  2018-05-21 11:57 ` [PATCH 16/33] mmc: sdhci-xenon: " Yisheng Xie
@ 2018-05-24  7:58   ` Adrian Hunter
  2018-05-28 11:27   ` Ulf Hansson
  1 sibling, 0 replies; 88+ messages in thread
From: Adrian Hunter @ 2018-05-24  7:58 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel; +Cc: Hu Ziji, Ulf Hansson, linux-mmc

On 21/05/18 14:57, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Hu Ziji <huziji@marvell.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-xenon-phy.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c
> index ec87943..a35804b 100644
> --- a/drivers/mmc/host/sdhci-xenon-phy.c
> +++ b/drivers/mmc/host/sdhci-xenon-phy.c
> @@ -814,15 +814,10 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,
>  {
>  	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>  	struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
> -	int i, ret;
> +	int ret;
>  
> -	for (i = 0; i < NR_PHY_TYPES; i++) {
> -		if (!strcmp(phy_name, phy_types[i])) {
> -			priv->phy_type = i;
> -			break;
> -		}
> -	}
> -	if (i == NR_PHY_TYPES) {
> +	priv->phy_type = match_string(phy_types, NR_PHY_TYPES, phy_name);
> +	if (priv->phy_type < 0) {
>  		dev_err(mmc_dev(host->mmc),
>  			"Unable to determine PHY name %s. Use default eMMC 5.1 PHY\n",
>  			phy_name);
> 

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

* Re: [PATCH 08/33] vfio: use match_string() helper
  2018-05-21 11:57 ` [PATCH 08/33] vfio: " Yisheng Xie
@ 2018-05-25 20:55   ` Alex Williamson
  0 siblings, 0 replies; 88+ messages in thread
From: Alex Williamson @ 2018-05-25 20:55 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: linux-kernel, kvm

On Mon, 21 May 2018 19:57:45 +0800
Yisheng Xie <xieyisheng1@huawei.com> wrote:

> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: kvm@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  drivers/vfio/vfio.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)

Applied to the vfio next branch for v4.18 with Andy's R-b.  Thanks,

Alex

 
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 721f97f..6483387 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -630,8 +630,6 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group,
>  
>  static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv)
>  {
> -	int i;
> -
>  	if (dev_is_pci(dev)) {
>  		struct pci_dev *pdev = to_pci_dev(dev);
>  
> @@ -639,12 +637,9 @@ static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv)
>  			return true;
>  	}
>  
> -	for (i = 0; i < ARRAY_SIZE(vfio_driver_whitelist); i++) {
> -		if (!strcmp(drv->name, vfio_driver_whitelist[i]))
> -			return true;
> -	}
> -
> -	return false;
> +	return match_string(vfio_driver_whitelist,
> +			    ARRAY_SIZE(vfio_driver_whitelist),
> +			    drv->name) >= 0;
>  }
>  
>  /*

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

* Re: [PATCH 16/33] mmc: sdhci-xenon: use match_string() helper
  2018-05-21 11:57 ` [PATCH 16/33] mmc: sdhci-xenon: " Yisheng Xie
  2018-05-24  7:58   ` Adrian Hunter
@ 2018-05-28 11:27   ` Ulf Hansson
  1 sibling, 0 replies; 88+ messages in thread
From: Ulf Hansson @ 2018-05-28 11:27 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: Linux Kernel Mailing List, Adrian Hunter, Hu Ziji, linux-mmc

On 21 May 2018 at 13:57, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Hu Ziji <huziji@marvell.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>

Thanks, applied for next!

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-xenon-phy.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c
> index ec87943..a35804b 100644
> --- a/drivers/mmc/host/sdhci-xenon-phy.c
> +++ b/drivers/mmc/host/sdhci-xenon-phy.c
> @@ -814,15 +814,10 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,
>  {
>         struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>         struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
> -       int i, ret;
> +       int ret;
>
> -       for (i = 0; i < NR_PHY_TYPES; i++) {
> -               if (!strcmp(phy_name, phy_types[i])) {
> -                       priv->phy_type = i;
> -                       break;
> -               }
> -       }
> -       if (i == NR_PHY_TYPES) {
> +       priv->phy_type = match_string(phy_types, NR_PHY_TYPES, phy_name);
> +       if (priv->phy_type < 0) {
>                 dev_err(mmc_dev(host->mmc),
>                         "Unable to determine PHY name %s. Use default eMMC 5.1 PHY\n",
>                         phy_name);
> --
> 1.7.12.4
>

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

* Applied "ASoC: dapm: use match_string() helper" to the asoc tree
  2018-05-21 11:58 ` [PATCH 33/33] ASoC: dapm: " Yisheng Xie
@ 2018-05-31 16:09   ` Mark Brown
  0 siblings, 0 replies; 88+ messages in thread
From: Mark Brown @ 2018-05-31 16:09 UTC (permalink / raw)
  To: Xie Yisheng
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, Yisheng Xie, Mark Brown, linux-kernel, Yisheng Xie,
	alsa-devel, Takashi Iwai, Liam Girdwood, Mark Brown, alsa-devel

The patch

   ASoC: dapm: use match_string() helper

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From f9e0b4afd4e9b19e95158962d81b5b776d57ca06 Mon Sep 17 00:00:00 2001
From: Xie Yisheng <xieyisheng1@huawei.com>
Date: Thu, 31 May 2018 19:11:23 +0800
Subject: [PATCH] ASoC: dapm: 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: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-dapm.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2d9709104ec5..1e9a36389667 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -724,18 +724,14 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
 		item = 0;
 	}
 
-	for (i = 0; i < e->items; i++) {
-		if (!(strcmp(control_name, e->texts[i]))) {
-			path->name = e->texts[i];
-			if (i == item)
-				path->connect = 1;
-			else
-				path->connect = 0;
-			return 0;
-		}
-	}
+	i = match_string(e->texts, e->items, control_name);
+	if (i < 0)
+		return -ENODEV;
+
+	path->name = e->texts[i];
+	path->connect = (i == item);
+	return 0;
 
-	return -ENODEV;
 }
 
 /* set up initial codec paths */
-- 
2.17.0

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

* Re: [PATCH 02/33] mfd: omap-usb-host: use match_string() helper
  2018-05-21 11:57 ` [PATCH 02/33] mfd: omap-usb-host: " Yisheng Xie
  2018-05-21 17:41   ` Tony Lindgren
@ 2018-06-04  6:15   ` Lee Jones
  1 sibling, 0 replies; 88+ messages in thread
From: Lee Jones @ 2018-06-04  6:15 UTC (permalink / raw)
  To: Yisheng Xie; +Cc: linux-kernel, Tony Lindgren, linux-omap

On Mon, 21 May 2018, Yisheng Xie wrote:

> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
> 
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: linux-omap@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
>  drivers/mfd/omap-usb-host.c | 24 ++----------------------
>  1 file changed, 2 insertions(+), 22 deletions(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 19/33] thermal: db8500: use match_string() helper
  2018-05-23  7:47     ` Yisheng Xie
@ 2018-06-05 16:14       ` Andy Shevchenko
  0 siblings, 0 replies; 88+ messages in thread
From: Andy Shevchenko @ 2018-06-05 16:14 UTC (permalink / raw)
  To: Yisheng Xie
  Cc: Linux Kernel Mailing List, Zhang Rui, Eduardo Valentin, Linux PM

On Wed, May 23, 2018 at 10:47 AM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> Hi Andy,
>
> On 2018/5/22 6:00, Andy Shevchenko wrote:
>> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
>>> match_string() returns the index of an array for a matching string,
>>> which can be used intead of open coded variant.
>>
>>> +       i = match_string((const char **)trip_point->cdev_name,
>>
>> Casting looks ugly. You need to constify the variable itself.
> When I tried to const cdev_name like:
> +++ b/include/linux/platform_data/db8500_thermal.h
> @@ -27,7 +27,7 @@
>  struct db8500_trip_point {
>         unsigned long temp;
>         enum thermal_trip_type type;
> -       char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH];
> +       char const cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH]; // const char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH] will also the same
>  };
>
> The compiler will also warning:
> drivers/thermal/db8500_thermal.c: In function ‘db8500_thermal_match_cdev’:
> drivers/thermal/db8500_thermal.c:53:2: warning: passing argument 1 of ‘match_string’ from incompatible pointer type [enabled by default]
>   i = match_string(trip_point->cdev_name, COOLING_DEV_MAX, cdev->type);
>   ^
> In file included from include/linux/bitmap.h:9:0,
>                  from include/linux/cpumask.h:12,
>                  from include/linux/rcupdate.h:44,
>                  from include/linux/radix-tree.h:28,
>                  from include/linux/idr.h:15,
>                  from include/linux/kernfs.h:14,
>                  from include/linux/sysfs.h:16,
>                  from kernel/include/linux/kobject.h:20,
>                  from kernel/include/linux/of.h:17,
>                  from include/linux/cpu_cooling.h:27,
>                  from drivers/thermal/db8500_thermal.c:20:
> include/linux/string.h:184:5: note: expected ‘const char * const*’ but argument is of type ‘const char (*)[20]’
>
> Any idea?

Yes.
If you wish to continue, you need to do two patches instead, where in
first you are changing fixed array size of pointers to dynamic one and
replace or loops from being by size to ones being NULL terminated.


-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2018-06-05 16:14 UTC | newest]

Thread overview: 88+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21 11:57 [PATCH 00/33] use match_string() helper Yisheng Xie
2018-05-21 11:57 ` [PATCH 01/33] usb: phy: " Yisheng Xie
2018-05-21 22:20   ` Andy Shevchenko
2018-05-22 10:02     ` Greg Kroah-Hartman
2018-05-22 11:12       ` Yisheng Xie
2018-05-21 11:57 ` [PATCH 02/33] mfd: omap-usb-host: " Yisheng Xie
2018-05-21 17:41   ` Tony Lindgren
2018-06-04  6:15   ` Lee Jones
2018-05-21 11:57 ` [PATCH 03/33] Staging: gdm724x: " Yisheng Xie
2018-05-21 21:35   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 04/33] gpiolib-of: " Yisheng Xie
2018-05-21 21:36   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 05/33] cxgb4: " Yisheng Xie
2018-05-21 21:39   ` Andy Shevchenko
2018-05-22  0:55     ` Yisheng Xie
2018-05-21 11:57 ` [PATCH 06/33] hp100: " Yisheng Xie
2018-05-21 11:57 ` [PATCH 07/33] iwlwifi: mvm: " Yisheng Xie
2018-05-21 20:12   ` Luca Coelho
2018-05-21 21:43   ` Andy Shevchenko
2018-05-22  3:30     ` Yisheng Xie
2018-05-22 20:41       ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 08/33] vfio: " Yisheng Xie
2018-05-25 20:55   ` Alex Williamson
2018-05-21 11:57 ` [PATCH 09/33] phy: tegra: " Yisheng Xie
2018-05-21 21:45   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 10/33] pata_hpt37x: " Yisheng Xie
2018-05-21 21:46   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 11/33] bus: fsl-mc: " Yisheng Xie
2018-05-21 11:57 ` [PATCH 12/33] clk: bcm2835: " Yisheng Xie
2018-05-21 17:48   ` Eric Anholt
2018-05-21 21:50   ` Andy Shevchenko
2018-05-22  3:42     ` Yisheng Xie
2018-05-21 11:57 ` [PATCH 13/33] clk: rockchip: " Yisheng Xie
2018-05-22 13:56   ` Heiko Stuebner
2018-05-21 11:57 ` [PATCH 14/33] clk: " Yisheng Xie
2018-05-21 21:53   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 15/33] cpufreq: intel_pstate: " Yisheng Xie
2018-05-21 11:57 ` [PATCH 16/33] mmc: sdhci-xenon: " Yisheng Xie
2018-05-24  7:58   ` Adrian Hunter
2018-05-28 11:27   ` Ulf Hansson
2018-05-21 11:57 ` [PATCH 17/33] pinctrl: armada-37xx: " Yisheng Xie
2018-05-21 21:55   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 18/33] power: supply: " Yisheng Xie
2018-05-21 21:58   ` Andy Shevchenko
2018-05-22 16:16     ` Sebastian Reichel
2018-05-21 11:57 ` [PATCH 19/33] thermal: db8500: " Yisheng Xie
2018-05-21 22:00   ` Andy Shevchenko
2018-05-23  7:47     ` Yisheng Xie
2018-06-05 16:14       ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 20/33] video: fbdev: pxafb: " Yisheng Xie
2018-05-21 22:01   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 21/33] drm/nouveau: " Yisheng Xie
2018-05-21 22:03   ` Andy Shevchenko
2018-05-21 11:57 ` [PATCH 22/33] drm/i915: " Yisheng Xie
2018-05-21 22:04   ` Andy Shevchenko
2018-05-22  8:36     ` Jani Nikula
2018-05-22  9:22       ` Yisheng Xie
2018-05-21 11:58 ` [PATCH 23/33] drm: i2c: ch7006: " Yisheng Xie
2018-05-21 11:58 ` [PATCH 24/33] drm: " Yisheng Xie
2018-05-21 22:06   ` Andy Shevchenko
2018-05-22  8:39     ` Jani Nikula
2018-05-21 11:58 ` [PATCH 25/33] ima: " Yisheng Xie
2018-05-23 14:42   ` Mimi Zohar
2018-05-21 11:58 ` [PATCH 26/33] apparmor: " Yisheng Xie
2018-05-21 15:33   ` John Johansen
2018-05-22  1:25     ` Yisheng Xie
2018-05-21 22:10   ` Andy Shevchenko
2018-05-21 11:58 ` [PATCH 27/33] sched/debug: " Yisheng Xie
2018-05-21 22:13   ` Andy Shevchenko
2018-05-22 12:10     ` Yisheng Xie
2018-05-22 20:29       ` Andy Shevchenko
2018-05-21 11:58 ` [PATCH 28/33] ALSA: dice " Yisheng Xie
2018-05-21 22:31   ` Takashi Sakamoto
2018-05-21 11:58 ` [PATCH 29/33] ALSA: oxfw: " Yisheng Xie
2018-05-21 22:26   ` [alsa-devel] " Takashi Sakamoto
2018-05-22  7:26     ` Takashi Iwai
2018-05-21 11:58 ` [PATCH 30/33] ALSA: oxygen: " Yisheng Xie
2018-05-21 22:23   ` Andy Shevchenko
2018-05-21 11:58 ` [PATCH 31/33] ASoC: max98088: " Yisheng Xie
2018-05-21 22:24   ` Andy Shevchenko
2018-05-22 12:30     ` Yisheng Xie
2018-05-22 17:23       ` Andy Shevchenko
2018-05-21 11:58 ` [PATCH 32/33] ASoC: max98095: " Yisheng Xie
2018-05-21 22:25   ` Andy Shevchenko
2018-05-21 11:58 ` [PATCH 33/33] ASoC: dapm: " Yisheng Xie
2018-05-31 16:09   ` Applied "ASoC: dapm: use match_string() helper" to the asoc tree Mark Brown
2018-05-21 22:27 ` [PATCH 00/33] use match_string() helper Andy Shevchenko
2018-05-22  0:52   ` Yisheng Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).