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: <20090817150558.3468426b.akpm@linux-foundation.org>
Date:	Mon, 17 Aug 2009 15:05:58 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	djwong@...ibm.com
Cc:	lenb@...nel.org, linux-acpi@...r.kernel.org, rui.zhang@...el.com,
	linux-kernel@...r.kernel.org, lm-sensors@...sensors.org
Subject: Re: [PATCH v2] acpi_power_meter: hwmon driver for ACPI 4.0 power
 meters

On Thu, 6 Aug 2009 13:42:57 -0700
"Darrick J. Wong" <djwong@...ibm.com> wrote:

> This driver exposes ACPI 4.0 compliant power meters as hardware monitoring
> devices.  This second revision of the driver also exports the ACPI string
> info as sysfs attributes, a list of the devices that the meter measures,
> and will send ACPI notifications over the ACPI netlink socket.
> 
>
> ...
>
> +static ssize_t set_avg_interval(struct device *dev,
> +				struct device_attribute *devattr,
> +				const char *buf, size_t count)
> +{
> +	struct acpi_device *acpi_dev = to_acpi_device(dev);
> +	struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
> +	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
> +	struct acpi_object_list args = { 1, &arg0 };
> +	int res;
> +	unsigned long temp;
> +	unsigned long long data;
> +	acpi_status status;
> +
> +	res = strict_strtoul(buf, 10, &temp);
> +	if (res)
> +		return res;
> +
> +	if (temp > resource->caps.max_avg_interval ||
> +	    temp < resource->caps.min_avg_interval)
> +		return -EINVAL;
> +	arg0.integer.value = temp;
> +
> +	mutex_lock(&resource->lock);
> +	status = acpi_evaluate_integer(resource->acpi_dev->handle, "_PAI",
> +				       &args, &data);
> +	if (!ACPI_FAILURE(status))
> +		resource->avg_interval = temp;
> +	mutex_unlock(&resource->lock);
> +
> +	if (ACPI_FAILURE(status)) {
> +		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PAI"));
> +		return -EINVAL;
> +	}
> +
> +	if (data)
> +		return -EINVAL;

I find this test of `data' inexplicable.  Is it just me, or do we need
a comment here?

> +	return count;
> +}
> +
>
> ...
>
> +static ssize_t set_cap(struct device *dev, struct device_attribute *devattr,
> +		       const char *buf, size_t count)
> +{
> +	struct acpi_device *acpi_dev = to_acpi_device(dev);
> +	struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
> +	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
> +	struct acpi_object_list args = { 1, &arg0 };
> +	int res;
> +	unsigned long temp;
> +	unsigned long long data;
> +	acpi_status status;
> +
> +	res = strict_strtoul(buf, 10, &temp);
> +	if (res)
> +		return res;
> +
> +	temp /= 1000;
> +	if (temp > resource->caps.max_cap || temp < resource->caps.min_cap)
> +		return -EINVAL;
> +	arg0.integer.value = temp;
> +
> +	mutex_lock(&resource->lock);
> +	status = acpi_evaluate_integer(resource->acpi_dev->handle, "_SHL",
> +				       &args, &data);
> +	if (!ACPI_FAILURE(status))
> +		resource->cap = temp;
> +	mutex_unlock(&resource->lock);
> +
> +	if (ACPI_FAILURE(status)) {
> +		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SHL"));
> +		return -EINVAL;
> +	}
> +
> +	if (data)
> +		return -EINVAL;

ditto.

> +	return count;
> +}
> +

--
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