linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
To: fangxiaozhi 00110321 <fangxiaozhi@huawei.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	zihan@huawei.com, Lin.Lei@huawei.com, greg@kroah.com,
	neil.yi@huawei.com, wangyuhua@huawei.com, huqiao36@huawei.com,
	balbi@ti.com, mdharm-usb@one-eyed-alien.net
Subject: Re: [PATCH 2/2]linux-usb:optimize to match the Huawei USB storage devices and support new switch command
Date: Sun, 13 Jan 2013 23:05:45 +0100	[thread overview]
Message-ID: <20130113220545.GB4876@breakpoint.cc> (raw)
In-Reply-To: <fe8cd5406b9b.6b9bfe8cd540@huawei.com>

On Fri, Jan 11, 2013 at 05:57:44PM +0800, fangxiaozhi 00110321 wrote:
> diff -uprN linux-3.8-rc3_orig/drivers/usb/storage/initializers.c linux-3.8-rc3/drivers/usb/storage/initializers.c
> --- linux-3.8-rc3_orig/drivers/usb/storage/initializers.c	2013-01-11 17:53:19.757842845 +0800
> +++ linux-3.8-rc3/drivers/usb/storage/initializers.c	2013-01-11 17:55:04.137841849 +0800
> @@ -104,3 +104,71 @@ int usb_stor_huawei_e220_init(struct us_
>  	US_DEBUGP("Huawei mode set result is %d\n", result);
>  	return 0;
>  }
> +
> +/* It will send a scsi switch command called rewind' to huawei dongle.
> + * When the dongle receives this command at the first time,
> + * it will reboot immediately. After rebooted, it will ignore this command.
> + * So it is  unnecessary to read its response. */
This multiline comment is wrong. See Documentation/CodingStyle Chapter 8:
Commenting

> +static int usb_stor_huawei_scsi_init(struct us_data *us)
> +{
> +	int result = 0;
> +	int act_len = 0;
> +	struct bulk_cb_wrap *bcbw = (struct bulk_cb_wrap *) us->iobuf;
> +	char rewind_cmd[] = {0x11, 0x06, 0x20, 0x00, 0x00, 0x01, 0x01, 0x00,
> +			0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
> +	
> +	bcbw->Signature = cpu_to_le32(US_BULK_CB_SIGN);
> +	bcbw->Tag = 0;
> +	bcbw->DataTransferLength = 0;
> +	bcbw->Flags = bcbw->Lun = 0;
> +	bcbw->Length = sizeof(rewind_cmd);
> +	memset(bcbw->CDB, 0, sizeof(bcbw->CDB));
> +	memcpy(bcbw->CDB, rewind_cmd, sizeof(rewind_cmd));

You asked me about this, and just replied.

> +	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcbw,
> +					US_BULK_CB_WRAP_LEN, &act_len);
> +	US_DEBUGP("transfer actual length=%d, result=%d\n", act_len, result);
> +	return result;
> +}
> +
> +/* It tries to find the supported Huawei USB dongles.
> + * In Huawei, they assign the following product IDs
> + * for all of their mobile broadband dongles,
> + * including the new dongles in the future.
> + * So if the product ID is not included in this list,
> + * it means it is not Huawei's mobile broadband dongles.*/

multiline comment again.

> +static int usb_stor_huawei_dongles_pid(struct us_data *us)
> +{
> +	struct usb_interface_descriptor *idesc;
> +	int idProduct;
> +	
> +	idesc = &us->pusb_intf->cur_altsetting->desc;
> +	idProduct = us->pusb_dev->descriptor.idProduct;
> +	/* The first port is CDROM,
> +	 * means the dongle in the single port mode,
> +	 * and a switch command is required to be sent. */

Multiline comment + means fits in the first line, doesn't it?

> +	if (idesc && idesc->bInterfaceNumber == 0) {
if you do

	if (!idesc || idesc-> != 0)
		return 0;

then you lose one ident level.

> +		if ((idProduct == 0x1001)
> +			|| (idProduct == 0x1003)
> +			|| (idProduct == 0x1004)
> +			|| (idProduct >= 0x1401 && idProduct <= 0x1500)
> +			|| (idProduct >= 0x1505 && idProduct <= 0x1600)
> +			|| (idProduct >= 0x1c02 && idProduct <= 0x2202)) {
> +			return 1;

what about the switch case here?

> +		}
> +	}
> +	return 0;
> +}
> +
> +int usb_stor_huawei_init(struct us_data *us)
> +{
> +	int result = 0;
> +	
> +	if (usb_stor_huawei_dongles_pid(us)) {
> +		if (us->pusb_dev->descriptor.idProduct >= 0x1446)
> +			result = usb_stor_huawei_scsi_init(us);
> +		else
> +			result = usb_stor_huawei_feature_init(us);
> +	}
> +	return result;
> +}
> Binary files linux-3.8-rc3_orig/drivers/usb/storage/initializers.o and linux-3.8-rc3/drivers/usb/storage/initializers.o differ
^^^

Sebastian

  parent reply	other threads:[~2013-01-13 22:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11  9:57 [PATCH 2/2]linux-usb:optimize to match the Huawei USB storage devices and support new switch command fangxiaozhi 00110321
2013-01-12  0:22 ` Greg KH
2013-01-14  2:29   ` Fangxiaozhi (Franko)
2013-01-13 22:05 ` Sebastian Andrzej Siewior [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-02-04  7:16 fangxiaozhi 00110321
2013-01-25  2:46 fangxiaozhi 00110321
2013-01-27 18:48 ` Sebastian Andrzej Siewior
2012-12-18  2:42 [PATCH 1/2]linux-usb:Define a new macro for USB storage match rules fangxiaozhi 00110321
2012-12-18  2:44 ` [PATCH 2/2]linux-usb:optimize to match the Huawei USB storage devices and support new switch command fangxiaozhi 00110321
2012-12-18 14:10   ` Sebastian Andrzej Siewior
2012-12-19  3:13     ` Fangxiaozhi (Franko)
2012-12-19  8:34       ` Sebastian Andrzej Siewior
2012-12-19 15:40         ` Matthew Dharm
2013-01-04  7:30           ` Fangxiaozhi (Franko)

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=20130113220545.GB4876@breakpoint.cc \
    --to=sebastian@breakpoint.cc \
    --cc=Lin.Lei@huawei.com \
    --cc=balbi@ti.com \
    --cc=fangxiaozhi@huawei.com \
    --cc=greg@kroah.com \
    --cc=huqiao36@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mdharm-usb@one-eyed-alien.net \
    --cc=neil.yi@huawei.com \
    --cc=wangyuhua@huawei.com \
    --cc=zihan@huawei.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;
as well as URLs for NNTP newsgroup(s).