Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp287367iof; Mon, 6 Jun 2022 03:34:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLAkniv/G51KVOFJBtCWZN1o8s3f3AhmKg3JogSnMwAxYGvuUNVAiM5i/KsPIxn+hq1QlQ X-Received: by 2002:a05:6a00:1a42:b0:51c:27ee:9393 with SMTP id h2-20020a056a001a4200b0051c27ee9393mr2292099pfv.78.1654511675179; Mon, 06 Jun 2022 03:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654511675; cv=none; d=google.com; s=arc-20160816; b=WnBMTcM12z49jPk9ikaH4zod8bMwRqKd7680cY4AzIP3AK+xyklfXWQkAXc8hZ9lKV 6S3KkkfBfifvvLjgBAQYOnGfOsRx804iAaWFO2G8W4gGc6W+RF8tzfqgujvesUYApIpU O4u3mC5lhA7t05lt5OG1kzU2mNZgrx+yizUKIgBSDWwz2yX7MzHEqNGvO2Q3wci0jByf nWlJinUsMU7eq0mvi8XMK3UMaqyyNfyPPS7mt42eLgpaznCYT3+2RuVyX6tp9PGYoTnh gmW05l6ZAXtKjcvxIEzVmThiLrAFvKG4WiNpTHlYY7pOJM2b768D2Dhsz85eATBYspfU H78A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JcCR3h3kfiULKpvJoy7UbrjsE9tqhYwXEElaW47BiWs=; b=fGDLHmKoQxft9Lls3lOtrR8c4sqYaLwOzH/DrDeau/EPJAfxnY6Dam96lHihSoVeh3 9woc7NLoMJ62/nsF8o7RdPQcUd79SJxaOda9nEHllYf2nYLAiIm4TfolIIwR1MBMbz33 uWlPTrZP3Hn9dHuvNOcZH7vauBJIUMD6aN2KPvUgBt/AURqbOXBBvotAa+1S/4Tvbic7 zwpHxC/wVQKzGWSaTfTj2MFkxEFze5xistKKU8gskhXrk48sCe7v1imvO75cgVGGt/48 j5y5vyAy+qpxTKQNsQGgjhD7viDyc3/pQ5/oqogDQjKKBFte6SjDq+3kcy8US+EAATkh n+2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L4QFCKs2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a14-20020a17090abe0e00b001e3015b93absi18414573pjs.12.2022.06.06.03.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 03:34:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L4QFCKs2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 300C615906D; Mon, 6 Jun 2022 03:12:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233802AbiFFKJ7 (ORCPT + 99 others); Mon, 6 Jun 2022 06:09:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233597AbiFFKGm (ORCPT ); Mon, 6 Jun 2022 06:06:42 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D1F714641C; Mon, 6 Jun 2022 03:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654509997; x=1686045997; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hs7tygBksGYt2BDKZ0A+aYzoQ3gQHRqzZByxTCUZYPc=; b=L4QFCKs2V3Hjw87ItBs3zuR8yjcvT87VtwlHptiH0rQDTYY3rS5Oq+5c d1RTMzYtQHIYpJxcDxI8zKMHA78+uUkXSZNWsr4pK+yG7ie2VuVPn6VRQ vDMlxloqv0P6+zDCug/n9g3SP09USTsp3TRdOcr9vtSvcBgoXURwm3TvP idEzi/BQ/Ihm7rqKoJ9RjIDGouyh3w/UsynlbkWtxSj83xCM+CVg/+rj0 dW0OGU8Y/VSuK440i2Njm3355b1NllQlkZx4vTj+clzfJvyML1lugWaLc PRtduJV8D/F6Z0cL5Whj1PsunihjjGmuv+H0tSJq27RbUcfCzIXe1lzIV Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="362987102" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="362987102" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 03:06:37 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="635523925" Received: from amkossek-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.57.11]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 03:06:35 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-serial@vger.kernel.org, Greg KH , Jiri Slaby , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 36/36] serial: 8250: Remove serial_rs485 sanitization from em485 Date: Mon, 6 Jun 2022 13:04:33 +0300 Message-Id: <20220606100433.13793-37-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220606100433.13793-1-ilpo.jarvinen@linux.intel.com> References: <20220606100433.13793-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Serial core handles serial_rs485 sanitization. When em485 init fails, there are two possible paths of entry: 1) uart_rs485_config (init path) that fully clears port->rs485 on error. 2) ioctl path with a pre-existing, valid port->rs485 unto which the kernel falls back on error and port->rs485 should therefore be kept untouched. The temporary rs485 struct is not returned to userspace in case of error so its flag don't matter. ...Thus SER_RS485_ENABLED clearing on error can/should be dropped. Signed-off-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_port.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index a825fbc215a7..4998799abae2 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -675,13 +675,6 @@ int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485) rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; } - /* clamp the delays to [0, 100ms] */ - rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); - rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); - - memset(rs485->padding, 0, sizeof(rs485->padding)); - port->rs485 = *rs485; - gpiod_set_value(port->rs485_term_gpio, rs485->flags & SER_RS485_TERMINATE_BUS); @@ -689,15 +682,8 @@ int serial8250_em485_config(struct uart_port *port, struct serial_rs485 *rs485) * Both serial8250_em485_init() and serial8250_em485_destroy() * are idempotent. */ - if (rs485->flags & SER_RS485_ENABLED) { - int ret = serial8250_em485_init(up); - - if (ret) { - rs485->flags &= ~SER_RS485_ENABLED; - port->rs485.flags &= ~SER_RS485_ENABLED; - } - return ret; - } + if (rs485->flags & SER_RS485_ENABLED) + return serial8250_em485_init(up); serial8250_em485_destroy(up); return 0; -- 2.30.2