* [PATCH] drivers: message: fusion: Simplify rounding
@ 2014-07-01 12:56 Rasmus Villemoes
2014-07-03 17:49 ` Joe Lawrence
2014-08-19 17:12 ` Christoph Hellwig
0 siblings, 2 replies; 6+ messages in thread
From: Rasmus Villemoes @ 2014-07-01 12:56 UTC (permalink / raw)
To: Sreekanth Reddy
Cc: DL-MPTFusionLinux, linux-scsi, linux-kernel, Rasmus Villemoes
Rounding up to a multiple of 4 should be done using the ALIGN
macro. As a bonus, this also makes the generated code smaller.
In GetIocFacts(), sz is assigned to a few lines below without being
read in the meantime, so it is ok that it doesn't end up with the same
value as facts->FWImageSize.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/message/fusion/mptbase.c | 7 +------
drivers/message/fusion/mptctl.c | 7 +------
2 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index ebc0af7..10b16a1 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -3175,12 +3175,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
facts->FWImageSize = le32_to_cpu(facts->FWImageSize);
}
- sz = facts->FWImageSize;
- if ( sz & 0x01 )
- sz += 1;
- if ( sz & 0x02 )
- sz += 2;
- facts->FWImageSize = sz;
+ facts->FWImageSize = ALIGN(facts->FWImageSize, 4);
if (!facts->RequestFrameSize) {
/* Something is wrong! */
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 8a050e8..1004392 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1749,12 +1749,7 @@ mptctl_replace_fw (unsigned long arg)
/* Allocate memory for the new FW image
*/
- newFwSize = karg.newImageSize;
-
- if (newFwSize & 0x01)
- newFwSize += 1;
- if (newFwSize & 0x02)
- newFwSize += 2;
+ newFwSize = ALIGN(karg.newImageSize, 4);
mpt_alloc_fw_memory(ioc, newFwSize);
if (ioc->cached_fw == NULL)
--
1.9.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: message: fusion: Simplify rounding
2014-07-01 12:56 [PATCH] drivers: message: fusion: Simplify rounding Rasmus Villemoes
@ 2014-07-03 17:49 ` Joe Lawrence
2014-08-19 17:12 ` Christoph Hellwig
1 sibling, 0 replies; 6+ messages in thread
From: Joe Lawrence @ 2014-07-03 17:49 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Sreekanth Reddy, DL-MPTFusionLinux, linux-scsi, linux-kernel
ALIGN is certainly more readable to me.
Reviewed-by: Joe Lawrence <joe.lawrence@stratus.com>
-- Joe
On Tue, 1 Jul 2014, Rasmus Villemoes wrote:
> Rounding up to a multiple of 4 should be done using the ALIGN
> macro. As a bonus, this also makes the generated code smaller.
>
> In GetIocFacts(), sz is assigned to a few lines below without being
> read in the meantime, so it is ok that it doesn't end up with the same
> value as facts->FWImageSize.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/message/fusion/mptbase.c | 7 +------
> drivers/message/fusion/mptctl.c | 7 +------
> 2 files changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> index ebc0af7..10b16a1 100644
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -3175,12 +3175,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
> facts->FWImageSize = le32_to_cpu(facts->FWImageSize);
> }
>
> - sz = facts->FWImageSize;
> - if ( sz & 0x01 )
> - sz += 1;
> - if ( sz & 0x02 )
> - sz += 2;
> - facts->FWImageSize = sz;
> + facts->FWImageSize = ALIGN(facts->FWImageSize, 4);
>
> if (!facts->RequestFrameSize) {
> /* Something is wrong! */
> diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
> index 8a050e8..1004392 100644
> --- a/drivers/message/fusion/mptctl.c
> +++ b/drivers/message/fusion/mptctl.c
> @@ -1749,12 +1749,7 @@ mptctl_replace_fw (unsigned long arg)
>
> /* Allocate memory for the new FW image
> */
> - newFwSize = karg.newImageSize;
> -
> - if (newFwSize & 0x01)
> - newFwSize += 1;
> - if (newFwSize & 0x02)
> - newFwSize += 2;
> + newFwSize = ALIGN(karg.newImageSize, 4);
>
> mpt_alloc_fw_memory(ioc, newFwSize);
> if (ioc->cached_fw == NULL)
> --
> 1.9.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: message: fusion: Simplify rounding
@ 2014-07-03 17:49 ` Joe Lawrence
0 siblings, 0 replies; 6+ messages in thread
From: Joe Lawrence @ 2014-07-03 17:49 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Sreekanth Reddy, DL-MPTFusionLinux, linux-scsi, linux-kernel
ALIGN is certainly more readable to me.
Reviewed-by: Joe Lawrence <joe.lawrence@stratus.com>
-- Joe
On Tue, 1 Jul 2014, Rasmus Villemoes wrote:
> Rounding up to a multiple of 4 should be done using the ALIGN
> macro. As a bonus, this also makes the generated code smaller.
>
> In GetIocFacts(), sz is assigned to a few lines below without being
> read in the meantime, so it is ok that it doesn't end up with the same
> value as facts->FWImageSize.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/message/fusion/mptbase.c | 7 +------
> drivers/message/fusion/mptctl.c | 7 +------
> 2 files changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> index ebc0af7..10b16a1 100644
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -3175,12 +3175,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
> facts->FWImageSize = le32_to_cpu(facts->FWImageSize);
> }
>
> - sz = facts->FWImageSize;
> - if ( sz & 0x01 )
> - sz += 1;
> - if ( sz & 0x02 )
> - sz += 2;
> - facts->FWImageSize = sz;
> + facts->FWImageSize = ALIGN(facts->FWImageSize, 4);
>
> if (!facts->RequestFrameSize) {
> /* Something is wrong! */
> diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
> index 8a050e8..1004392 100644
> --- a/drivers/message/fusion/mptctl.c
> +++ b/drivers/message/fusion/mptctl.c
> @@ -1749,12 +1749,7 @@ mptctl_replace_fw (unsigned long arg)
>
> /* Allocate memory for the new FW image
> */
> - newFwSize = karg.newImageSize;
> -
> - if (newFwSize & 0x01)
> - newFwSize += 1;
> - if (newFwSize & 0x02)
> - newFwSize += 2;
> + newFwSize = ALIGN(karg.newImageSize, 4);
>
> mpt_alloc_fw_memory(ioc, newFwSize);
> if (ioc->cached_fw == NULL)
> --
> 1.9.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: message: fusion: Simplify rounding
2014-07-03 17:49 ` Joe Lawrence
@ 2014-08-06 9:11 ` Rasmus Villemoes
-1 siblings, 0 replies; 6+ messages in thread
From: Rasmus Villemoes @ 2014-08-06 9:11 UTC (permalink / raw)
To: Joe Lawrence; +Cc: Sreekanth Reddy, DL-MPTFusionLinux, linux-scsi, linux-kernel
Joe Lawrence <joe.lawrence@stratus.com> writes:
> On Tue, 1 Jul 2014, Rasmus Villemoes wrote:
>
>> Rounding up to a multiple of 4 should be done using the ALIGN
>> macro. As a bonus, this also makes the generated code smaller.
>>
>> In GetIocFacts(), sz is assigned to a few lines below without being
>> read in the meantime, so it is ok that it doesn't end up with the same
>> value as facts->FWImageSize.
>>
>> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>> ---
>> drivers/message/fusion/mptbase.c | 7 +------
>> drivers/message/fusion/mptctl.c | 7 +------
>> 2 files changed, 2 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
>> index ebc0af7..10b16a1 100644
>> --- a/drivers/message/fusion/mptbase.c
>> +++ b/drivers/message/fusion/mptbase.c
>> @@ -3175,12 +3175,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
>> facts->FWImageSize = le32_to_cpu(facts->FWImageSize);
>> }
>>
>> - sz = facts->FWImageSize;
>> - if ( sz & 0x01 )
>> - sz += 1;
>> - if ( sz & 0x02 )
>> - sz += 2;
>> - facts->FWImageSize = sz;
>> + facts->FWImageSize = ALIGN(facts->FWImageSize, 4);
>>
>> if (!facts->RequestFrameSize) {
>> /* Something is wrong! */
>> diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
>> index 8a050e8..1004392 100644
>> --- a/drivers/message/fusion/mptctl.c
>> +++ b/drivers/message/fusion/mptctl.c
>> @@ -1749,12 +1749,7 @@ mptctl_replace_fw (unsigned long arg)
>>
>> /* Allocate memory for the new FW image
>> */
>> - newFwSize = karg.newImageSize;
>> -
>> - if (newFwSize & 0x01)
>> - newFwSize += 1;
>> - if (newFwSize & 0x02)
>> - newFwSize += 2;
>> + newFwSize = ALIGN(karg.newImageSize, 4);
>>
>> mpt_alloc_fw_memory(ioc, newFwSize);
>> if (ioc->cached_fw == NULL)
>
> ALIGN is certainly more readable to me.
>
> Reviewed-by: Joe Lawrence <joe.lawrence@stratus.com>
>
> -- Joe
Did anyone pick this up?
Thanks,
Rasmus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: message: fusion: Simplify rounding
@ 2014-08-06 9:11 ` Rasmus Villemoes
0 siblings, 0 replies; 6+ messages in thread
From: Rasmus Villemoes @ 2014-08-06 9:11 UTC (permalink / raw)
To: Joe Lawrence; +Cc: Sreekanth Reddy, DL-MPTFusionLinux, linux-scsi, linux-kernel
Joe Lawrence <joe.lawrence@stratus.com> writes:
> On Tue, 1 Jul 2014, Rasmus Villemoes wrote:
>
>> Rounding up to a multiple of 4 should be done using the ALIGN
>> macro. As a bonus, this also makes the generated code smaller.
>>
>> In GetIocFacts(), sz is assigned to a few lines below without being
>> read in the meantime, so it is ok that it doesn't end up with the same
>> value as facts->FWImageSize.
>>
>> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>> ---
>> drivers/message/fusion/mptbase.c | 7 +------
>> drivers/message/fusion/mptctl.c | 7 +------
>> 2 files changed, 2 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
>> index ebc0af7..10b16a1 100644
>> --- a/drivers/message/fusion/mptbase.c
>> +++ b/drivers/message/fusion/mptbase.c
>> @@ -3175,12 +3175,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
>> facts->FWImageSize = le32_to_cpu(facts->FWImageSize);
>> }
>>
>> - sz = facts->FWImageSize;
>> - if ( sz & 0x01 )
>> - sz += 1;
>> - if ( sz & 0x02 )
>> - sz += 2;
>> - facts->FWImageSize = sz;
>> + facts->FWImageSize = ALIGN(facts->FWImageSize, 4);
>>
>> if (!facts->RequestFrameSize) {
>> /* Something is wrong! */
>> diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
>> index 8a050e8..1004392 100644
>> --- a/drivers/message/fusion/mptctl.c
>> +++ b/drivers/message/fusion/mptctl.c
>> @@ -1749,12 +1749,7 @@ mptctl_replace_fw (unsigned long arg)
>>
>> /* Allocate memory for the new FW image
>> */
>> - newFwSize = karg.newImageSize;
>> -
>> - if (newFwSize & 0x01)
>> - newFwSize += 1;
>> - if (newFwSize & 0x02)
>> - newFwSize += 2;
>> + newFwSize = ALIGN(karg.newImageSize, 4);
>>
>> mpt_alloc_fw_memory(ioc, newFwSize);
>> if (ioc->cached_fw == NULL)
>
> ALIGN is certainly more readable to me.
>
> Reviewed-by: Joe Lawrence <joe.lawrence@stratus.com>
>
> -- Joe
Did anyone pick this up?
Thanks,
Rasmus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drivers: message: fusion: Simplify rounding
2014-07-01 12:56 [PATCH] drivers: message: fusion: Simplify rounding Rasmus Villemoes
2014-07-03 17:49 ` Joe Lawrence
@ 2014-08-19 17:12 ` Christoph Hellwig
1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2014-08-19 17:12 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Sreekanth Reddy, DL-MPTFusionLinux, linux-scsi, linux-kernel
On Tue, Jul 01, 2014 at 02:56:20PM +0200, Rasmus Villemoes wrote:
> Rounding up to a multiple of 4 should be done using the ALIGN
> macro. As a bonus, this also makes the generated code smaller.
>
> In GetIocFacts(), sz is assigned to a few lines below without being
> read in the meantime, so it is ok that it doesn't end up with the same
> value as facts->FWImageSize.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Reviewed-by: Joe Lawrence <joe.lawrence@stratus.com>
Thanks, applied to the drivers-for-3.18 branch.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-08-19 17:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-01 12:56 [PATCH] drivers: message: fusion: Simplify rounding Rasmus Villemoes
2014-07-03 17:49 ` Joe Lawrence
2014-07-03 17:49 ` Joe Lawrence
2014-08-06 9:11 ` Rasmus Villemoes
2014-08-06 9:11 ` Rasmus Villemoes
2014-08-19 17:12 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.