From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Fri, 21 Sep 2012 10:09:52 -0600 Subject: [U-Boot] [PATCH V3 3/8] disk: introduce get_device() In-Reply-To: <505C6354.6010604@gmail.com> References: <1348007874-20466-1-git-send-email-swarren@wwwdotorg.org> <1348007874-20466-4-git-send-email-swarren@wwwdotorg.org> <505C6354.6010604@gmail.com> Message-ID: <505C9150.6040206@wwwdotorg.org> 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/21/2012 06:53 AM, Rob Herring wrote: > 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(). >> +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. bootdevice names a partition (or can name a partition), whereas this function is about retrieving a device handle and never a partition handle. I'm not sure it makes semantic sense to always fall back to bootdevice for commands that call get_device() directly. I'd far prefer people to always just pass the device they want to a command rather than relying implicitly on environment variables. If we did read bootdevice here, we'd end up having to read/parse it in both get_device() and get_device_and_partition(), here to extract just the device portion and in get_device_and_partition() to extract just the partition portion. And we'd have to make sure the code here only allowed the user to specify a partition /if/ this function was called from get_device_and_partition() and not if a command called it directly. That all seems a bit complex.