Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1272967
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port |
| Date | 2015-11-19 10:50 +0100 |
| Message-ID | <qwu0N-7xT-3@gated-at.bofh.it> (permalink) |
| References | <qvm5j-4b0-3@gated-at.bofh.it> <qwcZX-4Lu-3@gated-at.bofh.it> <qwrcB-5Lq-11@gated-at.bofh.it> <qwtR9-7uw-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 19 November 2015 at 17:36, Peter Hurley <peter@hurleysoftware.com> wrote:
> On 11/19/2015 01:48 AM, Baolin Wang wrote:
>>>
>>>> +{
>>>> + struct gscons_info *info = gserial_cons.data;
>>>> + int port_num = gserial_cons.index;
>>>> + struct usb_request *req;
>>>> + struct gs_port *port;
>>>> + struct usb_ep *ep;
>>>> +
>>>> + if (port_num >= MAX_U_SERIAL_PORTS || port_num < 0) {
>>>> + pr_err("%s: port num [%d] exceeds the range.\n",
>>>> + __func__, port_num);
>>>> + return -ENXIO;
>>>> + }
>>>> +
>>>> + port = ports[port_num].port;
>>>> + if (!port) {
>>>> + pr_err("%s: serial line [%d] not allocated.\n",
>>>> + __func__, port_num);
>>>> + return -ENODEV;
>>>> + }
>>>> +
>>>> + if (!port->port_usb) {
>>>> + pr_err("%s: no port usb.\n", __func__);
>>>> + return -ENODEV;
>>>> + }
>>>> +
>>>> + ep = port->port_usb->in;
>>>> + if (!ep) {
>>>> + pr_err("%s: no usb endpoint.\n", __func__);
>>>> + return -ENXIO;
>>>> + }
>>>
>>> Looking at the caller, gserial_connect(), none of the error
>>> conditions above look possible.
>>>
>>
>> I re-look the code and do some tests, I found the checking is
>> necessary. Cause we get the port number from the console->index, if
>> the cmdline is not set the ttyGS0 as the console, the console->index
>> will be -1 that is a wrong value. Also the serial.c file will create 1
>> usb-to-seial port as default (default n_ports = 1), so we need to
>> check the port and the endpoint of the port. So I think here checking
>> is necessary and I have tested it.
>
> static void gs_console_connect(int port_num)
> {
> .
> .
> if (port_num != gserial_cons.index)
> return;
> .
OK. Thanks.
> .
>
>
> @@ -1219,6 +1453,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
> gser->disconnect(gser);
> }
>
> + status = gs_console_connect(port_num);
> spin_unlock_irqrestore(&port->port_lock, flags);
>
> return status;
>
>
>
>
>
>
>
--
Baolin.wang
Best Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port Peter Hurley <peter@hurleysoftware.com> - 2015-11-18 16:40 +0100
Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port Baolin Wang <baolin.wang@linaro.org> - 2015-11-19 03:40 +0100
Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port Peter Hurley <peter@hurleysoftware.com> - 2015-11-19 11:30 +0100
Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port Baolin Wang <baolin.wang@linaro.org> - 2015-11-19 12:20 +0100
Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port Baolin Wang <baolin.wang@linaro.org> - 2015-11-19 07:50 +0100
Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port Peter Hurley <peter@hurleysoftware.com> - 2015-11-19 10:40 +0100
Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port Baolin Wang <baolin.wang@linaro.org> - 2015-11-19 10:50 +0100
csiph-web