Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serdev: Split and export serdev_acpi_get_uart_resource()

The same as for I²C Serial Bus resource split and export
serdev_acpi_get_uart_resource(). We have already a few users
one of which is converted here.

Rationale of this is to consolidate parsing UART Serial Bus
resource in one place as it's done, e.g., for I²C Serial Bus.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210806111736.66591-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
0a732d7d 217b04c6

+43 -7
+29 -7
drivers/tty/serdev/core.c
··· 564 564 int index; 565 565 }; 566 566 567 + /** 568 + * serdev_acpi_get_uart_resource - Gets UARTSerialBus resource if type matches 569 + * @ares: ACPI resource 570 + * @uart: Pointer to UARTSerialBus resource will be returned here 571 + * 572 + * Checks if the given ACPI resource is of type UARTSerialBus. 573 + * In this case, returns a pointer to it to the caller. 574 + * 575 + * Return: True if resource type is of UARTSerialBus, otherwise false. 576 + */ 577 + bool serdev_acpi_get_uart_resource(struct acpi_resource *ares, 578 + struct acpi_resource_uart_serialbus **uart) 579 + { 580 + struct acpi_resource_uart_serialbus *sb; 581 + 582 + if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) 583 + return false; 584 + 585 + sb = &ares->data.uart_serial_bus; 586 + if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_UART) 587 + return false; 588 + 589 + *uart = sb; 590 + return true; 591 + } 592 + EXPORT_SYMBOL_GPL(serdev_acpi_get_uart_resource); 593 + 567 594 static int acpi_serdev_parse_resource(struct acpi_resource *ares, void *data) 568 595 { 569 596 struct acpi_serdev_lookup *lookup = data; 570 597 struct acpi_resource_uart_serialbus *sb; 571 598 acpi_status status; 572 599 573 - if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) 574 - return 1; 575 - 576 - if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART) 600 + if (!serdev_acpi_get_uart_resource(ares, &sb)) 577 601 return 1; 578 602 579 603 if (lookup->index != -1 && lookup->n++ != lookup->index) 580 604 return 1; 581 - 582 - sb = &ares->data.uart_serial_bus; 583 605 584 606 status = acpi_get_handle(lookup->device_handle, 585 607 sb->resource_source.string_ptr, ··· 610 588 return 1; 611 589 612 590 /* 613 - * NOTE: Ideally, we would also want to retreive other properties here, 591 + * NOTE: Ideally, we would also want to retrieve other properties here, 614 592 * once setting them before opening the device is supported by serdev. 615 593 */ 616 594
+14
include/linux/serdev.h
··· 327 327 } 328 328 #endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */ 329 329 330 + struct acpi_resource; 331 + struct acpi_resource_uart_serialbus; 332 + 333 + #ifdef CONFIG_ACPI 334 + bool serdev_acpi_get_uart_resource(struct acpi_resource *ares, 335 + struct acpi_resource_uart_serialbus **uart); 336 + #else 337 + static inline bool serdev_acpi_get_uart_resource(struct acpi_resource *ares, 338 + struct acpi_resource_uart_serialbus **uart) 339 + { 340 + return false; 341 + } 342 + #endif /* CONFIG_ACPI */ 343 + 330 344 #endif /*_LINUX_SERDEV_H */