kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Greg Kroah-Hartman <greg@kroah.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 04/12] staging: usbip: stub_main.c: code cleanup
Date: Sat, 21 May 2011 11:45:31 +0000	[thread overview]
Message-ID: <4DD7A5DB.7050000@bfs.de> (raw)
In-Reply-To: <20110520184517.GB83316@haskell.muteddisk.com>



Am 20.05.2011 20:45, schrieb matt mooney:
> On 11:08 Fri 20 May     , walter harms wrote:
>>
>>
>> Am 20.05.2011 06:36, schrieb matt mooney:
>>> Remove match_find() and replace with get_busid_idx(); change
>>> get_busid_priv(), add_match_busid(), and del_match_busid() to use
>>> get_busid_idx(); and cleanup code in the other functions.
>>>
>>> Signed-off-by: matt mooney <mfm@muteddisk.com>
>>> ---
>>>  drivers/staging/usbip/stub_main.c |  147 ++++++++++++++++++-------------------
>>>  1 files changed, 73 insertions(+), 74 deletions(-)
>>>
>>> diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c
>>> index 0ca1462..00398a6 100644
>>> --- a/drivers/staging/usbip/stub_main.c
>>> +++ b/drivers/staging/usbip/stub_main.c
>>> @@ -50,82 +50,90 @@ static void init_busid_table(void)
>>>  	spin_lock_init(&busid_table_lock);
>>>  }
>>>  
>>> -int match_busid(const char *busid)
>>> +/*
>>> + * Find the index of the busid by name.
>>> + * Must be called with busid_table_lock held.
>>> + */
>>> +static int get_busid_idx(const char *busid)
>>>  {
>>>  	int i;
>>> +	int idx = -1;
>>>  
>>> -	spin_lock(&busid_table_lock);
>>>  	for (i = 0; i < MAX_BUSID; i++)
>>>  		if (busid_table[i].name[0])
>>>  			if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
>>> -				/* already registerd */
>>> -				spin_unlock(&busid_table_lock);
>>> -				return 0;
>>> +				idx = i;
>>> +				break;
>>>  			}
>>> -	spin_unlock(&busid_table_lock);
>>> -
>>> -	return 1;
>>> +	return idx;
>>>  }
>>>  
>>>  struct bus_id_priv *get_busid_priv(const char *busid)
>>>  {
>>> -	int i;
>>> +	int idx;
>>> +	struct bus_id_priv *bid = NULL;
>>>  
>>>  	spin_lock(&busid_table_lock);
>>> -	for (i = 0; i < MAX_BUSID; i++)
>>> -		if (busid_table[i].name[0])
>>> -			if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
>>> -				/* already registerd */
>>> -				spin_unlock(&busid_table_lock);
>>> -				return &(busid_table[i]);
>>> -			}
>>> +	idx = get_busid_idx(busid);
>>> +	if (idx >= 0)
>>> +		bid = &(busid_table[idx]);
>>>  	spin_unlock(&busid_table_lock);
>>>  
>>> -	return NULL;
>>> +	return bid;
>>>  }
>>>  
>>>  static int add_match_busid(char *busid)
>>>  {
>>>  	int i;
>>> -
>>> -	if (!match_busid(busid))
>>> -		return 0;
>>> +	int ret = -1;
>>>  
>>>  	spin_lock(&busid_table_lock);
>>> +	/* already registered? */
>>> +	if (get_busid_idx(busid) >= 0) {
>>> +		ret = 0;
>>> +		goto out;
>>> +	}
>>> +
>>>  	for (i = 0; i < MAX_BUSID; i++)
>>>  		if (!busid_table[i].name[0]) {
>>>  			strncpy(busid_table[i].name, busid, BUSID_SIZE);
>>
>> i am missing an if() here ??
> 
> I am not sure what you mean. It should be correct.
>  

ups, sorry my fault
missread it as strcmp() everything is fine now.

re,
 wh


  reply	other threads:[~2011-05-21 11:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20  4:36 [PATCH 00/12] staging: usbip matt mooney
2011-05-20  4:36 ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ matt mooney
2011-05-20  4:59   ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and Greg KH
2011-05-20  5:25     ` matt mooney
2011-05-20 12:53       ` Greg KH
2011-05-20 18:51         ` [PATCH 01/12] staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_ matt mooney
2011-05-20  4:36 ` [PATCH 02/12] staging: usbip: remove unnecessary lines and extra return statements matt mooney
2011-05-20  4:36 ` [PATCH 03/12] staging: usbip: stub_main.c: reorder functions matt mooney
2011-05-20  8:37   ` walter harms
2011-05-20 18:42   ` matt mooney
2011-05-20  4:36 ` [PATCH 04/12] staging: usbip: stub_main.c: code cleanup matt mooney
2011-05-20  9:08   ` walter harms
2011-05-20 18:45     ` matt mooney
2011-05-21 11:45       ` walter harms [this message]
2011-05-20  4:36 ` [PATCH 05/12] staging: usbip: stub_main.c: rename init and exit functions matt mooney
2011-05-20  4:37 ` [PATCH 06/12] staging: usbip: stub_main.c: use KMEM_CACHE macro matt mooney
2011-05-20  4:37 ` [PATCH 07/12] staging: usbip: usbip_common.c: fix misspelled function name matt mooney
2011-05-20  4:37 ` [PATCH 08/12] staging: usbip: usbip_common.h: reorganize and document request headers matt mooney
2011-05-20  4:37 ` [PATCH 09/12] staging: usbip: stub_dev.c: move stub_driver definition and update driver name matt mooney
2011-05-20  4:37 ` [PATCH 10/12] staging: usbip: userspace: bind_driver.c: update kernel module name matt mooney
2011-05-20  4:37 ` [PATCH 11/12] staging: usbip: usbip_common.c: rename init and exit functions matt mooney
2011-05-20  4:37 ` [PATCH 12/12] staging: usbip: vhci_hcd.c: " matt mooney

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=4DD7A5DB.7050000@bfs.de \
    --to=wharms@bfs.de \
    --cc=greg@kroah.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).