From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Herring Date: Fri, 21 Sep 2012 07:53:40 -0500 Subject: [U-Boot] [PATCH V3 3/8] disk: introduce get_device() In-Reply-To: <1348007874-20466-4-git-send-email-swarren@wwwdotorg.org> References: <1348007874-20466-1-git-send-email-swarren@wwwdotorg.org> <1348007874-20466-4-git-send-email-swarren@wwwdotorg.org> Message-ID: <505C6354.6010604@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 09/18/2012 05:37 PM, Stephen Warren wrote: > From: Stephen Warren > > This patch introduces function get_device(). This looks up a > block_dev_desc_t from an interface name (e.g. mmc) and device number > (e.g. 0). This function is essentially the non-partition-specific > prefix of get_device_and_partition(). > > Signed-off-by: Stephen Warren > --- > v3: New patch. > --- > disk/part.c | 22 ++++++++++++++++++++++ > include/part.h | 5 +++++ > 2 files changed, 27 insertions(+), 0 deletions(-) > > diff --git a/disk/part.c b/disk/part.c > index 277a243..9920d48 100644 > --- a/disk/part.c > +++ b/disk/part.c > @@ -435,6 +435,28 @@ void print_part (block_dev_desc_t * dev_desc) > > #endif > > +int get_device(const char *ifname, const char *dev_str, > + block_dev_desc_t **dev_desc) > +{ > + char *ep; > + int dev; > + Why don't you look up bootdevice here? That would be more consistent behavior. Rob > + dev = simple_strtoul(dev_str, &ep, 16); > + if (*ep) { > + printf("** Bad device specification %s %s **\n", > + ifname, dev_str); > + return -1; > + } > + > + *dev_desc = get_dev(ifname, dev); > + if (!(*dev_desc) || ((*dev_desc)->type == DEV_TYPE_UNKNOWN)) { > + printf("** Bad device %s %s **\n", ifname, dev_str); > + return -1; > + } > + > + return dev; > +} > + > #define MAX_SEARCH_PARTITIONS 16 > int get_device_and_partition(const char *ifname, const char *dev_str, > block_dev_desc_t **dev_desc, > diff --git a/include/part.h b/include/part.h > index a6d06f3..144df4e 100644 > --- a/include/part.h > +++ b/include/part.h > @@ -112,6 +112,8 @@ int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t > void print_part (block_dev_desc_t *dev_desc); > void init_part (block_dev_desc_t *dev_desc); > void dev_print(block_dev_desc_t *dev_desc); > +int get_device(const char *ifname, const char *dev_str, > + block_dev_desc_t **dev_desc); > int get_device_and_partition(const char *ifname, const char *dev_str, > block_dev_desc_t **dev_desc, > disk_partition_t *info); > @@ -131,6 +133,9 @@ static inline int get_partition_info (block_dev_desc_t * dev_desc, int part, > static inline void print_part (block_dev_desc_t *dev_desc) {} > static inline void init_part (block_dev_desc_t *dev_desc) {} > static inline void dev_print(block_dev_desc_t *dev_desc) {} > +static inline int get_device(const char *ifname, const char *dev_str, > + block_dev_desc_t **dev_desc) > +{ return -1; } > static inline int get_device_and_partition(const char *ifname, > const char *dev_str, > block_dev_desc_t **dev_desc, >