p = buf;
sleep_ticks = simple_strtoul(p, &p, 0);
#endif
-------- ---- retval = pm_send_all(PM_SUSPEND, (void *) 2);
-------- ----
-------- ---- if (retval)
-------- ---- return retval;
au_sleep();
-- -- - - retval = pm_send_all(PM_RESUME, (void *) 0);
-- -- - - }
-- -- - - return retval;
-- -- - - }
-- -- - -
-- -- - - static int pm_do_suspend(ctl_table * ctl, int write, struct file *file,
-- -- - - void __user *buffer, size_t * len, loff_t *ppos)
-- -- - - {
-- -- - - int retval = 0;
-- -- - -
-- -- - - if (!write) {
-- -- - - *len = 0;
-- -- - - } else {
-- -- - - retval = pm_send_all(PM_SUSPEND, (void *) 2);
-- -- - - if (retval)
-- -- - - return retval;
-- -- - - suspend_mode = 1;
-- -- - -
-------- ---- retval = pm_send_all(PM_RESUME, (void *) 0);
}
- - - --- return retval;
- - - ---}
- - - ---
- - - ---static int pm_do_suspend(ctl_table * ctl, int write, struct file *file,
- - - --- void __user *buffer, size_t * len, loff_t *ppos)
- - - ---{
- - - --- int retval = 0;
- - - ---
- - - --- if (!write) {
- - - --- *len = 0;
- - - --- } else {
- - - --- retval = pm_send_all(PM_SUSPEND, (void *) 2);
- - - --- if (retval)
- - - --- return retval;
- - - --- suspend_mode = 1;
- - - ---
- - - --- retval = pm_send_all(PM_RESUME, (void *) 0);
- - - --- }
-------- ---- return retval;
++++++++ ++++ return 0;
}
-------- ----
static int pm_do_freq(ctl_table * ctl, int write, struct file *file,
void __user *buffer, size_t * len, loff_t *ppos)
{
static int acpi_video_bus_add_fs(struct acpi_device *device)
{
- long device_id;
- int status;
------------ struct proc_dir_entry *entry = NULL;
------------ struct acpi_video_bus *video;
--------- --
- struct device *dev;
++++++++++++ struct acpi_video_bus *video = acpi_driver_data(device);
++++++++++++ struct proc_dir_entry *device_dir;
++++++++++++ struct proc_dir_entry *entry;
--------- -- video = acpi_driver_data(device);
- status =
- acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
++++++++++++ device_dir = proc_mkdir(acpi_device_bid(device), acpi_video_dir);
++++++++++++ if (!device_dir)
++++++++++++ return -ENOMEM;
- if (!ACPI_SUCCESS(status))
- return -ENODEV;
-
- /* We need to attempt to determine whether the _ADR refers to a
- PCI device or not. There's no terribly good way to do this,
- so the best we can hope for is to assume that there'll never
- be a video device in the host bridge */
- if (device_id >= 0x10000) {
- /* It looks like a PCI device. Does it exist? */
- dev = acpi_get_physical_device(device->handle);
- } else {
- /* It doesn't look like a PCI device. Does its parent
- exist? */
- acpi_handle phandle;
- if (acpi_get_parent(device->handle, &phandle))
- return -ENODEV;
- dev = acpi_get_physical_device(phandle);
- }
- if (!dev)
- return -ENODEV;
- put_device(dev);
-
-
-
- video = acpi_driver_data(device);
-
------------ if (!acpi_device_dir(device)) {
------------ acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
------------ acpi_video_dir);
------------ if (!acpi_device_dir(device))
------------ return -ENODEV;
------------ video->dir = acpi_device_dir(device);
------------ acpi_device_dir(device)->owner = THIS_MODULE;
------------ }
++++++++++++ device_dir->owner = THIS_MODULE;
/* 'info' [R] */
------------ entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
++++++++++++ entry = create_proc_entry("info", S_IRUGO, device_dir);
if (!entry)
------------ return -ENODEV;
------------ else {
------------ entry->proc_fops = &acpi_video_bus_info_fops;
------------ entry->data = acpi_driver_data(device);
------------ entry->owner = THIS_MODULE;
------------ }
++++++++++++ goto err_remove_dir;
++++++++++++
++++++++++++ entry->proc_fops = &acpi_video_bus_info_fops;
++++++++++++ entry->data = acpi_driver_data(device);
++++++++++++ entry->owner = THIS_MODULE;
/* 'ROM' [R] */
------------ entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
++++++++++++ entry = create_proc_entry("ROM", S_IRUGO, device_dir);
if (!entry)
------------ return -ENODEV;
------------ else {
------------ entry->proc_fops = &acpi_video_bus_ROM_fops;
------------ entry->data = acpi_driver_data(device);
------------ entry->owner = THIS_MODULE;
------------ }
++++++++++++ goto err_remove_info;
++++++++++++
++++++++++++ entry->proc_fops = &acpi_video_bus_ROM_fops;
++++++++++++ entry->data = acpi_driver_data(device);
++++++++++++ entry->owner = THIS_MODULE;
/* 'POST_info' [R] */
------------ entry =
------------ create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
++++++++++++ entry = create_proc_entry("POST_info", S_IRUGO, device_dir);
if (!entry)
------------ return -ENODEV;
------------ else {
------------ entry->proc_fops = &acpi_video_bus_POST_info_fops;
------------ entry->data = acpi_driver_data(device);
------------ entry->owner = THIS_MODULE;
------------ }
++++++++++++ goto err_remove_rom;
++++++++++++
++++++++++++ entry->proc_fops = &acpi_video_bus_POST_info_fops;
++++++++++++ entry->data = acpi_driver_data(device);
++++++++++++ entry->owner = THIS_MODULE;
/* 'POST' [R/W] */
------------ entry =
------------ create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
------------ acpi_device_dir(device));
++++++++++++ entry = create_proc_entry("POST", S_IFREG | S_IRUGO | S_IWUSR,
++++++++++++ device_dir);
if (!entry)
------------ return -ENODEV;
------------ else {
------------ acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
------------ entry->proc_fops = &acpi_video_bus_POST_fops;
------------ entry->data = acpi_driver_data(device);
------------ entry->owner = THIS_MODULE;
------------ }
++++++++++++ goto err_remove_post_info;
++++++++++++
++++++++++++ acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
++++++++++++ entry->proc_fops = &acpi_video_bus_POST_fops;
++++++++++++ entry->data = acpi_driver_data(device);
++++++++++++ entry->owner = THIS_MODULE;
/* 'DOS' [R/W] */
------------ entry =
------------ create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
------------ acpi_device_dir(device));
++++++++++++ entry = create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IWUSR,
++++++++++++ device_dir);
if (!entry)
------------ return -ENODEV;
------------ else {
------------ acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
------------ entry->proc_fops = &acpi_video_bus_DOS_fops;
------------ entry->data = acpi_driver_data(device);
------------ entry->owner = THIS_MODULE;
------------ }
++++++++++++ goto err_remove_post;
++++++++++ +
++++++++++++ acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
++++++++++++ entry->proc_fops = &acpi_video_bus_DOS_fops;
++++++++++++ entry->data = acpi_driver_data(device);
++++++++++++ entry->owner = THIS_MODULE;
+
++++++++++++ video->dir = acpi_device_dir(device) = device_dir;
return 0;
++++++++++++
++++++++++++ err_remove_post:
++++++++++++ remove_proc_entry("POST", device_dir);
++++++++++++ err_remove_post_info:
++++++++++++ remove_proc_entry("POST_info", device_dir);
++++++++++++ err_remove_rom:
++++++++++++ remove_proc_entry("ROM", device_dir);
++++++++++++ err_remove_info:
++++++++++++ remove_proc_entry("info", device_dir);
++++++++++++ err_remove_dir:
++++++++++++ remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
++++++++++++ return -ENOMEM;
}
static int acpi_video_bus_remove_fs(struct acpi_device *device)
bd->props.brightness : 0);
}
----------- -static struct backlight_ops ibm_backlight_data = {
----------- - .get_brightness = brightness_get,
----------- - .update_status = brightness_update_status,
----------- -};
----------- -
----------- -/* --------------------------------------------------------------------- */
----------- -
----------- -static int __init tpacpi_query_bcll_levels(acpi_handle handle)
----------- -{
----------- - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
----------- - union acpi_object *obj;
----------- - int rc;
----------- -
----------- - if (ACPI_SUCCESS(acpi_evaluate_object(handle, NULL, NULL, &buffer))) {
----------- - obj = (union acpi_object *)buffer.pointer;
----------- - if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
----------- - printk(TPACPI_ERR "Unknown BCLL data, "
----------- - "please report this to %s\n", TPACPI_MAIL);
----------- - rc = 0;
----------- - } else {
----------- - rc = obj->package.count;
----------- - }
----------- - } else {
----------- - return 0;
----------- - }
----------- -
----------- - kfree(buffer.pointer);
----------- - return rc;
----------- -}
----------- -
----------- -static acpi_status __init brightness_find_bcll(acpi_handle handle, u32 lvl,
----------- - void *context, void **rv)
--------- - -{
--------- - - char name[ACPI_PATH_SEGMENT_LENGTH];
--------- - - struct acpi_buffer buffer = { sizeof(name), &name };
--------- - -
--------- - - if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
--------- - - !strncmp("BCLL", name, sizeof(name) - 1)) {
--------- - - if (tpacpi_query_bcll_levels(handle) == 16) {
--------- - - *rv = handle;
--------- - - return AE_CTRL_TERMINATE;
--------- - - } else {
--------- - - return AE_OK;
--------- - - }
--------- - - } else {
--------- - - return AE_OK;
--------- - - }
--------- - -}
--------- - -
--------- - -static int __init brightness_check_levels(void)
+++++++++++ +static int brightness_get(struct backlight_device *bd)
{
--------- - - int status;
--------- - - void *found_node = NULL;
- char name[ACPI_PATH_SEGMENT_LENGTH];
- struct acpi_buffer buffer = { sizeof(name), &name };
+++++++++++ + int status, res;
- if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
- !strncmp("BCLL", name, sizeof(name) - 1)) {
- if (tpacpi_query_bcll_levels(handle) == 16) {
- *rv = handle;
- return AE_CTRL_TERMINATE;
- } else {
- return AE_OK;
- }
- } else {
- return AE_OK;
- }
- }
-
- static int __init brightness_check_levels(void)
- {
- int status;
- void *found_node = NULL;
-
----------- - if (!vid_handle) {
----------- - TPACPI_ACPIHANDLE_INIT(vid);
----------- - }
----------- - if (!vid_handle)
----------- - return 0;
----------- -
----------- - /* Search for a BCLL package with 16 levels */
----------- - status = acpi_walk_namespace(ACPI_TYPE_PACKAGE, vid_handle, 3,
----------- - brightness_find_bcll, NULL,
----------- - &found_node);
----------- -
----------- - return (ACPI_SUCCESS(status) && found_node != NULL);
----------- -}
----------- -
----------- -static acpi_status __init brightness_find_bcl(acpi_handle handle, u32 lvl,
----------- - void *context, void **rv)
----------- -{
----------- - char name[ACPI_PATH_SEGMENT_LENGTH];
----------- - struct acpi_buffer buffer = { sizeof(name), &name };
+++++++++++ + res = brightness_get_raw(&status);
+++++++++++ + if (res < 0)
+++++++++++ + return 0; /* FIXME: teach backlight about error handling */
----------- - if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) &&
----------- - !strncmp("_BCL", name, sizeof(name) - 1)) {
----------- - *rv = handle;
----------- - return AE_CTRL_TERMINATE;
----------- - } else {
----------- - return AE_OK;
----------- - }
+++++++++++ + return status & TP_EC_BACKLIGHT_LVLMSK;
}
----------- -static int __init brightness_check_std_acpi_support(void)
----------- -{
----------- - int status;
----------- - void *found_node = NULL;
----------- -
----------- - if (!vid_handle) {
----------- - TPACPI_ACPIHANDLE_INIT(vid);
----------- - }
----------- - if (!vid_handle)
----------- - return 0;
----------- -
----------- - /* Search for a _BCL method, but don't execute it */
----------- - status = acpi_walk_namespace(ACPI_TYPE_METHOD, vid_handle, 3,
----------- - brightness_find_bcl, NULL, &found_node);
+++++++++++ +static struct backlight_ops ibm_backlight_data = {
+++++++++++ + .get_brightness = brightness_get,
+++++++++++ + .update_status = brightness_update_status,
+++++++++++ +};
----------- - return (ACPI_SUCCESS(status) && found_node != NULL);
----------- -}
+++++++++++ +/* --------------------------------------------------------------------- */
static int __init brightness_init(struct ibm_init_struct *iibm)
{