linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: linux-can@vger.kernel.org
Cc: Marek Vasut <marex@denx.de>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 2/5][RFC] can: Factor out alloc_socketdev()
Date: Thu,  9 Jun 2016 21:21:01 +0200	[thread overview]
Message-ID: <1465500064-5402-2-git-send-email-marex@denx.de> (raw)
In-Reply-To: <1465500064-5402-1-git-send-email-marex@denx.de>

Factor out alloc_socketdev() from alloc_candev() to make it possible
to register different socket devices -- like kline -- using the same
codepath.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev.c   | 11 +++++++++--
 include/linux/can/dev.h |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 141c2a4..f8ef6b0 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -641,7 +641,8 @@ EXPORT_SYMBOL_GPL(alloc_can_err_skb);
 /*
  * Allocate and setup space for the CAN network device
  */
-struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
+struct net_device *alloc_socketdev(const char *name, int sizeof_priv,
+				   unsigned int echo_skb_max)
 {
 	struct net_device *dev;
 	struct can_priv *priv;
@@ -653,7 +654,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
 	else
 		size = sizeof_priv;
 
-	dev = alloc_netdev(size, "can%d", NET_NAME_UNKNOWN, can_setup);
+	dev = alloc_netdev(size, name, NET_NAME_UNKNOWN, can_setup);
 	if (!dev)
 		return NULL;
 
@@ -671,6 +672,12 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
 
 	return dev;
 }
+EXPORT_SYMBOL_GPL(alloc_socketdev);
+
+struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
+{
+	return alloc_socketdev("can%d", sizeof_priv, echo_skb_max);
+}
 EXPORT_SYMBOL_GPL(alloc_candev);
 
 /*
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 735f9f8..9b0520d 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -114,6 +114,7 @@ u8 can_dlc2len(u8 can_dlc);
 /* map the sanitized data length to an appropriate data length code */
 u8 can_len2dlc(u8 len);
 
+struct net_device *alloc_socketdev(const char *name, int sizeof_priv, unsigned int echo_skb_max);
 struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
 void free_candev(struct net_device *dev);
 
-- 
2.7.0


  reply	other threads:[~2016-06-09 19:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 19:21 [PATCH 1/5][RFC] can: slcan: Replace sizeof struct can_frame with CAN_MTU Marek Vasut
2016-06-09 19:21 ` Marek Vasut [this message]
2016-06-09 19:21 ` [PATCH 3/5][RFC] can: Add register_candevice() Marek Vasut
2016-06-09 19:21 ` [PATCH 4/5][RFC] can: kline: Add KLine rtnl configuration options Marek Vasut
2016-06-09 20:21   ` Menschel.P
2016-06-11 19:40     ` Marek Vasut
2016-06-12 15:36       ` Patrick Menschel
2016-06-12 17:34         ` Marek Vasut
2016-06-09 19:21 ` [PATCH 5/5][RFC] can: kline: Add KLine ldisc Marek Vasut
2016-06-17  9:24 ` [PATCH 1/5][RFC] can: slcan: Replace sizeof struct can_frame with CAN_MTU Marc Kleine-Budde
2016-06-17  9:25   ` Marek Vasut

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=1465500064-5402-2-git-send-email-marex@denx.de \
    --to=marex@denx.de \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=socketcan@hartkopp.net \
    /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).