diff mbox

[1/1,linux-next] IB/mthca: use swap() in mthca_make_profile()

Message ID 1433953911-23735-1-git-send-email-fabf@skynet.be (mailing list archive)
State Accepted
Headers show

Commit Message

Fabian Frederick June 10, 2015, 4:31 p.m. UTC
Use kernel.h macro definition.

Thanks to Julia Lawall for Coccinelle scripting support.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 drivers/infiniband/hw/mthca/mthca_profile.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Doug Ledford June 12, 2015, 3:24 p.m. UTC | #1
On 06/10/2015 12:31 PM, Fabian Frederick wrote:
> Use kernel.h macro definition.
> 
> Thanks to Julia Lawall for Coccinelle scripting support.
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>

Thanks, applied.

> ---
>  drivers/infiniband/hw/mthca/mthca_profile.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c
> index 8edb28a..15d0644 100644
> --- a/drivers/infiniband/hw/mthca/mthca_profile.c
> +++ b/drivers/infiniband/hw/mthca/mthca_profile.c
> @@ -77,7 +77,6 @@ s64 mthca_make_profile(struct mthca_dev *dev,
>  	u64 mem_base, mem_avail;
>  	s64 total_size = 0;
>  	struct mthca_resource *profile;
> -	struct mthca_resource tmp;
>  	int i, j;
>  
>  	profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL);
> @@ -136,11 +135,8 @@ s64 mthca_make_profile(struct mthca_dev *dev,
>  	 */
>  	for (i = MTHCA_RES_NUM; i > 0; --i)
>  		for (j = 1; j < i; ++j) {
> -			if (profile[j].size > profile[j - 1].size) {
> -				tmp            = profile[j];
> -				profile[j]     = profile[j - 1];
> -				profile[j - 1] = tmp;
> -			}
> +			if (profile[j].size > profile[j - 1].size)
> +				swap(profile[j], profile[j - 1]);
>  		}
>  
>  	for (i = 0; i < MTHCA_RES_NUM; ++i) {
>
diff mbox

Patch

diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c
index 8edb28a..15d0644 100644
--- a/drivers/infiniband/hw/mthca/mthca_profile.c
+++ b/drivers/infiniband/hw/mthca/mthca_profile.c
@@ -77,7 +77,6 @@  s64 mthca_make_profile(struct mthca_dev *dev,
 	u64 mem_base, mem_avail;
 	s64 total_size = 0;
 	struct mthca_resource *profile;
-	struct mthca_resource tmp;
 	int i, j;
 
 	profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL);
@@ -136,11 +135,8 @@  s64 mthca_make_profile(struct mthca_dev *dev,
 	 */
 	for (i = MTHCA_RES_NUM; i > 0; --i)
 		for (j = 1; j < i; ++j) {
-			if (profile[j].size > profile[j - 1].size) {
-				tmp            = profile[j];
-				profile[j]     = profile[j - 1];
-				profile[j - 1] = tmp;
-			}
+			if (profile[j].size > profile[j - 1].size)
+				swap(profile[j], profile[j - 1]);
 		}
 
 	for (i = 0; i < MTHCA_RES_NUM; ++i) {