diff mbox

[1/2] can: bfin_can: simplify xmit id1 setup

Message ID 1308861380-27485-1-git-send-email-vapier@gentoo.org
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Mike Frysinger June 23, 2011, 8:36 p.m. UTC
If we look closely, the 4 writes to TRANSMIT_CHL.id1 can be collapsed
down into much simpler code.  So do just that.

This also fixes a build failure due to the I/O macros no longer
getting pulled in.  Their minor (and accidental) usage here gets
dropped as part of the unification.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 drivers/net/can/bfin_can.c |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)

Comments

Hartkopp, Oliver, Dr. (EESC/5) June 24, 2011, 10:46 a.m. UTC | #1
Am 23.06.2011 22:36, schrieb Mike Frysinger:
> If we look closely, the 4 writes to TRANSMIT_CHL.id1 can be collapsed
> down into much simpler code.  So do just that.

Hello Mike,

unfortunately you addressed the wrong people to ack your patch.

In MAINTAINERS there are entries for the CAN NETWORK LAYER and for CAN 
NETWORK DRIVERS which addresses the code in drivers/net/can/...

Additionally you should address your patch to the author of the driver 
(Barry Song <21cnbao@gmail.com>).

Tnx & best regards,
Oliver



>
> This also fixes a build failure due to the I/O macros no longer
> getting pulled in.  Their minor (and accidental) usage here gets
> dropped as part of the unification.
>
> Signed-off-by: Mike Frysinger<vapier@gentoo.org>
> ---
>   drivers/net/can/bfin_can.c |   21 ++++++---------------
>   1 files changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
> index b6e890d..dc6ef4a 100644
> --- a/drivers/net/can/bfin_can.c
> +++ b/drivers/net/can/bfin_can.c
> @@ -243,21 +243,12 @@ static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev)
>   	/* fill id */
>   	if (id&  CAN_EFF_FLAG) {
>   		bfin_write16(&reg->chl[TRANSMIT_CHL].id0, id);
> -		if (id&  CAN_RTR_FLAG)
> -			writew(((id&  0x1FFF0000)>>  16) | IDE | AME | RTR,
> -					&reg->chl[TRANSMIT_CHL].id1);
> -		else
> -			writew(((id&  0x1FFF0000)>>  16) | IDE | AME,
> -					&reg->chl[TRANSMIT_CHL].id1);
> -
> -	} else {
> -		if (id&  CAN_RTR_FLAG)
> -			writew((id<<  2) | AME | RTR,
> -				&reg->chl[TRANSMIT_CHL].id1);
> -		else
> -			bfin_write16(&reg->chl[TRANSMIT_CHL].id1,
> -					(id<<  2) | AME);
> -	}
> +		val = ((id&  0x1FFF0000)>>  16) | IDE;
> +	} else
> +		val = (id<<  2);
> +	if (id&  CAN_RTR_FLAG)
> +		val |= RTR;
> +	bfin_write16(&reg->chl[TRANSMIT_CHL].id1, val | AME);
>
>   	/* fill payload */
>   	for (i = 0; i<  8; i += 2) {

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mike Frysinger June 24, 2011, 2:32 p.m. UTC | #2
On Fri, Jun 24, 2011 at 06:46, Oliver Hartkopp wrote:
> In MAINTAINERS there are entries for the CAN NETWORK LAYER and for CAN
> NETWORK DRIVERS which addresses the code in drivers/net/can/...

hmm, wonder when this changed.  oh well, updated local .git/mail now.

> Additionally you should address your patch to the author of the driver
> (Barry Song <21cnbao@gmail.com>).

he's already in the cc list.  he's an ADI employee (like me) who
watches the Blackfin mailing lists.
-mike
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
index b6e890d..dc6ef4a 100644
--- a/drivers/net/can/bfin_can.c
+++ b/drivers/net/can/bfin_can.c
@@ -243,21 +243,12 @@  static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	/* fill id */
 	if (id & CAN_EFF_FLAG) {
 		bfin_write16(&reg->chl[TRANSMIT_CHL].id0, id);
-		if (id & CAN_RTR_FLAG)
-			writew(((id & 0x1FFF0000) >> 16) | IDE | AME | RTR,
-					&reg->chl[TRANSMIT_CHL].id1);
-		else
-			writew(((id & 0x1FFF0000) >> 16) | IDE | AME,
-					&reg->chl[TRANSMIT_CHL].id1);
-
-	} else {
-		if (id & CAN_RTR_FLAG)
-			writew((id << 2) | AME | RTR,
-				&reg->chl[TRANSMIT_CHL].id1);
-		else
-			bfin_write16(&reg->chl[TRANSMIT_CHL].id1,
-					(id << 2) | AME);
-	}
+		val = ((id & 0x1FFF0000) >> 16) | IDE;
+	} else
+		val = (id << 2);
+	if (id & CAN_RTR_FLAG)
+		val |= RTR;
+	bfin_write16(&reg->chl[TRANSMIT_CHL].id1, val | AME);
 
 	/* fill payload */
 	for (i = 0; i < 8; i += 2) {