Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-10 Thread Ivan Safonov

On 11/09/2015 03:24 AM, Andy Shevchenko wrote:

On Sun, Nov 8, 2015 at 1:26 PM, Ivan Safonov  wrote:

On 11/08/2015 05:11 PM, Andy Shevchenko wrote:

On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:

Ideally the function should not change the variables outside of its body.
-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
   {
  u32 i;

-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
  pfwbuf[i] = 0;

memset() ?


-   *pfwlen = i;
+   return i;
   }

   static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt,
u8 *buffer, u32 size)
  u32 page_no, remain;
  u32 page, offset;

-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);



memset applied in another patch. Here only replacement of the function type.

Since it's used only once it would be nice to replace it by plain
memset() in one patch.



I doubt its usefulness.
Perhaps, this function is not needed because firmware copied byte by byte.
It is function for firmware uploading (I don't know why it is so 
written, but in the case of the size of the firmware a multiple of 4, it 
can be easier):

static void _rtl88e_fw_block_write(struct adapter *adapt,
   const u8 *buffer, u32 size)
{
u32 blk_sz = sizeof(u32);
const u8 *byte_buffer;
const u32 *dword_buffer = (u32 *)buffer;
u32 i, write_address, blk_cnt, remain;

blk_cnt = size / blk_sz;
remain = size % blk_sz;

write_address = FW_8192C_START_ADDRESS;

for (i = 0; i < blk_cnt; i++, write_address += blk_sz)
usb_write32(adapt, write_address, dword_buffer[i]);

byte_buffer = buffer + blk_cnt * blk_sz;
for (i = 0; i < remain; i++, write_address++)
usb_write8(adapt, write_address, byte_buffer[i]);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-10 Thread Ivan Safonov

On 11/09/2015 03:24 AM, Andy Shevchenko wrote:

On Sun, Nov 8, 2015 at 1:26 PM, Ivan Safonov  wrote:

On 11/08/2015 05:11 PM, Andy Shevchenko wrote:

On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:

Ideally the function should not change the variables outside of its body.
-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
   {
  u32 i;

-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
  pfwbuf[i] = 0;

memset() ?


-   *pfwlen = i;
+   return i;
   }

   static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt,
u8 *buffer, u32 size)
  u32 page_no, remain;
  u32 page, offset;

-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);



memset applied in another patch. Here only replacement of the function type.

Since it's used only once it would be nice to replace it by plain
memset() in one patch.



I doubt its usefulness.
Perhaps, this function is not needed because firmware copied byte by byte.
It is function for firmware uploading (I don't know why it is so 
written, but in the case of the size of the firmware a multiple of 4, it 
can be easier):

static void _rtl88e_fw_block_write(struct adapter *adapt,
   const u8 *buffer, u32 size)
{
u32 blk_sz = sizeof(u32);
const u8 *byte_buffer;
const u32 *dword_buffer = (u32 *)buffer;
u32 i, write_address, blk_cnt, remain;

blk_cnt = size / blk_sz;
remain = size % blk_sz;

write_address = FW_8192C_START_ADDRESS;

for (i = 0; i < blk_cnt; i++, write_address += blk_sz)
usb_write32(adapt, write_address, dword_buffer[i]);

byte_buffer = buffer + blk_cnt * blk_sz;
for (i = 0; i < remain; i++, write_address++)
usb_write8(adapt, write_address, byte_buffer[i]);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-08 Thread Andy Shevchenko
On Sun, Nov 8, 2015 at 1:26 PM, Ivan Safonov  wrote:
> On 11/08/2015 05:11 PM, Andy Shevchenko wrote:
>>
>> On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:
>>>
>>> Ideally the function should not change the variables outside of its body.

>>> -static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
>>> +static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
>>>   {
>>>  u32 i;
>>>
>>> -   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
>>> +   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
>>>  pfwbuf[i] = 0;
>>
>> memset() ?
>>
>>> -   *pfwlen = i;
>>> +   return i;
>>>   }
>>>
>>>   static void _rtl88e_fw_page_write(struct adapter *adapt,
>>> @@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt,
>>> u8 *buffer, u32 size)
>>>  u32 page_no, remain;
>>>  u32 page, offset;
>>>
>>> -   _rtl88e_fill_dummy(buf_ptr, );
>>> +   size = _rtl88e_fill_dummy(buf_ptr, size);


> memset applied in another patch. Here only replacement of the function type.

Since it's used only once it would be nice to replace it by plain
memset() in one patch.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-08 Thread Ivan Safonov

On 11/08/2015 05:11 PM, Andy Shevchenko wrote:

On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:

Ideally the function should not change the variables outside of its body.

Signed-off-by: Ivan Safonov 
---
  drivers/staging/rtl8188eu/hal/fw.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 4d72537..5b569ef 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
 usb_write8(adapt, write_address, byte_buffer[i]);
  }

-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
  {
 u32 i;

-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
 pfwbuf[i] = 0;

memset() ?


-   *pfwlen = i;
+   return i;
  }

  static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
*buffer, u32 size)
 u32 page_no, remain;
 u32 page, offset;

-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);

 page_no = size / FW_8192C_PAGE_SIZE;
 remain = size % FW_8192C_PAGE_SIZE;
--
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


memset applied in another patch. Here only replacement of the function type.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-08 Thread Andy Shevchenko
On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:
> Ideally the function should not change the variables outside of its body.
>
> Signed-off-by: Ivan Safonov 
> ---
>  drivers/staging/rtl8188eu/hal/fw.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
> b/drivers/staging/rtl8188eu/hal/fw.c
> index 4d72537..5b569ef 100644
> --- a/drivers/staging/rtl8188eu/hal/fw.c
> +++ b/drivers/staging/rtl8188eu/hal/fw.c
> @@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
> usb_write8(adapt, write_address, byte_buffer[i]);
>  }
>
> -static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
> +static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
>  {
> u32 i;
>
> -   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
> +   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
> pfwbuf[i] = 0;

memset() ?

>
> -   *pfwlen = i;
> +   return i;
>  }
>
>  static void _rtl88e_fw_page_write(struct adapter *adapt,
> @@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
> *buffer, u32 size)
> u32 page_no, remain;
> u32 page, offset;
>
> -   _rtl88e_fill_dummy(buf_ptr, );
> +   size = _rtl88e_fill_dummy(buf_ptr, size);
>
> page_no = size / FW_8192C_PAGE_SIZE;
> remain = size % FW_8192C_PAGE_SIZE;
> --
> 2.4.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-08 Thread Andy Shevchenko
On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:
> Ideally the function should not change the variables outside of its body.
>
> Signed-off-by: Ivan Safonov 
> ---
>  drivers/staging/rtl8188eu/hal/fw.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
> b/drivers/staging/rtl8188eu/hal/fw.c
> index 4d72537..5b569ef 100644
> --- a/drivers/staging/rtl8188eu/hal/fw.c
> +++ b/drivers/staging/rtl8188eu/hal/fw.c
> @@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
> usb_write8(adapt, write_address, byte_buffer[i]);
>  }
>
> -static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
> +static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
>  {
> u32 i;
>
> -   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
> +   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
> pfwbuf[i] = 0;

memset() ?

>
> -   *pfwlen = i;
> +   return i;
>  }
>
>  static void _rtl88e_fw_page_write(struct adapter *adapt,
> @@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
> *buffer, u32 size)
> u32 page_no, remain;
> u32 page, offset;
>
> -   _rtl88e_fill_dummy(buf_ptr, );
> +   size = _rtl88e_fill_dummy(buf_ptr, size);
>
> page_no = size / FW_8192C_PAGE_SIZE;
> remain = size % FW_8192C_PAGE_SIZE;
> --
> 2.4.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-08 Thread Ivan Safonov

On 11/08/2015 05:11 PM, Andy Shevchenko wrote:

On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:

Ideally the function should not change the variables outside of its body.

Signed-off-by: Ivan Safonov 
---
  drivers/staging/rtl8188eu/hal/fw.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 4d72537..5b569ef 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
 usb_write8(adapt, write_address, byte_buffer[i]);
  }

-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
  {
 u32 i;

-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
 pfwbuf[i] = 0;

memset() ?


-   *pfwlen = i;
+   return i;
  }

  static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
*buffer, u32 size)
 u32 page_no, remain;
 u32 page, offset;

-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);

 page_no = size / FW_8192C_PAGE_SIZE;
 remain = size % FW_8192C_PAGE_SIZE;
--
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


memset applied in another patch. Here only replacement of the function type.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-08 Thread Andy Shevchenko
On Sun, Nov 8, 2015 at 1:26 PM, Ivan Safonov  wrote:
> On 11/08/2015 05:11 PM, Andy Shevchenko wrote:
>>
>> On Sun, Nov 8, 2015 at 8:37 AM, Ivan Safonov  wrote:
>>>
>>> Ideally the function should not change the variables outside of its body.

>>> -static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
>>> +static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
>>>   {
>>>  u32 i;
>>>
>>> -   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
>>> +   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
>>>  pfwbuf[i] = 0;
>>
>> memset() ?
>>
>>> -   *pfwlen = i;
>>> +   return i;
>>>   }
>>>
>>>   static void _rtl88e_fw_page_write(struct adapter *adapt,
>>> @@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt,
>>> u8 *buffer, u32 size)
>>>  u32 page_no, remain;
>>>  u32 page, offset;
>>>
>>> -   _rtl88e_fill_dummy(buf_ptr, );
>>> +   size = _rtl88e_fill_dummy(buf_ptr, size);


> memset applied in another patch. Here only replacement of the function type.

Since it's used only once it would be nice to replace it by plain
memset() in one patch.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-07 Thread Ivan Safonov
Ideally the function should not change the variables outside of its body.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 4d72537..5b569ef 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
usb_write8(adapt, write_address, byte_buffer[i]);
 }
 
-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
 {
u32 i;
 
-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
pfwbuf[i] = 0;
 
-   *pfwlen = i;
+   return i;
 }
 
 static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
*buffer, u32 size)
u32 page_no, remain;
u32 page, offset;
 
-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);
 
page_no = size / FW_8192C_PAGE_SIZE;
remain = size % FW_8192C_PAGE_SIZE;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/12] staging: rtl8188eu: return value and argument types changed in _rtl88e_write_fw function

2015-11-07 Thread Ivan Safonov
Ideally the function should not change the variables outside of its body.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/hal/fw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/fw.c 
b/drivers/staging/rtl8188eu/hal/fw.c
index 4d72537..5b569ef 100644
--- a/drivers/staging/rtl8188eu/hal/fw.c
+++ b/drivers/staging/rtl8188eu/hal/fw.c
@@ -75,14 +75,14 @@ static void _rtl88e_fw_block_write(struct adapter *adapt,
usb_write8(adapt, write_address, byte_buffer[i]);
 }
 
-static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen)
+static u32 _rtl88e_fill_dummy(u8 *pfwbuf, u32 pfwlen)
 {
u32 i;
 
-   for (i = *pfwlen; i < roundup(*pfwlen, 4); i++)
+   for (i = pfwlen; i < roundup(pfwlen, 4); i++)
pfwbuf[i] = 0;
 
-   *pfwlen = i;
+   return i;
 }
 
 static void _rtl88e_fw_page_write(struct adapter *adapt,
@@ -103,7 +103,7 @@ static void _rtl88e_write_fw(struct adapter *adapt, u8 
*buffer, u32 size)
u32 page_no, remain;
u32 page, offset;
 
-   _rtl88e_fill_dummy(buf_ptr, );
+   size = _rtl88e_fill_dummy(buf_ptr, size);
 
page_no = size / FW_8192C_PAGE_SIZE;
remain = size % FW_8192C_PAGE_SIZE;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/