diff mbox series

[U-Boot,v3,11/31] blk: Call part_init() in the post_probe() method

Message ID 1539595287-31378-12-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Simon Glass
Headers show
Series virtio: Introduce VirtIO driver support | expand

Commit Message

Bin Meng Oct. 15, 2018, 9:21 a.m. UTC
part_init() is currently called in every DM BLK driver, either
in its bind() or probe() method. However we can use the BLK
uclass driver's post_probe() method to do it automatically.

Update all DM BLK drivers to adopt this change.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 cmd/sata.c                        |  9 ---------
 common/usb_storage.c              |  4 +---
 drivers/block/blk-uclass.c        | 12 ++++++++++++
 drivers/block/ide.c               |  2 --
 drivers/block/sandbox.c           |  2 +-
 drivers/mmc/mmc.c                 |  3 ---
 drivers/nvme/nvme.c               |  1 -
 drivers/scsi/scsi.c               |  1 -
 lib/efi_driver/efi_block_device.c |  2 --
 9 files changed, 14 insertions(+), 22 deletions(-)

Comments

Simon Glass Oct. 24, 2018, 5:31 p.m. UTC | #1
part_init() is currently called in every DM BLK driver, either
in its bind() or probe() method. However we can use the BLK
uclass driver's post_probe() method to do it automatically.

Update all DM BLK drivers to adopt this change.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 cmd/sata.c                        |  9 ---------
 common/usb_storage.c              |  4 +---
 drivers/block/blk-uclass.c        | 12 ++++++++++++
 drivers/block/ide.c               |  2 --
 drivers/block/sandbox.c           |  2 +-
 drivers/mmc/mmc.c                 |  3 ---
 drivers/nvme/nvme.c               |  1 -
 drivers/scsi/scsi.c               |  1 -
 lib/efi_driver/efi_block_device.c |  2 --
 9 files changed, 14 insertions(+), 22 deletions(-)

Applied to u-boot-dm/next, thanks!
Hannes Schmelzer Dec. 13, 2018, 7:19 a.m. UTC | #2
On 10/15/18 11:21 AM, Bin Meng wrote:
> part_init() is currently called in every DM BLK driver, either
> in its bind() or probe() method. However we can use the BLK
> uclass driver's post_probe() method to do it automatically.
>
> Update all DM BLK drivers to adopt this change.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>   cmd/sata.c                        |  9 ---------
>   common/usb_storage.c              |  4 +---
>   drivers/block/blk-uclass.c        | 12 ++++++++++++
>   drivers/block/ide.c               |  2 --
>   drivers/block/sandbox.c           |  2 +-
>   drivers/mmc/mmc.c                 |  3 ---
>   drivers/nvme/nvme.c               |  1 -
>   drivers/scsi/scsi.c               |  1 -
>   lib/efi_driver/efi_block_device.c |  2 --
>   9 files changed, 14 insertions(+), 22 deletions(-)
Hi Bin,

sorry for this very late report on this.
I Just merged the 'v2019.01-rc1' tag into my branch and noticed that 
filesystem on my eMMC targets are not working anymore.
Bisect showed up, that this commit breaks the stuff.

I reviewed the change a bit and i would say that all other block devices 
should work as known, except MMC, NVME and EFI (i do not have one, so i 
cannot test).
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 585951c..d6b9cdc 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -2444,9 +2444,6 @@ static int mmc_startup(struct mmc *mmc)
>   	bdesc->product[0] = 0;
>   	bdesc->revision[0] = 0;
>   #endif
> -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
> -	part_init(bdesc);
> -#endif
>   
>   	return 0;
>   }
i changed this to:

#if (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)) && \
      !defined(CONFIG_BLK)
     part_init(bdesc);
#endif


> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> index eb6fded..1ee0a0a 100644
> --- a/drivers/nvme/nvme.c
> +++ b/drivers/nvme/nvme.c
> @@ -664,7 +664,6 @@ static int nvme_blk_probe(struct udevice *udev)
>   	sprintf(desc->vendor, "0x%.4x", pplat->vendor);
>   	memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
>   	memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
> -	part_init(desc);
>   
>   	return 0;
>   }
>
> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
> index 7b71b4d..3f147cf 100644
> --- a/lib/efi_driver/efi_block_device.c
> +++ b/lib/efi_driver/efi_block_device.c
> @@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
>   		return ret;
>   	EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
>   
> -	ret = blk_prepare_device(bdev);
> -
>   	/* Create handles for the partions of the block device */
>   	disks = efi_bl_bind_partitions(handle, bdev);
>   	EFI_PRINT("Found %d partitions\n", disks);
here i cannot see some alternative if CONFIG_BLK is enabled.

I know, everything shall be converted to DM since the deadline is quite 
close.
But i also think that upon this day everything should work as expected.

cheers,
Hannes
Bin Meng Dec. 13, 2018, 7:26 a.m. UTC | #3
Hi Hannes,

On Thu, Dec 13, 2018 at 3:19 PM Hannes Schmelzer <hannes@schmelzer.or.at> wrote:
>
>
>
> On 10/15/18 11:21 AM, Bin Meng wrote:
> > part_init() is currently called in every DM BLK driver, either
> > in its bind() or probe() method. However we can use the BLK
> > uclass driver's post_probe() method to do it automatically.
> >
> > Update all DM BLK drivers to adopt this change.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > Changes in v3: None
> > Changes in v2: None
> >
> >   cmd/sata.c                        |  9 ---------
> >   common/usb_storage.c              |  4 +---
> >   drivers/block/blk-uclass.c        | 12 ++++++++++++
> >   drivers/block/ide.c               |  2 --
> >   drivers/block/sandbox.c           |  2 +-
> >   drivers/mmc/mmc.c                 |  3 ---
> >   drivers/nvme/nvme.c               |  1 -
> >   drivers/scsi/scsi.c               |  1 -
> >   lib/efi_driver/efi_block_device.c |  2 --
> >   9 files changed, 14 insertions(+), 22 deletions(-)
> Hi Bin,
>
> sorry for this very late report on this.
> I Just merged the 'v2019.01-rc1' tag into my branch and noticed that
> filesystem on my eMMC targets are not working anymore.
> Bisect showed up, that this commit breaks the stuff.
>
> I reviewed the change a bit and i would say that all other block devices
> should work as known, except MMC, NVME and EFI (i do not have one, so i
> cannot test).
> > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> > index 585951c..d6b9cdc 100644
> > --- a/drivers/mmc/mmc.c
> > +++ b/drivers/mmc/mmc.c
> > @@ -2444,9 +2444,6 @@ static int mmc_startup(struct mmc *mmc)
> >       bdesc->product[0] = 0;
> >       bdesc->revision[0] = 0;
> >   #endif
> > -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
> > -     part_init(bdesc);
> > -#endif
> >
> >       return 0;
> >   }
> i changed this to:
>
> #if (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)) && \
>       !defined(CONFIG_BLK)
>      part_init(bdesc);
> #endif

I don't understand. The patch above removed 3 lines. Did you say that
you added back these 3 lines with additional "!defined(CONFIG_BLK)"?

>
>
> > diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> > index eb6fded..1ee0a0a 100644
> > --- a/drivers/nvme/nvme.c
> > +++ b/drivers/nvme/nvme.c
> > @@ -664,7 +664,6 @@ static int nvme_blk_probe(struct udevice *udev)
> >       sprintf(desc->vendor, "0x%.4x", pplat->vendor);
> >       memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
> >       memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
> > -     part_init(desc);
> >
> >       return 0;
> >   }
> >
> > diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
> > index 7b71b4d..3f147cf 100644
> > --- a/lib/efi_driver/efi_block_device.c
> > +++ b/lib/efi_driver/efi_block_device.c
> > @@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
> >               return ret;
> >       EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
> >
> > -     ret = blk_prepare_device(bdev);
> > -
> >       /* Create handles for the partions of the block device */
> >       disks = efi_bl_bind_partitions(handle, bdev);
> >       EFI_PRINT("Found %d partitions\n", disks);
> here i cannot see some alternative if CONFIG_BLK is enabled.
>

I don't understand your comments here too...

> I know, everything shall be converted to DM since the deadline is quite
> close.
> But i also think that upon this day everything should work as expected.
>

Regards,
Bin
Hannes Schmelzer Dec. 13, 2018, 7:32 a.m. UTC | #4
On 12/13/18 8:26 AM, Bin Meng wrote:
> Hi Hannes,
Hi Bin,
> On Thu, Dec 13, 2018 at 3:19 PM Hannes Schmelzer <hannes@schmelzer.or.at> wrote:
>>
>>
>> On 10/15/18 11:21 AM, Bin Meng wrote:
>>> part_init() is currently called in every DM BLK driver, either
>>> in its bind() or probe() method. However we can use the BLK
>>> uclass driver's post_probe() method to do it automatically.
>>>
>>> Update all DM BLK drivers to adopt this change.
>>>
>>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>> Changes in v3: None
>>> Changes in v2: None
>>>
>>>    cmd/sata.c                        |  9 ---------
>>>    common/usb_storage.c              |  4 +---
>>>    drivers/block/blk-uclass.c        | 12 ++++++++++++
>>>    drivers/block/ide.c               |  2 --
>>>    drivers/block/sandbox.c           |  2 +-
>>>    drivers/mmc/mmc.c                 |  3 ---
>>>    drivers/nvme/nvme.c               |  1 -
>>>    drivers/scsi/scsi.c               |  1 -
>>>    lib/efi_driver/efi_block_device.c |  2 --
>>>    9 files changed, 14 insertions(+), 22 deletions(-)
>> Hi Bin,
>>
>> sorry for this very late report on this.
>> I Just merged the 'v2019.01-rc1' tag into my branch and noticed that
>> filesystem on my eMMC targets are not working anymore.
>> Bisect showed up, that this commit breaks the stuff.
>>
>> I reviewed the change a bit and i would say that all other block devices
>> should work as known, except MMC, NVME and EFI (i do not have one, so i
>> cannot test).
>>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>>> index 585951c..d6b9cdc 100644
>>> --- a/drivers/mmc/mmc.c
>>> +++ b/drivers/mmc/mmc.c
>>> @@ -2444,9 +2444,6 @@ static int mmc_startup(struct mmc *mmc)
>>>        bdesc->product[0] = 0;
>>>        bdesc->revision[0] = 0;
>>>    #endif
>>> -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
>>> -     part_init(bdesc);
>>> -#endif
>>>
>>>        return 0;
>>>    }
>> i changed this to:
>>
>> #if (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)) && \
>>        !defined(CONFIG_BLK)
>>       part_init(bdesc);
>> #endif
> I don't understand. The patch above removed 3 lines. Did you say that
> you added back these 3 lines with additional "!defined(CONFIG_BLK)"?
Yes,
in case if CONFIG_BLK is disabled (meaning blk-uclass.c isn't compiled 
in and does therefore nothing),
the part_init(...) has to be done here.
>
>>> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
>>> index eb6fded..1ee0a0a 100644
>>> --- a/drivers/nvme/nvme.c
>>> +++ b/drivers/nvme/nvme.c
>>> @@ -664,7 +664,6 @@ static int nvme_blk_probe(struct udevice *udev)
>>>        sprintf(desc->vendor, "0x%.4x", pplat->vendor);
>>>        memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
>>>        memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
>>> -     part_init(desc);
>>>
>>>        return 0;
>>>    }
>>>
>>> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
>>> index 7b71b4d..3f147cf 100644
>>> --- a/lib/efi_driver/efi_block_device.c
>>> +++ b/lib/efi_driver/efi_block_device.c
>>> @@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
>>>                return ret;
>>>        EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
>>>
>>> -     ret = blk_prepare_device(bdev);
>>> -
>>>        /* Create handles for the partions of the block device */
>>>        disks = efi_bl_bind_partitions(handle, bdev);
>>>        EFI_PRINT("Found %d partitions\n", disks);
>> here i cannot see some alternative if CONFIG_BLK is enabled.
>>
>> I don't understand your comments here too...
With alternative i mean, that:
If CONFIG_BLK is disabled within the code here some part_init has to be 
done.
Otherwise Partitions and following filesystems cannot work.
>
>> I know, everything shall be converted to DM since the deadline is quite
>> close.
>> But i also think that upon this day everything should work as expected.
>>
> Regards,
> Bin
cheers,
Hannes
Bin Meng Dec. 13, 2018, 7:40 a.m. UTC | #5
Hi Hannes,

On Thu, Dec 13, 2018 at 3:32 PM Hannes Schmelzer <hannes@schmelzer.or.at> wrote:
>
>
>
> On 12/13/18 8:26 AM, Bin Meng wrote:
> > Hi Hannes,
> Hi Bin,
> > On Thu, Dec 13, 2018 at 3:19 PM Hannes Schmelzer <hannes@schmelzer.or.at> wrote:
> >>
> >>
> >> On 10/15/18 11:21 AM, Bin Meng wrote:
> >>> part_init() is currently called in every DM BLK driver, either
> >>> in its bind() or probe() method. However we can use the BLK
> >>> uclass driver's post_probe() method to do it automatically.
> >>>
> >>> Update all DM BLK drivers to adopt this change.
> >>>
> >>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> >>> Reviewed-by: Simon Glass <sjg@chromium.org>
> >>> ---
> >>>
> >>> Changes in v3: None
> >>> Changes in v2: None
> >>>
> >>>    cmd/sata.c                        |  9 ---------
> >>>    common/usb_storage.c              |  4 +---
> >>>    drivers/block/blk-uclass.c        | 12 ++++++++++++
> >>>    drivers/block/ide.c               |  2 --
> >>>    drivers/block/sandbox.c           |  2 +-
> >>>    drivers/mmc/mmc.c                 |  3 ---
> >>>    drivers/nvme/nvme.c               |  1 -
> >>>    drivers/scsi/scsi.c               |  1 -
> >>>    lib/efi_driver/efi_block_device.c |  2 --
> >>>    9 files changed, 14 insertions(+), 22 deletions(-)
> >> Hi Bin,
> >>
> >> sorry for this very late report on this.
> >> I Just merged the 'v2019.01-rc1' tag into my branch and noticed that
> >> filesystem on my eMMC targets are not working anymore.
> >> Bisect showed up, that this commit breaks the stuff.
> >>
> >> I reviewed the change a bit and i would say that all other block devices
> >> should work as known, except MMC, NVME and EFI (i do not have one, so i
> >> cannot test).
> >>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> >>> index 585951c..d6b9cdc 100644
> >>> --- a/drivers/mmc/mmc.c
> >>> +++ b/drivers/mmc/mmc.c
> >>> @@ -2444,9 +2444,6 @@ static int mmc_startup(struct mmc *mmc)
> >>>        bdesc->product[0] = 0;
> >>>        bdesc->revision[0] = 0;
> >>>    #endif
> >>> -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
> >>> -     part_init(bdesc);
> >>> -#endif
> >>>
> >>>        return 0;
> >>>    }
> >> i changed this to:
> >>
> >> #if (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)) && \
> >>        !defined(CONFIG_BLK)
> >>       part_init(bdesc);
> >> #endif
> > I don't understand. The patch above removed 3 lines. Did you say that
> > you added back these 3 lines with additional "!defined(CONFIG_BLK)"?
> Yes,
> in case if CONFIG_BLK is disabled (meaning blk-uclass.c isn't compiled
> in and does therefore nothing),
> the part_init(...) has to be done here.

OK, now I understand. But you should convert your board to use DM MMC
instead. It's the right timing now.

> >
> >>> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> >>> index eb6fded..1ee0a0a 100644
> >>> --- a/drivers/nvme/nvme.c
> >>> +++ b/drivers/nvme/nvme.c
> >>> @@ -664,7 +664,6 @@ static int nvme_blk_probe(struct udevice *udev)
> >>>        sprintf(desc->vendor, "0x%.4x", pplat->vendor);
> >>>        memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
> >>>        memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
> >>> -     part_init(desc);
> >>>
> >>>        return 0;
> >>>    }
> >>>
> >>> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
> >>> index 7b71b4d..3f147cf 100644
> >>> --- a/lib/efi_driver/efi_block_device.c
> >>> +++ b/lib/efi_driver/efi_block_device.c
> >>> @@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
> >>>                return ret;
> >>>        EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
> >>>
> >>> -     ret = blk_prepare_device(bdev);
> >>> -
> >>>        /* Create handles for the partions of the block device */
> >>>        disks = efi_bl_bind_partitions(handle, bdev);
> >>>        EFI_PRINT("Found %d partitions\n", disks);
> >> here i cannot see some alternative if CONFIG_BLK is enabled.
> >>
> >> I don't understand your comments here too...
> With alternative i mean, that:
> If CONFIG_BLK is disabled within the code here some part_init has to be
> done.

No, this one I still don't understand. The EFI block device is a DM
driver. It cannot work when CONFIG_BLK is disabled.

> Otherwise Partitions and following filesystems cannot work.
> >
> >> I know, everything shall be converted to DM since the deadline is quite
> >> close.
> >> But i also think that upon this day everything should work as expected.
> >>

Regards,
Bin
Hannes Schmelzer Dec. 13, 2018, 7:48 a.m. UTC | #6
On 12/13/18 8:40 AM, Bin Meng wrote:
> Hi Hannes,
Hi Bin,
>>> On Thu, Dec 13, 2018 at 3:19 PM Hannes Schmelzer <hannes@schmelzer.or.at> wrote:
>>>>
>>>> On 10/15/18 11:21 AM, Bin Meng wrote:
>>>>> part_init() is currently called in every DM BLK driver, either
>>>>> in its bind() or probe() method. However we can use the BLK
>>>>> uclass driver's post_probe() method to do it automatically.
>>>>>
>>>>> Update all DM BLK drivers to adopt this change.
>>>>>
>>>>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>> ---
>>>>>
>>>>> Changes in v3: None
>>>>> Changes in v2: None
>>>>>
>>>>>     cmd/sata.c                        |  9 ---------
>>>>>     common/usb_storage.c              |  4 +---
>>>>>     drivers/block/blk-uclass.c        | 12 ++++++++++++
>>>>>     drivers/block/ide.c               |  2 --
>>>>>     drivers/block/sandbox.c           |  2 +-
>>>>>     drivers/mmc/mmc.c                 |  3 ---
>>>>>     drivers/nvme/nvme.c               |  1 -
>>>>>     drivers/scsi/scsi.c               |  1 -
>>>>>     lib/efi_driver/efi_block_device.c |  2 --
>>>>>     9 files changed, 14 insertions(+), 22 deletions(-)
>>>> Hi Bin,
>>>>
>>>> sorry for this very late report on this.
>>>> I Just merged the 'v2019.01-rc1' tag into my branch and noticed that
>>>> filesystem on my eMMC targets are not working anymore.
>>>> Bisect showed up, that this commit breaks the stuff.
>>>>
>>>> I reviewed the change a bit and i would say that all other block devices
>>>> should work as known, except MMC, NVME and EFI (i do not have one, so i
>>>> cannot test).
>>>>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>>>>> index 585951c..d6b9cdc 100644
>>>>> --- a/drivers/mmc/mmc.c
>>>>> +++ b/drivers/mmc/mmc.c
>>>>> @@ -2444,9 +2444,6 @@ static int mmc_startup(struct mmc *mmc)
>>>>>         bdesc->product[0] = 0;
>>>>>         bdesc->revision[0] = 0;
>>>>>     #endif
>>>>> -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
>>>>> -     part_init(bdesc);
>>>>> -#endif
>>>>>
>>>>>         return 0;
>>>>>     }
>>>> i changed this to:
>>>>
>>>> #if (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)) && \
>>>>         !defined(CONFIG_BLK)
>>>>        part_init(bdesc);
>>>> #endif
>>> I don't understand. The patch above removed 3 lines. Did you say that
>>> you added back these 3 lines with additional "!defined(CONFIG_BLK)"?
>> Yes,
>> in case if CONFIG_BLK is disabled (meaning blk-uclass.c isn't compiled
>> in and does therefore nothing),
>> the part_init(...) has to be done here.
> OK, now I understand. But you should convert your board to use DM MMC
> instead. It's the right timing now.
OK, thats already on my plan to do this since the deadline becomes closer.
So we let the "bug" as it is and force people to convert more quickly ;-)

>
>>>>> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
>>>>> index eb6fded..1ee0a0a 100644
>>>>> --- a/drivers/nvme/nvme.c
>>>>> +++ b/drivers/nvme/nvme.c
>>>>> @@ -664,7 +664,6 @@ static int nvme_blk_probe(struct udevice *udev)
>>>>>         sprintf(desc->vendor, "0x%.4x", pplat->vendor);
>>>>>         memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
>>>>>         memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
>>>>> -     part_init(desc);
>>>>>
>>>>>         return 0;
>>>>>     }
>>>>>
>>>>> diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
>>>>> index 7b71b4d..3f147cf 100644
>>>>> --- a/lib/efi_driver/efi_block_device.c
>>>>> +++ b/lib/efi_driver/efi_block_device.c
>>>>> @@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
>>>>>                 return ret;
>>>>>         EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
>>>>>
>>>>> -     ret = blk_prepare_device(bdev);
>>>>> -
>>>>>         /* Create handles for the partions of the block device */
>>>>>         disks = efi_bl_bind_partitions(handle, bdev);
>>>>>         EFI_PRINT("Found %d partitions\n", disks);
>>>> here i cannot see some alternative if CONFIG_BLK is enabled.
>>>>
>>>> I don't understand your comments here too...
>> With alternative i mean, that:
>> If CONFIG_BLK is disabled within the code here some part_init has to be
>> done.
> No, this one I still don't understand. The EFI block device is a DM
> driver. It cannot work when CONFIG_BLK is disabled.
OK. I don't catched that the EFI cannot work without DM,
i just took notice that there is no "non-DM" alternative.
So it is OK as it is.
diff mbox series

Patch

diff --git a/cmd/sata.c b/cmd/sata.c
index 4f0c6e0..6d62ba8 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -51,7 +51,6 @@  int sata_probe(int devnum)
 {
 #ifdef CONFIG_AHCI
 	struct udevice *dev;
-	struct udevice *blk;
 	int rc;
 
 	rc = uclass_get_device(UCLASS_AHCI, devnum, &dev);
@@ -67,14 +66,6 @@  int sata_probe(int devnum)
 		return CMD_RET_FAILURE;
 	}
 
-	rc = blk_get_from_parent(dev, &blk);
-	if (!rc) {
-		struct blk_desc *desc = dev_get_uclass_platdata(blk);
-
-		if (desc->lba > 0 && desc->blksz > 0)
-			part_init(desc);
-	}
-
 	return 0;
 #else
 	return sata_initialize() < 0 ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index d92ebb6..560d605 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -226,9 +226,7 @@  static int usb_stor_probe_device(struct usb_device *udev)
 		blkdev->lun = lun;
 
 		ret = usb_stor_get_info(udev, data, blkdev);
-		if (ret == 1)
-			ret = blk_prepare_device(dev);
-		if (!ret) {
+		if (ret == 1) {
 			usb_max_devs++;
 			debug("%s: Found device %p\n", __func__, udev);
 		} else {
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index facf527..95e7b54 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -644,8 +644,20 @@  int blk_unbind_all(int if_type)
 	return 0;
 }
 
+static int blk_post_probe(struct udevice *dev)
+{
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
+	struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+	part_init(desc);
+#endif
+
+	return 0;
+}
+
 UCLASS_DRIVER(blk) = {
 	.id		= UCLASS_BLK,
 	.name		= "blk",
+	.post_probe	= blk_post_probe,
 	.per_device_platdata_auto_alloc_size = sizeof(struct blk_desc),
 };
diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 38adb6a..4b8a4ea 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -1169,8 +1169,6 @@  static int ide_blk_probe(struct udevice *udev)
 		BLK_REV_SIZE);
 	desc->revision[BLK_REV_SIZE] = '\0';
 
-	part_init(desc);
-
 	return 0;
 }
 
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 576d049..d3b1aaa 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -142,7 +142,7 @@  int host_dev_bind(int devnum, char *filename)
 		goto err_file;
 	}
 
-	return blk_prepare_device(dev);
+	return 0;
 err_file:
 	os_close(fd);
 err:
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 585951c..d6b9cdc 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2444,9 +2444,6 @@  static int mmc_startup(struct mmc *mmc)
 	bdesc->product[0] = 0;
 	bdesc->revision[0] = 0;
 #endif
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
-	part_init(bdesc);
-#endif
 
 	return 0;
 }
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index eb6fded..1ee0a0a 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -664,7 +664,6 @@  static int nvme_blk_probe(struct udevice *udev)
 	sprintf(desc->vendor, "0x%.4x", pplat->vendor);
 	memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
 	memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
-	part_init(desc);
 
 	return 0;
 }
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index bc6ac8c..df47e2f 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -592,7 +592,6 @@  static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
 	memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor));
 	memcpy(&bdesc->product, &bd.product, sizeof(bd.product));
 	memcpy(&bdesc->revision, &bd.revision,	sizeof(bd.revision));
-	part_init(bdesc);
 
 	if (verbose) {
 		printf("  Device %d: ", 0);
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index 7b71b4d..3f147cf 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -173,8 +173,6 @@  static int efi_bl_bind(efi_handle_t handle, void *interface)
 		return ret;
 	EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
 
-	ret = blk_prepare_device(bdev);
-
 	/* Create handles for the partions of the block device */
 	disks = efi_bl_bind_partitions(handle, bdev);
 	EFI_PRINT("Found %d partitions\n", disks);