mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
efi_driver: blk: Switch to use platdata_auto_alloc_size for the driver data
Currently the efi block driver uses priv_auto_alloc_size for the driver data, however that's only available after the device probe phase. In order to make it accessible in an earlier phase, switch to use platdata_auto_alloc_size instead. This patch is the prerequisite for the follow up patch of DM BLK driver changes to work with EFI loader. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@ -38,7 +38,7 @@
|
|||||||
* handle handle of the controller on which this driver is installed
|
* handle handle of the controller on which this driver is installed
|
||||||
* io block io protocol proxied by this driver
|
* io block io protocol proxied by this driver
|
||||||
*/
|
*/
|
||||||
struct efi_blk_priv {
|
struct efi_blk_platdata {
|
||||||
efi_handle_t handle;
|
efi_handle_t handle;
|
||||||
struct efi_block_io *io;
|
struct efi_block_io *io;
|
||||||
};
|
};
|
||||||
@ -55,8 +55,8 @@ struct efi_blk_priv {
|
|||||||
static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
|
static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
|
||||||
void *buffer)
|
void *buffer)
|
||||||
{
|
{
|
||||||
struct efi_blk_priv *priv = dev->priv;
|
struct efi_blk_platdata *platdata = dev_get_platdata(dev);
|
||||||
struct efi_block_io *io = priv->io;
|
struct efi_block_io *io = platdata->io;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
|
||||||
EFI_PRINT("%s: read '%s', from block " LBAFU ", " LBAFU " blocks\n",
|
EFI_PRINT("%s: read '%s', from block " LBAFU ", " LBAFU " blocks\n",
|
||||||
@ -84,8 +84,8 @@ static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
|
|||||||
static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
|
static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
|
||||||
const void *buffer)
|
const void *buffer)
|
||||||
{
|
{
|
||||||
struct efi_blk_priv *priv = dev->priv;
|
struct efi_blk_platdata *platdata = dev_get_platdata(dev);
|
||||||
struct efi_block_io *io = priv->io;
|
struct efi_block_io *io = platdata->io;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
|
||||||
EFI_PRINT("%s: write '%s', from block " LBAFU ", " LBAFU " blocks\n",
|
EFI_PRINT("%s: write '%s', from block " LBAFU ", " LBAFU " blocks\n",
|
||||||
@ -135,7 +135,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
|
|||||||
struct efi_object *obj = efi_search_obj(handle);
|
struct efi_object *obj = efi_search_obj(handle);
|
||||||
struct efi_block_io *io = interface;
|
struct efi_block_io *io = interface;
|
||||||
int disks;
|
int disks;
|
||||||
struct efi_blk_priv *priv;
|
struct efi_blk_platdata *platdata;
|
||||||
|
|
||||||
EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io);
|
EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io);
|
||||||
|
|
||||||
@ -163,16 +163,16 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
|
|||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
/* Set the DM_FLAG_NAME_ALLOCED flag to avoid a memory leak */
|
/* Set the DM_FLAG_NAME_ALLOCED flag to avoid a memory leak */
|
||||||
device_set_name_alloced(bdev);
|
device_set_name_alloced(bdev);
|
||||||
/* Allocate priv */
|
|
||||||
|
platdata = dev_get_platdata(bdev);
|
||||||
|
platdata->handle = handle;
|
||||||
|
platdata->io = interface;
|
||||||
|
|
||||||
ret = device_probe(bdev);
|
ret = device_probe(bdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
|
EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
|
||||||
|
|
||||||
priv = bdev->priv;
|
|
||||||
priv->handle = handle;
|
|
||||||
priv->io = interface;
|
|
||||||
|
|
||||||
ret = blk_prepare_device(bdev);
|
ret = blk_prepare_device(bdev);
|
||||||
|
|
||||||
/* Create handles for the partions of the block device */
|
/* Create handles for the partions of the block device */
|
||||||
@ -193,7 +193,7 @@ U_BOOT_DRIVER(efi_blk) = {
|
|||||||
.name = "efi_blk",
|
.name = "efi_blk",
|
||||||
.id = UCLASS_BLK,
|
.id = UCLASS_BLK,
|
||||||
.ops = &efi_blk_ops,
|
.ops = &efi_blk_ops,
|
||||||
.priv_auto_alloc_size = sizeof(struct efi_blk_priv),
|
.platdata_auto_alloc_size = sizeof(struct efi_blk_platdata),
|
||||||
};
|
};
|
||||||
|
|
||||||
/* EFI driver operators */
|
/* EFI driver operators */
|
||||||
|
Reference in New Issue
Block a user