linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Oliver Neukum <oneukum@suse.com>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	Bin Gao <bin.gao@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATHCv10 1/2] usb: USB Type-C connector class
Date: Wed, 16 Nov 2016 16:31:07 +0100	[thread overview]
Message-ID: <20161116153107.GB30001@kroah.com> (raw)
In-Reply-To: <20161116152024.GD30235@kuha.fi.intel.com>

On Wed, Nov 16, 2016 at 05:20:24PM +0200, Heikki Krogerus wrote:
> Hi Greg,
> 
> On Mon, Nov 14, 2016 at 10:51:48AM +0100, Greg KH wrote:
> > > +static int sysfs_strmatch(const char * const *array, size_t n, const char *str)
> > > +{
> > > +	const char *item;
> > > +	int index;
> > > +
> > > +	for (index = 0; index < n; index++) {
> > > +		item = array[index];
> > > +		if (!item)
> > > +			break;
> > > +		if (sysfs_streq(item, str))
> > > +			return index;
> > > +	}
> > > +
> > > +	return -EINVAL;
> > > +}
> > 
> > should we make this a core sysfs function?
> 
> Last question before I send v11. Is the following (the helper) OK?
> 
> 
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 26b6f6a..5606810 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -135,6 +135,16 @@ static inline int strtobool(const char *s, bool *res)
>  }
>  
>  int match_string(const char * const *array, size_t n, const char *string);
> +int __sysfs_strmatch(const char * const *array, size_t n, const char *string);
> +
> +/**
> + * sysfs_strmatch - matches given string in an array
> + * @a: array of strings
> + * @s: string to match with
> + *
> + * Helper for __sysfs_strmatch(). Calculates the size of @a automatically.
> + */
> +#define sysfs_strmatch(a, s) __sysfs_strmatch(a, ARRAY_SIZE(a), s)

People will bikeshed the name.  Why not just use sysfs_match_string() as
this does the same as match_string, but calls sysfs_string instead of
strcmp().

thanks,

greg k-h

  parent reply	other threads:[~2016-11-16 15:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19 11:16 [PATHCv10 0/2] USB Type-C Connector class Heikki Krogerus
2016-09-19 11:16 ` [PATHCv10 1/2] usb: USB Type-C connector class Heikki Krogerus
2016-11-14  9:51   ` Greg KH
2016-11-14 12:32     ` Heikki Krogerus
2016-11-14 14:11       ` Greg KH
2016-11-14 14:39         ` Heikki Krogerus
2016-11-14 15:08           ` Greg KH
2016-11-14 14:34       ` Guenter Roeck
2016-11-16  8:47         ` Oliver Neukum
2016-11-14 20:46       ` Guenter Roeck
2016-11-15  7:07         ` Greg KH
2016-11-15  9:25           ` Guenter Roeck
2016-11-16  0:19             ` Badhri Jagan Sridharan
2016-11-16  9:30               ` Heikki Krogerus
2016-11-16  9:39                 ` Oliver Neukum
2016-11-16  9:49                 ` Greg KH
2016-11-16 11:09                   ` Heikki Krogerus
2016-11-16 11:27                     ` Oliver Neukum
2016-11-16 14:30                       ` Badhri Jagan Sridharan
2016-11-16 14:43                         ` Heikki Krogerus
2016-11-16 15:20     ` Heikki Krogerus
2016-11-16 15:25       ` Badhri Jagan Sridharan
2016-11-16 15:31       ` Greg KH [this message]
2016-11-17  8:28         ` Heikki Krogerus
2016-09-19 11:16 ` [PATHCv10 2/2] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY Heikki Krogerus
2016-11-10 21:36 ` [PATHCv10 0/2] USB Type-C Connector class Guenter Roeck
2016-11-11 11:04   ` Heikki Krogerus
2016-11-14  7:46     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161116153107.GB30001@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bin.gao@linux.intel.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=oneukum@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).