From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 15/44] dm: blk: Add a legacy block interface
Date: Tue, 12 Apr 2016 14:28:36 -0600 [thread overview]
Message-ID: <570D5A74.4060505@wwwdotorg.org> (raw)
In-Reply-To: <1460256336-30436-16-git-send-email-sjg@chromium.org>
On 04/09/2016 08:45 PM, Simon Glass wrote:
> There is quite a bit of duplicated common code related to block devices
> in the IDE and SCSI implementations.
>
> Create some helper functions that can be used to reduce the duplication.
> These rely on a linker list of interface-type drivers
It'd be useful to know if this gets thrown away later in the series if
everything is converted to DM. That would affect how thoroughly one
reviews it.
At this point I'm slightly lost where the series is going, since it all
seems to be adding a slew of stuff for legacy paths more than converting
to DM block devices. Perhaps it'll become more clear as I go along.
> diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
> +#ifdef HAVE_BLOCK_DEVICE
> +int blk_list_part(enum if_type if_type)
> +{
> + struct blk_driver *drv = blk_driver_lookup_type(if_type);
> + struct blk_desc *desc;
> + int devnum, ok;
> +
> + if (!drv)
> + return -ENOSYS;
Nit: If drv can be NULL, I'd prefer to see the assignment right before
the line that tests it rather than in the declaration. That makes it
clearer to someone that they can't insert a line into the variable
declarations that uses drv. That's something I've seen happen, and it's
hard to spot the issue in a patch if the context isn't long enough to
see this not-yet-happened test later in the code.
> + for (ok = 0, devnum = 0; devnum < drv->max_devs; ++devnum) {
> + if (get_desc(drv, devnum, &desc))
> + continue;
> + if (desc->part_type != PART_TYPE_UNKNOWN) {
> + ++ok;
> + if (devnum)
> + putc('\n');
> + part_print(desc);
Does this function support dumping the partition list for multiple
devices in one invocation? If so, that seems odd; is there any command
to do that? If not, I would expect a break here, and I'm not sure what
if (devnum) putc() is about. Also, shouldn't the putc happen if a
previous iteration of the for loop did print something, not based on the
index in the list, since presumably it's possible that entries 0..2 are
PART_TYPE_UNKNOWN and entry 3 isn't?
> +int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
What does "dselect" mean as opposed to "select"?
> +struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
Doesn't this get a desc not a devnum? It seems to be /by/ typename+devnum.
> diff --git a/include/blk.h b/include/blk.h
> +struct blk_driver {
> + /**
> + * select_hwpart() - Select a hardware partition
> + *
> + * Some devices (e.g. MMC) can support partitioning at the hardware
> + * level. This is quite separate from the normal idea of
> + * software-based partitions. MMC hardware partitions must be
> + * explicitly selected. Once selected only the region of the device
> + * covered by that partition is accessible.
> + *
> + * The MMC standard provides for two boot partitions (numbered 1 and 2),
> + * rpmb (3), and up to 4 addition general-purpose partitions (4-7).
There's also partition 0, the main user data partition, which is what is
primarily used.
> + *
> + * @desc: Block device descriptor
> + * @hwpart: Hardware partition number to select. 0 means the raw
> + * device, 1 is the first partition, 2 is the second, etc.
0 isn't really "raw". At least to me, "raw" implies access to all data
on the storage medium including partition tables, inter-partition gaps,
and data across all partitions. However, for eMMC "0" means just another
partition like any other partition, but this one just happens to be the
one that's used most/typically.
next prev parent reply other threads:[~2016-04-12 20:28 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-10 2:44 [U-Boot] [PATCH 00/44] dm: blk: Add more driver-model support for block devices Simon Glass
2016-04-10 2:44 ` [U-Boot] [PATCH 01/44] Revert "dm: sandbox: Drop the pre-DM host implementation" Simon Glass
2016-04-10 2:44 ` [U-Boot] [PATCH 02/44] dm: sandbox: Add a board for sandbox without CONFIG_BLK Simon Glass
2016-04-10 2:44 ` [U-Boot] [PATCH 03/44] pci: Drop CONFIG_SYS_SCSI_SCAN_BUS_REVERSE Simon Glass
2016-04-11 5:02 ` Bin Meng
2016-04-10 2:44 ` [U-Boot] [PATCH 04/44] dm: Rename disk uclass to ahci Simon Glass
2016-04-10 2:44 ` [U-Boot] [PATCH 05/44] Allow iotrace byte access to use an address of any size Simon Glass
2016-04-12 20:00 ` Stephen Warren
2016-04-10 2:44 ` [U-Boot] [PATCH 06/44] sandbox: Add string and 16-bit I/O functions Simon Glass
2016-04-12 20:02 ` Stephen Warren
2016-04-10 2:44 ` [U-Boot] [PATCH 07/44] sandbox: Add dummy SCSI functions Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 08/44] sandbox: Add dummy SATA functions Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 09/44] dm: scsi: Remove the forward declarations Simon Glass
2016-04-12 20:04 ` Stephen Warren
2016-04-10 2:45 ` [U-Boot] [PATCH 10/44] dm: scsi: Fix up code style Simon Glass
2016-04-12 20:05 ` Stephen Warren
2016-04-10 2:45 ` [U-Boot] [PATCH 11/44] dm: ide: Correct various code style problems Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 12/44] dm: ide: Remove the forward declarations Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 13/44] dm: sata: Fix code style problems in cmd/sata.c Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 14/44] dm: scsi: Rename CONFIG_CMD_SCSI to CONFIG_SCSI Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 15/44] dm: blk: Add a legacy block interface Simon Glass
2016-04-12 20:28 ` Stephen Warren [this message]
2016-05-01 18:56 ` Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 16/44] dm: systemace: " Simon Glass
2016-04-12 20:31 ` Stephen Warren
2016-05-01 18:56 ` Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 17/44] dm: sandbox: Add a legacy host " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 18/44] dm: usb: Add a legacy block interface for USB storage Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 19/44] dm: mmc: Add a legacy block interface for MMC Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 20/44] dm: mmc: Add an implementation of the 'devnum' functions Simon Glass
2016-04-12 20:40 ` Stephen Warren
2016-05-01 18:56 ` Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 21/44] dm: scsi: Separate the non-command code into its own file Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 22/44] dm: ide: " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 23/44] dm: sata: " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 24/44] dm: disk: Use legacy block driver info for block device access Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 25/44] dm: usb: Drop the get_dev() function Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 26/44] dm: ide: " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 27/44] dm: mmc: " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 28/44] dm: scsi: " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 29/44] dm: sata: " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 30/44] dm: systemace: " Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 31/44] dm: blk: Drop the systemace.h header Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 32/44] dm: sandbox: Drop the host_get_dev() function Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 33/44] dm: part: Drop the get_dev() method Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 34/44] dm: ide: Add support for driver-model block devices Simon Glass
2016-04-12 20:49 ` Stephen Warren
2016-05-01 18:56 ` Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 35/44] dm: sandbox: Enable IDE Simon Glass
2016-04-12 20:50 ` Stephen Warren
2016-05-01 18:56 ` Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 36/44] dm: scsi: Add support for driver-model block devices Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 37/44] dm: sandbox: Enable SCSI Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 38/44] dm: sata: Add support for driver-model block devices Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 39/44] dm: sandbox: Enable SATA Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 40/44] dm: blk: Allow blk_create_device() to allocate the device number Simon Glass
2016-04-12 20:56 ` Stephen Warren
2016-05-01 18:56 ` Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 41/44] dm: blk: Add a easier way to create a named block device Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 42/44] dm: systemace: Reorder function to avoid forward declarataions Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 43/44] dm: systemace: Add driver-mode block-device support Simon Glass
2016-04-10 2:45 ` [U-Boot] [PATCH 44/44] dm: sandbox: Enable systemace Simon Glass
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=570D5A74.4060505@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=u-boot@lists.denx.de \
/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