RE: [PATCH] tools: imagetool: Remove unnecessary check from toc0_verify_cert_item()

2024-08-01 Thread Seung-Woo Kim
Hi,

> -Original Message-
> From: Andre Przywara 
> Sent: Thursday, August 1, 2024 6:28 PM
> Subject: Re: [PATCH] tools: imagetool: Remove unnecessary check from
> toc0_verify_cert_item()
> 
> On Thu,  1 Aug 2024 10:01:00 +0900
> Seung-Woo Kim  wrote:
> 
> Hi,
> 
> > Remove unnecessary null check from toc0_verify_cert_item() because the
> > array digest is always not null.
> 
> Do you mean it's always not NULL *as currently used*? Because digest is a
> function parameter, so within the scope of this function definition can be
> NULL.
> I agree that *currently* there is only one caller, and this passes the
> addresses of a local variable from the stack, though it's never NULL.
> 
> But I don't think this check hurts (looks like the compiler removes it
> anyway), and it makes the code more robust. So is there any problem with
> this check? Why do you want it to be removed?

Because in my gcc-14 environment, it gives -Wnonnull-compare warning.

tools/sunxi_toc0.c: In function 'toc0_verify_cert_item':
tools/sunxi_toc0.c:447:12: warning: 'nonnull' argument 'digest' compared to
NULL [-Wnonnull-compare]
  447 |         if (digest && memcmp(&extension->digest, digest,
SHA256_DIGEST_LENGTH)) {
  |^

Regards,
- Seung-Woo Kim

> 
> Cheers,
> Andre
> 
> >
> > Signed-off-by: Seung-Woo Kim 
> > ---
> >  tools/sunxi_toc0.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c index
> > 292649fe90f1..76693647a095 100644
> > --- a/tools/sunxi_toc0.c
> > +++ b/tools/sunxi_toc0.c
> > @@ -444,7 +444,7 @@ static int toc0_verify_cert_item(const uint8_t
> > *buf, uint32_t len, RSA *fw_key,
> >
> > /* If a digest was provided, compare it to the embedded digest. */
> > extension = &totalSequence->mainSequence.explicit3.extension;
> > -   if (digest && memcmp(&extension->digest, digest,
> SHA256_DIGEST_LENGTH)) {
> > +   if (memcmp(&extension->digest, digest, SHA256_DIGEST_LENGTH)) {
> > pr_err("Wrong firmware digest in certificate\n");
> > goto err;
> > }




[PATCH] tools: imagetool: Remove unnecessary check from toc0_verify_cert_item()

2024-07-31 Thread Seung-Woo Kim
Remove unnecessary null check from toc0_verify_cert_item()
because the array digest is always not null.

Signed-off-by: Seung-Woo Kim 
---
 tools/sunxi_toc0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c
index 292649fe90f1..76693647a095 100644
--- a/tools/sunxi_toc0.c
+++ b/tools/sunxi_toc0.c
@@ -444,7 +444,7 @@ static int toc0_verify_cert_item(const uint8_t *buf, 
uint32_t len, RSA *fw_key,
 
/* If a digest was provided, compare it to the embedded digest. */
extension = &totalSequence->mainSequence.explicit3.extension;
-   if (digest && memcmp(&extension->digest, digest, SHA256_DIGEST_LENGTH)) 
{
+   if (memcmp(&extension->digest, digest, SHA256_DIGEST_LENGTH)) {
pr_err("Wrong firmware digest in certificate\n");
goto err;
}
-- 
2.19.2



[PATCH] eeprom: starfive: set eth0 mac address properly

2023-08-11 Thread Seung-Woo Kim
fdt_fixup_ethernet() sets eth0 mac address from ethaddr. Set
ethaddr to environment instead of eth0addr.

Signed-off-by: Seung-Woo Kim 
---
 board/starfive/visionfive2/visionfive2-i2c-eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c 
b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
index befe7888c400..c334d98cf6e5 100644
--- a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
+++ b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
@@ -504,7 +504,7 @@ int mac_read_from_eeprom(void)
}
 
// 1, setup ethaddr env
-   eth_env_set_enetaddr("eth0addr", pbuf.eeprom.atom4.data.mac0_addr);
+   eth_env_set_enetaddr("ethaddr", pbuf.eeprom.atom4.data.mac0_addr);
eth_env_set_enetaddr("eth1addr", pbuf.eeprom.atom4.data.mac1_addr);
 
/**
-- 
2.19.2



[RESEND][PATCH] gadget: f_thor: fix wrong file size cast

2021-01-20 Thread Seung-Woo Kim
Casting 32bit int value directly into 64bit unsigned type causes
wrong value for file size equal or larger than 2GB. Fix the wrong
file size by casting uint32_t first.

Fixes: commit 1fe9ae76b113 ("gadget: f_thor: update to support more than 4GB 
file as thor 5.0")
Reported-by: Junghoon Kim 
Reviewed-by: Jaehoon Chung 
Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/f_thor.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 88fc87f2e907..559ffb759ed7 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -266,8 +266,8 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
 
switch (rqt->rqt_data) {
case RQT_DL_INIT:
-   thor_file_size = (unsigned long long int)rqt->int_data[0] +
-(((unsigned long long int)rqt->int_data[1])
+   thor_file_size = (uint64_t)(uint32_t)rqt->int_data[0] +
+(((uint64_t)(uint32_t)rqt->int_data[1])
  << 32);
debug("INIT: total %llu bytes\n", thor_file_size);
break;
@@ -280,8 +280,8 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
break;
}
 
-   thor_file_size = (unsigned long long int)rqt->int_data[1] +
-(((unsigned long long int)rqt->int_data[2])
+   thor_file_size = (uint64_t)(uint32_t)rqt->int_data[1] +
+(((uint64_t)(uint32_t)rqt->int_data[2])
  << 32);
memcpy(f_name, rqt->str_data[0], F_NAME_BUF_SIZE);
f_name[F_NAME_BUF_SIZE] = '\0';
-- 
2.19.2



[PATCH] gadget: f_thor: fix wrong file size cast

2020-10-16 Thread Seung-Woo Kim
Casting 32bit int value directly into 64bit unsigned type causes
wrong value for file size equal or larger than 2GB. Fix the wrong
file size by casting uint32_t first.

Fixes: commit 1fe9ae76b113 ("gadget: f_thor: update to support more than 4GB 
file as thor 5.0")
Reported-by: Junghoon Kim 
Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/f_thor.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 88fc87f2e9..559ffb759e 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -266,8 +266,8 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
 
switch (rqt->rqt_data) {
case RQT_DL_INIT:
-   thor_file_size = (unsigned long long int)rqt->int_data[0] +
-(((unsigned long long int)rqt->int_data[1])
+   thor_file_size = (uint64_t)(uint32_t)rqt->int_data[0] +
+(((uint64_t)(uint32_t)rqt->int_data[1])
  << 32);
debug("INIT: total %llu bytes\n", thor_file_size);
break;
@@ -280,8 +280,8 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
break;
}
 
-   thor_file_size = (unsigned long long int)rqt->int_data[1] +
-(((unsigned long long int)rqt->int_data[2])
+   thor_file_size = (uint64_t)(uint32_t)rqt->int_data[1] +
+(((uint64_t)(uint32_t)rqt->int_data[2])
  << 32);
memcpy(f_name, rqt->str_data[0], F_NAME_BUF_SIZE);
f_name[F_NAME_BUF_SIZE] = '\0';
-- 
2.19.2



Re: [PATCH] mmc: bcm283x: fix int to pointer cast

2020-05-15 Thread Seung-Woo Kim
Hi Jaehoon,

On 2020년 05월 15일 20:07, Jaehoon Chung wrote:
> On 5/15/20 7:14 PM, Seung-Woo Kim wrote:
>> On build with 32 bit, there is a warning for int-to-pointer-cast.
>> Fix the int to pointer cast by using uintptr_t.
> 
> Could you share in more detail? I didn't see any warning with gcc 9.2 / 8.3 / 
> 7.4 /6.5.

Sorry for not giving detail. If I applied PICe XHCI support [1], and
build rpi_4_32b, then I got related warning.

If [1] is not applied, then this can be ignored.

[1]
https://patchwork.ozlabs.org/project/uboot/patch/20200504124523.23484-7-s.nawro...@samsung.com/

Best Regards,
- Seung-Woo Kim

> 
> 
> Best Regards,
> Jaehoon Chung
> 
> 
>>
>> Signed-off-by: Seung-Woo Kim 
>> ---
>>  drivers/mmc/bcm2835_sdhci.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c
>> index 39c93db275..c31f099f25 100644
>> --- a/drivers/mmc/bcm2835_sdhci.c
>> +++ b/drivers/mmc/bcm2835_sdhci.c
>> @@ -209,7 +209,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
>>  priv->last_write = 0;
>>  
>>  host->name = dev->name;
>> -host->ioaddr = (void *)base;
>> +host->ioaddr = (void *)(uintptr_t)base;
>>  host->quirks = SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B |
>>  SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_NO_HISPD_BIT;
>>  host->max_clk = emmc_freq;
>>
> 
> 
> 

-- 
Seung-Woo Kim
Samsung Research
--



[PATCH] mmc: bcm283x: fix int to pointer cast

2020-05-15 Thread Seung-Woo Kim
On build with 32 bit, there is a warning for int-to-pointer-cast.
Fix the int to pointer cast by using uintptr_t.

Signed-off-by: Seung-Woo Kim 
---
 drivers/mmc/bcm2835_sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c
index 39c93db275..c31f099f25 100644
--- a/drivers/mmc/bcm2835_sdhci.c
+++ b/drivers/mmc/bcm2835_sdhci.c
@@ -209,7 +209,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
priv->last_write = 0;
 
host->name = dev->name;
-   host->ioaddr = (void *)base;
+   host->ioaddr = (void *)(uintptr_t)base;
host->quirks = SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B |
SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_NO_HISPD_BIT;
host->max_clk = emmc_freq;
-- 
2.19.2



[PATCH] gadget: f_thor: add missing line breaks for pr_err()

2020-02-13 Thread Seung-Woo Kim
After the commit 9b643e312d52 ("treewide: replace with error()
with pr_err()"), there are pr_err() usages without line break. Add
missing line breaks for pr_err() used in f_thor.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/f_thor.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 5a023a2b34..ee646fdd5c 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -174,7 +174,7 @@ static long long int download_head(unsigned long long total,
transfer_buffer, THOR_STORE_UNIT_SIZE,
(*cnt)++);
if (ret) {
-   pr_err("DFU write failed [%d] cnt: %d",
+   pr_err("DFU write failed [%d] cnt: %d\n",
  ret, *cnt);
return ret;
}
@@ -224,14 +224,14 @@ static int download_tail(long long int left, int cnt)
 
transfer_buffer = dfu_get_buf(dfu_entity);
if (!transfer_buffer) {
-   pr_err("Transfer buffer not allocated!");
+   pr_err("Transfer buffer not allocated!\n");
return -ENXIO;
}
 
if (left) {
ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
if (ret) {
-   pr_err("DFU write failed [%d]: left: %llu", ret, left);
+   pr_err("DFU write failed[%d]: left: %llu\n", ret, left);
return ret;
}
}
@@ -245,7 +245,7 @@ static int download_tail(long long int left, int cnt)
 */
ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
if (ret)
-   pr_err("DFU flush failed!");
+   pr_err("DFU flush failed!\n");
 
return ret;
 }
@@ -290,7 +290,7 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
 
alt_setting_num = dfu_get_alt(f_name);
if (alt_setting_num < 0) {
-   pr_err("Alt setting [%d] to write not found!",
+   pr_err("Alt setting [%d] to write not found!\n",
  alt_setting_num);
rsp->ack = -ENODEV;
ret = rsp->ack;
@@ -316,7 +316,7 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
debug("DL EXIT\n");
break;
default:
-   pr_err("Operation not supported: %d", rqt->rqt_data);
+   pr_err("Operation not supported: %d\n", rqt->rqt_data);
ret = -ENOTSUPP;
}
 
@@ -347,7 +347,7 @@ static int process_data(void)
puts("RQT: UPLOAD not supported!\n");
break;
default:
-   pr_err("unknown request (%d)", rqt->rqt);
+   pr_err("unknown request (%d)\n", rqt->rqt);
}
 
return ret;
@@ -546,7 +546,7 @@ static int thor_rx_data(void)
 
status = usb_ep_queue(dev->out_ep, dev->out_req, 0);
if (status) {
-   pr_err("kill %s:  resubmit %d bytes --> %d",
+   pr_err("kill %s:  resubmit %d bytes --> %d\n",
  dev->out_ep->name, dev->out_req->length, status);
usb_ep_set_halt(dev->out_ep);
return -EAGAIN;
@@ -580,7 +580,7 @@ static void thor_tx_data(unsigned char *data, int len)
 
status = usb_ep_queue(dev->in_ep, dev->in_req, 0);
if (status) {
-   pr_err("kill %s:  resubmit %d bytes --> %d",
+   pr_err("kill %s:  resubmit %d bytes --> %d\n",
  dev->in_ep->name, dev->in_req->length, status);
usb_ep_set_halt(dev->in_ep);
}
@@ -613,7 +613,7 @@ static void thor_rx_tx_complete(struct usb_ep *ep, struct 
usb_request *req)
case -ESHUTDOWN:/* disconnect from host */
case -EREMOTEIO:/* short read */
case -EOVERFLOW:
-   pr_err("ERROR:%d", status);
+   pr_err("ERROR:%d\n", status);
break;
}
 
@@ -653,7 +653,7 @@ thor_func_setup(struct usb_function *f, const struct 
usb_ctrlrequest *ctrl)
break;
 
default:
-   pr_err("thor_setup: unknown request: %d", ctrl->bRequest);
+   pr_err("thor_setup: unknown request: %d\n", ctrl->bRequest);
}
 
if (value >= 0) {
@

Re: [PATCH RESEND] usbtty: fix possible alignment issues

2020-01-07 Thread Seung-Woo Kim
Hi,

On 2020년 01월 07일 22:22, Tom Rini wrote:
> On Tue, Jan 07, 2020 at 02:25:02PM +0900, Seung-Woo Kim wrote:
> 
...
>> ---
>>  drivers/serial/usbtty.c | 9 ++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
>> index f1c1a260da..54e67dd0d1 100644
>> --- a/drivers/serial/usbtty.c
>> +++ b/drivers/serial/usbtty.c
>> @@ -48,6 +48,8 @@
>>  #define CONFIG_USBD_DATA_INTERFACE_STR "Bulk Data Interface"
>>  #define CONFIG_USBD_CTRL_INTERFACE_STR "Control Interface"
>>  
>> +typedef struct { __le16 val; } __attribute__((aligned(16))) __le16_packed;
>> +
>>  /*
>>   * Buffers to hold input and output data
>>   */
>> @@ -372,14 +374,15 @@ static int fill_buffer (circbuf_t * buf);
>>  void usbtty_poll (void);
>>  
>>  /* utility function for converting char* to wide string used by USB */
>> -static void str2wide (char *str, u16 * wide)
>> +static void str2wide (char *str, void *wide)
>>  {
>>  int i;
>> +__le16_packed   *tmp = wide;
>>  for (i = 0; i < strlen (str) && str[i]; i++){
>>  #if defined(__LITTLE_ENDIAN)
>> -wide[i] = (u16) str[i];
>> +tmp[i].val = (u16) str[i];
>>  #elif defined(__BIG_ENDIAN)
>> -wide[i] = ((u16)(str[i])<<8);
>> +tmp[i].val = ((u16)(str[i])<<8);
>>  #else
>>  #error "__LITTLE_ENDIAN or __BIG_ENDIAN undefined"
>>  #endif
> 
> We generally don't want packed structs and do need to disable this
> warning in general.  Is this _really_ a problem, or are we just
> silencing the compiler here?  Thanks!

The change makes just silence for the warnings as like composite.c in
usb gadget.

Regards,
- Seung-Woo Kim


[PATCH RESEND] usbtty: fix possible alignment issues

2020-01-06 Thread Seung-Woo Kim
With gcc9, below warnings are shown:
  drivers/serial/usbtty.c: In function 'usbtty_init_strings':
  drivers/serial/usbtty.c:590:44: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
590 |  str2wide (CONFIG_USBD_MANUFACTURER, string->wData);
|  ~~^~~
  drivers/serial/usbtty.c:596:44: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
597 |  str2wide (CONFIG_USBD_PRODUCT_NAME, string->wData);
|  ~~^~~
  drivers/serial/usbtty.c:603:33: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
604 |  str2wide (serial_number, string->wData);
|   ~~^~~
  drivers/serial/usbtty.c:610:49: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
611 |  str2wide (CONFIG_USBD_CONFIGURATION_STR, string->wData);
|   ~~^~~
  drivers/serial/usbtty.c:617:50: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
618 |  str2wide (CONFIG_USBD_DATA_INTERFACE_STR, string->wData);
|~~^~~
  drivers/serial/usbtty.c:623:50: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
624 |  str2wide (CONFIG_USBD_CTRL_INTERFACE_STR, string->wData);
|~~^~~

Fix the issues by using packed structure.

Ref: commit 616ebd8b9cb4 ("usb: composite: fix possible alignment issues")
Signed-off-by: Seung-Woo Kim 
---
resend with proper e-mail address
---
 drivers/serial/usbtty.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index f1c1a260da..54e67dd0d1 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -48,6 +48,8 @@
 #define CONFIG_USBD_DATA_INTERFACE_STR "Bulk Data Interface"
 #define CONFIG_USBD_CTRL_INTERFACE_STR "Control Interface"
 
+typedef struct { __le16 val; } __attribute__((aligned(16))) __le16_packed;
+
 /*
  * Buffers to hold input and output data
  */
@@ -372,14 +374,15 @@ static int fill_buffer (circbuf_t * buf);
 void usbtty_poll (void);
 
 /* utility function for converting char* to wide string used by USB */
-static void str2wide (char *str, u16 * wide)
+static void str2wide (char *str, void *wide)
 {
int i;
+   __le16_packed   *tmp = wide;
for (i = 0; i < strlen (str) && str[i]; i++){
#if defined(__LITTLE_ENDIAN)
-   wide[i] = (u16) str[i];
+   tmp[i].val = (u16) str[i];
#elif defined(__BIG_ENDIAN)
-   wide[i] = ((u16)(str[i])<<8);
+   tmp[i].val = ((u16)(str[i])<<8);
#else
#error "__LITTLE_ENDIAN or __BIG_ENDIAN undefined"
#endif
-- 
2.19.2



[PATCH] usbtty: fix possible alignment issues

2020-01-06 Thread Seung-Woo Kim
With gcc9, below warnings are shown:
  drivers/serial/usbtty.c: In function 'usbtty_init_strings':
  drivers/serial/usbtty.c:590:44: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
590 |  str2wide (CONFIG_USBD_MANUFACTURER, string->wData);
|  ~~^~~
  drivers/serial/usbtty.c:596:44: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
597 |  str2wide (CONFIG_USBD_PRODUCT_NAME, string->wData);
|  ~~^~~
  drivers/serial/usbtty.c:603:33: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
604 |  str2wide (serial_number, string->wData);
|   ~~^~~
  drivers/serial/usbtty.c:610:49: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
611 |  str2wide (CONFIG_USBD_CONFIGURATION_STR, string->wData);
|   ~~^~~
  drivers/serial/usbtty.c:617:50: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
618 |  str2wide (CONFIG_USBD_DATA_INTERFACE_STR, string->wData);
|~~^~~
  drivers/serial/usbtty.c:623:50: warning: taking address of packed member of 
'struct usb_string_descriptor' may result in an unaligned pointer value 
[-Waddress-of-packed-member]
624 |  str2wide (CONFIG_USBD_CTRL_INTERFACE_STR, string->wData);
|~~^~~

Fix the issues by using packed structure.

Ref: commit 616ebd8b9cb4 ("usb: composite: fix possible alignment issues")
Signed-off-by: Seung-Woo Kim 
---
 drivers/serial/usbtty.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index f1c1a260da..54e67dd0d1 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -48,6 +48,8 @@
 #define CONFIG_USBD_DATA_INTERFACE_STR "Bulk Data Interface"
 #define CONFIG_USBD_CTRL_INTERFACE_STR "Control Interface"
 
+typedef struct { __le16 val; } __attribute__((aligned(16))) __le16_packed;
+
 /*
  * Buffers to hold input and output data
  */
@@ -372,14 +374,15 @@ static int fill_buffer (circbuf_t * buf);
 void usbtty_poll (void);
 
 /* utility function for converting char* to wide string used by USB */
-static void str2wide (char *str, u16 * wide)
+static void str2wide (char *str, void *wide)
 {
int i;
+   __le16_packed   *tmp = wide;
for (i = 0; i < strlen (str) && str[i]; i++){
#if defined(__LITTLE_ENDIAN)
-   wide[i] = (u16) str[i];
+   tmp[i].val = (u16) str[i];
#elif defined(__BIG_ENDIAN)
-   wide[i] = ((u16)(str[i])<<8);
+   tmp[i].val = ((u16)(str[i])<<8);
#else
#error "__LITTLE_ENDIAN or __BIG_ENDIAN undefined"
#endif
-- 
2.19.2



Re: [U-Boot] [PATCH] Revert "arm: config: fix default console only to specify the device"

2019-03-25 Thread Seung-Woo Kim
Hello Anand,

> -Original Message-
> From: Anand Moon [mailto:linux.am...@gmail.com]
> Sent: Monday, March 25, 2019 3:45 PM
> To: Seung-Woo Kim
> Cc: U-Boot Mailing List; Lukasz Majewski
> Subject: Re: [U-Boot] [PATCH] Revert "arm: config: fix default console only 
> to specify the device"
> 
> Hi Seung-Woo,
> 
> On Tue, 20 Nov 2018 at 11:25, Seung-Woo Kim  wrote:
> >
> > This reverts commit 232ed3ca534708527a9515c7c41bc3542949525c.
> >
> > In exynos boards, ${console} is used to set bootargs but it sets
> > without "console=", so CONFIG_DEFAULT_CONSOLE for these boards is
> > designated with "console=" but it is removed. So revert the commit.
> >
> > References for using ${console} in
> >board/samsung/common/bootscripts/autoboot.cmd
> >board/samsung/common/bootscripts/bootzimg.cmd
> >
> > Signed-off-by: Seung-Woo Kim 
> > ---
> >  include/configs/odroid.h| 4 ++--
> >  include/configs/odroid_xu3.h| 4 ++--
> >  include/configs/s5p_goni.h  | 4 ++--
> >  include/configs/s5pc210_universal.h | 4 ++--
> >  include/configs/trats.h | 4 ++--
> >  include/configs/trats2.h| 4 ++--
> >  6 files changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/include/configs/odroid.h b/include/configs/odroid.h
> > index ad77242e38..c3520bb15f 100644
> > --- a/include/configs/odroid.h
> > +++ b/include/configs/odroid.h
> > @@ -40,7 +40,7 @@
> >  /* Console configuration */
> >
> >  #define CONFIG_BOOTCOMMAND "run distro_bootcmd ; run autoboot"
> > -#define CONFIG_DEFAULT_CONSOLE "ttySAC1,115200n8"
> > +#define CONFIG_DEFAULT_CONSOLE "console=ttySAC1,115200n8\0"
> >
> >  #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_LOAD_ADDR \
> > - GENERATED_GBL_DATA_SIZE)
> > @@ -157,7 +157,7 @@
> > "elif test -e mmc 0 uImage; then; " \
> > "run boot_uimg;" \
> > "fi;\0" \
> > -   "console=" CONFIG_DEFAULT_CONSOLE "\0" \
> > +   "console=" CONFIG_DEFAULT_CONSOLE \
> > "mmcbootdev=0\0" \
> > "mmcbootpart=1\0" \
> > "mmcrootdev=0\0" \

<...>

> > --
> > 2.19.1
> 
> This revert commit breaks the booting of the Odroid U3 using latest
> u-boot on ArchLinux.
> I have just tried to install archlinux on sdcard and update the latest kernel
> after compiling the latest u-boot and upgrade.
> It fails to boot up at-least their is not console output on the serial port.
> 
> [0] https://www.spinics.net/lists/arm-kernel/msg713918.html
> 
> I shared the my input on above link.
> Can your verify this from your side.

In my case, it works fine for booting mainline kernel at least.
Can you try after "env default -a; saveenv; reset;" command from u-boot prompt?
When I cleared env, console in env is "console=console=ttySAC1,115200n8".
Please refer below my system console log from odroud-u3.

U-Boot 2019.04-rc4-00051-ge7134b9714 (Mar 26 2019 - 13:00:45 +0900)

CPU:   Exynos4412 @ 1 GHz
Model: Odroid based on Exynos4412
Type:  u3
DRAM:  2 GiB
LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
LDO21@TFLASH_2.8V: set 280 uV; enabling
MMC:   sdhci@1253 - probe failed: -19

Loading Environment from MMC... OK
Net:   No ethernet found.
Hit any key to stop autoboot:  0 
Odroid # 
Odroid # 
Odroid # printenv
arch=arm
autoboot=if test -e mmc 0 boot.scr; then; run boot_script; elif test -e mmc 0 
Image.itb; then; run boot_fit;elif test -e mmc 0 zImage; then; run 
boot_zimg;elif test -e mmc 0 uImage; then; run boot_uimg;fi;
<...>
console=console=ttySAC1,115200n8
<...>
Environment size: 4657/16380 bytes
Odroid # run autoboot
55205 bytes read in 4 ms (13.2 MiB/s)
8556752 bytes read in 299 ms (27.3 MiB/s)
Kernel image @ 0x4100 [ 0x00 - 0x8290d0 ]
## Flattened Device Tree blob at 4080
   Booting using the fdt blob at 0x4080
   Loading Device Tree to 4ffef000, end 47a4 ... OK

Starting kernel ...

[0.00] Booting Linux on physical CPU 0xa00

Best Regards,
- Seung-Woo Kim

> 
> Best Regards
> -Anand

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] Revert "arm: config: fix default console only to specify the device"

2018-11-19 Thread Seung-Woo Kim
This reverts commit 232ed3ca534708527a9515c7c41bc3542949525c.

In exynos boards, ${console} is used to set bootargs but it sets
without "console=", so CONFIG_DEFAULT_CONSOLE for these boards is
designated with "console=" but it is removed. So revert the commit.

References for using ${console} in
   board/samsung/common/bootscripts/autoboot.cmd
   board/samsung/common/bootscripts/bootzimg.cmd

Signed-off-by: Seung-Woo Kim 
---
 include/configs/odroid.h| 4 ++--
 include/configs/odroid_xu3.h| 4 ++--
 include/configs/s5p_goni.h  | 4 ++--
 include/configs/s5pc210_universal.h | 4 ++--
 include/configs/trats.h | 4 ++--
 include/configs/trats2.h| 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/configs/odroid.h b/include/configs/odroid.h
index ad77242e38..c3520bb15f 100644
--- a/include/configs/odroid.h
+++ b/include/configs/odroid.h
@@ -40,7 +40,7 @@
 /* Console configuration */
 
 #define CONFIG_BOOTCOMMAND "run distro_bootcmd ; run autoboot"
-#define CONFIG_DEFAULT_CONSOLE "ttySAC1,115200n8"
+#define CONFIG_DEFAULT_CONSOLE "console=ttySAC1,115200n8\0"
 
 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_LOAD_ADDR \
- GENERATED_GBL_DATA_SIZE)
@@ -157,7 +157,7 @@
"elif test -e mmc 0 uImage; then; " \
"run boot_uimg;" \
"fi;\0" \
-   "console=" CONFIG_DEFAULT_CONSOLE "\0" \
+   "console=" CONFIG_DEFAULT_CONSOLE \
"mmcbootdev=0\0" \
"mmcbootpart=1\0" \
"mmcrootdev=0\0" \
diff --git a/include/configs/odroid_xu3.h b/include/configs/odroid_xu3.h
index f683ee46e3..3b9a945e7c 100644
--- a/include/configs/odroid_xu3.h
+++ b/include/configs/odroid_xu3.h
@@ -30,7 +30,7 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_LOAD_ADDR - 0x100)
 
-#define CONFIG_DEFAULT_CONSOLE "ttySAC2,115200n8"
+#define CONFIG_DEFAULT_CONSOLE "console=ttySAC2,115200n8\0"
 
 /* USB */
 #define CONFIG_USB_EHCI_EXYNOS
@@ -99,7 +99,7 @@
MEM_LAYOUT_ENV_SETTINGS \
BOOTENV \
"rootfstype=ext4\0" \
-   "console=" CONFIG_DEFAULT_CONSOLE "\0"\
+   "console=" CONFIG_DEFAULT_CONSOLE \
"fdtfile=exynos5422-odroidxu3.dtb\0" \
"boardname=odroidxu3\0" \
"mmcbootdev=0\0" \
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 87ddc20a52..ff634d91dd 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -87,7 +87,7 @@
 
 #define CONFIG_BOOTCOMMAND "run mmcboot"
 
-#define CONFIG_DEFAULT_CONSOLE "ttySAC2,115200n8"
+#define CONFIG_DEFAULT_CONSOLE "console=ttySAC2,115200n8\0"
 
 #define CONFIG_RAMDISK_BOOT"root=/dev/ram0 rw rootfstype=ext4" \
" ${console} ${meminfo}"
@@ -134,7 +134,7 @@
"bootchart=set opts init=/sbin/bootchartd; run bootcmd\0" \
"verify=n\0" \
"rootfstype=ext4\0" \
-   "console=" CONFIG_DEFAULT_CONSOLE "\0"\
+   "console=" CONFIG_DEFAULT_CONSOLE \
"meminfo=mem=80M mem=256M@0x4000 mem=128M@0x5000\0" \
"loaduimage=ext4load mmc ${mmcdev}:${mmcbootpart} 0x30007FC0 uImage\0" \
"mmcdev=0\0" \
diff --git a/include/configs/s5pc210_universal.h 
b/include/configs/s5pc210_universal.h
index 999bdd1676..832032da18 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -27,7 +27,7 @@
 /* Console configuration */
 
 #define CONFIG_BOOTCOMMAND "run mmcboot"
-#define CONFIG_DEFAULT_CONSOLE "ttySAC1,115200n8"
+#define CONFIG_DEFAULT_CONSOLE "console=ttySAC1,115200n8\0"
 
 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_LOAD_ADDR \
- GENERATED_GBL_DATA_SIZE)
@@ -108,7 +108,7 @@
"mmcoops=mmc read 0 0x4000 0x40 8; md 0x4000 0x400\0" \
"verify=n\0" \
"rootfstype=ext4\0" \
-   "console=" CONFIG_DEFAULT_CONSOLE "\0" \
+   "console=" CONFIG_DEFAULT_CONSOLE \
"mtdparts=" CONFIG_MTDPARTS_DEFAULT \
"mbrparts=" MBRPARTS_DEFAULT \
"meminfo=crashkernel=32M@0x5000\0" \
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 223fce49a7..af8e8ce3b6 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -36,7 +36,7 @@
 #define CONFIG_MACH_TYPE   MACH_TYPE_TRATS
 
 #define CONFIG_BOOTCOMMAND "run autoboot"
-#define CONFIG

[U-Boot] [PATCH v2] script: Make get_default_envs.sh script exclude tools/env

2018-06-04 Thread Seung-Woo Kim
If building envtools, there is env directory in tools directory.
Make the get_default_envs.sh script exclude tools/env directory.

Signed-off-by: Seung-Woo Kim 
---
Change from v1
- fix typp as Minkyu's comment
---
 scripts/get_default_envs.sh |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/get_default_envs.sh b/scripts/get_default_envs.sh
index 2872653..da86a9d 100755
--- a/scripts/get_default_envs.sh
+++ b/scripts/get_default_envs.sh
@@ -23,7 +23,7 @@ else
 fi
 
 env_obj_file_path=$(find ${path} -path "*/env/*" -not -path "*/spl/*" \
--name "${ENV_OBJ_FILE}")
+-not -path "*/tools/*" -name "${ENV_OBJ_FILE}")
 [ -z "${env_obj_file_path}" ] && \
 { echoerr "File '${ENV_OBJ_FILE}' not found!"; exit 1; }
 
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] fs: fat: fix wrong casting to unsigned value of sect_to_cluster()

2018-06-04 Thread Seung-Woo Kim
Hello,

On 2018년 06월 05일 06:58, Tom Rini wrote:
> On Mon, Jun 04, 2018 at 08:45:54PM +0900, Seung-Woo Kim wrote:
> 
>> After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector
>> <-> cluster conversions"), it is hung up writing new file to FAT16
>> disk with more than 19 files in armv7. It is because result value
>> of sect_to_cluster() is not proper by casting from signed value to
>> unsigned value. Fix the wrong casting of sect_to_cluster().
>>
>> Reported-by: Jaehoon Chung 
>> Signed-off-by: Seung-Woo Kim 
>> ---
>>  include/fat.h |2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Can you please also update test/fs-test.sh with a testcase for this?
> Thanks!
> 

The simple test way is doing fat-write more than 20 files with long file
name to FAT16 image.

For example, in my armv7 odroid-xu3 target with empty fat16 root,
writing like following:

fatwrite mmc 0 1300 0100 4
fatwrite mmc 0 1300 0200 4
..
fatwrite mmc 0 1300 2100 4

and then 22th writing was failed like following:

ODROID-XU3 # fatwrite mmc 0 1300 2200 4
writing 2200
Error: Invalid FAT entry: 0x3ffa
Invalid FAT entry
Error: Invalid FAT entry: 0x3ffa

I tested same thing with sandbox u-boot on x86, there was no error like
armv7. So, I am not sure it is helpful to add testcase for this.

Best Regards,
- Seung-Woo Kim


-- 
Seung-Woo Kim
Samsung Research
--

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] fs: fat: fix wrong casting to unsigned value of sect_to_cluster()

2018-06-04 Thread Seung-Woo Kim
After the commit 265edc03d5a1 ("fs/fat: Clean up open-coded sector
<-> cluster conversions"), it is hung up writing new file to FAT16
disk with more than 19 files in armv7. It is because result value
of sect_to_cluster() is not proper by casting from signed value to
unsigned value. Fix the wrong casting of sect_to_cluster().

Reported-by: Jaehoon Chung 
Signed-off-by: Seung-Woo Kim 
---
 include/fat.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/fat.h b/include/fat.h
index 7dada41..09e1423 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -180,7 +180,7 @@ static inline u32 clust_to_sect(fsdata *fsdata, u32 clust)
return fsdata->data_begin + clust * fsdata->clust_size;
 }
 
-static inline u32 sect_to_clust(fsdata *fsdata, u32 sect)
+static inline u32 sect_to_clust(fsdata *fsdata, int sect)
 {
return (sect - fsdata->data_begin) / fsdata->clust_size;
 }
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/3] cmd: add missing line breaks for pr_err()

2018-06-04 Thread Seung-Woo Kim
After the commit 9b643e312d52 ("treewide: replace with error() with
pr_err()"), there are some pr_err() with no line break. Add missing
line breaks.

Signed-off-by: Seung-Woo Kim 
---
 cmd/fastboot.c |2 +-
 cmd/regulator.c|2 +-
 cmd/thordown.c |6 +++---
 cmd/usb_mass_storage.c |6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index 557257a..e6ae057 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -48,7 +48,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
 
ret = board_usb_init(controller_index, USB_INIT_DEVICE);
if (ret) {
-   pr_err("USB init failed: %d", ret);
+   pr_err("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
}
 
diff --git a/cmd/regulator.c b/cmd/regulator.c
index 89461b6..ed8d778 100644
--- a/cmd/regulator.c
+++ b/cmd/regulator.c
@@ -70,7 +70,7 @@ static int curr_dev_and_platdata(struct udevice **devp,
 
*uc_pdata = dev_get_uclass_platdata(*devp);
if (!*uc_pdata) {
-   pr_err("Regulator: %s - missing platform data!", currdev->name);
+   pr_err("Regulator: %s - missing platform data!\n", 
currdev->name);
return CMD_RET_FAILURE;
}
 
diff --git a/cmd/thordown.c b/cmd/thordown.c
index e297de2..2615ada 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -32,7 +32,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
int controller_index = simple_strtoul(usb_controller, NULL, 0);
ret = board_usb_init(controller_index, USB_INIT_DEVICE);
if (ret) {
-   pr_err("USB init failed: %d", ret);
+   pr_err("USB init failed: %d\n", ret);
ret = CMD_RET_FAILURE;
goto exit;
}
@@ -41,14 +41,14 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 
ret = thor_init();
if (ret) {
-   pr_err("THOR DOWNLOAD failed: %d", ret);
+   pr_err("THOR DOWNLOAD failed: %d\n", ret);
ret = CMD_RET_FAILURE;
goto exit;
}
 
ret = thor_handle();
if (ret) {
-   pr_err("THOR failed: %d", ret);
+   pr_err("THOR failed: %d\n", ret);
ret = CMD_RET_FAILURE;
goto exit;
}
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index 89b9ddf..0d55114 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -161,21 +161,21 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
controller_index = (unsigned int)(simple_strtoul(
usb_controller, NULL, 0));
if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
-   pr_err("Couldn't init USB controller.");
+   pr_err("Couldn't init USB controller.\n");
rc = CMD_RET_FAILURE;
goto cleanup_ums_init;
}
 
rc = fsg_init(ums, ums_count);
if (rc) {
-   pr_err("fsg_init failed");
+   pr_err("fsg_init failed\n");
rc = CMD_RET_FAILURE;
goto cleanup_board;
}
 
rc = g_dnl_register("usb_dnl_ums");
if (rc) {
-   pr_err("g_dnl_register failed");
+   pr_err("g_dnl_register failed\n");
rc = CMD_RET_FAILURE;
goto cleanup_board;
}
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/3] board: samsung: add missing line breaks for pr_err()

2018-06-04 Thread Seung-Woo Kim
After the commit 9b643e312d52 ("treewide: replace with error() with
pr_err()"), there are some pr_err() with no line break. Add missing
line breaks.

Signed-off-by: Seung-Woo Kim 
---
 board/samsung/common/exynos5-dt.c |2 +-
 board/samsung/common/misc.c   |2 +-
 board/samsung/odroid/odroid.c |   12 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/board/samsung/common/exynos5-dt.c 
b/board/samsung/common/exynos5-dt.c
index 9f6f654..8c3a9ea 100644
--- a/board/samsung/common/exynos5-dt.c
+++ b/board/samsung/common/exynos5-dt.c
@@ -164,7 +164,7 @@ int board_usb_init(int index, enum usb_init_type init)
samsung_get_base_usb3_phy();
 
if (!phy) {
-   pr_err("usb3 phy not supported");
+   pr_err("usb3 phy not supported\n");
return -ENODEV;
}
 
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index c9df7e6..05243fc 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -456,7 +456,7 @@ void draw_logo(void)
 
addr = panel_info.logo_addr;
if (!addr) {
-   pr_err("There is no logo data.");
+   pr_err("There is no logo data.\n");
return;
}
 
diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
index 1c2bd01..552333f 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -428,7 +428,7 @@ int exynos_power_init(void)
};
 
if (regulator_list_autoset(mmc_regulators, NULL, true))
-   pr_err("Unable to init all mmc regulators");
+   pr_err("Unable to init all mmc regulators\n");
 
return 0;
 }
@@ -441,7 +441,7 @@ static int s5pc210_phy_control(int on)
 
ret = regulator_get_by_platname("VDD_UOTG_3.0V", &dev);
if (ret) {
-   pr_err("Regulator get error: %d", ret);
+   pr_err("Regulator get error: %d\n", ret);
return ret;
}
 
@@ -486,25 +486,25 @@ int board_usb_init(int index, enum usb_init_type init)
 
ret = regulator_get_by_platname("VCC_P3V3_2.85V", &dev);
if (ret) {
-   pr_err("Regulator get error: %d", ret);
+   pr_err("Regulator get error: %d\n", ret);
return ret;
}
 
ret = regulator_set_enable(dev, true);
if (ret) {
-   pr_err("Regulator %s enable setting error: %d", dev->name, ret);
+   pr_err("Regulator %s enable setting error: %d\n", dev->name, 
ret);
return ret;
}
 
ret = regulator_set_value(dev, 75);
if (ret) {
-   pr_err("Regulator %s value setting error: %d", dev->name, ret);
+   pr_err("Regulator %s value setting error: %d\n", dev->name, 
ret);
return ret;
}
 
ret = regulator_set_value(dev, 330);
if (ret) {
-   pr_err("Regulator %s value setting error: %d", dev->name, ret);
+   pr_err("Regulator %s value setting error: %d\n", dev->name, 
ret);
return ret;
}
 #endif
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/3] gadget: f_thor: fix hang-up with ctrl-c

2018-06-03 Thread Seung-Woo Kim
After the commit 6aae84769a0b ("gadget: f_thor: Fix memory leaks of
usb request and its buffer"), there is hang-up with ctrl-c in some
udc. It is because req of out_ep is freed before out_ep is disabled.
Fix hang-up with ctrl-c by disabling ep before free req of the ep.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/f_thor.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 1aa6be4..8b3b19f 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -877,14 +877,14 @@ static void thor_func_disable(struct usb_function *f)
 
/* Avoid freeing memory when ep is still claimed */
if (dev->in_ep->driver_data) {
-   free_ep_req(dev->in_ep, dev->in_req);
usb_ep_disable(dev->in_ep);
+   free_ep_req(dev->in_ep, dev->in_req);
dev->in_ep->driver_data = NULL;
}
 
if (dev->out_ep->driver_data) {
-   usb_ep_free_request(dev->out_ep, dev->out_req);
usb_ep_disable(dev->out_ep);
+   usb_ep_free_request(dev->out_ep, dev->out_req);
dev->out_ep->driver_data = NULL;
}
 
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] script: Make get_default_envs.sh script exclude tools/env

2018-06-03 Thread Seung-Woo Kim
If building envtools, there is env directory in tools directory.
Mafe the get_default_envs.sh script exclude tools/env directory.

Signed-off-by: Seung-Woo Kim 
---
 scripts/get_default_envs.sh |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/get_default_envs.sh b/scripts/get_default_envs.sh
index 2872653..da86a9d 100755
--- a/scripts/get_default_envs.sh
+++ b/scripts/get_default_envs.sh
@@ -23,7 +23,7 @@ else
 fi
 
 env_obj_file_path=$(find ${path} -path "*/env/*" -not -path "*/spl/*" \
--name "${ENV_OBJ_FILE}")
+-not -path "*/tools/*" -name "${ENV_OBJ_FILE}")
 [ -z "${env_obj_file_path}" ] && \
 { echoerr "File '${ENV_OBJ_FILE}' not found!"; exit 1; }
 
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3] gadget: f_thor: Fix memory leaks of usb request and its buffer

2018-05-24 Thread Seung-Woo Kim
There are memory leaks of usb request and its buffer for ep0,
in_ep, and out ep. Fix memory leaks of usb request and its buffer.

Signed-off-by: Seung-Woo Kim 
---
Change from v2
- replace only once used local function, thor_start_ep(), with generic functions
  as Lukasz commented

Change from v1
- remove allocation of out_ep request instead of allocating and freeing
- fix use error path instead of duplicated error handling code
---
---
 drivers/usb/gadget/f_thor.c |   65 +--
 1 file changed, 32 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index c8eda05..1aa6be4 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -620,22 +620,6 @@ static void thor_rx_tx_complete(struct usb_ep *ep, struct 
usb_request *req)
  status, req->actual, req->length);
 }
 
-static struct usb_request *thor_start_ep(struct usb_ep *ep)
-{
-   struct usb_request *req;
-
-   req = alloc_ep_req(ep, THOR_PACKET_SIZE);
-   debug("%s: ep:%p req:%p\n", __func__, ep, req);
-
-   if (!req)
-   return NULL;
-
-   memset(req->buf, 0, req->length);
-   req->complete = thor_rx_tx_complete;
-
-   return req;
-}
-
 static void thor_setup_complete(struct usb_ep *ep, struct usb_request *req)
 {
if (req->status || req->actual != req->length)
@@ -752,6 +736,13 @@ int thor_handle(void)
return 0;
 }
 
+static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
+{
+   if (req->buf)
+   free(req->buf);
+   usb_ep_free_request(ep, req);
+}
+
 static int thor_func_bind(struct usb_configuration *c, struct usb_function *f)
 {
struct usb_gadget *gadget = c->cdev->gadget;
@@ -860,21 +851,18 @@ static int thor_func_bind(struct usb_configuration *c, 
struct usb_function *f)
return 0;
 
  fail:
+   if (dev->req)
+   free_ep_req(gadget->ep0, dev->req);
free(dev);
return status;
 }
 
-static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
-{
-   free(req->buf);
-   usb_ep_free_request(ep, req);
-}
-
 static void thor_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_thor *f_thor = func_to_thor(f);
struct thor_dev *dev = f_thor->dev;
 
+   free_ep_req(dev->gadget->ep0, dev->req);
free(dev);
memset(thor_func, 0, sizeof(*thor_func));
thor_func = NULL;
@@ -895,8 +883,6 @@ static void thor_func_disable(struct usb_function *f)
}
 
if (dev->out_ep->driver_data) {
-   free(dev->out_req->buf);
-   dev->out_req->buf = NULL;
usb_ep_free_request(dev->out_ep, dev->out_req);
usb_ep_disable(dev->out_ep);
dev->out_ep->driver_data = NULL;
@@ -924,16 +910,17 @@ static int thor_eps_setup(struct usb_function *f)
 
result = usb_ep_enable(ep, d);
if (result)
-   goto exit;
+   goto err;
 
ep->driver_data = cdev; /* claim */
-   req = thor_start_ep(ep);
+   req = alloc_ep_req(ep, THOR_PACKET_SIZE);
if (!req) {
-   usb_ep_disable(ep);
result = -EIO;
-   goto exit;
+   goto err_disable_in_ep;
}
 
+   memset(req->buf, 0, req->length);
+   req->complete = thor_rx_tx_complete;
dev->in_req = req;
ep = dev->out_ep;
d = ep_desc(gadget, &hs_out_desc, &fs_out_desc);
@@ -941,22 +928,34 @@ static int thor_eps_setup(struct usb_function *f)
 
result = usb_ep_enable(ep, d);
if (result)
-   goto exit;
+   goto err_free_in_req;
 
ep->driver_data = cdev; /* claim */
-   req = thor_start_ep(ep);
+   req = usb_ep_alloc_request(ep, 0);
if (!req) {
-   usb_ep_disable(ep);
result = -EIO;
-   goto exit;
+   goto err_disable_out_ep;
}
 
+   req->complete = thor_rx_tx_complete;
dev->out_req = req;
/* ACM control EP */
ep = dev->int_ep;
ep->driver_data = cdev; /* claim */
 
- exit:
+   return 0;
+
+ err_disable_out_ep:
+   usb_ep_disable(dev->out_ep);
+
+ err_free_in_req:
+   free_ep_req(dev->in_ep, dev->in_req);
+   dev->in_req = NULL;
+
+ err_disable_in_ep:
+   usb_ep_disable(dev->in_ep);
+
+ err:
return result;
 }
 
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] gadget: f_thor: Fix memory leaks of usb request and its buffer

2018-05-24 Thread Seung-Woo Kim
Hello Lukasz,

On 2018년 05월 25일 07:52, Lukasz Majewski wrote:
> Hi Seung-Woo,
> 
>> There are memory leaks of usb request and its buffer for ep0,
>> in_ep, and out ep. Fix memory leaks of usb request and its buffer.
>>
>> Signed-off-by: Seung-Woo Kim 
>> ---
>> Change from v1
>> - remove allocation of out_ep request instead of allocating and
>> freeing
>> - fix use error path instead of duplicated error handling code
>> ---
>>  drivers/usb/gadget/f_thor.c |   45
>> --- 1 file changed, 29
>> insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
>> index c8eda05..02d6844 100644
>> --- a/drivers/usb/gadget/f_thor.c
>> +++ b/drivers/usb/gadget/f_thor.c
>> @@ -752,6 +752,13 @@ int thor_handle(void)
>>  return 0;
>>  }
>>  
>> +static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
>> +{
>> +if (req->buf)
>> +free(req->buf);
>> +usb_ep_free_request(ep, req);
>> +}
>> +
>>  static int thor_func_bind(struct usb_configuration *c, struct
>> usb_function *f) {
>>  struct usb_gadget *gadget = c->cdev->gadget;
>> @@ -860,21 +867,18 @@ static int thor_func_bind(struct
>> usb_configuration *c, struct usb_function *f) return 0;
>>  
>>   fail:
>> +if (dev->req)
>> +free_ep_req(gadget->ep0, dev->req);
>>  free(dev);
>>  return status;
>>  }
>>  
>> -static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
>> -{
>> -free(req->buf);
>> -usb_ep_free_request(ep, req);
>> -}
>> -
>>  static void thor_unbind(struct usb_configuration *c, struct
>> usb_function *f) {
>>  struct f_thor *f_thor = func_to_thor(f);
>>  struct thor_dev *dev = f_thor->dev;
>>  
>> +free_ep_req(dev->gadget->ep0, dev->req);
> 
> Till this change - no issues.
> 
>>  free(dev);
>>  memset(thor_func, 0, sizeof(*thor_func));
>>  thor_func = NULL;
>> @@ -895,8 +899,6 @@ static void thor_func_disable(struct usb_function
>> *f) }
>>  
>>  if (dev->out_ep->driver_data) {
>> -free(dev->out_req->buf);
>> -dev->out_req->buf = NULL;
>   
> I think that this setting (to NULL) was needed to be able to ctrl+C
> from thor command and then run it again (as some code checks if buf is
> NULL).

From the comment about usb_ep_free_request(), it frees request object.
So, it looks not required. Actually, dev->out_req = NULL; is more
necessary, but in my test, ctrl-c or thor communication failure also
flow till thor_unbind() where dev is also freed.

> 
>>  usb_ep_free_request(dev->out_ep, dev->out_req);
>>  usb_ep_disable(dev->out_ep);
>>  dev->out_ep->driver_data = NULL;
>> @@ -924,14 +926,13 @@ static int thor_eps_setup(struct usb_function
>> *f) 
>>  result = usb_ep_enable(ep, d);
>>  if (result)
>> -goto exit;
>> +goto err;
>>  
>>  ep->driver_data = cdev; /* claim */
>>  req = thor_start_ep(ep);
>>  if (!req) {
>> -usb_ep_disable(ep);
>>  result = -EIO;
>> -goto exit;
>> +goto err_disable_in_ep;
>>  }
>>  
>>  dev->in_req = req;
>> @@ -941,22 +942,34 @@ static int thor_eps_setup(struct usb_function
>> *f) 
>>  result = usb_ep_enable(ep, d);
>>  if (result)
>> -goto exit;
>> +goto err_free_in_req;
>>  
>>  ep->driver_data = cdev; /* claim */
>> -req = thor_start_ep(ep);
>> +req = usb_ep_alloc_request(ep, 0);
> 
> Is this safe to replace thor_start_ep() - which tunes the ep params -
> with generic function?

It is safe, because there is no tuning ep param. The function has 3
steps including usb_ep_alloc_request() and allocating buffer with
memalign() and setting complete() callback to thor_rx_tx_complete().
For out_req, buffer allocation is not required because buffer for
out_req is always set from thor_set_dma() usually with dfu_buffer before rx.

> 
> ( I do see the req->complete = thor_rx_tx_complete below ).
> 
> If the thor_start_ep can be replaced with generic code, then maybe we
> can remove it?

It is possible to replace in_req case. If you prefer that, I will send
v3 after replacing thor_start_ep() usage with generic functions.

Best Regards,
- Seung-Woo Kim


> 
>>

[U-Boot] [PATCH v2] gadget: f_thor: Fix memory leaks of usb request and its buffer

2018-05-23 Thread Seung-Woo Kim
There are memory leaks of usb request and its buffer for ep0,
in_ep, and out ep. Fix memory leaks of usb request and its buffer.

Signed-off-by: Seung-Woo Kim 
---
Change from v1
- remove allocation of out_ep request instead of allocating and freeing
- fix use error path instead of duplicated error handling code
---
 drivers/usb/gadget/f_thor.c |   45 ---
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index c8eda05..02d6844 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -752,6 +752,13 @@ int thor_handle(void)
return 0;
 }
 
+static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
+{
+   if (req->buf)
+   free(req->buf);
+   usb_ep_free_request(ep, req);
+}
+
 static int thor_func_bind(struct usb_configuration *c, struct usb_function *f)
 {
struct usb_gadget *gadget = c->cdev->gadget;
@@ -860,21 +867,18 @@ static int thor_func_bind(struct usb_configuration *c, 
struct usb_function *f)
return 0;
 
  fail:
+   if (dev->req)
+   free_ep_req(gadget->ep0, dev->req);
free(dev);
return status;
 }
 
-static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
-{
-   free(req->buf);
-   usb_ep_free_request(ep, req);
-}
-
 static void thor_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_thor *f_thor = func_to_thor(f);
struct thor_dev *dev = f_thor->dev;
 
+   free_ep_req(dev->gadget->ep0, dev->req);
free(dev);
memset(thor_func, 0, sizeof(*thor_func));
thor_func = NULL;
@@ -895,8 +899,6 @@ static void thor_func_disable(struct usb_function *f)
}
 
if (dev->out_ep->driver_data) {
-   free(dev->out_req->buf);
-   dev->out_req->buf = NULL;
usb_ep_free_request(dev->out_ep, dev->out_req);
usb_ep_disable(dev->out_ep);
dev->out_ep->driver_data = NULL;
@@ -924,14 +926,13 @@ static int thor_eps_setup(struct usb_function *f)
 
result = usb_ep_enable(ep, d);
if (result)
-   goto exit;
+   goto err;
 
ep->driver_data = cdev; /* claim */
req = thor_start_ep(ep);
if (!req) {
-   usb_ep_disable(ep);
result = -EIO;
-   goto exit;
+   goto err_disable_in_ep;
}
 
dev->in_req = req;
@@ -941,22 +942,34 @@ static int thor_eps_setup(struct usb_function *f)
 
result = usb_ep_enable(ep, d);
if (result)
-   goto exit;
+   goto err_free_in_req;
 
ep->driver_data = cdev; /* claim */
-   req = thor_start_ep(ep);
+   req = usb_ep_alloc_request(ep, 0);
if (!req) {
-   usb_ep_disable(ep);
result = -EIO;
-   goto exit;
+   goto err_disable_out_ep;
}
 
+   req->complete = thor_rx_tx_complete;
dev->out_req = req;
/* ACM control EP */
ep = dev->int_ep;
ep->driver_data = cdev; /* claim */
 
- exit:
+   return 0;
+
+ err_disable_out_ep:
+   usb_ep_disable(dev->out_ep);
+
+ err_free_in_req:
+   free_ep_req(dev->in_ep, dev->in_req);
+   dev->in_req = NULL;
+
+ err_disable_in_ep:
+   usb_ep_disable(dev->in_ep);
+
+ err:
return result;
 }
 
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] gadget: f_thor: Fix memory leaks of usb request and its buffer

2018-05-23 Thread Seung-Woo Kim
There are memory leaks of usb request and its buffer for ep0,
in_ep, and out ep. Fix memory leaks of usb request and its buffer.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/f_thor.c |   34 +-
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index c8eda05..ec8bd50 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -752,6 +752,13 @@ int thor_handle(void)
return 0;
 }
 
+static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
+{
+   if (req->buf)
+   free(req->buf);
+   usb_ep_free_request(ep, req);
+}
+
 static int thor_func_bind(struct usb_configuration *c, struct usb_function *f)
 {
struct usb_gadget *gadget = c->cdev->gadget;
@@ -860,21 +867,18 @@ static int thor_func_bind(struct usb_configuration *c, 
struct usb_function *f)
return 0;
 
  fail:
+   if (dev->req)
+   free_ep_req(gadget->ep0, dev->req);
free(dev);
return status;
 }
 
-static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
-{
-   free(req->buf);
-   usb_ep_free_request(ep, req);
-}
-
 static void thor_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_thor *f_thor = func_to_thor(f);
struct thor_dev *dev = f_thor->dev;
 
+   free_ep_req(dev->gadget->ep0, dev->req);
free(dev);
memset(thor_func, 0, sizeof(*thor_func));
thor_func = NULL;
@@ -895,9 +899,9 @@ static void thor_func_disable(struct usb_function *f)
}
 
if (dev->out_ep->driver_data) {
-   free(dev->out_req->buf);
+   /* buf of out_req is set with thor_set_dma(), so just clear */
dev->out_req->buf = NULL;
-   usb_ep_free_request(dev->out_ep, dev->out_req);
+   free_ep_req(dev->out_ep, dev->out_req);
usb_ep_disable(dev->out_ep);
dev->out_ep->driver_data = NULL;
}
@@ -940,17 +944,29 @@ static int thor_eps_setup(struct usb_function *f)
debug("(d)bEndpointAddress: 0x%x\n", d->bEndpointAddress);
 
result = usb_ep_enable(ep, d);
-   if (result)
+   if (result) {
+   free_ep_req(dev->in_ep, dev->in_req);
+   dev->in_req = NULL;
+   usb_ep_disable(dev->in_ep);
goto exit;
+   }
 
ep->driver_data = cdev; /* claim */
req = thor_start_ep(ep);
if (!req) {
usb_ep_disable(ep);
+   free_ep_req(dev->in_ep, dev->in_req);
+   dev->in_req = NULL;
+   usb_ep_disable(dev->in_ep);
result = -EIO;
goto exit;
}
 
+   /* buf of out_req will be set with thor_set_dma(), so clear it */
+   free(req->buf);
+   req->buf = NULL;
+   req->length = 0;
+
dev->out_req = req;
/* ACM control EP */
ep = dev->int_ep;
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] gadget: f_thor: update to support more than 4GB file as thor 5.0

2018-05-10 Thread Seung-Woo Kim
Hello Lukasz,

On 2018년 05월 10일 19:58, Lukasz Majewski wrote:
> Hi Seung-Woo,
> 
>> During file download, it only uses 32bit variable for file size and
>> it limits maximum file size less than 4GB. Update to support more
>> than 4GB file with using two 32bit variables for file size as thor
>> protocol 5.0.
> 
> I assume that it was also tested that this patch will not break devices
> already using protocol version 4 (like some hobbysts trats2 users, or
> odroid XU3)?

Yes, of course. I have checked all those devices are using THOR protocol
version 4.0 and tested with the devices.

> 
> To be more specific - is the init_data[1] zeroed in the earlier version
> (version 4) of the THOR protocol?

From the thor tool like Tizen lthor[1], it clears all request.

And THOR protocol 5.0 support has also done from Tizen lthor  and it is
currently under review. I have tested THOR protocol 5.0 device with THOR
protocol 4.0 lthor and reserve way also. From lthor with THOR protocol
5.0, I just added to check protocol version of target and if the target
protocol version is less than 5.0 than I made lthor refuse 4GB or larger
file.

[1]: https://git.tizen.org/cgit/tools/lthor

Best Regards,
- Seung-Woo Kim

> 
>>
>> Signed-off-by: Seung-Woo Kim 
>> ---
>>  drivers/usb/gadget/f_thor.c |   10 +++---
>>  drivers/usb/gadget/f_thor.h |2 +-
>>  2 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
>> index 6d38cb6..c8eda05 100644
>> --- a/drivers/usb/gadget/f_thor.c
>> +++ b/drivers/usb/gadget/f_thor.c
>> @@ -262,8 +262,10 @@ static long long int process_rqt_download(const
>> struct rqt_box *rqt) 
>>  switch (rqt->rqt_data) {
>>  case RQT_DL_INIT:
>> -thor_file_size = rqt->int_data[0];
>> -debug("INIT: total %d bytes\n", rqt->int_data[0]);
>> +thor_file_size = (unsigned long long
>> int)rqt->int_data[0] +
>> + (((unsigned long long
>> int)rqt->int_data[1])
>> +  << 32);
>> +debug("INIT: total %llu bytes\n", thor_file_size);
>>  break;
>>  case RQT_DL_FILE_INFO:
>>  file_type = rqt->int_data[0];
>> @@ -274,7 +276,9 @@ static long long int process_rqt_download(const
>> struct rqt_box *rqt) break;
>>  }
>>  
>> -thor_file_size = rqt->int_data[1];
>> +thor_file_size = (unsigned long long
>> int)rqt->int_data[1] +
>> + (((unsigned long long
>> int)rqt->int_data[2])
>> +  << 32);
>>  memcpy(f_name, rqt->str_data[0], F_NAME_BUF_SIZE);
>>  f_name[F_NAME_BUF_SIZE] = '\0';
>>  
>> diff --git a/drivers/usb/gadget/f_thor.h b/drivers/usb/gadget/f_thor.h
>> index 47abc8a..8ba3fa2 100644
>> --- a/drivers/usb/gadget/f_thor.h
>> +++ b/drivers/usb/gadget/f_thor.h
>> @@ -34,7 +34,7 @@ struct usb_cdc_attribute_vendor_descriptor {
>>  __u8 DAUValue;
>>  } __packed;
>>  
>> -#define VER_PROTOCOL_MAJOR  4
>> +#define VER_PROTOCOL_MAJOR  5
>>  #define VER_PROTOCOL_MINOR  0
>>  
>>  enum rqt {
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --
> 
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> 

-- 
Seung-Woo Kim
Samsung Research
--

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/2] gadget: f_thor: update to support more than 4GB file as thor 5.0

2018-05-09 Thread Seung-Woo Kim
During file download, it only uses 32bit variable for file size and
it limits maximum file size less than 4GB. Update to support more
than 4GB file with using two 32bit variables for file size as thor
protocol 5.0.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/f_thor.c |   10 +++---
 drivers/usb/gadget/f_thor.h |2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 6d38cb6..c8eda05 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -262,8 +262,10 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
 
switch (rqt->rqt_data) {
case RQT_DL_INIT:
-   thor_file_size = rqt->int_data[0];
-   debug("INIT: total %d bytes\n", rqt->int_data[0]);
+   thor_file_size = (unsigned long long int)rqt->int_data[0] +
+(((unsigned long long int)rqt->int_data[1])
+ << 32);
+   debug("INIT: total %llu bytes\n", thor_file_size);
break;
case RQT_DL_FILE_INFO:
file_type = rqt->int_data[0];
@@ -274,7 +276,9 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
break;
}
 
-   thor_file_size = rqt->int_data[1];
+   thor_file_size = (unsigned long long int)rqt->int_data[1] +
+(((unsigned long long int)rqt->int_data[2])
+ << 32);
memcpy(f_name, rqt->str_data[0], F_NAME_BUF_SIZE);
f_name[F_NAME_BUF_SIZE] = '\0';
 
diff --git a/drivers/usb/gadget/f_thor.h b/drivers/usb/gadget/f_thor.h
index 47abc8a..8ba3fa2 100644
--- a/drivers/usb/gadget/f_thor.h
+++ b/drivers/usb/gadget/f_thor.h
@@ -34,7 +34,7 @@ struct usb_cdc_attribute_vendor_descriptor {
__u8 DAUValue;
 } __packed;
 
-#define VER_PROTOCOL_MAJOR 4
+#define VER_PROTOCOL_MAJOR 5
 #define VER_PROTOCOL_MINOR 0
 
 enum rqt {
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] gadget: f_thor: fix filename overflow

2018-05-09 Thread Seung-Woo Kim
The thor sender can send filename without null character and it is
used without consideration of overflow. Actually, character array
for filename is assigned with DEFINE_CACHE_ALIGN_BUFFER() and it
is bigger than size of memcpy, so there was no real overflow.
Fix filename overflow for code level integrity.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/f_thor.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index f874509..6d38cb6 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -47,7 +47,7 @@ DEFINE_CACHE_ALIGN_BUFFER(unsigned char, thor_rx_data_buf,
 /* ** */
 /* THOR protocol - transmission handling */
 /* ** */
-DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE);
+DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE + 1);
 static unsigned long long int thor_file_size;
 static int alt_setting_num;
 
@@ -276,6 +276,7 @@ static long long int process_rqt_download(const struct 
rqt_box *rqt)
 
thor_file_size = rqt->int_data[1];
memcpy(f_name, rqt->str_data[0], F_NAME_BUF_SIZE);
+   f_name[F_NAME_BUF_SIZE] = '\0';
 
debug("INFO: name(%s, %d), size(%llu), type(%d)\n",
  f_name, 0, thor_file_size, file_type);
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] spl: spl_mmc: add __maybe_unused to mmc_load_image_raw_sector()

2017-09-18 Thread Seung-Woo Kim
If there are no CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR and CONFIG_SPL_OS_BOOT,
there is unused-function build warning. Add __maybe_unused macro
to remove the warning.

Signed-off-by: Seung-Woo Kim 
---
 common/spl/spl_mmc.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index b26..b57e0b0 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -52,8 +52,9 @@ static ulong h_spl_load_read(struct spl_load_info *load, 
ulong sector,
return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
 }
 
-static int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
-struct mmc *mmc, unsigned long sector)
+static __maybe_unused
+int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
+ struct mmc *mmc, unsigned long sector)
 {
unsigned long count;
struct image_header *header;
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] usb: dwc2: Align size of invalidating dcache before starting DMA

2017-08-31 Thread Seung-Woo Kim
Hello,

This patch was tested with Exynos4412 Odroid-U3 board for THOR usb gadget 
driver.

Best Regards,
- Seung-Woo Kim

> -Original Message-
> From: Seung-Woo Kim [mailto:sw0312@samsung.com]
> Sent: Monday, July 31, 2017 6:08 PM
> To: u-boot@lists.denx.de; lu...@denx.de; ma...@denx.de
> Cc: sw0312@samsung.com; xzy...@rock-chips.com; jh80.ch...@samsung.com
> Subject: [PATCH] usb: dwc2: Align size of invalidating dcache before starting 
> DMA
> 
> During using dwc2 usb gadget, if usb message size is too small,
> following cache misaligned warning is shown:
> 
>CACHE: Misaligned operation at range [bfdbcb00, bfdbcb04]
> 
> Align size of invalidating dcache before starting DMA to remove the
> warning.
> 
> Signed-off-by: Seung-Woo Kim 
> ---
>  drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c |3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c 
> b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> index 0d6d2fb..b6164af 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> @@ -111,7 +111,8 @@ static int setdma_rx(struct dwc2_ep *ep, struct 
> dwc2_request *req)
>   ctrl =  readl(®->out_endp[ep_num].doepctl);
> 
>   invalidate_dcache_range((unsigned long) ep->dma_buf,
> - (unsigned long) ep->dma_buf + ep->len);
> + (unsigned long) ep->dma_buf +
> + ROUND(ep->len, CONFIG_SYS_CACHELINE_SIZE));
> 
>   writel((unsigned int) ep->dma_buf, ®->out_endp[ep_num].doepdma);
>   writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),
> --
> 1.7.9.5


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] usb: dwc2: Align size of invalidating dcache before starting DMA

2017-07-31 Thread Seung-Woo Kim
During using dwc2 usb gadget, if usb message size is too small,
following cache misaligned warning is shown:

   CACHE: Misaligned operation at range [bfdbcb00, bfdbcb04]

Align size of invalidating dcache before starting DMA to remove the
warning.

Signed-off-by: Seung-Woo Kim 
---
 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c 
b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index 0d6d2fb..b6164af 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -111,7 +111,8 @@ static int setdma_rx(struct dwc2_ep *ep, struct 
dwc2_request *req)
ctrl =  readl(®->out_endp[ep_num].doepctl);
 
invalidate_dcache_range((unsigned long) ep->dma_buf,
-   (unsigned long) ep->dma_buf + ep->len);
+   (unsigned long) ep->dma_buf +
+   ROUND(ep->len, CONFIG_SYS_CACHELINE_SIZE));
 
writel((unsigned int) ep->dma_buf, ®->out_endp[ep_num].doepdma);
writel(DOEPT_SIZ_PKT_CNT(pktcnt) | DOEPT_SIZ_XFER_SIZE(length),
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [RESEND][PATCH] mmc: s5p_sdhci: fix to check proper pinmux id

2016-11-24 Thread Seung-Woo Kim
At sdhci_get_config(), there was wrong condition to check pimux
id, so this patch fixes to check proper pinmux id.

Signed-off-by: Seung-Woo Kim 
---
I was not in the mailing list, so I just resend.
---
 drivers/mmc/s5p_sdhci.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
index b329bef..ac737e0 100644
--- a/drivers/mmc/s5p_sdhci.c
+++ b/drivers/mmc/s5p_sdhci.c
@@ -152,7 +152,7 @@ static int sdhci_get_config(const void *blob, int node, 
struct sdhci_host *host)
 
/* Get device id */
dev_id = pinmux_decode_periph_id(blob, node);
-   if (dev_id < PERIPH_ID_SDMMC0 && dev_id > PERIPH_ID_SDMMC3) {
+   if (dev_id < PERIPH_ID_SDMMC0 || dev_id > PERIPH_ID_SDMMC3) {
debug("MMC: Can't get device id\n");
return -EINVAL;
}
-- 
1.7.9.5

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


[U-Boot] [PATCH] mmc: s5p_sdhci: fix to check proper pinmux id

2016-11-24 Thread Seung-Woo Kim
At sdhci_get_config(), there was wrong condition to check pimux
id, so this patch fixes to check proper pinmux id.

Signed-off-by: Seung-Woo Kim 
---
 drivers/mmc/s5p_sdhci.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
index b329bef..ac737e0 100644
--- a/drivers/mmc/s5p_sdhci.c
+++ b/drivers/mmc/s5p_sdhci.c
@@ -152,7 +152,7 @@ static int sdhci_get_config(const void *blob, int node, 
struct sdhci_host *host)
 
/* Get device id */
dev_id = pinmux_decode_periph_id(blob, node);
-   if (dev_id < PERIPH_ID_SDMMC0 && dev_id > PERIPH_ID_SDMMC3) {
+   if (dev_id < PERIPH_ID_SDMMC0 || dev_id > PERIPH_ID_SDMMC3) {
debug("MMC: Can't get device id\n");
return -EINVAL;
}
-- 
1.7.9.5

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