From patchwork Wed Feb 18 19:52:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dileep Katta X-Patchwork-Id: 44794 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4CA8B21554 for ; Wed, 18 Feb 2015 19:52:55 +0000 (UTC) Received: by lbdu10 with SMTP id u10sf2250274lbd.3 for ; Wed, 18 Feb 2015 11:52:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=7Pphs+DZP38QdLUBiLBsVJIvu2MQ1QbYKJiz9P60Eek=; b=XBHWqan45k848Y2n1xVkQG9WLW5cRvUsFGk6U4impIm3ICw4WHPyaMYLFMp+OwSozp FXNIqD6b/mCrfHCyTesK0oQKTZshurlU6g8vQN4TzUlGWddqRRb92nwmCu5QwQdE5zTZ SFMJgBctNPEsQ0WQuk3tjOebRNP02TLGg3gsdfj456mY+qyqxHnFFOJyHsIyklURjdrc ZUKu1je0Q9hkKLDTbj/D2XqoFDNLIeRAtJstGRSnUoQsSaFBwLazOplLoiIAE6V2qDLb 3svUa2tore8+ae7wh1AqdYE/hzV1Zn+Y0momUzK+p+HD3FfIPouREaZQR7y8+jPTM7T1 eRpg== X-Gm-Message-State: ALoCoQkS7H6ubVEbbzhiFBVaPrfPfGcRIuCKYf9m4cHr6vvxa5X/MQfkRaWrkWchKt1jHn0GWyMT X-Received: by 10.152.19.100 with SMTP id d4mr134835lae.7.1424289174324; Wed, 18 Feb 2015 11:52:54 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.131 with SMTP id k3ls73684lak.21.gmail; Wed, 18 Feb 2015 11:52:54 -0800 (PST) X-Received: by 10.112.17.39 with SMTP id l7mr927129lbd.114.1424289174085; Wed, 18 Feb 2015 11:52:54 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id q11si8826412lal.149.2015.02.18.11.52.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Feb 2015 11:52:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by labge10 with SMTP id ge10so3437131lab.12 for ; Wed, 18 Feb 2015 11:52:54 -0800 (PST) X-Received: by 10.112.14.196 with SMTP id r4mr976968lbc.86.1424289173770; Wed, 18 Feb 2015 11:52:53 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp46656lbj; Wed, 18 Feb 2015 11:52:53 -0800 (PST) X-Received: by 10.180.90.197 with SMTP id by5mr3441153wib.70.1424289172660; Wed, 18 Feb 2015 11:52:52 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id fm6si37056315wjc.133.2015.02.18.11.52.52; Wed, 18 Feb 2015 11:52:52 -0800 (PST) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D518A4A049; Wed, 18 Feb 2015 20:52:50 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xUJg17pewGne; Wed, 18 Feb 2015 20:52:50 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 055054A041; Wed, 18 Feb 2015 20:52:50 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D49054A041 for ; Wed, 18 Feb 2015 20:52:46 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n1i8lWY993U5 for ; Wed, 18 Feb 2015 20:52:46 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by theia.denx.de (Postfix) with ESMTPS id 589DD4A029 for ; Wed, 18 Feb 2015 20:52:43 +0100 (CET) Received: by padhz1 with SMTP id hz1so3565894pad.9 for ; Wed, 18 Feb 2015 11:52:42 -0800 (PST) X-Received: by 10.66.233.74 with SMTP id tu10mr1246454pac.135.1424289162087; Wed, 18 Feb 2015 11:52:42 -0800 (PST) Received: from localhost.localdomain ([106.51.142.94]) by mx.google.com with ESMTPSA id gi6sm21342889pbd.93.2015.02.18.11.52.39 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Feb 2015 11:52:41 -0800 (PST) From: Dileep Katta To: u-boot@lists.denx.de, robherring2@gmail.com, trini@ti.com, rob.herring@linaro.org, srae@broadcom.com, l.majewski@samsung.com, angelabaker@ti.com Date: Thu, 19 Feb 2015 01:22:27 +0530 Message-Id: <1424289147-21828-1-git-send-email-dileep.katta@linaro.org> X-Mailer: git-send-email 1.8.3.2 Cc: Dileep Katta Subject: [U-Boot] [PATCH v1 1/1] fastboot: Update getvar command to get 'userdata' partition size X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dileep.katta@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This patch adds functionality to getvar command to get the userdata partition size. Signed-off-by: Dileep Katta --- common/fb_mmc.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 2 ++ include/fb_mmc.h | 2 ++ 3 files changed, 42 insertions(+) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 6ea3938..1bb6335 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -32,6 +32,44 @@ void fastboot_okay(const char *s) strncat(response_str, s, RESPONSE_LEN - 4 - 1); } +void fb_mmc_get_ptn_size(const char *cmd, char *response) +{ + int ret; + block_dev_desc_t *dev_desc; + disk_partition_t info; + u32 sz_mb; + u64 sz = 0; + char buf[RESPONSE_LEN]; + + /* initialize the response buffer */ + response_str = response; + + dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); + if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { + error("invalid mmc device"); + fastboot_fail("invalid mmc device"); + return; + } + + ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); + if (ret) { + error("cannot find partition: '%s'", cmd); + fastboot_fail("cannot find partition"); + return; + } + + sz = (info.size * (u64)info.blksz) >> 10; + + if (sz >= 0xFFFFFFFF) { + sz_mb = (u32)(sz >> 10); + sprintf(buf, "0x%d MB", sz_mb); + fastboot_okay(buf); + } else { + sprintf(buf, "%d KB", (u32)sz); + fastboot_okay(buf); + } +} + static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, const char *part_name, void *buffer, unsigned int download_bytes) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 310175a..17b64ef 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -363,6 +363,8 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strncat(response, s, chars_left); else strcpy(response, "FAILValue not set"); + } else if (!strcmp_l1("userdata_size", cmd)) { + fb_mmc_get_ptn_size("userdata", response); } else { error("unknown variable: %s\n", cmd); strcpy(response, "FAILVariable not implemented"); diff --git a/include/fb_mmc.h b/include/fb_mmc.h index 1ad1d13..353f325 100644 --- a/include/fb_mmc.h +++ b/include/fb_mmc.h @@ -4,5 +4,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +void fb_mmc_get_ptn_size(const char *cmd, char *response); + void fb_mmc_flash_write(const char *cmd, void *download_buffer, unsigned int download_bytes, char *response);