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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 29 Jan 2020 19:15:11 +0100
From:   Lars-Peter Clausen <lars@...afoo.de>
To:     Mircea Caprioru <mircea.caprioru@...log.com>, jic23@...nel.org
Cc:     Michael.Hennerich@...log.com, alexandru.ardelean@...log.com,
        gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
        linux-iio@...r.kernel.org
Subject: Re: [PATCH V3] iio: adc: ad7124: Add direct reg access

[...]
>   
> +static int ad7124_reg_access(struct iio_dev *indio_dev,
> +			     unsigned int reg,
> +			     unsigned int writeval,
> +			     unsigned int *readval)
> +{
> +	struct ad7124_state *st = iio_priv(indio_dev);
> +	int ret;
> +
> +	if (reg >= AD7124_REG_NO)

How about ARRAY_SIZE(ad7124_reg_size)? That will make sure that the 
check is always correct and does not depend on an extra constant that 
might go out-of-sync with the array. It also makes it easier for 
reviewers to check that the code is correct. Otherwise they'll have to 
count how many entries there are in ad7124_reg_size.

> +		return -EINVAL;
> +
> +	if (readval)
> +		ret = ad_sd_read_reg(&st->sd, reg, ad7124_reg_size[reg],
> +				     readval);
> +	else
> +		ret = ad_sd_write_reg(&st->sd, reg, ad7124_reg_size[reg],
> +				      writeval);
> +
> +	return ret;
> +}
> +
>   static IIO_CONST_ATTR(in_voltage_scale_available,
>   	"0.000001164 0.000002328 0.000004656 0.000009313 0.000018626 0.000037252 0.000074505 0.000149011 0.000298023");
>   
> @@ -375,6 +406,7 @@ static const struct attribute_group ad7124_attrs_group = {
>   static const struct iio_info ad7124_info = {
>   	.read_raw = ad7124_read_raw,
>   	.write_raw = ad7124_write_raw,
> +	.debugfs_reg_access = &ad7124_reg_access,
>   	.validate_trigger = ad_sd_validate_trigger,
>   	.attrs = &ad7124_attrs_group,
>   };
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ