diff mbox series

[01/25] tty: Change return type to void

Message ID 1536029091-4426-2-git-send-email-climbbb.kim@gmail.com
State Not Applicable
Headers show
Series Change tty_port(standard)_install's return type | expand

Commit Message

Jaejoong Kim Sept. 4, 2018, 2:44 a.m. UTC
Many drivers with tty use the tty_stand_install(). But, there is no
need to handle the error, since it always returns 0. So, change the
return type of tty_standard_install() and tty_port_install() to void
type and remove unnecessary exception handling where we use these
functions.

Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
---
 drivers/tty/tty_io.c   | 10 ++++++----
 drivers/tty/tty_port.c |  4 ++--
 include/linux/tty.h    |  4 ++--
 3 files changed, 10 insertions(+), 8 deletions(-)

Comments

Sergei Shtylyov Sept. 4, 2018, 10:45 a.m. UTC | #1
Hello!

On 9/4/2018 5:44 AM, Jaejoong Kim wrote:

> Many drivers with tty use the tty_stand_install(). But, there is no
> need to handle the error, since it always returns 0. So, change the
> return type of tty_standard_install() and tty_port_install() to void
> type and remove unnecessary exception handling where we use these
> functions.
> 
> Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
> ---
>   drivers/tty/tty_io.c   | 10 ++++++----
>   drivers/tty/tty_port.c |  4 ++--
>   include/linux/tty.h    |  4 ++--
>   3 files changed, 10 insertions(+), 8 deletions(-)
> 
[...]
> diff --git a/include/linux/tty.h b/include/linux/tty.h
> index c56e397..63cdac1 100644
> --- a/include/linux/tty.h
> +++ b/include/linux/tty.h
> @@ -556,7 +556,7 @@ extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
>   extern void tty_release_struct(struct tty_struct *tty, int idx);
>   extern int tty_release(struct inode *inode, struct file *filp);
>   extern void tty_init_termios(struct tty_struct *tty);
> -extern int tty_standard_install(struct tty_driver *driver,
> +extern void tty_standard_install(struct tty_driver *driver,
>   		struct tty_struct *tty);
>   
>   extern struct mutex tty_mutex;
> @@ -688,7 +688,7 @@ extern int tty_port_close_start(struct tty_port *port,
>   extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty);
>   extern void tty_port_close(struct tty_port *port,
>   				struct tty_struct *tty, struct file *filp);
> -extern int tty_port_install(struct tty_port *port, struct tty_driver *driver,
> +extern void tty_port_install(struct tty_port *port, struct tty_driver *driver,
>   				struct tty_struct *tty);

    You need to update all the callers in the same patch -- the kernel must 
remain buildable after each patch but you seem to have spread that update 
among a lot of patches..

[...]

MBR, Sergei
Jiri Slaby Sept. 5, 2018, 5:57 a.m. UTC | #2
On 09/05/2018, 03:08 AM, Jaejoong Kim wrote:
>     > @@ -688,7 +688,7 @@ extern int tty_port_close_start(struct
>     tty_port *port,
>     >   extern void tty_port_close_end(struct tty_port *port, struct
>     tty_struct *tty);
>     >   extern void tty_port_close(struct tty_port *port,
>     >                               struct tty_struct *tty, struct file
>     *filp);
>     > -extern int tty_port_install(struct tty_port *port, struct
>     tty_driver *driver,
>     > +extern void tty_port_install(struct tty_port *port, struct
>     tty_driver *driver,
>     >                               struct tty_struct *tty);
> 
>         You need to update all the callers in the same patch -- the
>     kernel must
>     remain buildable after each patch but you seem to have spread that
>     update
>     among a lot of patches..
> 
> 
> OK. I will make several patches as one patch.

You don't have to. Just reorder the patches as suggested by Sam. (First,
make everybody ignore the return value, then change these return types
to void.)

BTW you can mention in this commit log, that this change is possible
after a3123fd0a4a5. That commit made tty_standard_install to always
return 0.

thanks,
diff mbox series

Patch

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 32bc3e3..b01cec8 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1196,13 +1196,12 @@  void tty_init_termios(struct tty_struct *tty)
 }
 EXPORT_SYMBOL_GPL(tty_init_termios);
 
-int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)
+void tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)
 {
 	tty_init_termios(tty);
 	tty_driver_kref_get(driver);
 	tty->count++;
 	driver->ttys[tty->index] = tty;
-	return 0;
 }
 EXPORT_SYMBOL_GPL(tty_standard_install);
 
@@ -1221,8 +1220,11 @@  EXPORT_SYMBOL_GPL(tty_standard_install);
 static int tty_driver_install_tty(struct tty_driver *driver,
 						struct tty_struct *tty)
 {
-	return driver->ops->install ? driver->ops->install(driver, tty) :
-		tty_standard_install(driver, tty);
+	if (driver->ops->install)
+		return driver->ops->install(driver, tty);
+
+	tty_standard_install(driver, tty);
+	return 0;
 }
 
 /**
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 25d7368..fd8d40d 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -656,11 +656,11 @@  EXPORT_SYMBOL(tty_port_close);
  * to a concrete tty specified by @tty. Use this or tty_port_register_device
  * (or both). Call tty_port_link_device as a last resort.
  */
-int tty_port_install(struct tty_port *port, struct tty_driver *driver,
+void tty_port_install(struct tty_port *port, struct tty_driver *driver,
 		struct tty_struct *tty)
 {
 	tty->port = port;
-	return tty_standard_install(driver, tty);
+	tty_standard_install(driver, tty);
 }
 EXPORT_SYMBOL_GPL(tty_port_install);
 
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c56e397..63cdac1 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -556,7 +556,7 @@  extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
 extern void tty_release_struct(struct tty_struct *tty, int idx);
 extern int tty_release(struct inode *inode, struct file *filp);
 extern void tty_init_termios(struct tty_struct *tty);
-extern int tty_standard_install(struct tty_driver *driver,
+extern void tty_standard_install(struct tty_driver *driver,
 		struct tty_struct *tty);
 
 extern struct mutex tty_mutex;
@@ -688,7 +688,7 @@  extern int tty_port_close_start(struct tty_port *port,
 extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty);
 extern void tty_port_close(struct tty_port *port,
 				struct tty_struct *tty, struct file *filp);
-extern int tty_port_install(struct tty_port *port, struct tty_driver *driver,
+extern void tty_port_install(struct tty_port *port, struct tty_driver *driver,
 				struct tty_struct *tty);
 extern int tty_port_open(struct tty_port *port,
 				struct tty_struct *tty, struct file *filp);