From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 1/3] dm: blk: add UCLASS_PARTITION
Date: Wed, 30 Jan 2019 14:28:06 +0900 [thread overview]
Message-ID: <20190130052804.GX20286@linaro.org> (raw)
In-Reply-To: <ce9c723f-f642-ad89-6876-46b5f0e5c437@gmx.de>
On Tue, Jan 29, 2019 at 11:20:01PM +0100, Heinrich Schuchardt wrote:
> On 1/29/19 3:59 AM, AKASHI Takahiro wrote:
> > UCLASS_PARTITION device will be created as a child node of
> > UCLASS_BLK device.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> > drivers/block/blk-uclass.c | 52 ++++++++++++++++++++++++++++++++++++++
> > include/dm/uclass-id.h | 1 +
> > 2 files changed, 53 insertions(+)
> >
> > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> > index baaf431e5e0c..d4ca30f23fc1 100644
> > --- a/drivers/block/blk-uclass.c
> > +++ b/drivers/block/blk-uclass.c
> > @@ -10,6 +10,8 @@
> > #include <dm/device-internal.h>
> > #include <dm/lists.h>
> > #include <dm/uclass-internal.h>
> > +#include <part.h>
> > +#include <string.h>
> >
> > static const char *if_typename_str[IF_TYPE_COUNT] = {
> > [IF_TYPE_IDE] = "ide",
> > @@ -654,3 +656,53 @@ UCLASS_DRIVER(blk) = {
> > .post_probe = blk_post_probe,
> > .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc),
> > };
> > +
> > +U_BOOT_DRIVER(blk_partition) = {
> > + .name = "blk_partition",
> > + .id = UCLASS_PARTITION,
> > + .platdata_auto_alloc_size = sizeof(struct disk_part),
> > +};
> > +
> > +UCLASS_DRIVER(partition) = {
> > + .id = UCLASS_PARTITION,
> > + .name = "partition",
> > +};
> > +
> > +#if defined(CONFIG_PARTITIONS) && defined(CONFIG_HAVE_BLOCK_DEVICE)
> > +int blk_create_partitions(struct udevice *parent)
> > +{
> > + int part;
> > + struct blk_desc *desc = dev_get_uclass_platdata(parent);
> > + disk_partition_t info;
> > + struct disk_part *part_data;
> > + char devname[32];
> > + struct udevice *dev;
> > + int disks = 0, ret;
> > +
> > + /* Add devices for each partition */
> > + for (part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
> > + if (part_get_info(desc, part, &info))
> > + continue;
> > + snprintf(devname, sizeof(devname), "%s:%d", parent->name,
> > + part);
> > +
> > + ret = device_bind_driver(parent, "blk_partition",
> > + strdup(devname), &dev);
> > + if (ret)
>
> This looks like a memory leak for the output of strdup().
Yes, I'm aware of that, but please note that this is a prototype
and so I haven't paid much attention to failure cases (error recovery).
First of all, even in the current implementation, we don't support
*unplugging* (or unbind in EFI jargon?) devices.
It's a more fundamental issue.
> > + return ret;
>
> Why would we leave here if one partition fails?
> Does this imply that all further partitions will fail?
> Should we use continue here?
Ditto. Please be patient for the time being :)
-Takahiro Akashi
> Best regards
>
> Heinrich
>
> > +
> > + part_data = dev_get_uclass_platdata(dev);
> > + part_data->partnum = part;
> > + part_data->gpt_part_info = info;
> > +
> > + disks++;
> > + }
> > +
> > + return disks;
> > +}
> > +#else
> > +int blk_create_partitions(struct udevice *dev)
> > +{
> > + return 0;
> > +}
> > +#endif
> > diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> > index f3bafb3c6353..e02b5f8fda42 100644
> > --- a/include/dm/uclass-id.h
> > +++ b/include/dm/uclass-id.h
> > @@ -65,6 +65,7 @@ enum uclass_id {
> > UCLASS_NVME, /* NVM Express device */
> > UCLASS_PANEL, /* Display panel, such as an LCD */
> > UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */
> > + UCLASS_PARTITION, /* Logical disk partition device */
> > UCLASS_PCH, /* x86 platform controller hub */
> > UCLASS_PCI, /* PCI bus */
> > UCLASS_PCI_GENERIC, /* Generic PCI bus device */
> >
>
next prev parent reply other threads:[~2019-01-30 5:28 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 2:59 [U-Boot] [RFC 0/3] dm, efi: integrate efi_disk into DM AKASHI Takahiro
2019-01-29 2:59 ` [U-Boot] [RFC 1/3] dm: blk: add UCLASS_PARTITION AKASHI Takahiro
2019-01-29 3:17 ` Sergey Kubushyn
2019-01-29 15:37 ` Alexander Graf
2019-01-29 17:46 ` Sergey Kubushyn
2019-01-29 18:02 ` Philipp Tomsich
2019-01-29 22:20 ` Heinrich Schuchardt
2019-01-30 5:28 ` AKASHI Takahiro [this message]
2019-01-31 1:00 ` Simon Glass
2019-01-29 2:59 ` [U-Boot] [RFC 2/3] efi_loader: associate BLK/PARTITION device to efi_disk AKASHI Takahiro
2019-01-29 22:33 ` Heinrich Schuchardt
2019-01-30 5:48 ` AKASHI Takahiro
2019-01-30 6:49 ` Heinrich Schuchardt
2019-01-30 7:26 ` AKASHI Takahiro
2019-01-31 1:22 ` Simon Glass
2019-02-01 5:54 ` AKASHI Takahiro
2019-02-02 14:15 ` Simon Glass
2019-02-06 3:15 ` AKASHI Takahiro
2019-02-06 7:54 ` AKASHI Takahiro
2019-01-29 2:59 ` [U-Boot] [RFC 3/3] drivers: align block device drivers with DM-efi integration AKASHI Takahiro
2019-01-29 16:19 ` Alexander Graf
2019-01-30 0:40 ` AKASHI Takahiro
2019-01-29 16:20 ` [U-Boot] [RFC 0/3] dm, efi: integrate efi_disk into DM Alexander Graf
2019-01-29 22:48 ` Heinrich Schuchardt
2019-01-30 5:18 ` AKASHI Takahiro
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=20190130052804.GX20286@linaro.org \
--to=takahiro.akashi@linaro.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