From: Oliver Hartkopp <socketcan@hartkopp.net>
To: linux-can@vger.kernel.org
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Subject: [PATCH can-next/b4 1/2] dummyxl: update config possibilities and rename dummyxl_priv
Date: Sun, 6 Jul 2025 15:35:49 +0200 [thread overview]
Message-ID: <20250706133550.47369-1-socketcan@hartkopp.net> (raw)
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
drivers/net/can/dummyxl.c | 55 +++++++++++++++++++++++++--------------
1 file changed, 35 insertions(+), 20 deletions(-)
diff --git a/drivers/net/can/dummyxl.c b/drivers/net/can/dummyxl.c
index ac1b579b4c1f..c61f27b93e9f 100644
--- a/drivers/net/can/dummyxl.c
+++ b/drivers/net/can/dummyxl.c
@@ -10,16 +10,17 @@
#include <linux/units.h>
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/skb.h>
-struct dummyxl {
+struct dummyxl_priv {
struct can_priv can;
struct net_device *dev;
};
-static struct dummyxl *dummyxl;
+/* pointer to our single dummy device (for removal) */
+static struct net_device *dummyxl_dev = NULL;
static const struct can_bittiming_const dummyxl_bittiming_const = {
.name = "dummyxl nominal",
.tseg1_min = 2,
.tseg1_max = 256,
@@ -71,11 +72,12 @@ static const struct can_tdc_const dummyxl_xl_tdc_const = {
.tdco_max = 127,
.tdcf_min = 0,
.tdcf_max = 127
};
-static void dummyxl_print_bittiming(struct net_device *dev, struct can_bittiming *bt)
+static void dummyxl_print_bittiming(struct net_device *dev,
+ struct can_bittiming *bt)
{
netdev_info(dev, "\tbitrate: %u\n", bt->bitrate);
netdev_info(dev, "\tsample_point: %u\n", bt->sample_point);
netdev_info(dev, "\ttq: %u\n", bt->tq);
netdev_info(dev, "\tprop_seg: %u\n", bt->prop_seg);
@@ -90,15 +92,14 @@ static void dummyxl_print_tdc(struct net_device *dev, struct can_tdc *tdc)
netdev_info(dev, "\t\ttdcv: %u\n", tdc->tdcv);
netdev_info(dev, "\t\ttdco: %u\n", tdc->tdco);
netdev_info(dev, "\t\ttdcf: %u\n", tdc->tdcf);
}
-static int dummyxl_netdev_open(struct net_device *dev)
+static void dummyxl_print_config(struct net_device *dev)
{
- struct dummyxl *priv = netdev_priv(dev);
+ struct dummyxl_priv *priv = netdev_priv(dev);
struct can_priv *can_priv = &priv->can;
- int ret;
netdev_info(dev, "CAN control mode/supported : %08X/%08X\n",
can_priv->ctrlmode, can_priv->ctrlmode_supported);
netdev_info(dev, "CAN CC nominal bittiming:\n");
dummyxl_print_bittiming(dev, &can_priv->bittiming);
@@ -129,10 +130,17 @@ static int dummyxl_netdev_open(struct net_device *dev)
}
} else {
netdev_info(dev, "CAN XL is off\n");
}
netdev_info(dev, "\n");
+}
+
+static int dummyxl_netdev_open(struct net_device *dev)
+{
+ int ret;
+
+ dummyxl_print_config(dev);
ret = open_candev(dev);
if (ret)
return ret;
netif_start_queue(dev);
@@ -174,50 +182,57 @@ static const struct net_device_ops dummyxl_netdev_ops = {
};
static int __init dummyxl_init(void)
{
struct net_device *dev;
- struct dummyxl *priv;
+ struct dummyxl_priv *priv;
int ret;
- dev = alloc_candev(sizeof(struct dummyxl), 0);
+ dev = alloc_candev(sizeof(struct dummyxl_priv), 0);
if (!dev)
return -ENOMEM;
dev->netdev_ops = &dummyxl_netdev_ops;
priv = netdev_priv(dev);
priv->can.bittiming_const = &dummyxl_bittiming_const;
- priv->can.bitrate_max = 8 * MEGA /* BPS */;
- priv->can.clock.freq = 80 * MEGA /* Hz */;
+ priv->can.bitrate_max = 20 * MEGA /* BPS */;
+ priv->can.clock.freq = 160 * MEGA /* Hz */;
priv->can.fd.data_bittiming_const = &dummyxl_fd_databittiming_const;
priv->can.fd.tdc_const = &dummyxl_fd_tdc_const;
priv->can.xl.data_bittiming_const = &dummyxl_xl_databittiming_const;
priv->can.xl.tdc_const = &dummyxl_xl_tdc_const;
- priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY |
- CAN_CTRLMODE_FD | CAN_CTRLMODE_TDC_AUTO |
- CAN_CTRLMODE_XL | CAN_CTRLMODE_XL_TDC_AUTO;
+ priv->can.ctrlmode_supported =
+ CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_CC_LEN8_DLC |
+ CAN_CTRLMODE_FD |
+ CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL |
+ CAN_CTRLMODE_XL |
+ CAN_CTRLMODE_XL_TDC_AUTO | CAN_CTRLMODE_XL_TDC_MANUAL |
+ CAN_CTRLMODE_XL_RRS | CAN_CTRLMODE_XL_TRX |
+ CAN_CTRLMODE_XL_ERR_SIGNAL;
priv->dev = dev;
- ret = register_candev(priv->dev);
+ ret = register_candev(dev);
if (ret) {
- free_candev(priv->dev);
+ free_candev(dev);
return ret;
}
- dummyxl = priv;
+ dummyxl_dev = dev;
netdev_info(dev, "dummyxl OK\n");
return 0;
}
static void __exit dummyxl_exit(void)
{
- struct net_device *dev = dummyxl->dev;
+ struct net_device *dev = dummyxl_dev;
- netdev_info(dev, "dummyxl bye bye\n");
- unregister_candev(dev);
- free_candev(dev);
+ if (dev) {
+ netdev_info(dev, "dummyxl bye bye\n");
+ unregister_candev(dev);
+ free_candev(dev);
+ }
}
module_init(dummyxl_init);
module_exit(dummyxl_exit);
--
2.47.2
next reply other threads:[~2025-07-06 13:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-06 13:35 Oliver Hartkopp [this message]
2025-07-06 13:35 ` [PATCH can-next/b4 2/2] dummyxl: print ctrlmode and PWM values Oliver Hartkopp
2025-07-13 17:25 ` Vincent Mailhol
2025-07-15 10:06 ` Marc Kleine-Budde
2025-07-15 10:58 ` Vincent Mailhol
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=20250706133550.47369-1-socketcan@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@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