Re: [PATCH v2 1/2] serdev: Split and export serdev_acpi_get_uart_resource()

From: Jiri Slaby
Date: Thu Aug 05 2021 - 03:33:15 EST


On 04. 08. 21, 16:29, Andy Shevchenko wrote:
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 <andriy.shevchenko@xxxxxxxxxxxxxxx>
Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
v2: added Rb tag (Hans)
drivers/tty/serdev/core.c | 36 +++++++++++++++++++++++++++++-------
include/linux/serdev.h | 14 ++++++++++++++
2 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 92498961fd92..436e3d1ba92c 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -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.
+ *
+ * Returns true if resource type is of UARTSerialBus, otherwise false.

Better to write:
* Return: True if resource type is of UARTSerialBus, otherwise false.
which is recognized by sphinx.

+ */
+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;

Why don't you return NULL, or sb, thus eliminating the parameter?

+}
+EXPORT_SYMBOL_GPL(serdev_acpi_get_uart_resource);

thanks,
--
js
suse labs