lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130210114729.GB5472@nekote.pengutronix.de>
Date:	Sun, 10 Feb 2013 12:47:30 +0100
From:	Wolfram Sang <w.sang@...gutronix.de>
To:	Tejun Heo <tj@...nel.org>
Cc:	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
	Jean Delvare <khali@...ux-fr.org>, linux-i2c@...r.kernel.org
Subject: Re: [PATCH v2] i2c: convert to idr_alloc()

Hi,

thanks for doing this cleanup series. Looks very worthwhile!

> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -935,25 +935,16 @@ out_list:
>   */
>  int i2c_add_adapter(struct i2c_adapter *adapter)
>  {
> -	int	id, res = 0;
> -
> -retry:
> -	if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0)
> -		return -ENOMEM;
> +	int res;

I'd vote for using 'id' as the variable name here. Feels more logical to
me and you are using 'id' in the other block, too.

> @@ -984,33 +975,19 @@ EXPORT_SYMBOL(i2c_add_adapter);
>  int i2c_add_numbered_adapter(struct i2c_adapter *adap)
>  {
>  	int	id;
> -	int	status;
>  
>  	if (adap->nr == -1) /* -1 means dynamically assign bus id */
>  		return i2c_add_adapter(adap);
>  	if (adap->nr & ~MAX_IDR_MASK)
>  		return -EINVAL;
>  
> -retry:
> -	if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0)
> -		return -ENOMEM;
> -
>  	mutex_lock(&core_lock);
> -	/* "above" here means "above or equal to", sigh;
> -	 * we need the "equal to" result to force the result
> -	 */
> -	status = idr_get_new_above(&i2c_adapter_idr, adap, adap->nr, &id);
> -	if (status == 0 && id != adap->nr) {
> -		status = -EBUSY;
> -		idr_remove(&i2c_adapter_idr, id);
> -	}
> +	id = idr_alloc(&i2c_adapter_idr, adap, adap->nr, adap->nr + 1,
> +		       GFP_KERNEL);
>  	mutex_unlock(&core_lock);
> -	if (status == -EAGAIN)
> -		goto retry;
> -
> -	if (status == 0)
> -		status = i2c_register_adapter(adap);
> -	return status;
> +	if (id < 0)
> +		return id == -ENOSPC ? -EBUSY : id;
> +	return i2c_register_adapter(adap);

Add an empty line before the return statement?

Thanks,

   Wolfram

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ