From patchwork Fri Jan 5 14:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 761738 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2080.outbound.protection.outlook.com [40.107.15.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 364F92E652; Fri, 5 Jan 2024 14:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kunbus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kunbus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="X4yanZ/f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLauKdM8GrYIQkQbUFaKq/DfLSq8tG4C2U0qlHIoFyYttTQjTBoXQIrHxDXeqvVSw9u2/xuU8gRbsEuLEdV19o+9icnRBAA3bPv+/zl4YGdUja1To1aoyIWCPiVDBS4qzPeBs9Z/Rx9/iDx1oRqIi8a/wvcraJBrptJwZz2FVdOy0MRr4P5fmak9bqPNE6zsSVSLW7OzIKEzOiFCZZJfhlyyj31AMvTD2KarF4Va4sgJaJ85qQyZWLhVq4U+HT+jJ6YOv1OtjHHYUgBRKPGeBDmPiCv40p33P8Xu0yo7Ni5TBNrWNM4ch5iwn/4EBhEstK4ZeGjFpcILCVEr5hKTZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aG14v1l0mNKMp5n7ZH3UkcOWh/FnIG3dYuQfg/M+qPs=; b=XT/qUy9uO8JAvJBHdTjAsZOMk6Y9Uq7CYz+jIrBm7vYAAmwRZJ3IHgFORrtcwylqAGQfQmpa/bmS2XsfslbIwCNouc8vnnULqFxRNZ94h1jOePu8mam0Gm+s1BpZFfEqYibGpGb9YEu5tCYRur5p9q3AG2DrY4jWP/bYeAvoLaf4EJtDNe9lZUl5kWOFJzaSNiN3yg1UCJq5iX3bjiu+31ol0g8J+8z3G4qdOUEvd0x64m5xhUoe2P8ESvDxU48ilR8AL4kIODfEzpcPfQ+OZcz4QLrnVozQKgCZWUZFlXY7q7PrbYhUb+op+k1rRljAN0mQGbDYkkYzaz/3vXwcWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aG14v1l0mNKMp5n7ZH3UkcOWh/FnIG3dYuQfg/M+qPs=; b=X4yanZ/f/oZgGQcZz+ma9CBBSUKpKx1uEle5+dCzEZAlPL+6qU1usaimqA1hKJE8rfM8WWRRUnz7m300pnDak7JzYWivXf11hGYbaFrcbmnU0CkV+C95Pq97scXIvV+lkcW2VRjI9DdIsEa4PDwncdaXlF7+HXO3Y2l3PjJMWh8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by DB9P193MB1403.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:2ae::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12:18 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb%6]) with mapi id 15.20.7159.015; Fri, 5 Jan 2024 14:12:18 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, hugo@hugovil.com, m.brock@vanmierlo.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v8 6/7] serial: omap: do not override settings for RS485 support Date: Fri, 5 Jan 2024 15:11:52 +0100 Message-ID: <20240105141153.19249-7-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|DB9P193MB1403:EE_ X-MS-Office365-Filtering-Correlation-Id: d6ab6fdf-e054-45f1-9e7b-08dc0df85371 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R6/SgkcEoxjAk8kKHxgrt9h24fYdsVaYgu5RaU+dxI6L7uAx2o7JBWwGnJr87+gx7WZKAnOBZWGJ9789A4PC2dfyeR5Vqok1/oGZxZ4bUF9KS0DDup4kpc6I7xvG0i+6uMxzSKOw8EPqMAfjznpX02h7T3/CbFycGqNexWwhQc4YotOPoMdxeZt3CInJIy4s4g5MN0Na13OWX98XA4q+q7S7sxb5hyBlXTw4FQmKTmXzvDsDkcQdhQJTTWeJO8kzm9mvff/c+t46NY1/h577fWi5vqzmCR+XpS8gNDwVYJOTYNdc8onZi5i3Hw8mGqpc8k0ct+0/Asg/od1tzmTppWHxNzYERygulYJR1nFp4NFT9npKjf9ZKplRT+Sm2v0Oe+4Py0OgQK83lWKi0p0HaczbdeEKUmsgkqSZT67g7RZsDj/bumNgOASNI9PB5/wA8NBCnO960eklOCOejf/Ib+6Um4SHah17AC/xVYQ+Sut+H7yE/8+bKmBPyiexmPmJ7ZN7FZKcnNVO77QTY+sMv8hNSYzM2LXWsns7ZY4xSRkclQUZfmtXNOS2PJMDRvS9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(136003)(396003)(39840400004)(346002)(366004)(376002)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(6666004)(478600001)(2616005)(83380400001)(5660300002)(1076003)(66574015)(6512007)(6486002)(66556008)(66946007)(66476007)(6506007)(52116002)(316002)(4326008)(41300700001)(86362001)(2906002)(8676002)(8936002)(7416002)(36756003)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6boWALpuO/N/z5qPZo2rpTJSyQDi?= =?utf-8?q?FcsddDuFq7uyoElVDhhADaQ3cH0qwxxSWiV/s8CJFXQtROU710UXkPWZXjaO2SH38?= =?utf-8?q?+u1QHv0EkzIViGg3yuKBdO2v6d1u6640TlaTDIcGPYcOibwuMM3IZNKsso13Zdsgd?= =?utf-8?q?MSLVTPOvJ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nQ00fEEQ0eOzF+tN+UP0RBHVNf6ojH62g5++0tMqhs7?= =?utf-8?q?gMmNE3imv0IGX1ndezHci/sty0eVuFDcT6pdc8hYuOVUGGZo7jAQ+WMpY4sVeq4fR?= =?utf-8?q?8TgN3pK2EclZjWW3lk9znvd1Qj6t9xmGhRke2OPSR5ZuPbok81Tuh+SYM/sZMGSRM?= =?utf-8?q?vDzCcQK1UcR4VWZMZU8owS5IVj2vM0srYIOcPtZCNKRolWtZCdbBmonwB4Lr80ZcW?= =?utf-8?q?5wp7kNfE4rewQ0tvGttoUA79Ul47s23B171xOTaByBelYFxtELecKCF4K3ClXviOw?= =?utf-8?q?x0q7gQVcfUVHeRpiqjVnvmmilzni+chaTfl4DZKG3I5uJ5RoUYV/6oiLOIOosUbQE?= =?utf-8?q?LTwMwdoRtRt+duImfNMSRaeLMPtVq2J0IyWW0TfCt57f9biHRufeJSRArtrASon0d?= =?utf-8?q?aSfcu8wmNHJJAsL+MIajoTbCGTEk+dIpyMS8mUP7Pipda3B+O02q93PbCRnyhqMdK?= =?utf-8?q?o8ZkkIvgd+LbUrpbj4l68EsG0huJcdmrsU5ROnNJC/R+38Za1FsjTB2PniI6HqjVI?= =?utf-8?q?5uO4DZQIf6AWroxXeAezXJzcat6jG0Zug=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6ab6fdf-e054-45f1-9e7b-08dc0df85371 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:18.4206 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uVnGjhFn0Z9nWiU+W2V5ebZygC+epw2MsQHz5hmgpUfsXSGv+4YwjdA9kkWsLz8Or4V1k/eto/M6ceg6Muo6Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1403 The drivers RS485 support is deactivated if there is no RTS GPIO available. This is done by nullifying the ports rs485_supported struct. After that however the settings in serial_omap_rs485_supported are assigned to the same structure unconditionally, which results in an unintended reactivation of RS485 support. Fix this by moving the assignment to the beginning of serial_omap_probe_rs485() and thus before the check for the RTS GPIO. Also relocate the assignment of serial_omap_config_rs485() to have the complete RS485 setup in one function. Fixes: e2752ae3cfc9 ("serial: omap: Disallow RS-485 if rts-gpio is not specified") Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/omap-serial.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index ad4c1c5d0a7f..f4c6ff806465 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1483,6 +1483,13 @@ static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) return omap_up_info; } +static const struct serial_rs485 serial_omap_rs485_supported = { + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | + SER_RS485_RX_DURING_TX, + .delay_rts_before_send = 1, + .delay_rts_after_send = 1, +}; + static int serial_omap_probe_rs485(struct uart_omap_port *up, struct device *dev) { @@ -1497,6 +1504,9 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, if (!np) return 0; + up->port.rs485_config = serial_omap_config_rs485; + up->port.rs485_supported = serial_omap_rs485_supported; + ret = uart_get_rs485_mode(&up->port); if (ret) return ret; @@ -1531,13 +1541,6 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, return 0; } -static const struct serial_rs485 serial_omap_rs485_supported = { - .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | - SER_RS485_RX_DURING_TX, - .delay_rts_before_send = 1, - .delay_rts_after_send = 1, -}; - static int serial_omap_probe(struct platform_device *pdev) { struct omap_uart_port_info *omap_up_info = dev_get_platdata(&pdev->dev); @@ -1604,17 +1607,11 @@ static int serial_omap_probe(struct platform_device *pdev) dev_info(up->port.dev, "no wakeirq for uart%d\n", up->port.line); - ret = serial_omap_probe_rs485(up, &pdev->dev); - if (ret < 0) - goto err_rs485; - sprintf(up->name, "OMAP UART%d", up->port.line); up->port.mapbase = mem->start; up->port.membase = base; up->port.flags = omap_up_info->flags; up->port.uartclk = omap_up_info->uartclk; - up->port.rs485_config = serial_omap_config_rs485; - up->port.rs485_supported = serial_omap_rs485_supported; if (!up->port.uartclk) { up->port.uartclk = DEFAULT_CLK_SPEED; dev_warn(&pdev->dev, @@ -1622,6 +1619,10 @@ static int serial_omap_probe(struct platform_device *pdev) DEFAULT_CLK_SPEED); } + ret = serial_omap_probe_rs485(up, &pdev->dev); + if (ret < 0) + goto err_rs485; + up->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; up->calc_latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; cpu_latency_qos_add_request(&up->pm_qos_request, up->latency);