From patchwork Wed Aug 7 14:08:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 13756345 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 4D60739FFE for ; Wed, 7 Aug 2024 14:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039740; cv=none; b=QgyqGhQGAEDEVar6Nz7HZ/leV3XF9Ys6VNK9pgFWVGMpSKXErY1rOR6cQw9AtHHnzsabYZ4Y3Cl9a4IgFXuI7JC+s8lPwM/whyCbeUju4jH726UIg6PrF3mnpsIUfz0LSUyKG/c39BFYeQ2vMBXopJoonHetK8OLtZ4AexLCWP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039740; c=relaxed/simple; bh=MVVntXK62hacBsCloC4VuYF1/PJRtCaKzPq6C9YFjvs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tAQ3baemxp1a1KT9ZGxoy/DwuV674rf3DgM3jVcKf1B/WJK+a+w0Ru05ftaJLM5nYa03JPM8eZA1PQXdokaM5Ci7QWqXa9fhlfIyxUfmz++O+x2rgVvAbkBNcK/oBgObZOycIiDKm9x2QYJce/Y/GfY4JlpkA/x33Ewp5kF6Pk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1sbhLQ-0002E5-Pu; Wed, 07 Aug 2024 16:08:52 +0200 From: Marco Felsch Date: Wed, 07 Aug 2024 16:08:48 +0200 Subject: [PATCH 1/3] serdev: ttyport: make use of tty_kopen_exclusive Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-v6-10-topic-usb-serial-serdev-v1-1-ed2cc5da591f@pengutronix.de> References: <20240807-v6-10-topic-usb-serial-serdev-v1-0-ed2cc5da591f@pengutronix.de> In-Reply-To: <20240807-v6-10-topic-usb-serial-serdev-v1-0-ed2cc5da591f@pengutronix.de> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Johan Hovold Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Marco Felsch X-Mailer: b4 0.14.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-usb@vger.kernel.org The purpose of serdev is to provide kernel drivers for particular serial device, serdev-ttyport is no exception here. Make use of the tty_kopen_exclusive() funciton to mark this tty device as kernel internal device. Signed-off-by: Marco Felsch --- drivers/tty/serdev/serdev-ttyport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c index 3d7ae7fa5018..94c43d25ddbe 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -103,11 +103,14 @@ static int ttyport_write_room(struct serdev_controller *ctrl) static int ttyport_open(struct serdev_controller *ctrl) { struct serport *serport = serdev_controller_get_drvdata(ctrl); + struct tty_driver *tty_drv = serport->tty_drv; struct tty_struct *tty; struct ktermios ktermios; + dev_t dev; int ret; - tty = tty_init_dev(serport->tty_drv, serport->tty_idx); + dev = MKDEV(tty_drv->major, tty_drv->minor_start + serport->tty_idx); + tty = tty_kopen_exclusive(dev); if (IS_ERR(tty)) return PTR_ERR(tty); serport->tty = tty; @@ -144,7 +147,7 @@ static int ttyport_open(struct serdev_controller *ctrl) tty->ops->close(tty, NULL); err_unlock: tty_unlock(tty); - tty_release_struct(tty, serport->tty_idx); + tty_kclose(tty); return ret; } @@ -161,7 +164,7 @@ static void ttyport_close(struct serdev_controller *ctrl) tty->ops->close(tty, NULL); tty_unlock(tty); - tty_release_struct(tty, serport->tty_idx); + tty_kclose(tty); } static unsigned int ttyport_set_baudrate(struct serdev_controller *ctrl, unsigned int speed) From patchwork Wed Aug 7 14:08:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 13756342 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 1509938DF9 for ; Wed, 7 Aug 2024 14:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039740; cv=none; b=NAGYivJOZtK8207j4NBYB/iV8FtpqjdMgfizym2x9lSOUr0oJvaFbvwuP9Z9664PoCNCmFmoLnaI+Hv0sgmBrRZVg4S3Mv94GajjVpKnBxL14ki99KTdZDJgXPTsD/MykHq/WB7rk8ROTF0A1gL0Pl9yfghmmUc+ixAuGq78gvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039740; c=relaxed/simple; bh=9hXhq6Gzs+DxBDizJYR+Z6DeOqGq51BP6C6316J+VqU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rm571x/H7gQl4l4EvVB0bxyNj1dMJ7txoKHg7e97YqJo392L8PYF7T+Dt4JjuWp/KSsWSrRNqbZ2VLC/JCgzBX/xSAexjeMHkkbSp2lBDHj3rc6xR6LrOTahjUPtZCa79NVCDpw5dpHbqFBMeboJmOobiY0skfnnmY3cmGam/VQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1sbhLQ-0002E5-Re; Wed, 07 Aug 2024 16:08:52 +0200 From: Marco Felsch Date: Wed, 07 Aug 2024 16:08:49 +0200 Subject: [PATCH 2/3] USB: serial: cosmetic cleanup mix Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-v6-10-topic-usb-serial-serdev-v1-2-ed2cc5da591f@pengutronix.de> References: <20240807-v6-10-topic-usb-serial-serdev-v1-0-ed2cc5da591f@pengutronix.de> In-Reply-To: <20240807-v6-10-topic-usb-serial-serdev-v1-0-ed2cc5da591f@pengutronix.de> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Johan Hovold Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Marco Felsch X-Mailer: b4 0.14.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-usb@vger.kernel.org Cosmetic cleanup: replace mix with only. Signed-off-by: Marco Felsch --- drivers/usb/serial/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 6c812d01b37d..df0196a30f33 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -149,7 +149,7 @@ const struct bus_type usb_serial_bus_type = { .match = usb_serial_device_match, .probe = usb_serial_device_probe, .remove = usb_serial_device_remove, - .drv_groups = usb_serial_drv_groups, + .drv_groups = usb_serial_drv_groups, }; int usb_serial_bus_register(struct usb_serial_driver *driver) From patchwork Wed Aug 7 14:08:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 13756343 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5EC963A1C4 for ; Wed, 7 Aug 2024 14:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039740; cv=none; b=so2Ggu6EsgdUNgbj2+hOhf4angofv501UZCG+I5XoPf2ISRQmc4x77ZA/CY04cBQ0jRK6UOkHE5Eg2w8XoNo5+ao1KaMMDc+UQ4FXgr7WeSnYTMFHxH8E69TdWxBeFD/mF5HZZwgLzQnNG6jfY7p03XVw94tpk9Da7fSC5RkHwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039740; c=relaxed/simple; bh=FqhMOL8S6qzJXyNhiI+GMvBv2supAxih1MgpogK4of0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IrlscLyyLzI9/Xr8JSiwwIQ2pdvKDNK3M9hHbUGWkiGmowehsW9UtM/O0siK3/t+EECS85wUh/UDCHJHS3zY8RmyIcs81ZorL8iC0OMd3JN8jayReG/b0GGF7nQ6GnxKMOnLvJ/mFyRhzx9VGhxEfzbX996ktkZImiHBWgr5MBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1sbhLQ-0002E5-TW; Wed, 07 Aug 2024 16:08:52 +0200 From: Marco Felsch Date: Wed, 07 Aug 2024 16:08:50 +0200 Subject: [PATCH 3/3] USB: serial: enable serdev support Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240807-v6-10-topic-usb-serial-serdev-v1-3-ed2cc5da591f@pengutronix.de> References: <20240807-v6-10-topic-usb-serial-serdev-v1-0-ed2cc5da591f@pengutronix.de> In-Reply-To: <20240807-v6-10-topic-usb-serial-serdev-v1-0-ed2cc5da591f@pengutronix.de> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Johan Hovold Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Marco Felsch X-Mailer: b4 0.14.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-usb@vger.kernel.org Enable serdev support by using the serdev opt-in tty-port registration helper. Signed-off-by: Marco Felsch --- drivers/usb/serial/bus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index df0196a30f33..84eca07f83fa 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -33,6 +33,7 @@ static int usb_serial_device_probe(struct device *dev) { struct usb_serial_port *port = to_usb_serial_port(dev); struct usb_serial_driver *driver; + struct device *host_dev; struct device *tty_dev; int retval = 0; int minor; @@ -50,8 +51,9 @@ 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); + host_dev = &port->serial->interface->dev; + tty_dev = tty_port_register_device_serdev(&port->port, + usb_serial_tty_driver, minor, host_dev, dev); if (IS_ERR(tty_dev)) { retval = PTR_ERR(tty_dev); goto err_port_remove; @@ -90,7 +92,7 @@ static void usb_serial_device_remove(struct device *dev) autopm_err = usb_autopm_get_interface(port->serial->interface); minor = port->minor; - tty_unregister_device(usb_serial_tty_driver, minor); + tty_port_unregister_device(&port->port, usb_serial_tty_driver, minor); driver = port->serial->type; if (driver->port_remove)