Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp795886pxu; Wed, 2 Dec 2020 03:44:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/wNGr7S8x8A5fnIs9kqFQm8MXA09D7B8VHaHVMOpZzeq0YDpm9+IFGrsajht/0pyKgGz4 X-Received: by 2002:a17:907:b09:: with SMTP id h9mr1894511ejl.155.1606909444296; Wed, 02 Dec 2020 03:44:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606909444; cv=none; d=google.com; s=arc-20160816; b=e3Uik3i7I78Q2tUjdh6NyCx2i/vaBJKCXbrVgsU5CaD8QJpWA/h4NI1Ju90QogkNvy aMO7kt+rEmB8H5VMJ6zG+V71xOEbA4Z8IYyDB8A7SRg4SFNBnXfWUqvAcg/wP8EOg19b t1H2se/ETxRch05u5JglwpB7VJ5CrtLL9AIJq1t2Nd0uf30iP4nS0UTdzKfpSOjpI/27 gZA1WrhGkUbFrQ19x3zT/2um4ikrl9SzhTNU3P6rB7i73tdaN9Yq/RvdChF+eNDGXVRR JB+F6+vQgpMemZNkJS2Tp7IigT8y/b8uY+0a2AzscWWi13OJ3ODLAlQ5yCcZWA/5Gt6b ygWw== 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=tP2HvplWRaMXdOrLEwAbMpgsLuB/LtE2K3OBH4UE6QM=; b=UzHrLLoZk+gMrVppvT4h0KD/tVkxVubABZLNIvAjTyTSHPQ9pES7fiedVIbufO2IoO mj+TYmeoqnb8O2+v+1LsVDUzKQQU5boZyTGlZTiD8qGfg6gT9byHQ8ccHAa/ifxGyLLC RgoZomZDaf4m9kUbN//zijaD1PLNvTME7TM8sdVFsiA2N0ELGEK7jBcI2y2Lgp3God+Z fsVJYnCvpFrlPinsWYXHmzHMTjYjLQMYnu+H/RsFze2IGMxBGg5R0C5XO5sJVasFu6yV ib0peryIrJHDLo/TXWphrK6sFyanZ+kAqJi7RzsnQdy39iSTUefCadHCKDjVHHKuh3ON Ja+A== 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 d16si669240ejm.152.2020.12.02.03.43.40; Wed, 02 Dec 2020 03:44:04 -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 S1729703AbgLBLkt (ORCPT + 99 others); Wed, 2 Dec 2020 06:40:49 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33337 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgLBLkd (ORCPT ); Wed, 2 Dec 2020 06:40:33 -0500 Received: by mail-lf1-f67.google.com with SMTP id l11so4202208lfg.0; Wed, 02 Dec 2020 03:40:16 -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=tP2HvplWRaMXdOrLEwAbMpgsLuB/LtE2K3OBH4UE6QM=; b=nBu7trBqYxRQlQbVfl9XsOSIEbGXmMrOXpSe718JzeiaJrprDBQDqo37xRRZl1CfPT V+0iltwTcp/2arRJQyw7K+/sLWajsm4gUUuYKOXqUllDR0NcvIQd/OIa9BO+YwyI1sWu ABtvH2PhT3fJ+ZEgZJH1Kjy0+dPZh/jdH3pIEgIa/Qohsgg3BmSUHAFy7ica2Jb/iqpA e5h04/5yoCPCqudWbhRLQkR+XYfc0VmFK7RiLA+4WNyY3xOiLIrEyL2vAtSwKb7FmtZ3 owQdGkIbTa0JUjCmJaYsQeiMpMdVbpL084nQeMx1rhr4qd1eip7Vvu6yInG+2t4isS9c 62pg== X-Gm-Message-State: AOAM5314Y+K4C64lm/goOvkRFZR22R2n4F8PLBoo3Ugep2wqLfOH3/8R pwJusy3bRKctKXf2b7uszJs= X-Received: by 2002:ac2:5a47:: with SMTP id r7mr974435lfn.525.1606909191191; Wed, 02 Dec 2020 03:39:51 -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 t20sm385034lff.153.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:49 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUd-000738-27; Wed, 02 Dec 2020 12:40:19 +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 v2 5/7] USB: serial: add sysfs attribute to suppress ready signalling on open Date: Wed, 2 Dec 2020 12:39:40 +0100 Message-Id: <20201202113942.27024-6-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-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 used 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 --- drivers/usb/serial/bus.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index eb0195cf37dd..db75cc5c3dfb 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -35,6 +35,37 @@ static int usb_serial_device_match(struct device *dev, return 0; } +static ssize_t nordy_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct usb_serial_port *port = dev_get_drvdata(dev); + + return sprintf(buf, "%d\n", tty_port_nordy(&port->port)); +} + +static ssize_t nordy_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct usb_serial_port *port = dev_get_drvdata(dev); + bool val; + int ret; + + ret = kstrtobool(buf, &val); + if (ret) + return ret; + + tty_port_set_nordy(&port->port, val); + + return count; +} +static DEVICE_ATTR_RW(nordy); + +static struct attribute *tty_attrs[] = { + &dev_attr_nordy.attr, + NULL +}; +ATTRIBUTE_GROUPS(tty); + static int usb_serial_device_probe(struct device *dev) { struct usb_serial_driver *driver; @@ -60,8 +91,8 @@ static int usb_serial_device_probe(struct device *dev) } minor = port->minor; - tty_dev = tty_port_register_device(&port->port, usb_serial_tty_driver, - minor, dev); + tty_dev = tty_port_register_device_attr(&port->port, + usb_serial_tty_driver, minor, dev, port, tty_groups); if (IS_ERR(tty_dev)) { retval = PTR_ERR(tty_dev); goto err_port_remove; -- 2.26.2