From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Subject: [PATCH 6/7] can: mcp251x: define helper functions mcp251x_is_2510, mcp251x_is_2515
Date: Fri, 15 Oct 2010 12:49:21 +0200 [thread overview]
Message-ID: <1287139762-23356-7-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1287139762-23356-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
drivers/net/can/mcp251x.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f5e2edd..28281f9 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -252,6 +252,16 @@ struct mcp251x_priv {
int restart_tx;
};
+#define MCP251X_IS(_model) \
+static inline int mcp251x_is_##_model(struct spi_device *spi) \
+{ \
+ struct mcp251x_platform_data *pdata = spi->dev.platform_data; \
+ return pdata->model == CAN_MCP251X_MCP##_model; \
+}
+
+MCP251X_IS(2510);
+MCP251X_IS(2515);
+
static void mcp251x_clean(struct net_device *net)
{
struct mcp251x_priv *priv = netdev_priv(net);
@@ -362,10 +372,9 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg,
static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf,
int len, int tx_buf_idx)
{
- struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
- if (pdata->model == CAN_MCP251X_MCP2510) {
+ if (mcp251x_is_2510(spi)) {
int i;
for (i = 1; i < TXBDAT_OFF + len; i++)
@@ -408,9 +417,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
int buf_idx)
{
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
- struct mcp251x_platform_data *pdata = spi->dev.platform_data;
- if (pdata->model == CAN_MCP251X_MCP2510) {
+ if (mcp251x_is_2510(spi)) {
int i, len;
for (i = 1; i < RXBDAT_OFF; i++)
--
1.7.0.4
next prev parent reply other threads:[~2010-10-15 10:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-15 10:49 [PATCH V2 0/7] can: mcp251x: fix and optimize driver Marc Kleine-Budde
[not found] ` <1287139762-23356-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2010-10-15 10:49 ` [PATCH 1/7] can: mcp251x: fix NOHZ local_softirq_pending 08 warning Marc Kleine-Budde
2010-10-15 10:49 ` [PATCH 2/7] can: mcp251x: increase rx_errors on overflow, not only rx_over_errors Marc Kleine-Budde
2010-10-15 10:49 ` [PATCH 3/7] can: mcp251x: allow to read two registers in one spi transfer Marc Kleine-Budde
2010-10-15 10:49 ` [PATCH 4/7] can: mcp251x: read-modify-write eflag only when needed Marc Kleine-Budde
2010-10-15 10:49 ` Marc Kleine-Budde [this message]
2010-10-17 14:29 ` [PATCH V2 0/7] can: mcp251x: fix and optimize driver Wolfgang Grandegger
[not found] ` <4CBB0851.9060601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-10-18 9:19 ` Marc Kleine-Budde
2010-10-15 10:49 ` [PATCH 5/7] can: mcp251x: write intf only when needed Marc Kleine-Budde
2010-10-15 10:49 ` [PATCH 7/7] can: mcp251x: optimize 2515, rx int gets cleared automatically 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=1287139762-23356-7-git-send-email-mkl@pengutronix.de \
--to=mkl-bicnvbalz9megne8c9+irq@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.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).