All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Kulhavy <brain@jikos.cz>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fastboot: add support for writing raw MMC
Date: Fri, 7 Oct 2016 08:59:38 +0200	[thread overview]
Message-ID: <18a9063e-8b8d-d3f7-e09c-287f8785ec82@jikos.cz> (raw)
In-Reply-To: <8e38ff35-ae91-584e-3606-86789bea45aa@samsung.com>



On 07/10/16 01:57, Jaehoon Chung wrote:
> On 10/05/2016 10:38 PM, Petr Kulhavy wrote:
>> The current fastboot implementation is only able to flash partition images.
>> However sometimes it is needed to write the raw MMC, e.g. when storing the
>> U-boot environment image or SPL.
>>
>> This patch adds the possibility to write MMC as a block device using a
>> special target name composed of "lba:" followed by the block address.
>> The address can be in decimal or hexadecimal with the "0x" prefix.
>>
>> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
>> ---
>>   common/fb_mmc.c             | 38 +++++++++++++++++++++++++++++++++++++-
>>   doc/README.android-fastboot | 15 +++++++++++++++
>>   2 files changed, 52 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
>> index 81a3bd0..c4fe2ac 100644
>> --- a/common/fb_mmc.c
>> +++ b/common/fb_mmc.c
>> @@ -27,6 +27,9 @@
>>   #define CONFIG_FASTBOOT_MBR_NAME "mbr"
>>   #endif
>>   
>> +#define FB_RAW_PREFIX		"lba:"
>> +#define FB_RAW_PREFIX_LEN	4
>> +
>>   struct fb_mmc_sparse {
>>   	struct blk_desc	*dev_desc;
>>   };
>> @@ -68,6 +71,29 @@ static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage *info,
>>   	return blkcnt;
>>   }
>>   
>> +/*
>> + * attempt to interpret the partition name as raw LBA
>> + * on success return 1 and fill info
>> + * on failure (not a LBA matching name) return 0 (info undefined)
>> + */
>> +static int get_raw_part_info(const struct blk_desc *dev_desc, const char *name,
>> +		disk_partition_t *info)
> Is it right about "const struct blk_desc ..."? Why use "const"?

This is a standard practice in C to make sure the function doesn't alter 
*dev_desc and in the header to indicate which parameters are inputs 
(read-only) and which outputs.
In fact this should be used all over the code, but in U-boot it's not 
very strictly followed.

>> +{
>> +	if (strlen(name) <= FB_RAW_PREFIX_LEN ||
>> +	    strncmp(name, FB_RAW_PREFIX, FB_RAW_PREFIX_LEN) != 0)
> strlen(name) was need to check?
To make sure there is at least one character after the ":", i.e. the 
input is not just "lba:". Otherwise the simple_stroul() returns 0.
There still could be some non-numeric characters though, but that check 
would be more complex and ideally done in simple_strtoul()

Regards
Petr

      reply	other threads:[~2016-10-07  6:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161005133851epcas1p10a1096f2601d402e4f0158af95824184@epcas1p1.samsung.com>
2016-10-05 13:38 ` [U-Boot] [PATCH] fastboot: add support for writing raw MMC Petr Kulhavy
2016-10-06 23:57   ` Jaehoon Chung
2016-10-07  6:59     ` Petr Kulhavy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18a9063e-8b8d-d3f7-e09c-287f8785ec82@jikos.cz \
    --to=brain@jikos.cz \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.