From: Zhang Rui <rui.zhang@intel.com>
To: "Darrick J. Wong" <djwong@us.ibm.com>
Cc: Len Brown <lenb@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
lm-sensors <lm-sensors@lm-sensors.org>,
linux-acpi <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH 2/2] acpi_power_meter: hwmon driver for ACPI 4.0 power meters
Date: Mon, 27 Jul 2009 14:45:55 +0800 [thread overview]
Message-ID: <1248677155.2670.132.camel@rzhang-dt> (raw)
In-Reply-To: <20090725004335.20709.52288.stgit@elm3a70.beaverton.ibm.com>
Hi, Darrick,
great job. :)
comments in-line.
On Sat, 2009-07-25 at 08:43 +0800, Darrick J. Wong wrote:
> +/* Handle ACPI event notifications */
> +static void acpi_power_meter_notify(struct acpi_device *device, u32 event)
> +{
> + struct acpi_power_meter_resource *resource;
> + int res;
> +
> + if (!device || !acpi_driver_data(device))
> + return;
> +
> + resource = acpi_driver_data(device);
> +
> + mutex_lock(&resource->lock);
> + switch (event) {
> + case METER_NOTIFY_CONFIG:
> + res = read_capabilities(resource);
> + if (res)
> + break;
> +
> + remove_attrs(resource);
> + setup_attrs(resource);
> + break;
> + case METER_NOTIFY_TRIP:
> + update_meter(resource);
> + break;
> + case METER_NOTIFY_CAP:
> + update_cap(resource);
> + break;
> + case METER_NOTIFY_INTERVAL:
> + update_avg_interval(resource);
> + break;
> + case METER_NOTIFY_CAPPING:
> + dev_info(&device->dev, "Capping in progress.\n");
> + break;
> + default:
> + BUG();
> + }
> + mutex_unlock(&resource->lock);
> +}
we should at least send a netlink event for an ACPI power meter
notification, shouldn't we?
> +
> +static int acpi_power_meter_add(struct acpi_device *device)
> +{
> + int res;
> + struct acpi_power_meter_resource *resource;
> +
> + if (!device)
> + return -EINVAL;
> +
> + resource = kzalloc(sizeof(struct acpi_power_meter_resource),
> + GFP_KERNEL);
> + if (!resource)
> + return -ENOMEM;
> +
> + resource->sensors_valid = 0;
> + resource->acpi_dev = device;
> + mutex_init(&resource->lock);
> + strcpy(acpi_device_name(device), ACPI_POWER_METER_DEVICE_NAME);
> + strcpy(acpi_device_class(device), ACPI_POWER_METER_CLASS);
> + device->driver_data = resource;
> +
> + res = read_capabilities(resource);
> + if (res)
> + goto exit_free;
> +
> + resource->trip[0] = resource->trip[1] = -1;
> +
> + res = setup_attrs(resource);
> + if (res)
> + goto exit_free;
> +
> + resource->hwmon_dev = hwmon_device_register(&device->dev);
> + if (IS_ERR(resource->hwmon_dev)) {
> + res = PTR_ERR(resource->hwmon_dev);
> + goto exit_remove;
> + }
> +
we should create the hwmon sysfs I/F for the hwmon device,
i.e. add the hwmon attributes
under /sys/devices/LINUXSYS:00/.../ACPI000D:00/hwmon0/
rather than /sys/devices/LINUXSYS:00/.../ACPI000D:00/
> + res = 0;
> + goto exit;
> +
> +exit_remove:
> + remove_attrs(resource);
> +exit_free:
> + kfree(resource);
> +exit:
> + return res;
> +}
> +
> +
> +static int __init acpi_power_meter_init(void)
> +{
> + int result;
> +
if (acpi_disable)
return -ENODEV;
> + result = acpi_bus_register_driver(&acpi_power_meter_driver);
> + if (result < 0)
> + return -ENODEV;
> +
> + return 0;
> +}
> +
> +static void __exit acpi_power_meter_exit(void)
> +{
> + acpi_bus_unregister_driver(&acpi_power_meter_driver);
> +}
> +
> +MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>");
> +MODULE_DESCRIPTION("ACPI 4.0 power meter driver");
> +MODULE_LICENSE("GPL");
> +
> +module_init(acpi_power_meter_init);
> +module_exit(acpi_power_meter_exit);
>
plus, _PMD is not supported in this driver, right?
I agree with Yakui that we can create some ACPI device sysfs attributes
besides the hwmon ones. e.g. exporting devices measured by the current
ACPI power meter device to user space.
thanks,
rui
next prev parent reply other threads:[~2009-07-27 6:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-25 0:43 [PATCH 0/2] ACPI 4.0 power meter Darrick J. Wong
2009-07-25 0:43 ` [PATCH 1/2] hwmon: Enhance the sysfs API for power meters Darrick J. Wong
2009-08-07 18:09 ` Pavel Machek
2009-08-08 17:40 ` Darrick J. Wong
2009-08-08 21:48 ` Pavel Machek
2009-08-10 21:12 ` Darrick J. Wong
2009-08-12 11:56 ` Pavel Machek
2009-08-18 23:32 ` Darrick J. Wong
2009-07-25 0:43 ` [PATCH 2/2] acpi_power_meter: hwmon driver for ACPI 4.0 " Darrick J. Wong
2009-07-27 1:44 ` ykzhao
2009-08-03 20:48 ` Darrick J. Wong
2009-07-27 6:45 ` Zhang Rui [this message]
2009-08-03 20:52 ` Darrick J. Wong
2009-07-28 1:25 ` Len Brown
2009-08-03 20:58 ` Darrick J. Wong
2009-08-06 20:42 ` [PATCH v2] " Darrick J. Wong
2009-08-17 22:05 ` Andrew Morton
2009-08-18 16:24 ` Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2009-08-18 23:47 [PATCH 0/2] ACPI 4.0 power meter Darrick J. Wong
2009-08-18 23:48 ` [PATCH 2/2] acpi_power_meter: hwmon driver for ACPI 4.0 power meters Darrick J. Wong
2009-08-20 23:47 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1248677155.2670.132.camel@rzhang-dt \
--to=rui.zhang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=djwong@us.ibm.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox