All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/21] use match_string() helper
@ 2018-05-31 11:11 Yisheng Xie
  2018-05-31 11:11   ` Yisheng Xie
                   ` (20 more replies)
  0 siblings, 21 replies; 113+ messages in thread
From: Yisheng Xie @ 2018-05-31 11:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: andy.shevchenko, 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
instead of open coded variant.

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

v2:
 - Remove the Patches which Andy already sent out, or maintainer already
   picked up.
 - Add Reviewed-by or Acked-by tags for some patchs.
 - Add some new patches[19-21].

Yisheng Xie (21):
  usb: phy: use match_string() helper
  mfd: omap-usb-host: use match_string() helper
  Staging: gdm724x: use match_string() helper
  cxgb4: use match_string() helper
  hp100: use match_string() helper
  iwlwifi: mvm: use match_string() helper
  bus: fsl-mc: use match_string() helper
  clk: bcm2835: use match_string() helper
  clk: use match_string() helper
  cpufreq: intel_pstate: use match_string() helper
  drm/nouveau: use match_string() helper
  drm: i2c: ch7006: use match_string() helper
  ima: use match_string() helper
  sched/debug: 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
  bcache: use match_string() helper
  powerpc/xmon: use match_string() helper
  sparc64: use match_string() helper

 arch/powerpc/xmon/xmon.c                         | 23 +++++++++---------
 arch/sparc/kernel/setup_64.c                     |  7 +++---
 drivers/bus/fsl-mc/fsl-mc-allocator.c            | 24 ++++--------------
 drivers/clk/bcm/clk-bcm2835.c                    | 13 +++++-----
 drivers/clk/clk.c                                |  8 ++----
 drivers/cpufreq/intel_pstate.c                   | 15 +++++-------
 drivers/gpu/drm/i2c/ch7006_drv.c                 | 13 ++++------
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c        | 13 ++++------
 drivers/md/bcache/util.c                         |  9 ++-----
 drivers/mfd/omap-usb-host.c                      | 24 ++----------------
 drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c   | 14 +++--------
 drivers/net/ethernet/hp/hp100.c                  |  9 +------
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 13 +++-------
 drivers/staging/gdm724x/gdm_tty.c                | 18 ++++----------
 drivers/usb/phy/of.c                             | 10 ++++----
 kernel/sched/debug.c                             | 31 ++++++++++++------------
 security/integrity/ima/ima_main.c                | 11 +++------
 sound/pci/oxygen/oxygen_mixer.c                  | 14 +++++------
 sound/soc/codecs/max98088.c                      | 13 ++++------
 sound/soc/codecs/max98095.c                      | 13 ++++------
 sound/soc/soc-dapm.c                             | 18 ++++++--------
 21 files changed, 109 insertions(+), 204 deletions(-)

-- 
1.7.12.4

^ permalink raw reply	[flat|nested] 113+ messages in thread
* [v2,01/21] usb: phy: use match_string() helper
  2018-05-31 11:11 [PATCH v2 00/21] use match_string() helper Yisheng Xie
@ 2018-05-31 11:11 ` Yisheng Xie
  2018-05-31 11:11 ` [PATCH v2 03/21] Staging: gdm724x: " Yisheng Xie
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 113+ messages in thread
From: Xie Yisheng @ 2018-05-31 11:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: andy.shevchenko, 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 instead 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>
---
v2:
 - donot rename err to ret  - per Andy

 drivers/usb/phy/of.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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

^ permalink raw reply related	[flat|nested] 113+ messages in thread
* [v2,01/21] usb: phy: use match_string() helper
  2018-05-31 11:11 ` [PATCH v2 01/21] " Yisheng Xie
@ 2018-05-31 16:55 ` Sergei Shtylyov
  -1 siblings, 0 replies; 113+ messages in thread
From: Sergei Shtylyov @ 2018-05-31 16:55 UTC (permalink / raw)
  To: Yisheng Xie, linux-kernel
  Cc: andy.shevchenko, linux-usb, Felipe Balbi, Greg Kroah-Hartman

Hello!

On 05/31/2018 02:11 PM, Yisheng Xie wrote:

> match_string() returns the index of an array for a matching string,
> which can be used instead 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>
> ---
> v2:
>  - donot rename err to ret  - per Andy

   Hm...

> 
>  drivers/usb/phy/of.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
> index 1ab134f..9d74081 100644
> --- a/drivers/usb/phy/of.c
> +++ b/drivers/usb/phy/of.c
> @@ -28,16 +28,16 @@
>  enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
>  {
>  	const char *phy_type;
> -	int err, i;
> +	int err;
>  
>  	err = of_property_read_string(np, "phy_type", &phy_type);
>  	if (err < 0)
>  		return USBPHY_INTERFACE_MODE_UNKNOWN;
>  
> -	for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
> -		if (!strcmp(phy_type, usbphy_modes[i]))
> -			return i;
> +	err = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type);
> +	if (err < 0)

   This is one of the few cases when 'err' is not the best name for such a
variable. I'd prefer to see something like 'match' or even 'rc' or 'ret'... :-)

> +		return USBPHY_INTERFACE_MODE_UNKNOWN;
>  
> -	return USBPHY_INTERFACE_MODE_UNKNOWN;
> +	return err;
>  }
>  EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
> 

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

^ permalink raw reply	[flat|nested] 113+ messages in thread
* [v2,01/21] usb: phy: use match_string() helper
  2018-05-31 16:55 ` [PATCH v2 01/21] " Sergei Shtylyov
@ 2018-05-31 18:47 ` Andy Shevchenko
  -1 siblings, 0 replies; 113+ messages in thread
From: Andy Shevchenko @ 2018-05-31 18:47 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Yisheng Xie, Linux Kernel Mailing List, USB, Felipe Balbi,
	Greg Kroah-Hartman

On Thu, May 31, 2018 at 7:55 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:

>>  - donot rename err to ret  - per Andy
>
>    Hm...

>> -     int err, i;

>> +     err = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type);
>> +     if (err < 0)
>
>    This is one of the few cases when 'err' is not the best name for such a
> variable. I'd prefer to see something like 'match' or even 'rc' or 'ret'... :-)

Then leaving i would make it?
I'm okay with either which just not renames err, b/c it's used with
something else in this function.

^ permalink raw reply	[flat|nested] 113+ messages in thread
* [v2,01/21] usb: phy: use match_string() helper
  2018-05-31 18:47 ` [PATCH v2 01/21] " Andy Shevchenko
@ 2018-05-31 18:56 ` Sergei Shtylyov
  -1 siblings, 0 replies; 113+ messages in thread
From: Sergei Shtylyov @ 2018-05-31 18:56 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Yisheng Xie, Linux Kernel Mailing List, USB, Felipe Balbi,
	Greg Kroah-Hartman

On 05/31/2018 09:47 PM, Andy Shevchenko wrote:

>>>  - donot rename err to ret  - per Andy
>>
>>    Hm...
> 
>>> -     int err, i;
> 
>>> +     err = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type);
>>> +     if (err < 0)
>>
>>    This is one of the few cases when 'err' is not the best name for such a
>> variable. I'd prefer to see something like 'match' or even 'rc' or 'ret'... :-)
> 
> Then leaving i would make it?

   Yes. :-)

> I'm okay with either which just not renames err, b/c it's used with
> something else in this function.

   Looking at it again, 'err' seems equally bad for the result of 
of_property_read_string()... unless the check there is changed to just *if* (err) --
this function never returns positive values, 0 means success, others mean error.

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

^ permalink raw reply	[flat|nested] 113+ messages in thread
* [v2,01/21] usb: phy: use match_string() helper
  2018-05-31 18:56 ` [PATCH v2 01/21] " Sergei Shtylyov
@ 2018-05-31 18:59 ` Andy Shevchenko
  -1 siblings, 0 replies; 113+ messages in thread
From: Andy Shevchenko @ 2018-05-31 18:59 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Yisheng Xie, Linux Kernel Mailing List, USB, Felipe Balbi,
	Greg Kroah-Hartman

On Thu, May 31, 2018 at 9:56 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> On 05/31/2018 09:47 PM, Andy Shevchenko wrote:

>>>> -     int err, i;

>>>> +     err = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type);
>>>> +     if (err < 0)
>>>
>>>    This is one of the few cases when 'err' is not the best name for such a
>>> variable. I'd prefer to see something like 'match' or even 'rc' or 'ret'... :-)
>>
>> Then leaving i would make it?
>    Yes. :-)

So, I leave it to Greg to decide either it's okay in this version, or
needs update with i left untouched.

>> I'm okay with either which just not renames err, b/c it's used with
>> something else in this function.
>
>    Looking at it again, 'err' seems equally bad for the result of
> of_property_read_string()... unless the check there is changed to just *if* (err) --
> this function never returns positive values, 0 means success, others mean error.

While you seems right, this is matter of another change which you are
welcome to propose.

^ permalink raw reply	[flat|nested] 113+ messages in thread
* [v2,01/21] usb: phy: use match_string() helper
  2018-05-31 18:59 ` [PATCH v2 01/21] " Andy Shevchenko
@ 2018-06-05  9:28 ` Yisheng Xie
  -1 siblings, 0 replies; 113+ messages in thread
From: Xie Yisheng @ 2018-06-05  9:28 UTC (permalink / raw)
  To: Andy Shevchenko, Sergei Shtylyov
  Cc: Linux Kernel Mailing List, USB, Felipe Balbi, Greg Kroah-Hartman

On 2018/6/1 2:59, Andy Shevchenko wrote:
> On Thu, May 31, 2018 at 9:56 PM, Sergei Shtylyov
> <sergei.shtylyov@cogentembedded.com> wrote:
>> On 05/31/2018 09:47 PM, Andy Shevchenko wrote:
> 
>>>>> -     int err, i;
> 
>>>>> +     err = match_string(usbphy_modes, ARRAY_SIZE(usbphy_modes), phy_type);
>>>>> +     if (err < 0)
>>>>
>>>>    This is one of the few cases when 'err' is not the best name for such a
>>>> variable. I'd prefer to see something like 'match' or even 'rc' or 'ret'... :-)
>>>
>>> Then leaving i would make it?
>>    Yes. :-)
> 
> So, I leave it to Greg to decide either it's okay in this version, or
> needs update with i left untouched.
Hi Greg,

IIRC, you seems want to keep the err unchanged, right?

Please let me know if another version is need.

Thanks
Yisheng

> 
>>> I'm okay with either which just not renames err, b/c it's used with
>>> something else in this function.
>>
>>    Looking at it again, 'err' seems equally bad for the result of
>> of_property_read_string()... unless the check there is changed to just *if* (err) --
>> this function never returns positive values, 0 means success, others mean error.
> 
> While you seems right, this is matter of another change which you are
> welcome to propose.
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2018-07-04 10:52 UTC | newest]

Thread overview: 113+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-31 11:11 [PATCH v2 00/21] use match_string() helper Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 02/21] mfd: omap-usb-host: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-06-04  7:44   ` Lee Jones
2018-06-04  8:13     ` Yisheng Xie
2018-06-04  8:13       ` Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 03/21] Staging: gdm724x: " Yisheng Xie
2018-05-31 11:44   ` Greg Kroah-Hartman
2018-05-31 12:12     ` Yisheng Xie
2018-06-06  2:21   ` [PATCH v3 " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 04/21] cxgb4: " Yisheng Xie
2018-06-05 13:19   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 05/21] hp100: " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 06/21] iwlwifi: mvm: " Yisheng Xie
2018-06-05 13:19   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 07/21] bus: fsl-mc: " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 08/21] clk: bcm2835: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-06-02  6:17   ` Stephen Boyd
2018-06-02  6:17     ` Stephen Boyd
2018-06-02  6:17     ` Stephen Boyd
2018-05-31 11:11 ` [PATCH v2 09/21] clk: " Yisheng Xie
2018-06-02  6:17   ` Stephen Boyd
2018-06-02  6:17     ` Stephen Boyd
2018-05-31 11:11 ` [PATCH v2 10/21] cpufreq: intel_pstate: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-06-26 15:23   ` Rafael J. Wysocki
2018-06-26 23:56     ` Srinivas Pandruvada
2018-07-04 10:52       ` Rafael J. Wysocki
     [not found] ` <1527765086-19873-1-git-send-email-xieyisheng1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2018-05-31 11:11   ` [PATCH v2 11/21] drm/nouveau: " Yisheng Xie
2018-05-31 11:11     ` Yisheng Xie
2018-06-05 13:20     ` Andy Shevchenko
2018-06-05 13:20       ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 12/21] drm: i2c: ch7006: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-06-05 13:21   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 13/21] ima: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-05-31 15:02   ` Mimi Zohar
2018-05-31 15:02     ` Mimi Zohar
2018-06-01 10:55     ` Andy Shevchenko
2018-06-01 10:55       ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 14/21] sched/debug: " Yisheng Xie
2018-06-05 13:21   ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 15/21] ALSA: oxygen: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-05-31 18:39   ` Takashi Iwai
2018-05-31 18:39     ` Takashi Iwai
2018-05-31 18:40     ` Andy Shevchenko
2018-05-31 18:43       ` Takashi Iwai
2018-05-31 18:43         ` Takashi Iwai
2018-05-31 18:44         ` Andy Shevchenko
2018-05-31 18:41   ` Andy Shevchenko
2018-05-31 18:59     ` Takashi Iwai
2018-05-31 19:02       ` Andy Shevchenko
2018-05-31 20:30         ` Takashi Iwai
2018-05-31 11:11 ` [PATCH v2 16/21] ASoC: max98088: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-05-31 11:49   ` Mark Brown
2018-05-31 12:25     ` Yisheng Xie
2018-05-31 12:25       ` Yisheng Xie
2018-05-31 16:02       ` Mark Brown
2018-06-01  0:38         ` Yisheng Xie
2018-06-01  0:38           ` Yisheng Xie
2018-05-31 16:09   ` Applied "ASoC: max98088: use match_string() helper" to the asoc tree Mark Brown
2018-05-31 16:09     ` Mark Brown
2018-05-31 11:11 ` [PATCH v2 17/21] ASoC: max98095: use match_string() helper Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-05-31 16:09   ` Applied "ASoC: max98095: use match_string() helper" to the asoc tree Mark Brown
2018-05-31 16:09     ` Mark Brown
2018-05-31 11:11 ` [PATCH v2 18/21] ASoC: dapm: use match_string() helper Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 19/21] bcache: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-06-01  3:45   ` Coly Li
2018-06-01  4:32     ` Yisheng Xie
2018-06-01  4:32       ` Yisheng Xie
2018-06-01  5:04       ` Coly Li
2018-05-31 11:11 ` [PATCH v2 20/21] powerpc/xmon: " Yisheng Xie
2018-06-04 14:11   ` [v2,20/21] " Michael Ellerman
2018-05-31 11:11 ` [PATCH v2 21/21] sparc64: " Yisheng Xie
2018-05-31 11:11   ` Yisheng Xie
2018-06-01 11:34   ` Andy Shevchenko
2018-06-01 11:34     ` Andy Shevchenko
2018-06-04  1:06     ` Yisheng Xie
2018-06-04  1:06       ` Yisheng Xie
2018-06-04 10:06       ` Andy Shevchenko
2018-06-04 10:06         ` Andy Shevchenko
2018-06-05  9:05         ` Yisheng Xie
2018-06-05  9:05           ` Yisheng Xie
2018-06-06  2:19   ` [PATCH v3 " Yisheng Xie
2018-06-06  2:19     ` Yisheng Xie
2018-06-06  5:01     ` Andy Shevchenko
2018-06-06  5:01       ` Andy Shevchenko
2018-06-21  1:13       ` Yisheng Xie
2018-06-21  1:13         ` Yisheng Xie
2018-06-21  1:39       ` [PATCH v4 " Yisheng Xie
2018-06-21  1:39         ` Yisheng Xie
2018-06-21  2:24         ` Andy Shevchenko
2018-06-21  2:24           ` Andy Shevchenko
2018-05-31 12:23 ` [PATCH v2 00/21] " Yisheng Xie
  -- strict thread matches above, loose matches on Subject: below --
2018-05-31 11:11 [v2,01/21] usb: phy: " Xie Yisheng
2018-05-31 11:11 ` [PATCH v2 01/21] " Yisheng Xie
2018-05-31 16:55 [v2,01/21] " Sergei Shtylyov
2018-05-31 16:55 ` [PATCH v2 01/21] " Sergei Shtylyov
2018-05-31 18:47 [v2,01/21] " Andy Shevchenko
2018-05-31 18:47 ` [PATCH v2 01/21] " Andy Shevchenko
2018-05-31 18:56 [v2,01/21] " Sergei Shtylyov
2018-05-31 18:56 ` [PATCH v2 01/21] " Sergei Shtylyov
2018-05-31 18:59 [v2,01/21] " Andy Shevchenko
2018-05-31 18:59 ` [PATCH v2 01/21] " Andy Shevchenko
2018-06-05  9:28 [v2,01/21] " Xie Yisheng
2018-06-05  9:28 ` [PATCH v2 01/21] " Yisheng Xie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.