@@ -228,7 +228,7 @@ struct usbh_serial *usbh_serial_open(const char *devname, uint32_t open_flags)
228228 return NULL ;
229229 }
230230
231- if (serial && serial -> driver && serial -> driver -> open ) {
231+ if (serial -> driver && serial -> driver -> open ) {
232232 ret = serial -> driver -> open (serial );
233233 if (ret < 0 ) {
234234 return NULL ;
@@ -335,6 +335,8 @@ int usbh_serial_control(struct usbh_serial *serial, int cmd, void *arg)
335335 struct usbh_serial_termios * termios = (struct usbh_serial_termios * )arg ;
336336 struct cdc_line_coding line_coding ;
337337
338+ USB_ASSERT (termios != NULL );
339+
338340 line_coding .dwDTERate = termios -> baudrate ;
339341 line_coding .bCharFormat = termios -> stopbits ;
340342 line_coding .bParityType = termios -> parity ;
@@ -347,7 +349,7 @@ int usbh_serial_control(struct usbh_serial *serial, int cmd, void *arg)
347349 usbh_kill_urb (& serial -> bulkout_urb );
348350 }
349351
350- if (serial && serial -> driver && serial -> driver -> set_line_coding ) {
352+ if (serial -> driver && serial -> driver -> set_line_coding ) {
351353 ret = serial -> driver -> set_line_coding (serial , & line_coding );
352354 if (ret < 0 ) {
353355 return ret ;
@@ -358,7 +360,7 @@ int usbh_serial_control(struct usbh_serial *serial, int cmd, void *arg)
358360
359361 memcpy (& serial -> line_coding , & line_coding , sizeof (struct cdc_line_coding ));
360362
361- if (serial && serial -> driver && serial -> driver -> set_flow_control ) {
363+ if (serial -> driver && serial -> driver -> set_flow_control ) {
362364 ret = serial -> driver -> set_flow_control (serial , termios -> rtscts );
363365 }
364366
@@ -383,8 +385,10 @@ int usbh_serial_control(struct usbh_serial *serial, int cmd, void *arg)
383385 struct usbh_serial_termios * termios = (struct usbh_serial_termios * )arg ;
384386 struct cdc_line_coding line_coding ;
385387
386- if (serial && serial -> driver && serial -> driver -> get_line_coding ) {
387- return serial -> driver -> get_line_coding (serial , & line_coding );
388+ USB_ASSERT (termios != NULL );
389+
390+ if (serial -> driver && serial -> driver -> get_line_coding ) {
391+ serial -> driver -> get_line_coding (serial , & line_coding );
388392 } else {
389393 memcpy (& line_coding , & serial -> line_coding , sizeof (struct cdc_line_coding ));
390394 }
@@ -424,7 +428,7 @@ int usbh_serial_control(struct usbh_serial *serial, int cmd, void *arg)
424428 uint32_t * flags = (uint32_t * )arg ;
425429 int status ;
426430
427- if (serial && serial -> driver && serial -> driver -> get_modem_status ) {
431+ if (serial -> driver && serial -> driver -> get_modem_status ) {
428432 status = serial -> driver -> get_modem_status (serial );
429433 if (status < 0 ) {
430434 return status ;
0 commit comments