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: 817637 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 E72BE3A1C4 for ; Wed, 7 Aug 2024 14:08:54 +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=1723039738; cv=none; b=rYetzEMUMo4lgwAE0yii9JBipHKzGthlz4tJhVZ1snMH6Gf+jk6oXGhCESFkFxB8uXB1utxf1IYMQiX9DpNkfIZvi2iq5oNSdczUi5c8JE8LfwxRrS87604T+EEwR+gN7NwGRlE1uBJNClScxUPPF2Jcyry1BzvpJheUQGL5jnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039738; c=relaxed/simple; bh=MVVntXK62hacBsCloC4VuYF1/PJRtCaKzPq6C9YFjvs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b34+qQkR3k3AIxWLl5aLjPlq2JMyCEZVu0vdBKTK6xfV3Hade9jmmfoMujU/u6lMzE2oMc3hEQYLBiDd7ozhHADNb2OYZ/MIGWsSBbM8SOyB/MuTTZREWiQXGQuRdNDaSZG13sKMAhqwdjLlmt+VQCBW0ETLQwPsVHc07V6sqSY= 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-serial@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-serial@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: 817638 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 E725C39FFE for ; Wed, 7 Aug 2024 14:08:54 +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=1723039737; cv=none; b=tlhT+t9pmhxYqmtem/PkbmDEKUjV4KlhYACObCOPVJkhfdGGODeGqJ7T5HbN16GnEwnHWutMOjGYbgYuO7JvWA2wyeAFgtkPRgjqk+nBxWqEU1AsMLPuZL9YdiivxaJmDxksHWralFJNOQXD3W0sBocUqjpxKHLPVAZEv3ER5oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039737; 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=PCqZJwym7e84t4KDi+65X/aUnV3WJMLpNYKrCxHtjIffhC090SUlJrMJ4bFCEUf16thQrWjXd6hBO+o+YKwn/9I3C7FGhvtGQLrUV+IC4dj7NN6UKZKd3vJ9beI07IbcaIQQKmSGe56yIK3xOBmQghokUI/jzpo0kdj+NLtGyRA= 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-serial@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-serial@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: 818009 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 E72953A1BF for ; Wed, 7 Aug 2024 14:08:54 +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=1723039737; cv=none; b=gojX9yQoC1ZXT/V64Qc6haJ5B8eIgYI4VXNXGWjvsT26nE8lkpC2UP/qz4bGclAnpIzJNL9eED7NcQzMr3Ycd9WfLlrdyTNzbRl08igfQAYA2SCjTNXX/86V7ECGh+iBFFAuoxXB4ZyCrA6nb23A/eUX5/OLZSjOTsCLbXuussk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723039737; c=relaxed/simple; bh=FqhMOL8S6qzJXyNhiI+GMvBv2supAxih1MgpogK4of0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H2GeLvwkf741gTCu7anOTrNvZIZGECoxXyrgt2sViLKSDM+ycCxa3wnDqDVxdd50T1naMUV/6XWITCHX+jSxA6vnbQxOmYuq8dyQVXnuCd2LHv8g5mGkk8cHWez/YYopM/lQzer9AaNyWtKno1yYGiq4fr1zDHak4pYv9bZSVI0= 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-serial@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-serial@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)