From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Benedikt Spranger <b.spranger@linutronix.de>
Cc: netdev@vger.kernel.org,
Alexander Frank <Alexander.Frank@eberspaecher.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Holger Dengler <dengler@linutronix.de>
Subject: Re: [PATCH 03/16] c_can: simplify arbitration register handling
Date: Mon, 09 Sep 2013 11:16:26 +0200 [thread overview]
Message-ID: <522D91EA.3020302@pengutronix.de> (raw)
In-Reply-To: <1378711513-2548-4-git-send-email-b.spranger@linutronix.de>
[-- Attachment #1: Type: text/plain, Size: 4042 bytes --]
On 09/09/2013 09:25 AM, Benedikt Spranger wrote:
> The IF1/2 Arbitration register of the C_CAN/D_CAN ip core is internaly
> a 32bit register. Do not use two different 16bit variables to handle
> the IF1/2 Arbitration register.
>
> Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
Looks good, nitpit inline.
Marc
> ---
> drivers/net/can/c_can/c_can.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
> index 081620b..bdb7bcd 100644
> --- a/drivers/net/can/c_can/c_can.c
> +++ b/drivers/net/can/c_can/c_can.c
> @@ -117,9 +117,9 @@
> IF_COMM_DATAA | IF_COMM_DATAB)
>
> /* IFx arbitration */
> -#define IF_ARB_MSGVAL BIT(15)
> -#define IF_ARB_MSGXTD BIT(14)
> -#define IF_ARB_TRANSMIT BIT(13)
> +#define IF_ARB_MSGVAL BIT(31)
> +#define IF_ARB_MSGXTD BIT(30)
> +#define IF_ARB_TRANSMIT BIT(29)
>
> /* IFx message control */
> #define IF_MCONT_NEWDAT BIT(15)
> @@ -133,6 +133,7 @@
> #define IF_MCONT_TXRQST BIT(8)
> #define IF_MCONT_EOB BIT(7)
> #define IF_MCONT_DLC_MASK 0xf
> +#define IF_MCONT_DLC_MAX 8
It's not used, is it?
>
> /*
> * IFx register masks:
> @@ -336,7 +337,7 @@ static void c_can_write_msg_object(struct net_device *dev,
> int iface, struct can_frame *frame, int objno)
> {
> int i;
> - u16 flags = 0;
> + u32 flags = IF_ARB_MSGVAL;
> unsigned int id;
> struct c_can_priv *priv = netdev_priv(dev);
>
> @@ -349,11 +350,11 @@ static void c_can_write_msg_object(struct net_device *dev,
> } else
> id = ((frame->can_id & CAN_SFF_MASK) << 18);
>
> - flags |= IF_ARB_MSGVAL;
> + id |= flags;
>
> priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface),
> IFX_WRITE_LOW_16BIT(id));
> - priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), flags |
> + priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface),
> IFX_WRITE_HIGH_16BIT(id));
>
> for (i = 0; i < frame->can_dlc; i += 2) {
> @@ -439,7 +440,7 @@ static void c_can_handle_lost_msg_obj(struct net_device *dev,
>
> static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl)
> {
> - u16 flags, data;
> + u16 data;
> int i;
> unsigned int val;
> struct c_can_priv *priv = netdev_priv(dev);
> @@ -455,16 +456,15 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl)
>
> frame->can_dlc = get_can_dlc(ctrl & 0x0F);
>
> - flags = priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface));
> - val = priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface)) |
> - (flags << 16);
> + val = (priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface)) << 16);
> + val |= priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface));
>
> - if (flags & IF_ARB_MSGXTD)
> + if (val & IF_ARB_MSGXTD)
> frame->can_id = (val & CAN_EFF_MASK) | CAN_EFF_FLAG;
> else
> frame->can_id = (val >> 18) & CAN_SFF_MASK;
>
> - if (flags & IF_ARB_TRANSMIT)
> + if (val & IF_ARB_TRANSMIT)
> frame->can_id |= CAN_RTR_FLAG;
> else {
> for (i = 0; i < frame->can_dlc; i += 2) {
> @@ -500,10 +500,11 @@ static void c_can_setup_receive_object(struct net_device *dev, int iface,
> priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface),
> IFX_WRITE_HIGH_16BIT(mask) | BIT(13));
>
> + id |= IF_ARB_MSGVAL;
> priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface),
> IFX_WRITE_LOW_16BIT(id));
> priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface),
> - (IF_ARB_MSGVAL | IFX_WRITE_HIGH_16BIT(id)));
> + (IFX_WRITE_HIGH_16BIT(id)));
>
> priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), mcont);
> c_can_object_put(dev, iface, objno, IF_COMM_ALL & ~IF_COMM_TXRQST);
>
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2013-09-09 9:16 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-09 7:24 [PATCH 00/16] Support for Eberspächer Flexcard DCAN function Benedikt Spranger
2013-09-09 7:24 ` [PATCH 01/16] c_can_platform: add FlexCard D-CAN support Benedikt Spranger
2013-09-09 8:22 ` Marc Kleine-Budde
2013-09-09 7:24 ` [PATCH 02/16] c_can: add generic D-CAN RAM initialization support Benedikt Spranger
2013-09-09 8:34 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 03/16] c_can: simplify arbitration register handling Benedikt Spranger
2013-09-09 9:16 ` Marc Kleine-Budde [this message]
2013-09-09 7:25 ` [PATCH 04/16] c_can: fix receive buffer configuration Benedikt Spranger
2013-09-09 10:51 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 05/16] c_can: use 32 bit access for D_CAN Benedikt Spranger
2013-09-09 9:37 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 06/16] c_can: consider set bittiming may fail Benedikt Spranger
2013-09-09 9:39 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 07/16] c_can: reconfigre message objects after leaving init state Benedikt Spranger
2013-09-09 7:25 ` [PATCH 08/16] c_can: Add FlexCard CAN TX fifo support Benedikt Spranger
2013-09-09 9:47 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 09/16] c_can: expicit 32bit access on D_CAN to message buffer data register Benedikt Spranger
2013-09-09 11:20 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 10/16] c_can: add 16bit align 32bit access functions Benedikt Spranger
2013-09-09 9:57 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 11/16] c_can: stop netqueue if hardware is busy Benedikt Spranger
2013-09-09 10:05 ` Marc Kleine-Budde
2013-09-09 10:21 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 12/16] c_can: Add flag to disable automatic retransmission of CAN frames Benedikt Spranger
2013-09-09 10:21 ` Marc Kleine-Budde
2013-09-09 10:34 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 13/16] c_can: flexcard: add ioctl to reset FIFO message object Benedikt Spranger
2013-09-09 10:24 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 14/16] flexcard: can: CAN local loopback using SKB pflags Benedikt Spranger
2013-09-09 7:25 ` [PATCH 15/16] flexcard: can: Configure CAN loopback packages (TXACK) Benedikt Spranger
2013-09-09 10:29 ` Marc Kleine-Budde
2013-09-09 7:25 ` [PATCH 16/16] c_can: fix TX packet accounting Benedikt Spranger
2013-09-09 10:31 ` Marc Kleine-Budde
2013-09-09 7:54 ` [PATCH 00/16] Support for Eberspächer Flexcard DCAN function Marc Kleine-Budde
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=522D91EA.3020302@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=Alexander.Frank@eberspaecher.com \
--cc=b.spranger@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=dengler@linutronix.de \
--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).