Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4184023pxu; Mon, 30 Nov 2020 20:56:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4rBOf3iyNW1XNnpknOjn41vPTt4umJgOohAjV0SJ6RBdv5/Nt0A2B2gJvQ6ptFAV+549x X-Received: by 2002:a17:906:e15:: with SMTP id l21mr1270067eji.509.1606798605482; Mon, 30 Nov 2020 20:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606798605; cv=none; d=google.com; s=arc-20160816; b=p3atBBjpBrRbBbgzGYU+JniN2i7vZ1zHL4aYl33b2qm0xg6jyefNjXZzfF/jBoO+UH jbIL/14ZShSJlfE2fKlQ1+HgP8qiud4xa6h81Q2sPIqgZ6rcZKGN6eEYUx8g0XferwDI db9VXW74kuFGp6gOJq9mjoizH/StF8fID2cjlK6w4UVIxDJRbG3tRApXtN0sM9IXyOU9 cgpAjTz19gElmjrx58CLb/J0bR3n9SpSWoZrC0e1SECObznJlOzdtzIQOySDmqgi24iO tmrJhseGKie2DusIyVOcLsqmJN+9rOM3S+JxeV+NnecYACWsgMusOJVtf9TiiGBLUG7x r9SA== 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; bh=vS6wFzkkLhX1TVsecDayO/AB9FKfg+OLWHQOURPFz3E=; b=N2E6FrKu1K9UswDBX3qBa7yRDAwra8TiBKXwd2DV70rP8nHKQwlTJKmliBBQ4fWSnj uX4/YFC+BlvgRXIipsHpJwH05thhEstjVNAwA46iCKYHCqCUsOwVs/e7BA4W4CmlqLYa CJOZjLQe/MsDfGINyE2HImGi0dkaN7iX4buXtu7TmbddYYgaOLOQDN+s1Gwgmoy0Qu+d aAlQxuc4fHJLn13/Ew0sLBnxVAB8UBXf0A5k1SApHsux/DRxT2BotHVTrPzay0lqvJgO xW4+9KuBzf8JUi4NX8mFYQ1P3qzScFO+BBdTLVxHgDzgphNFTGjWsS8bpUJjZEyAUGai qhTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si268614eja.104.2020.11.30.20.56.22; Mon, 30 Nov 2020 20:56:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728419AbgK3Pio (ORCPT + 99 others); Mon, 30 Nov 2020 10:38:44 -0500 Received: from mail-lf1-f45.google.com ([209.85.167.45]:41724 "EHLO mail-lf1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728321AbgK3Pih (ORCPT ); Mon, 30 Nov 2020 10:38:37 -0500 Received: by mail-lf1-f45.google.com with SMTP id r24so22430174lfm.8; Mon, 30 Nov 2020 07:38:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vS6wFzkkLhX1TVsecDayO/AB9FKfg+OLWHQOURPFz3E=; b=KzT3A2a0J/CwmqpJisiZQ0+SYcqGDb/Vg3v8pIancuxMUMCL/DfRNTy3MXNALt03+9 8jZ9TfJM6NwlBfCHUfEy+4e3bMuzamDxLqNsXV+TMNl8FLMuiLKwl/s8AFGNI74cyuIJ kk36c65X4jK/jUw7/GAEGhBW5LtuxVtqiCjE6x2DSuSL2f1v9egPgqvVuxB+MqQ6aUnX pYFMcY0bDIHgDFpGGKya9FhITlhqL2U0FCrghieC+OPytoq4mBx0t87g5bgJYHeKoFML +O85nuEojoH6CdW6KGXhxuWr0WLoYZZ/5LhB37zIgUBDM+R7KqXEqHERc3o0ymHpHaOA LTmw== X-Gm-Message-State: AOAM532tYPCAdecwGvYhA86G+tVoZxd0EtY6TgcPri9ZS4fFCRGT5S0X qRxuOe6bzLP1o/bMzKJHejs= X-Received: by 2002:a19:fc0f:: with SMTP id a15mr9469592lfi.248.1606750674784; Mon, 30 Nov 2020 07:37:54 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id q16sm2950131ljj.32.2020.11.30.07.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 07:37:52 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kjlFu-0002Ol-Ob; Mon, 30 Nov 2020 16:38:22 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/5] serial: core: add sysfs attribute to suppress ready signalling on open Date: Mon, 30 Nov 2020 16:37:39 +0100 Message-Id: <20201130153742.9163-3-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201130153742.9163-1-johan@kernel.org> References: <20201130153742.9163-1-johan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a nordy sysfs attribute to suppress raising the modem-control lines on open to signal DTE readiness. This can be use to prevent undesirable side-effects on open for applications where the DTR and RTS lines are used for non-standard purposes such as generating power-on and reset pulses. Signed-off-by: Johan Hovold --- Documentation/ABI/testing/sysfs-tty | 7 +++++++ drivers/tty/serial/serial_core.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty index e157130a6792..2634b4bf9c7f 100644 --- a/Documentation/ABI/testing/sysfs-tty +++ b/Documentation/ABI/testing/sysfs-tty @@ -161,3 +161,10 @@ Contact: Andy Shevchenko Description: Allows user to detach or attach back the given device as kernel console. It shows and accepts a boolean variable. + +What: /sys/class/tty/ttyS0/nordy +Date: November 2020 +Contact: Johan Hovold +Description: + Show and store the port NORDY flag which suppresses raising + the modem-control lines on open to signal DTE readiness. diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f41cba10b86b..063a617182ce 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2805,6 +2805,33 @@ static ssize_t console_store(struct device *dev, return ret < 0 ? ret : count; } +static ssize_t nordy_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct tty_port *port = dev_get_drvdata(dev); + + return sprintf(buf, "%d\n", tty_port_nordy(port)); +} + +static ssize_t nordy_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct tty_port *port = dev_get_drvdata(dev); + unsigned int val; + int ret; + + ret = kstrtouint(buf, 0, &val); + if (ret) + return ret; + + if (val > 1) + return -EINVAL; + + tty_port_set_nordy(port, val); + + return count; +} + static DEVICE_ATTR_RO(uartclk); static DEVICE_ATTR_RO(type); static DEVICE_ATTR_RO(line); @@ -2819,6 +2846,7 @@ static DEVICE_ATTR_RO(io_type); static DEVICE_ATTR_RO(iomem_base); static DEVICE_ATTR_RO(iomem_reg_shift); static DEVICE_ATTR_RW(console); +static DEVICE_ATTR_RW(nordy); static struct attribute *tty_dev_attrs[] = { &dev_attr_uartclk.attr, @@ -2835,6 +2863,7 @@ static struct attribute *tty_dev_attrs[] = { &dev_attr_iomem_base.attr, &dev_attr_iomem_reg_shift.attr, &dev_attr_console.attr, + &dev_attr_nordy.attr, NULL }; -- 2.26.2