From: Dan Carpenter <dan.carpenter@oracle.com>
To: Igal Liberman <igal.liberman@freescale.com>
Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>
Subject: [patch -next] fsl/fman: use the ALIGN() macro
Date: Wed, 6 Jan 2016 13:03:08 +0300 [thread overview]
Message-ID: <20160106100308.GE23185@mwanda> (raw)
The original code works fine but the issue is that static checkers
complain about this:
~(u16)(OFFSET_UNITS - 1)
In that expression the cast to u16 is a no-op because we cast the value
15 to a u16 but then type promotion rules automatically cast it back to
an int and then we do the bitwise negate.
It's cleaner to use the kernel's ALIGN() macro instead.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I think this patch is correct, but I haven't tested it, so please review
carefully.
diff --git a/drivers/net/ethernet/freescale/fman/fman_sp.c b/drivers/net/ethernet/freescale/fman/fman_sp.c
index f9e7aa3..b527da1 100644
--- a/drivers/net/ethernet/freescale/fman/fman_sp.c
+++ b/drivers/net/ethernet/freescale/fman/fman_sp.c
@@ -92,11 +92,8 @@ int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy *
u32 tmp;
/* Align start of internal context data to 16 byte */
- int_context_data_copy->ext_buf_offset = (u16)
- ((buffer_prefix_content->priv_data_size & (OFFSET_UNITS - 1)) ?
- ((buffer_prefix_content->priv_data_size + OFFSET_UNITS) &
- ~(u16)(OFFSET_UNITS - 1)) :
- buffer_prefix_content->priv_data_size);
+ int_context_data_copy->ext_buf_offset =
+ (u16)ALIGN(buffer_prefix_content->priv_data_size, 16);
/* Translate margin and int_context params to FM parameters */
/* Initialize with illegal value. Later we'll set legal values. */
next reply other threads:[~2016-01-06 10:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-06 10:03 Dan Carpenter [this message]
2016-01-06 20:27 ` [patch -next] fsl/fman: use the ALIGN() macro David Miller
2016-01-06 20:35 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160106100308.GE23185@mwanda \
--to=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=igal.liberman@freescale.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).