@@ -843,7 +843,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
843
843
unsigned int change_irq , change_port , closing_wait ;
844
844
unsigned int old_custom_divisor , close_delay ;
845
845
upf_t old_flags , new_flags ;
846
- int retval = 0 ;
846
+ int retval ;
847
847
848
848
if (!uport )
849
849
return - EIO ;
@@ -882,21 +882,18 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
882
882
if (!(uport -> flags & UPF_FIXED_PORT )) {
883
883
unsigned int uartclk = new_info -> baud_base * 16 ;
884
884
/* check needs to be done here before other settings made */
885
- if (uartclk == 0 ) {
886
- retval = - EINVAL ;
887
- goto exit ;
888
- }
885
+ if (uartclk == 0 )
886
+ return - EINVAL ;
889
887
}
890
888
if (!capable (CAP_SYS_ADMIN )) {
891
- retval = - EPERM ;
892
889
if (change_irq || change_port ||
893
890
(new_info -> baud_base != uport -> uartclk / 16 ) ||
894
891
(close_delay != port -> close_delay ) ||
895
892
(closing_wait != port -> closing_wait ) ||
896
893
(new_info -> xmit_fifo_size &&
897
894
new_info -> xmit_fifo_size != uport -> fifosize ) ||
898
895
(((new_flags ^ old_flags ) & ~UPF_USR_MASK ) != 0 ))
899
- goto exit ;
896
+ return - EPERM ;
900
897
uport -> flags = ((uport -> flags & ~UPF_USR_MASK ) |
901
898
(new_flags & UPF_USR_MASK ));
902
899
uport -> custom_divisor = new_info -> custom_divisor ;
@@ -906,30 +903,24 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
906
903
if (change_irq || change_port ) {
907
904
retval = security_locked_down (LOCKDOWN_TIOCSSERIAL );
908
905
if (retval )
909
- goto exit ;
906
+ return retval ;
910
907
}
911
908
912
- /*
913
- * Ask the low level driver to verify the settings.
914
- */
915
- if (uport -> ops -> verify_port )
909
+ /* Ask the low level driver to verify the settings. */
910
+ if (uport -> ops -> verify_port ) {
916
911
retval = uport -> ops -> verify_port (uport , new_info );
912
+ if (retval )
913
+ return retval ;
914
+ }
917
915
918
916
if ((new_info -> irq >= irq_get_nr_irqs ()) || (new_info -> irq < 0 ) ||
919
917
(new_info -> baud_base < 9600 ))
920
- retval = - EINVAL ;
921
-
922
- if (retval )
923
- goto exit ;
918
+ return - EINVAL ;
924
919
925
920
if (change_port || change_irq ) {
926
- retval = - EBUSY ;
927
-
928
- /*
929
- * Make sure that we are the sole user of this port.
930
- */
921
+ /* Make sure that we are the sole user of this port. */
931
922
if (tty_port_users (port ) > 1 )
932
- goto exit ;
923
+ return - EBUSY ;
933
924
934
925
/*
935
926
* We need to shutdown the serial port at the old
@@ -967,40 +958,33 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
967
958
*/
968
959
if (uport -> type != PORT_UNKNOWN && uport -> ops -> request_port ) {
969
960
retval = uport -> ops -> request_port (uport );
970
- } else {
971
- /* Always success - Jean II */
972
- retval = 0 ;
973
- }
974
-
975
- /*
976
- * If we fail to request resources for the
977
- * new port, try to restore the old settings.
978
- */
979
- if (retval ) {
980
- uport -> iobase = old_iobase ;
981
- uport -> type = old_type ;
982
- uport -> hub6 = old_hub6 ;
983
- uport -> iotype = old_iotype ;
984
- uport -> regshift = old_shift ;
985
- uport -> mapbase = old_mapbase ;
986
-
987
- if (old_type != PORT_UNKNOWN ) {
988
- retval = uport -> ops -> request_port (uport );
989
- /*
990
- * If we failed to restore the old settings,
991
- * we fail like this.
992
- */
993
- if (retval )
994
- uport -> type = PORT_UNKNOWN ;
995
-
996
- /*
997
- * We failed anyway.
998
- */
999
- retval = - EBUSY ;
961
+ /*
962
+ * If we fail to request resources for the
963
+ * new port, try to restore the old settings.
964
+ */
965
+ if (retval ) {
966
+ uport -> iobase = old_iobase ;
967
+ uport -> type = old_type ;
968
+ uport -> hub6 = old_hub6 ;
969
+ uport -> iotype = old_iotype ;
970
+ uport -> regshift = old_shift ;
971
+ uport -> mapbase = old_mapbase ;
972
+
973
+ if (old_type != PORT_UNKNOWN ) {
974
+ retval = uport -> ops -> request_port (uport );
975
+ /*
976
+ * If we failed to restore the old
977
+ * settings, we fail like this.
978
+ */
979
+ if (retval )
980
+ uport -> type = PORT_UNKNOWN ;
981
+
982
+ /* We failed anyway. */
983
+ return - EBUSY ;
984
+ }
985
+
986
+ return retval ;
1000
987
}
1001
-
1002
- /* Added to return the correct error -Ram Gupta */
1003
- goto exit ;
1004
988
}
1005
989
}
1006
990
@@ -1017,9 +1001,9 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
1017
1001
uport -> fifosize = new_info -> xmit_fifo_size ;
1018
1002
1019
1003
check_and_exit :
1020
- retval = 0 ;
1021
1004
if (uport -> type == PORT_UNKNOWN )
1022
- goto exit ;
1005
+ return 0 ;
1006
+
1023
1007
if (tty_port_initialized (port )) {
1024
1008
if (((old_flags ^ uport -> flags ) & UPF_SPD_MASK ) ||
1025
1009
old_custom_divisor != uport -> custom_divisor ) {
@@ -1035,15 +1019,17 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
1035
1019
}
1036
1020
uart_change_line_settings (tty , state , NULL );
1037
1021
}
1038
- } else {
1039
- retval = uart_startup (tty , state , true);
1040
- if (retval == 0 )
1041
- tty_port_set_initialized (port , true);
1042
- if (retval > 0 )
1043
- retval = 0 ;
1022
+
1023
+ return 0 ;
1044
1024
}
1045
- exit :
1046
- return retval ;
1025
+
1026
+ retval = uart_startup (tty , state , true);
1027
+ if (retval < 0 )
1028
+ return retval ;
1029
+ if (retval == 0 )
1030
+ tty_port_set_initialized (port , true);
1031
+
1032
+ return 0 ;
1047
1033
}
1048
1034
1049
1035
static int uart_set_info_user (struct tty_struct * tty , struct serial_struct * ss )
0 commit comments