public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Felipe Balbi <balbi@ti.com>, Greg KH <gregkh@linuxfoundation.org>,
	r.baldyga@samsung.com, fabio.estevam@freescale.com,
	Philip Oberstaller <Philip.Oberstaller@septentrio.com>,
	scottwood@freescale.com, Mark Brown <broonie@kernel.org>,
	USB <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget: Add the console support for usb-to-serial port
Date: Thu, 19 Nov 2015 04:36:40 -0500	[thread overview]
Message-ID: <564D9828.5060107@hurleysoftware.com> (raw)
In-Reply-To: <CAMz4kuKAn=nEtCkjc6VBVkVbCf7CWYmgzBNHHcg59f=A3y93gg@mail.gmail.com>

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;
	.
	.


@@ -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;








  reply	other threads:[~2015-11-19  9:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16  7:05 [PATCH] usb: gadget: Add the console support for usb-to-serial port Baolin Wang
2015-11-17 13:34 ` Andy Shevchenko
2015-11-18  2:15   ` Baolin Wang
2015-11-18  9:32     ` Andy Shevchenko
2015-11-18 10:44       ` Baolin Wang
2015-11-18 12:05         ` David Laight
2015-11-18 12:45           ` Baolin Wang
2015-11-18 15:32 ` Peter Hurley
2015-11-19  2:35   ` Baolin Wang
2015-11-19 10:28     ` Peter Hurley
2015-11-19 11:14       ` Baolin Wang
2015-11-19  6:48   ` Baolin Wang
2015-11-19  9:36     ` Peter Hurley [this message]
2015-11-19  9:44       ` Baolin Wang
  -- strict thread matches above, loose matches on Subject: below --
2015-10-23  5:29 Baolin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=564D9828.5060107@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=Philip.Oberstaller@septentrio.com \
    --cc=balbi@ti.com \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=fabio.estevam@freescale.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=r.baldyga@samsung.com \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox