From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Date: Fri, 4 Mar 2016 01:09:56 +0100 Subject: [U-Boot] [PATCH v5 12/30] disk/part.c: Expose list of available block drivers In-Reply-To: <1457050214-117592-1-git-send-email-agraf@suse.de> References: <1457050214-117592-1-git-send-email-agraf@suse.de> Message-ID: <1457050214-117592-13-git-send-email-agraf@suse.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de We have a pretty nice and generic interface to ask for a specific block device. However, that one is still based around the magic notion that we know the driver name. In order to be able to write fully generic disk access code, expose the currently internal list to other source files so that they can scan through all available block drivers. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass Tested-by: Simon Glass --- disk/part.c | 7 +------ include/part.h | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/disk/part.c b/disk/part.c index 1935b28..d265c2b 100644 --- a/disk/part.c +++ b/disk/part.c @@ -20,13 +20,8 @@ #define PRINTF(fmt,args...) #endif -struct block_drvr { - char *name; - block_dev_desc_t* (*get_dev)(int dev); - int (*select_hwpart)(int dev_num, int hwpart); -}; -static const struct block_drvr block_drvr[] = { +const struct block_drvr block_drvr[] = { #if defined(CONFIG_CMD_IDE) { .name = "ide", .get_dev = ide_get_dev, }, #endif diff --git a/include/part.h b/include/part.h index dc23949..6e6205b 100644 --- a/include/part.h +++ b/include/part.h @@ -42,6 +42,12 @@ struct block_dev_desc { void *priv; /* driver private struct pointer */ }; +struct block_drvr { + char *name; + block_dev_desc_t* (*get_dev)(int dev); + int (*select_hwpart)(int dev_num, int hwpart); +}; + #define BLOCK_CNT(size, block_dev_desc) (PAD_COUNT(size, block_dev_desc->blksz)) #define PAD_TO_BLOCKSIZE(size, block_dev_desc) \ (PAD_SIZE(size, block_dev_desc->blksz)) @@ -123,6 +129,8 @@ int get_device(const char *ifname, const char *dev_str, int get_device_and_partition(const char *ifname, const char *dev_part_str, block_dev_desc_t **dev_desc, disk_partition_t *info, int allow_whole_dev); + +extern const struct block_drvr block_drvr[]; #else static inline block_dev_desc_t *get_dev(const char *ifname, int dev) { return NULL; } -- 1.8.5.6