--- drivers/acpi/acpi_system.c.orig Mon Mar 18 14:29:45 2002 +++ drivers/acpi/acpi_system.c Mon Mar 18 14:29:20 2002 @@ -415,40 +415,44 @@ loff_t *ppos) { int result = 0; - char outbuf[ACPI_MAX_STRING]; - int size = 0; struct acpi_bus_event event; + static char str[ACPI_MAX_STRING]; + static int chars_remaining = 0; + static char *ptr; ACPI_FUNCTION_TRACE("acpi_system_read_event"); - memset(&event, 0, sizeof(struct acpi_bus_event)); + if (!chars_remaining) { + memset(&event, 0, sizeof(struct acpi_bus_event)); - if (count < ACPI_MAX_STRING) - goto end; - - if ((file->f_flags & O_NONBLOCK) - && (list_empty(&acpi_bus_event_list))) - return_VALUE(-EAGAIN); - - result = acpi_bus_receive_event(&event); - if (0 != result) { - size = sprintf(outbuf, "error\n"); - goto end; + if ((file->f_flags & O_NONBLOCK) + && (list_empty(&acpi_bus_event_list))) + return_VALUE(-EAGAIN); + + result = acpi_bus_receive_event(&event); + if (0 != result) { + return_VALUE(-EIO); + } + + chars_remaining = sprintf(str, "%s %s %08x %08x\n", + event.device_class?event.device_class:"", + event.bus_id?event.bus_id:"", + event.type, event.data); + ptr = str; } - size = sprintf(outbuf, "%s %s %08x %08x\n", - event.device_class?event.device_class:"", - event.bus_id?event.bus_id:"", - event.type, - event.data); + if (chars_remaining < count) { + count = chars_remaining; + } -end: - if (copy_to_user(buffer, outbuf, size)) + if (copy_to_user(buffer, ptr, count)) return_VALUE(-EFAULT); - *ppos += size; + *ppos += count; + chars_remaining -= count; + ptr += count; - return_VALUE(size); + return_VALUE(count); } static int