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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZJwGCNA+ZURri24i@smile.fi.intel.com>
Date:   Wed, 28 Jun 2023 13:06:00 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     George Stark <gnstark@...rdevices.ru>
Cc:     jic23@...nel.org, lars@...afoo.de, neil.armstrong@...aro.org,
        khilman@...libre.com, jbrunet@...libre.com,
        martin.blumenstingl@...glemail.com, nuno.sa@...log.com,
        linux-iio@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org, linux-amlogic@...ts.infradead.org,
        kernel@...rdevices.ru
Subject: Re: [PATCH v3 5/5] meson saradc: support reading from channel 7 mux
 inputs

On Wed, Jun 28, 2023 at 01:37:18AM +0300, George Stark wrote:
> Add iio channel for every channel 7 mux input.
> Meson saradc channel 7 is connected to a mux that can switch channel
> input to well-known sources like Vdd, GND and several Vdd dividers.

...

> +static enum meson_sar_adc_chan7_mux_sel chan7_mux_values[] = {
> +	CHAN7_MUX_VSS,
> +	CHAN7_MUX_VDD_DIV4,
> +	CHAN7_MUX_VDD_DIV2,
> +	CHAN7_MUX_VDD_MUL3_DIV4,
> +	CHAN7_MUX_VDD,
> +};
> +
> +static const char * const chan7_mux_names[] = {
> +	"gnd",
> +	"0.25vdd",
> +	"0.5vdd",
> +	"0.75vdd",
> +	"vdd",

For the sake of robustness you can assign like this

	[CHAN7_MUX_VDD_DIV2] = "0.5vdd",

>  };

...

> -	if (chan->type == IIO_VOLTAGE)
> -		return sprintf(label, "channel-%d\n", chan->channel);
> +	if (chan->type == IIO_VOLTAGE) {

> +		if (chan->channel <= NUM_CHAN_7)

I believe you can get rid of this conditional and make diff less ping-pong-ish,
  see below.

> +			return sprintf(label, "channel-%d\n", chan->channel);
> +		if (chan->channel >= NUM_MUX_0_VSS)
> +			return sprintf(label, "%s\n",
> +				chan7_mux_names[chan->channel - NUM_MUX_0_VSS]);
> +	}


	if (chan->type == IIO_VOLTAGE && chan->channel >= NUM_MUX_0_VSS)
		return sprintf(label, "%s\n", chan7_mux_names[chan->channel - NUM_MUX_0_VSS]);

	if (chan->type == IIO_VOLTAGE)
		return sprintf(label, "channel-%d\n", chan->channel);


-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ