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: <Yw9KcvaFzCcPw7qw@smile.fi.intel.com>
Date:   Wed, 31 Aug 2022 14:48:02 +0300
From:   Andy Shevchenko <andriy.shevchenko@...el.com>
To:     Eliav Farber <farbere@...zon.com>
Cc:     jdelvare@...e.com, linux@...ck-us.net, robh+dt@...nel.org,
        p.zabel@...gutronix.de, rtanwar@...linear.com,
        linux-hwmon@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, talel@...zon.com, hhhawa@...zon.com,
        jonnyc@...zon.com, hanochu@...zon.com, ronenk@...zon.com,
        itamark@...zon.com, shellykz@...zon.com, shorer@...zon.com,
        amitlavi@...zon.com, almogbs@...zon.com, dkl@...zon.com,
        rahul.tanwar@...ux.intel.com
Subject: Re: [PATCH v3 09/19] hwmon: (mr75203) add VM active channel support

On Tue, Aug 30, 2022 at 07:22:02PM +0000, Eliav Farber wrote:
> Add active channel support per voltage monitor.
> The number of active channels is read from the device-tree.
> When absent in device-tree, all channels are assumed to be used.
> 
> This shall be useful to expose sysfs only for inputs that are connected
> to a voltage source.
> 
> Setting number of active channels to 0, means that entire VM sensor is
> not used.

...

> +struct voltage_device {
> +	u32 vm_map;	/* Map channel number to VM index */
> +	u32 ch_map;	/* Map channel number to channel index */
> +};
> +
> +struct voltage_channels {
> +	u32 total;	/* Total number of channels in all VMs */
> +	u8 max;		/* Maximum number of channels among all VMs */
> +};

Why not convert them to kernel doc?

...

> +	ret = device_property_read_u8_array(dev, "moortec,vm-active-channels",
> +					    vm_active_ch, vm_num);
> +	if (ret) {
> +		/*
> +		 * Incase vm-active-channels property is not defined,
> +		 * we assume each VM sensor has all of its channels
> +		 * active.
> +		 */
> +		for (i = 0; i < vm_num; i++)
> +			vm_active_ch[i] = ch_num;

NIH memset().

> +		pvt->vm_channels.max = ch_num;
> +		pvt->vm_channels.total = ch_num * vm_num;
> +	} else {
> +		for (i = 0; i < vm_num; i++) {
> +			if (vm_active_ch[i] > ch_num) {
> +				dev_err(dev, "invalid active channels: %u\n",
> +					vm_active_ch[i]);
> +				return -EINVAL;
> +			}
> +
> +			pvt->vm_channels.total += vm_active_ch[i];
> +
> +			if (vm_active_ch[i] > pvt->vm_channels.max)
> +				pvt->vm_channels.max = vm_active_ch[i];
> +		}
> +	}

...

> +	k = 0;
> +	for (i = 0; i < vm_num; i++)
> +		for (j = 0; j < vm_active_ch[i]; j++) {
> +			pvt->vd[k].vm_map = vm_idx[i];
> +			pvt->vd[k].ch_map = j;

> +			k++;

How is it different from moving this outside the inner loop as

	k += vm_active_ch[i];

?

> +		}

Missed outer {}.


-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ