From nobody Sun Feb 8 02:11:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5743DC4321E for ; Tue, 29 Nov 2022 11:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232798AbiK2LBT (ORCPT ); Tue, 29 Nov 2022 06:01:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232625AbiK2LAg (ORCPT ); Tue, 29 Nov 2022 06:00:36 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12B3F60EB4 for ; Tue, 29 Nov 2022 03:00:28 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id h131-20020a1c2189000000b003d02dd48c45so8160623wmh.0 for ; Tue, 29 Nov 2022 03:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wYb7Bk90e+N6jZPfw1QqOet30B/UaUEuFBD0IKIzTR8=; b=f3Z0rv/OhcPtzb4yCaFXJB2JtfotgQpUkcIzzXUWqT8dKmkk8TQVerVytP5+vtYPPi gPanRIqSoiER/lBrR7ZmoGLzSkTIWIANIDCxi3VnCRNVjaJ3lLl13Z50UlLYruHmX997 Yafs8AdQIoBi9bDMyieTWMl4nri9JxOkXpIYS/zAEjDZkSavQg8CbVqkbznTBwndb1st 0eAVvPT7DDFq07jE3QG0KFV9NjOc5KX5uAwQ372BO32wntma2E+4i9qVanRyS9RHVHJ2 4AiZ9TUZZbyxPC20Aj247BGJZckPx7f/IUuxqKwV4yZTPMAXxvr63uzTUUJh/mXnd37y 1K6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wYb7Bk90e+N6jZPfw1QqOet30B/UaUEuFBD0IKIzTR8=; b=E3roq2YMUNK2Ghl/Xxtw13Y1Pu2+solRdU1WhB/Z/HFOVGJkzgh+wg50Aygcveqz7K aNjYKBvsbxenG+GZXtsIayDTPSr9HpoA3Um386KiLw+5jmPoGLl0RGLZGcRtTQKOitS5 PV2zIziioB1Ysmxulhj8J7DS7+WuSS031isVU5iyiN38iWDYtebtSxfZk9FHxL+OEuIH G3332XG2vM3S31asp11+3GVba8rvjl10FemnHHIOhtNHUkWEeqRIXELODugWiVNlwX2k Zhv9XFUzCTKf6vDg8ZekMj/E/rO2JrieahHd6TfVqiDMzOj9K6hlZ3qZ1wx9D0AtoUQu ZYGQ== X-Gm-Message-State: ANoB5pkOObxdKX0Nn+Bd8PCEwgLAraainKmiHEwQfveW4ThdDxeD6T9R F7K67So/kru0mk0I/2TAebM0OA== X-Google-Smtp-Source: AA0mqf7kcNvRZM+TZlTpO8UIwY1CdpXqD3jZgB40INQk3zzjpbmJqa4RKxYWhawskqmZy73znKIEXw== X-Received: by 2002:a05:600c:35c4:b0:3cf:9668:e8f8 with SMTP id r4-20020a05600c35c400b003cf9668e8f8mr31955528wmq.195.1669719627575; Tue, 29 Nov 2022 03:00:27 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:6b19:1d8e:fbca:fd02]) by smtp.gmail.com with ESMTPSA id q19-20020a1cf313000000b003a3170a7af9sm1617658wmq.4.2022.11.29.03.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 03:00:27 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Jiri Slaby , Srinivas Kandagatla , Vinod Koul , Alex Elder , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, Bartosz Golaszewski , Konrad Dybcio Subject: [PATCH v4 10/13] tty: serial: qcom-geni-serial: use of_device_id data Date: Tue, 29 Nov 2022 12:00:09 +0100 Message-Id: <20221129110012.224685-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221129110012.224685-1-brgl@bgdev.pl> References: <20221129110012.224685-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Instead of checking the device compatible in probe(), assign the device-specific data to struct of_device_id. We'll use it later when providing SE DMA support. Signed-off-by: Bartosz Golaszewski Reviewed-by: Konrad Dybcio --- drivers/tty/serial/qcom_geni_serial.c | 46 ++++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qco= m_geni_serial.c index 7d6330f85ec2..fe15fc0e1345 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -95,6 +95,11 @@ /* We always configure 4 bytes per FIFO word */ #define BYTES_PER_FIFO_WORD 4U =20 +struct qcom_geni_device_data { + bool console; + void (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop); +}; + struct qcom_geni_private_data { /* NOTE: earlycon port will have NULL here */ struct uart_driver *drv; @@ -114,7 +119,6 @@ struct qcom_geni_serial_port { u32 tx_fifo_width; u32 rx_fifo_depth; bool setup; - void (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop); unsigned int baud; void *rx_fifo; u32 loopback; @@ -126,6 +130,7 @@ struct qcom_geni_serial_port { bool cts_rts_swap; =20 struct qcom_geni_private_data private_data; + const struct qcom_geni_device_data *dev_data; }; =20 static const struct uart_ops qcom_geni_console_pops; @@ -640,7 +645,7 @@ static void qcom_geni_serial_handle_rx(struct uart_port= *uport, bool drop) total_bytes +=3D last_word_byte_cnt; else total_bytes +=3D BYTES_PER_FIFO_WORD; - port->handle_rx(uport, total_bytes, drop); + port->dev_data->handle_rx(uport, total_bytes, drop); } =20 static void qcom_geni_serial_stop_rx(struct uart_port *uport) @@ -1344,13 +1349,14 @@ static int qcom_geni_serial_probe(struct platform_d= evice *pdev) struct uart_port *uport; struct resource *res; int irq; - bool console =3D false; struct uart_driver *drv; + const struct qcom_geni_device_data *data; =20 - if (of_device_is_compatible(pdev->dev.of_node, "qcom,geni-debug-uart")) - console =3D true; + data =3D of_device_get_match_data(&pdev->dev); + if (!data) + return -EINVAL; =20 - if (console) { + if (data->console) { drv =3D &qcom_geni_console_driver; line =3D of_alias_get_id(pdev->dev.of_node, "serial"); } else { @@ -1360,7 +1366,7 @@ static int qcom_geni_serial_probe(struct platform_dev= ice *pdev) line =3D of_alias_get_id(pdev->dev.of_node, "hsuart"); } =20 - port =3D get_port_from_line(line, console); + port =3D get_port_from_line(line, data->console); if (IS_ERR(port)) { dev_err(&pdev->dev, "Invalid line %d\n", line); return PTR_ERR(port); @@ -1372,6 +1378,7 @@ static int qcom_geni_serial_probe(struct platform_dev= ice *pdev) return -ENODEV; =20 uport->dev =3D &pdev->dev; + port->dev_data =3D data; port->se.dev =3D &pdev->dev; port->se.wrapper =3D dev_get_drvdata(pdev->dev.parent); port->se.clk =3D devm_clk_get(&pdev->dev, "se"); @@ -1390,7 +1397,7 @@ static int qcom_geni_serial_probe(struct platform_dev= ice *pdev) port->rx_fifo_depth =3D DEF_FIFO_DEPTH_WORDS; port->tx_fifo_width =3D DEF_FIFO_WIDTH_BITS; =20 - if (!console) { + if (!data->console) { port->rx_fifo =3D devm_kcalloc(uport->dev, port->rx_fifo_depth, sizeof(u32), GFP_KERNEL); if (!port->rx_fifo) @@ -1420,7 +1427,7 @@ static int qcom_geni_serial_probe(struct platform_dev= ice *pdev) uport->irq =3D irq; uport->has_sysrq =3D IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE); =20 - if (!console) + if (!data->console) port->wakeup_irq =3D platform_get_irq_optional(pdev, 1); =20 if (of_property_read_bool(pdev->dev.of_node, "rx-tx-swap")) @@ -1442,7 +1449,6 @@ static int qcom_geni_serial_probe(struct platform_dev= ice *pdev) port->private_data.drv =3D drv; uport->private_data =3D &port->private_data; platform_set_drvdata(pdev, port); - port->handle_rx =3D console ? handle_rx_console : handle_rx_uart; =20 ret =3D uart_add_one_port(drv, uport); if (ret) @@ -1522,14 +1528,30 @@ static int __maybe_unused qcom_geni_serial_sys_resu= me(struct device *dev) return ret; } =20 +static const struct qcom_geni_device_data qcom_geni_console_data =3D { + .console =3D true, + .handle_rx =3D handle_rx_console, +}; + +static const struct qcom_geni_device_data qcom_geni_uart_data =3D { + .console =3D false, + .handle_rx =3D handle_rx_uart, +}; + static const struct dev_pm_ops qcom_geni_serial_pm_ops =3D { SET_SYSTEM_SLEEP_PM_OPS(qcom_geni_serial_sys_suspend, qcom_geni_serial_sys_resume) }; =20 static const struct of_device_id qcom_geni_serial_match_table[] =3D { - { .compatible =3D "qcom,geni-debug-uart", }, - { .compatible =3D "qcom,geni-uart", }, + { + .compatible =3D "qcom,geni-debug-uart", + .data =3D &qcom_geni_console_data, + }, + { + .compatible =3D "qcom,geni-uart", + .data =3D &qcom_geni_uart_data, + }, {} }; MODULE_DEVICE_TABLE(of, qcom_geni_serial_match_table); --=20 2.37.2