diff options
-rw-r--r-- | drivers/acpi/video.c | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 980a74188781..3f0e4bccf9db 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -57,8 +57,6 @@ | |||
57 | #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88 | 57 | #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88 |
58 | #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89 | 58 | #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89 |
59 | 59 | ||
60 | #define ACPI_VIDEO_HEAD_INVALID (~0u - 1) | ||
61 | #define ACPI_VIDEO_HEAD_END (~0u) | ||
62 | #define MAX_NAME_LEN 20 | 60 | #define MAX_NAME_LEN 20 |
63 | 61 | ||
64 | #define ACPI_VIDEO_DISPLAY_CRT 1 | 62 | #define ACPI_VIDEO_DISPLAY_CRT 1 |
@@ -1440,11 +1438,15 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device) | |||
1440 | static struct acpi_video_device_attrib* | 1438 | static struct acpi_video_device_attrib* |
1441 | acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id) | 1439 | acpi_video_get_device_attr(struct acpi_video_bus *video, unsigned long device_id) |
1442 | { | 1440 | { |
1443 | int count; | 1441 | struct acpi_video_enumerated_device *ids; |
1442 | int i; | ||
1443 | |||
1444 | for (i = 0; i < video->attached_count; i++) { | ||
1445 | ids = &video->attached_array[i]; | ||
1446 | if ((ids->value.int_val & 0xffff) == device_id) | ||
1447 | return &ids->value.attrib; | ||
1448 | } | ||
1444 | 1449 | ||
1445 | for(count = 0; count < video->attached_count; count++) | ||
1446 | if((video->attached_array[count].value.int_val & 0xffff) == device_id) | ||
1447 | return &(video->attached_array[count].value.attrib); | ||
1448 | return NULL; | 1450 | return NULL; |
1449 | } | 1451 | } |
1450 | 1452 | ||
@@ -1571,20 +1573,16 @@ static void | |||
1571 | acpi_video_device_bind(struct acpi_video_bus *video, | 1573 | acpi_video_device_bind(struct acpi_video_bus *video, |
1572 | struct acpi_video_device *device) | 1574 | struct acpi_video_device *device) |
1573 | { | 1575 | { |
1576 | struct acpi_video_enumerated_device *ids; | ||
1574 | int i; | 1577 | int i; |
1575 | 1578 | ||
1576 | #define IDS_VAL(i) video->attached_array[i].value.int_val | 1579 | for (i = 0; i < video->attached_count; i++) { |
1577 | #define IDS_BIND(i) video->attached_array[i].bind_info | 1580 | ids = &video->attached_array[i]; |
1578 | 1581 | if (device->device_id == (ids->value.int_val & 0xffff)) { | |
1579 | for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID && | 1582 | ids->bind_info = device; |
1580 | i < video->attached_count; i++) { | ||
1581 | if (device->device_id == (IDS_VAL(i) & 0xffff)) { | ||
1582 | IDS_BIND(i) = device; | ||
1583 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i)); | 1583 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i)); |
1584 | } | 1584 | } |
1585 | } | 1585 | } |
1586 | #undef IDS_VAL | ||
1587 | #undef IDS_BIND | ||
1588 | } | 1586 | } |
1589 | 1587 | ||
1590 | /* | 1588 | /* |
@@ -1603,7 +1601,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) | |||
1603 | int status; | 1601 | int status; |
1604 | int count; | 1602 | int count; |
1605 | int i; | 1603 | int i; |
1606 | struct acpi_video_enumerated_device *active_device_list; | 1604 | struct acpi_video_enumerated_device *active_list; |
1607 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 1605 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
1608 | union acpi_object *dod = NULL; | 1606 | union acpi_object *dod = NULL; |
1609 | union acpi_object *obj; | 1607 | union acpi_object *obj; |
@@ -1624,13 +1622,10 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) | |||
1624 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n", | 1622 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n", |
1625 | dod->package.count)); | 1623 | dod->package.count)); |
1626 | 1624 | ||
1627 | active_device_list = kmalloc((1 + | 1625 | active_list = kcalloc(1 + dod->package.count, |
1628 | dod->package.count) * | 1626 | sizeof(struct acpi_video_enumerated_device), |
1629 | sizeof(struct | 1627 | GFP_KERNEL); |
1630 | acpi_video_enumerated_device), | 1628 | if (!active_list) { |
1631 | GFP_KERNEL); | ||
1632 | |||
1633 | if (!active_device_list) { | ||
1634 | status = -ENOMEM; | 1629 | status = -ENOMEM; |
1635 | goto out; | 1630 | goto out; |
1636 | } | 1631 | } |
@@ -1640,23 +1635,24 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) | |||
1640 | obj = &dod->package.elements[i]; | 1635 | obj = &dod->package.elements[i]; |
1641 | 1636 | ||
1642 | if (obj->type != ACPI_TYPE_INTEGER) { | 1637 | if (obj->type != ACPI_TYPE_INTEGER) { |
1643 | printk(KERN_ERR PREFIX "Invalid _DOD data\n"); | 1638 | printk(KERN_ERR PREFIX |
1644 | active_device_list[i].value.int_val = | 1639 | "Invalid _DOD data in element %d\n", i); |
1645 | ACPI_VIDEO_HEAD_INVALID; | 1640 | continue; |
1646 | } | 1641 | } |
1647 | active_device_list[i].value.int_val = obj->integer.value; | 1642 | |
1648 | active_device_list[i].bind_info = NULL; | 1643 | active_list[count].value.int_val = obj->integer.value; |
1644 | active_list[count].bind_info = NULL; | ||
1649 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, | 1645 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, |
1650 | (int)obj->integer.value)); | 1646 | (int)obj->integer.value)); |
1651 | count++; | 1647 | count++; |
1652 | } | 1648 | } |
1653 | active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END; | ||
1654 | 1649 | ||
1655 | kfree(video->attached_array); | 1650 | kfree(video->attached_array); |
1656 | 1651 | ||
1657 | video->attached_array = active_device_list; | 1652 | video->attached_array = active_list; |
1658 | video->attached_count = count; | 1653 | video->attached_count = count; |
1659 | out: | 1654 | |
1655 | out: | ||
1660 | kfree(buffer.pointer); | 1656 | kfree(buffer.pointer); |
1661 | return status; | 1657 | return status; |
1662 | } | 1658 | } |