All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2,3/5] usb: gadget: u_serial: make OBEX port not a console
@ 2019-02-27 10:39 Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-02-27 10:39 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: linux-usb, Felipe Balbi

On Wed, Feb 27, 2019 at 11:14:27AM +0100, Michał Mirosław wrote:
> On Wed, Feb 27, 2019 at 10:36:25AM +0100, Greg Kroah-Hartman wrote:
> > On Wed, Feb 27, 2019 at 10:29:38AM +0100, Michał Mirosław wrote:
> > >  /* management of individual TTY ports */
> > > +int gserial_alloc_line_raw(unsigned char *port_line);
> > >  int gserial_alloc_line(unsigned char *port_line);
> > What is the difference between "raw" and "not raw"?  I can't even answer
> > that question, and I maintain the tty layer, so what hope is there for
> > someone else?  :)
> > 
> > nameing is hard, I know...
> 
> Yes it is. gserial_alloc_line_no_console() then?

That makes a lot more sense to me, thank you.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [v2,3/5] usb: gadget: u_serial: make OBEX port not a console
@ 2019-02-27 10:14 Michał Mirosław
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Mirosław @ 2019-02-27 10:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Felipe Balbi

On Wed, Feb 27, 2019 at 10:36:25AM +0100, Greg Kroah-Hartman wrote:
> On Wed, Feb 27, 2019 at 10:29:38AM +0100, Michał Mirosław wrote:
> >  /* management of individual TTY ports */
> > +int gserial_alloc_line_raw(unsigned char *port_line);
> >  int gserial_alloc_line(unsigned char *port_line);
> What is the difference between "raw" and "not raw"?  I can't even answer
> that question, and I maintain the tty layer, so what hope is there for
> someone else?  :)
> 
> nameing is hard, I know...

Yes it is. gserial_alloc_line_no_console() then?

Best Regards,
Michał Mirosław

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [v2,3/5] usb: gadget: u_serial: make OBEX port not a console
@ 2019-02-27  9:36 Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-02-27  9:36 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: linux-usb, Felipe Balbi

On Wed, Feb 27, 2019 at 10:29:38AM +0100, Michał Mirosław wrote:
>  /* management of individual TTY ports */
> +int gserial_alloc_line_raw(unsigned char *port_line);
>  int gserial_alloc_line(unsigned char *port_line);

What is the difference between "raw" and "not raw"?  I can't even answer
that question, and I maintain the tty layer, so what hope is there for
someone else?  :)

nameing is hard, I know...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [v2,3/5] usb: gadget: u_serial: make OBEX port not a console
@ 2019-02-27  9:29 Michał Mirosław
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Mirosław @ 2019-02-27  9:29 UTC (permalink / raw)
  To: linux-usb; +Cc: Felipe Balbi, Greg Kroah-Hartman

Prevent OBEX serial port from ever becoming a console. Console messages
will definitely break the protocol, and since you have to instantiate
the port making it explicitly for OBEX, there is no point in allowing
console to break it by mistake.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
  v2: change of API
    + commit message massage
---
 drivers/usb/gadget/function/f_obex.c   |  2 +-
 drivers/usb/gadget/function/u_serial.c | 16 ++++++++++++----
 drivers/usb/gadget/function/u_serial.h |  1 +
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c
index 55b7f57d2dc7..3f11f41619f9 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -432,7 +432,7 @@ static struct usb_function_instance *obex_alloc_inst(void)
 		return ERR_PTR(-ENOMEM);
 
 	opts->func_inst.free_func_inst = obex_free_inst;
-	ret = gserial_alloc_line(&opts->port_num);
+	ret = gserial_alloc_line_raw(&opts->port_num);
 	if (ret) {
 		kfree(opts);
 		return ERR_PTR(ret);
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 8d2d861e1543..3466d94f1441 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1179,7 +1179,7 @@ void gserial_free_line(unsigned char port_num)
 }
 EXPORT_SYMBOL_GPL(gserial_free_line);
 
-int gserial_alloc_line(unsigned char *line_num)
+int gserial_alloc_line_raw(unsigned char *line_num)
 {
 	struct usb_cdc_line_coding	coding;
 	struct gs_port			*port;
@@ -1220,12 +1220,20 @@ int gserial_alloc_line(unsigned char *line_num)
 		goto err;
 	}
 	*line_num = port_num;
-
-	if (!port_num)
-		gs_console_init(port);
 err:
 	return ret;
 }
+EXPORT_SYMBOL_GPL(gserial_alloc_line_raw);
+
+int gserial_alloc_line(unsigned char *line_num)
+{
+	int ret = gserial_alloc_line_raw(line_num);
+
+	if (!ret && !*line_num)
+		gs_console_init(ports[*line_num].port);
+
+	return ret;
+}
 EXPORT_SYMBOL_GPL(gserial_alloc_line);
 
 /**
diff --git a/drivers/usb/gadget/function/u_serial.h b/drivers/usb/gadget/function/u_serial.h
index 9acaac1cbb75..a86bd3ce4781 100644
--- a/drivers/usb/gadget/function/u_serial.h
+++ b/drivers/usb/gadget/function/u_serial.h
@@ -54,6 +54,7 @@ struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t flags);
 void gs_free_req(struct usb_ep *, struct usb_request *req);
 
 /* management of individual TTY ports */
+int gserial_alloc_line_raw(unsigned char *port_line);
 int gserial_alloc_line(unsigned char *port_line);
 void gserial_free_line(unsigned char port_line);
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-27 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 10:39 [v2,3/5] usb: gadget: u_serial: make OBEX port not a console Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2019-02-27 10:14 Michał Mirosław
2019-02-27  9:36 Greg Kroah-Hartman
2019-02-27  9:29 Michał Mirosław

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.