All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@mvista.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: James.Bottomley@suse.de, Tejun Heo <tj@kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	akpm@linux-foundation.org, linux-scsi@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH resend 3/4] scsi/sd: Add a no_read_capacity_16 scsi_device flag
Date: Thu, 22 Jul 2010 19:16:08 +0400	[thread overview]
Message-ID: <4C4860B8.70205@ru.mvista.com> (raw)
In-Reply-To: <1279811521-11372-3-git-send-email-hdegoede@redhat.com>

Hello.

Hans de Goede wrote:

> I know I know, I seem to have a nack for digging up buggy usb devices
> which don't work with Linux, and I'm crazy enough to try to make them
> work. So this time a friend of mine asked me to get an mp4 player (an
> mp3 player which can play videos on a small screen) to work with Linux.

> It is based on the well known rockbox chipset for which we already have
> an unusual devs entries to work around some of its bugs. But this model
> comes with an additional twist.

> This model chokes on read_capacity_16 calls. Now normally we don't make
> those calls, but this model comes with an sdcard slot and when there
> is no card in there (and shipped from the factory there is none), it
> reports a size of 0. However this time the programmers actually
> got the read_capacity_10 response right! So they substract one from
> the size as stored internally in the mp3 player before reporting it back,
> resulting in an answer of ... 0xffffffff sectors, causing sd.c to
> try a read_capacity_16, on which the device crashes.

> This patch adds a flag to scsi_device to indicate that a a device cannot
> handle read_capacity_16, and when this flag is set if a device reports
> an lba of 0xffffffff as answer to a read_capacity_10, assumes it tries
> to report a size of 0.

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[...]
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 8802e48..1ad339b 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
[...]
> @@ -1578,6 +1581,15 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
>  	sector_size = get_unaligned_be32(&buffer[4]);
>  	lba = get_unaligned_be32(&buffer[0]);
>  
> +	if (sdp->no_read_capacity_16 && (lba == 0xffffffff)) {

    Parens around == are not necessary.

> +		/* Some buggy (usb cardreader) devices return an lba of
> +		   0xffffffff when the want to report a size of 0 (with
> +		   which they really mean no media is present) */

    According to CodingStyle, the preferred format of the multi-line comments 
is this:

/*
  * bla
  * bla
  */

WBR, Sergei

  reply	other threads:[~2010-07-22 15:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-22 15:11 [PATCH resend 1/4] scsi/sr: add no_read_disc_info scsi_device flag Hans de Goede
2010-07-22 15:11 ` [PATCH resend 2/4] usb-storage: Add new no_read_disc_info quirk Hans de Goede
2010-07-22 15:12 ` [PATCH resend 3/4] scsi/sd: Add a no_read_capacity_16 scsi_device flag Hans de Goede
2010-07-22 15:16   ` Sergei Shtylyov [this message]
     [not found] ` <1279811521-11372-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-07-22 15:12   ` [PATCH resend 4/4] usb-storage: Add new no_read_capacity_16 quirk Hans de Goede
  -- strict thread matches above, loose matches on Subject: below --
2010-07-23  8:52 [PATCH resend 1/4] scsi/sr: add no_read_disc_info scsi_device flag Hans de Goede
2010-07-23  8:52 ` [PATCH resend 3/4] scsi/sd: Add a no_read_capacity_16 " Hans de Goede

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=4C4860B8.70205@ru.mvista.com \
    --to=sshtylyov@mvista.com \
    --cc=James.Bottomley@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    /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 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.