[U-Boot] [PATCH 2/5] mmc: initialize mmc_cmd with 0

2016-08-11 Thread Peng Fan
Using {0} to initialize mmc_cmd, before filling the structure.

Signed-off-by: Peng Fan 
Cc: Jaehoon Chung 
Cc: Simon Glass 
Cc: Bin Meng 
Cc: Stefan Wahren 
Cc: Clemens Gruber 
Cc: Kever Yang 
Cc: Eric Nelson 
Cc: Stephen Warren 
---
 drivers/mmc/mmc.c   | 28 ++--
 drivers/mmc/mmc_write.c |  4 ++--
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index efe517a..21bd0dc 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -139,7 +139,7 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
struct mmc_data *data)
 
 int mmc_send_status(struct mmc *mmc, int timeout)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
int err, retries = 5;
 
cmd.cmdidx = MMC_CMD_SEND_STATUS;
@@ -183,7 +183,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 
 int mmc_set_blocklen(struct mmc *mmc, int len)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
 
if (mmc->ddr_mode)
return 0;
@@ -198,7 +198,7 @@ int mmc_set_blocklen(struct mmc *mmc, int len)
 static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
   lbaint_t blkcnt)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
struct mmc_data data;
 
if (blkcnt > 1)
@@ -291,7 +291,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, 
lbaint_t blkcnt,
 
 static int mmc_go_idle(struct mmc *mmc)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
int err;
 
udelay(1000);
@@ -314,7 +314,7 @@ static int sd_send_op_cond(struct mmc *mmc)
 {
int timeout = 1000;
int err;
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
 
while (1) {
cmd.cmdidx = MMC_CMD_APP_CMD;
@@ -380,7 +380,7 @@ static int sd_send_op_cond(struct mmc *mmc)
 
 static int mmc_send_op_cond_iter(struct mmc *mmc, int use_arg)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
int err;
 
cmd.cmdidx = MMC_CMD_SEND_OP_COND;
@@ -422,7 +422,7 @@ static int mmc_send_op_cond(struct mmc *mmc)
 
 static int mmc_complete_op_cond(struct mmc *mmc)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
int timeout = 1000;
uint start;
int err;
@@ -466,7 +466,7 @@ static int mmc_complete_op_cond(struct mmc *mmc)
 
 static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
struct mmc_data data;
int err;
 
@@ -487,7 +487,7 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
 
 int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
int timeout = 1000;
int ret;
 
@@ -820,7 +820,7 @@ int mmc_getcd(struct mmc *mmc)
 
 static int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
struct mmc_data data;
 
/* Switch the frequency */
@@ -842,7 +842,7 @@ static int sd_switch(struct mmc *mmc, int mode, int group, 
u8 value, u8 *resp)
 static int sd_change_freq(struct mmc *mmc)
 {
int err;
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
ALLOC_CACHE_ALIGN_BUFFER(uint, scr, 2);
ALLOC_CACHE_ALIGN_BUFFER(uint, switch_status, 16);
struct mmc_data data;
@@ -952,7 +952,7 @@ retry_scr:
 static int sd_read_ssr(struct mmc *mmc)
 {
int err, i;
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
ALLOC_CACHE_ALIGN_BUFFER(uint, ssr, 16);
struct mmc_data data;
int timeout;
@@ -1072,7 +1072,7 @@ static int mmc_startup(struct mmc *mmc)
int err, i;
uint mult, freq;
u64 cmult, csize, capacity;
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
int timeout = 1000;
@@ -1555,7 +1555,7 @@ static int mmc_startup(struct mmc *mmc)
 
 static int mmc_send_if_cond(struct mmc *mmc)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
int err;
 
cmd.cmdidx = SD_CMD_SEND_IF_COND;
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index 0f8b5c7..4149f4a 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -17,7 +17,7 @@
 
 static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
ulong end;
int err, start_cmd, end_cmd;
 
@@ -119,7 +119,7 @@ unsigned long mmc_berase(struct blk_desc *block_dev, 
lbaint_t start,
 static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t start,
lbaint_t blkcnt, const void *src)
 {
-   struct mmc_cmd cmd;
+   struct mmc_cmd cmd = {0};
struct mmc_data data;

Re: [U-Boot] [PATCH 2/5] mmc: initialize mmc_cmd with 0

2016-08-12 Thread Simon Glass
Hi Peng,

On 11 August 2016 at 05:00, Peng Fan  wrote:
> Using {0} to initialize mmc_cmd, before filling the structure.
>
> Signed-off-by: Peng Fan 
> Cc: Jaehoon Chung 
> Cc: Simon Glass 
> Cc: Bin Meng 
> Cc: Stefan Wahren 
> Cc: Clemens Gruber 
> Cc: Kever Yang 
> Cc: Eric Nelson 
> Cc: Stephen Warren 
> ---
>  drivers/mmc/mmc.c   | 28 ++--
>  drivers/mmc/mmc_write.c |  4 ++--
>  2 files changed, 16 insertions(+), 16 deletions(-)

Why is this needed? Does it affect code size?

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/5] mmc: initialize mmc_cmd with 0

2016-08-13 Thread Peng Fan
Hi Simon,
On Fri, Aug 12, 2016 at 11:20:25AM -0600, Simon Glass wrote:
>Hi Peng,
>
>On 11 August 2016 at 05:00, Peng Fan  wrote:
>> Using {0} to initialize mmc_cmd, before filling the structure.
>>
>> Signed-off-by: Peng Fan 
>> Cc: Jaehoon Chung 
>> Cc: Simon Glass 
>> Cc: Bin Meng 
>> Cc: Stefan Wahren 
>> Cc: Clemens Gruber 
>> Cc: Kever Yang 
>> Cc: Eric Nelson 
>> Cc: Stephen Warren 
>> ---
>>  drivers/mmc/mmc.c   | 28 ++--
>>  drivers/mmc/mmc_write.c |  4 ++--
>>  2 files changed, 16 insertions(+), 16 deletions(-)
>
>Why is this needed? Does it affect code size?

I add a timeout entry in mmc_cmd, but I do not want to specify a value for 
timeout
for each mmc_cmd. So I use {0}.

Then to those who want use timeout, a value can be assigned to timeout, just 
like
I added in the patchset for mmc erase.

Thanks,
Peng.

>
>Regards,
>Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/5] mmc: initialize mmc_cmd with 0

2016-08-17 Thread Simon Glass
Hi Peng,

On 12 August 2016 at 19:41, Peng Fan  wrote:
> Hi Simon,
> On Fri, Aug 12, 2016 at 11:20:25AM -0600, Simon Glass wrote:
>>Hi Peng,
>>
>>On 11 August 2016 at 05:00, Peng Fan  wrote:
>>> Using {0} to initialize mmc_cmd, before filling the structure.
>>>
>>> Signed-off-by: Peng Fan 
>>> Cc: Jaehoon Chung 
>>> Cc: Simon Glass 
>>> Cc: Bin Meng 
>>> Cc: Stefan Wahren 
>>> Cc: Clemens Gruber 
>>> Cc: Kever Yang 
>>> Cc: Eric Nelson 
>>> Cc: Stephen Warren 
>>> ---
>>>  drivers/mmc/mmc.c   | 28 ++--
>>>  drivers/mmc/mmc_write.c |  4 ++--
>>>  2 files changed, 16 insertions(+), 16 deletions(-)
>>
>>Why is this needed? Does it affect code size?
>
> I add a timeout entry in mmc_cmd, but I do not want to specify a value for 
> timeout
> for each mmc_cmd. So I use {0}.
>
> Then to those who want use timeout, a value can be assigned to timeout, just 
> like
> I added in the patchset for mmc erase.

Instead of that, can you assign the value to 0, or whatever you want?
You might want to have a helper like mmc_init_cmd() to zero things
out.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/5] mmc: initialize mmc_cmd with 0

2016-08-17 Thread Peng Fan
Hi Simon,

On Wed, Aug 17, 2016 at 09:45:35PM -0600, Simon Glass wrote:
>Hi Peng,
>
>On 12 August 2016 at 19:41, Peng Fan  wrote:
>> Hi Simon,
>> On Fri, Aug 12, 2016 at 11:20:25AM -0600, Simon Glass wrote:
>>>Hi Peng,
>>>
>>>On 11 August 2016 at 05:00, Peng Fan  wrote:
 Using {0} to initialize mmc_cmd, before filling the structure.

 Signed-off-by: Peng Fan 
 Cc: Jaehoon Chung 
 Cc: Simon Glass 
 Cc: Bin Meng 
 Cc: Stefan Wahren 
 Cc: Clemens Gruber 
 Cc: Kever Yang 
 Cc: Eric Nelson 
 Cc: Stephen Warren 
 ---
  drivers/mmc/mmc.c   | 28 ++--
  drivers/mmc/mmc_write.c |  4 ++--
  2 files changed, 16 insertions(+), 16 deletions(-)
>>>
>>>Why is this needed? Does it affect code size?
>>
>> I add a timeout entry in mmc_cmd, but I do not want to specify a value for 
>> timeout
>> for each mmc_cmd. So I use {0}.
>>
>> Then to those who want use timeout, a value can be assigned to timeout, just 
>> like
>> I added in the patchset for mmc erase.
>
>Instead of that, can you assign the value to 0, or whatever you want?
>You might want to have a helper like mmc_init_cmd() to zero things
>out.

Ok. Will follow your suggestion in V3.

Thanks,
Peng.

>
>Regards,
>Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot