serdev: Split and export serdev_acpi_get_uart_resource()
Subsystems (5)
PATCH v3 1/2 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.
---
v3: amended kernel doc to have RETURN section (Jiri)
drivers/tty/serdev/core.c | 36 +++++++++++++++++++++++++++++------- include/linux/serdev.h | 14 ++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-)
drivers/tty/serdev/core.c +29 -7
@@ -562,23 +562,45 @@ struct acpi_serdev_lookup {int index; }; +/** +* serdev_acpi_get_uart_resource - Gets UARTSerialBus resource if type matches +* @ares: ACPI resource +* @uart: Pointer to UARTSerialBus resource will be returned here +* +* Checks if the given ACPI resource is of type UARTSerialBus. +* In this case, returns a pointer to it to the caller. +* +* Return: True if resource type is of UARTSerialBus, otherwise false. +*/ +bool serdev_acpi_get_uart_resource (struct acpi_resource *ares, +struct acpi_resource_uart_serialbus **uart) +{ +struct acpi_resource_uart_serialbus *sb; + +if (ares->type !=ACPI_RESOURCE_TYPE_SERIAL_BUS ) +return false; + + sb = &ares->data.uart_serial_bus; +if (sb->type !=ACPI_RESOURCE_SERIAL_TYPE_UART ) +return false; + + *uart = sb; +return true; +} +EXPORT_SYMBOL_GPL (serdev_acpi_get_uart_resource); +static int acpi_serdev_parse_resource (struct acpi_resource *ares,void *data) {struct acpi_serdev_lookup *lookup = data;struct acpi_resource_uart_serialbus *sb;acpi_status status; -if (ares->type !=ACPI_RESOURCE_TYPE_SERIAL_BUS ) -return 1 ; - -if (ares->data.common_serial_bus.type !=ACPI_RESOURCE_SERIAL_TYPE_UART ) +if (!serdev_acpi_get_uart_resource (ares, &sb))return 1 ;if (lookup->index !=-1 && lookup->n++ != lookup->index)return 1 ; - sb = &ares->data.uart_serial_bus; - status =acpi_get_handle (lookup->device_handle, sb->resource_source.string_ptr, &lookup->controller_handle);
@@ -586,7 +608,7 @@ static int acpi_serdev_parse_resource(struct acpi_resource *ares, void *data)return 1 ;/* -* NOTE: Ideally, we would also want to retreive other properties here, +* NOTE: Ideally, we would also want to retrieve other properties here, * once setting them before opening the device is supported by serdev. */
include/linux/serdev.h +14 -0
@@ -327,4 +327,18 @@ static inline int serdev_tty_port_unregister(struct tty_port *port) }#endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */ +struct acpi_resource ; +struct acpi_resource_uart_serialbus ; + +#ifdef CONFIG_ACPI +bool serdev_acpi_get_uart_resource (struct acpi_resource *ares, +struct acpi_resource_uart_serialbus **uart); +#else +static inline bool serdev_acpi_get_uart_resource (struct acpi_resource *ares, +struct acpi_resource_uart_serialbus **uart) +{ +return false; +} +#endif /* CONFIG_ACPI */ +#endif /*_LINUX_SERDEV_H */
Signature · 1 line
2.30.2
PATCH v3 2/2 platform/surface: aggregator: Use serdev_acpi_get_uart_resource() helper
serdev provides a generic helper to get UART Serial Bus resources. Use it instead of an open coded variant.
---
v3: no changes
drivers/platform/surface/aggregator/core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/platform/surface/aggregator/core.c +1 -8
@@ -301,20 +301,13 @@ static acpi_status ssam_serdev_setup_via_acpi_crs(struct acpi_resource *rsc, void *ctx) {struct serdev_device *serdev = ctx; -struct acpi_resource_common_serialbus *serial;struct acpi_resource_uart_serialbus *uart;bool flow_control;int status =0 ; -if (rsc->type !=ACPI_RESOURCE_TYPE_SERIAL_BUS ) +if (!serdev_acpi_get_uart_resource (rsc, &uart))return AE_OK ; - serial = &rsc->data.common_serial_bus; -if (serial->type !=ACPI_RESOURCE_SERIAL_TYPE_UART ) -return AE_OK ; - - uart = &rsc->data.uart_serial_bus; -/* Set up serdev device. */ serdev_device_set_baudrate (serdev, uart->default_baud_rate);
Signature · 1 line
2.30.2
Hi,
Quoted 9 lines · Andy Shevchenko
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.
Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Hans de Goede <[email protected]>
As mentioned before I believe it is best if this series is merged in its entirety through to the tty tree, here is my ack for patch 2/2 for that:
Greg, can you pickup the entire series please?
Regards,
Hans
Quoted 95 lines
---
v3: amended kernel doc to have RETURN section (Jiri)drivers/tty/serdev/core.c | 36 +++++++++++++++++++++++++++++------- include/linux/serdev.h | 14 ++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-)drivers/tty/serdev/core.c +29
-7@@ -562,23 +562,45 @@ struct acpi_serdev_lookup {int index; }; +/** +* serdev_acpi_get_uart_resource - Gets UARTSerialBus resource if type matches +* @ares: ACPI resource +* @uart: Pointer to UARTSerialBus resource will be returned here +* +* Checks if the given ACPI resource is of type UARTSerialBus. +* In this case, returns a pointer to it to the caller. +* +* Return: True if resource type is of UARTSerialBus, otherwise false. +*/ +bool serdev_acpi_get_uart_resource (struct acpi_resource *ares, +struct acpi_resource_uart_serialbus **uart) +{ +struct acpi_resource_uart_serialbus *sb; + +if (ares->type !=ACPI_RESOURCE_TYPE_SERIAL_BUS ) +return false; + + sb = &ares->data.uart_serial_bus; +if (sb->type !=ACPI_RESOURCE_SERIAL_TYPE_UART ) +return false; + + *uart = sb; +return true; +} +EXPORT_SYMBOL_GPL (serdev_acpi_get_uart_resource); +static int acpi_serdev_parse_resource (struct acpi_resource *ares,void *data) {struct acpi_serdev_lookup *lookup = data;struct acpi_resource_uart_serialbus *sb;acpi_status status; -if (ares->type !=ACPI_RESOURCE_TYPE_SERIAL_BUS ) -return 1 ; - -if (ares->data.common_serial_bus.type !=ACPI_RESOURCE_SERIAL_TYPE_UART ) +if (!serdev_acpi_get_uart_resource (ares, &sb))return 1 ;if (lookup->index !=-1 && lookup->n++ != lookup->index)return 1 ; - sb = &ares->data.uart_serial_bus; - status =acpi_get_handle (lookup->device_handle, sb->resource_source.string_ptr, &lookup->controller_handle);@@ -586,7 +608,7 @@ static int acpi_serdev_parse_resource(struct acpi_resource *ares, void *data)return 1 ;/* -* NOTE: Ideally, we would also want to retreive other properties here, +* NOTE: Ideally, we would also want to retrieve other properties here, * once setting them before opening the device is supported by serdev. */ include/linux/serdev.h +14
-0@@ -327,4 +327,18 @@ static inline int serdev_tty_port_unregister(struct tty_port *port) }#endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */ +struct acpi_resource ; +struct acpi_resource_uart_serialbus ; + +#ifdef CONFIG_ACPI +bool serdev_acpi_get_uart_resource (struct acpi_resource *ares, +struct acpi_resource_uart_serialbus **uart); +#else +static inline bool serdev_acpi_get_uart_resource (struct acpi_resource *ares, +struct acpi_resource_uart_serialbus **uart) +{ +return false; +} +#endif /* CONFIG_ACPI */ +#endif /*_LINUX_SERDEV_H */
Greg Kroah-Hartman
maintainerQuoted 13 lines · Hans de Goede
Hi,
Quoted 9 lines · Andy Shevchenko
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.
Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Hans de Goede <[email protected]>
Quoted 7 lines
As mentioned before I believe it is best if this series is merged in its entirety through to the tty tree, here is my ack for patch 2/2 for that:
Acked-by Hans de Goede <[email protected]>Greg, can you pickup the entire series please?
Now picked up, thanks.
greg k-h