[U-Boot] [RFC 04/11] misc: fs_loader: Allow initializing blkdev using platform data

Chee, Tien Fong tien.fong.chee at intel.com
Tue May 21 05:40:59 UTC 2019


On Thu, 2019-05-16 at 15:54 -0500, Andreas Dannenberg wrote:
> To give us more flexibility using the FS loader eliminate the need of
> always having to use the ENV to configure the block device but rather
> allow the respective block device and partition to be setup through
> platform data.
> 
> Signed-off-by: Andreas Dannenberg <dannenberg at ti.com>

Why not using DT method?

> ---
>  drivers/misc/fs_loader.c | 17 ++++++++++++++++-
>  include/fs_loader.h      |  4 ++++
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
> index f42eeff8f6..69f474da99 100644
> --- a/drivers/misc/fs_loader.c
> +++ b/drivers/misc/fs_loader.c
> @@ -81,6 +81,15 @@ static int select_fs_dev(struct device_platdata
> *plat)
>  				return -ENODEV;
>  			}
>  		}
> +	} else if (plat->blkdev) {
> +		struct blk_desc *desc = blk_get_by_device(plat-
> >blkdev);
> +
> +		if (desc) {
> +			ret = fs_set_blk_dev_with_part(desc, plat-
> >blkpart);
> +		} else {
> +			debug("%s: No device found\n", __func__);
> +			return -ENODEV;
> +		}
>  	} else if (plat->mtdpart && plat->ubivol) {
>  		ret = mount_ubifs(plat->mtdpart, plat->ubivol);
>  		if (ret)
> @@ -138,13 +147,18 @@ static int _request_firmware_prepare(struct
> udevice *dev,
>  static int fw_get_filesystem_firmware(struct udevice *dev)
>  {
>  	loff_t actread;
> -	char *storage_interface, *dev_part, *ubi_mtdpart,
> *ubi_volume;
> +	char *storage_interface = NULL;
> +	char *dev_part = NULL;
> +	char *ubi_mtdpart = NULL;
> +	char *ubi_volume = NULL;
>  	int ret;
>  
> +#if CONFIG_IS_ENABLED(ENV_SUPPORT)
>  	storage_interface = env_get("storage_interface");
>  	dev_part = env_get("fw_dev_part");
>  	ubi_mtdpart = env_get("fw_ubi_mtdpart");
>  	ubi_volume = env_get("fw_ubi_volume");
> +#endif
>  
>  	if (storage_interface && dev_part) {
>  		ret = fs_set_blk_dev(storage_interface, dev_part,
> FS_TYPE_ANY);
> @@ -159,6 +173,7 @@ static int fw_get_filesystem_firmware(struct
> udevice *dev)
>  		else
>  			ret = -ENODEV;
>  	} else {
> +		debug("%s: init via platdata\n", __func__);
>  		ret = select_fs_dev(dev->platdata);
>  	}
>  
> diff --git a/include/fs_loader.h b/include/fs_loader.h
> index b728c06fcf..adaa2b5db8 100644
> --- a/include/fs_loader.h
> +++ b/include/fs_loader.h
> @@ -28,11 +28,15 @@ struct phandle_part {
>   * This holds information about all supported storage devices for
> driver use.
>   *
>   * @phandlepart: Attribute data for block device.
> + * @blkdev: Block device (alternative to using phandlepart)
> + * @blkpart: Partition number of block device (alternative to using
> phandlepart)
>   * @mtdpart: MTD partition for ubi partition.
>   * @ubivol: UBI volume-name for ubifsmount.
>   */
>  struct device_platdata {
>  	struct phandle_part phandlepart;
> +	struct udevice *blkdev;
> +	u32 blkpart;
>  	char *mtdpart;
>  	char *ubivol;
>  };


More information about the U-Boot mailing list