]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
can: kvaser_pciefd: Split driver into C-file and header-file.
authorJimmy Assarsson <extja@kvaser.com>
Fri, 25 Jul 2025 12:32:26 +0000 (14:32 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 25 Jul 2025 15:53:50 +0000 (17:53 +0200)
Split driver into C-file and header-file, to simplify future patches.
Move common definitions and declarations to a header file.

Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Link: https://patch.msgid.link/20250725123230.8-7-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/Makefile
drivers/net/can/kvaser_pciefd/Makefile [new file with mode: 0644]
drivers/net/can/kvaser_pciefd/kvaser_pciefd.h [new file with mode: 0644]
drivers/net/can/kvaser_pciefd/kvaser_pciefd_core.c [moved from drivers/net/can/kvaser_pciefd.c with 97% similarity]

index a71db2cfe990d553faf1213b10fb1d98d768647b..56138d8ddfd238a9c20971a913deed314aee1372 100644 (file)
@@ -25,7 +25,7 @@ obj-$(CONFIG_CAN_FLEXCAN)     += flexcan/
 obj-$(CONFIG_CAN_GRCAN)                += grcan.o
 obj-$(CONFIG_CAN_IFI_CANFD)    += ifi_canfd/
 obj-$(CONFIG_CAN_JANZ_ICAN3)   += janz-ican3.o
-obj-$(CONFIG_CAN_KVASER_PCIEFD)        += kvaser_pciefd.o
+obj-$(CONFIG_CAN_KVASER_PCIEFD)        += kvaser_pciefd/
 obj-$(CONFIG_CAN_MSCAN)                += mscan/
 obj-$(CONFIG_CAN_M_CAN)                += m_can/
 obj-$(CONFIG_CAN_PEAK_PCIEFD)  += peak_canfd/
diff --git a/drivers/net/can/kvaser_pciefd/Makefile b/drivers/net/can/kvaser_pciefd/Makefile
new file mode 100644 (file)
index 0000000..ea1bf10
--- /dev/null
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_CAN_KVASER_PCIEFD) += kvaser_pciefd.o
+kvaser_pciefd-y = kvaser_pciefd_core.o
diff --git a/drivers/net/can/kvaser_pciefd/kvaser_pciefd.h b/drivers/net/can/kvaser_pciefd/kvaser_pciefd.h
new file mode 100644 (file)
index 0000000..55bb7e0
--- /dev/null
@@ -0,0 +1,90 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
+/* kvaser_pciefd common definitions and declarations
+ *
+ * Copyright (C) 2025 KVASER AB, Sweden. All rights reserved.
+ */
+
+#ifndef _KVASER_PCIEFD_H
+#define _KVASER_PCIEFD_H
+
+#include <linux/can/dev.h>
+#include <linux/completion.h>
+#include <linux/pci.h>
+#include <linux/spinlock.h>
+#include <linux/timer.h>
+#include <linux/types.h>
+
+#define KVASER_PCIEFD_MAX_CAN_CHANNELS 8UL
+#define KVASER_PCIEFD_DMA_COUNT 2U
+#define KVASER_PCIEFD_DMA_SIZE (4U * 1024U)
+#define KVASER_PCIEFD_CAN_TX_MAX_COUNT 17U
+
+struct kvaser_pciefd;
+
+struct kvaser_pciefd_address_offset {
+       u32 serdes;
+       u32 pci_ien;
+       u32 pci_irq;
+       u32 sysid;
+       u32 loopback;
+       u32 kcan_srb_fifo;
+       u32 kcan_srb;
+       u32 kcan_ch0;
+       u32 kcan_ch1;
+};
+
+struct kvaser_pciefd_irq_mask {
+       u32 kcan_rx0;
+       u32 kcan_tx[KVASER_PCIEFD_MAX_CAN_CHANNELS];
+       u32 all;
+};
+
+struct kvaser_pciefd_dev_ops {
+       void (*kvaser_pciefd_write_dma_map)(struct kvaser_pciefd *pcie,
+                                           dma_addr_t addr, int index);
+};
+
+struct kvaser_pciefd_driver_data {
+       const struct kvaser_pciefd_address_offset *address_offset;
+       const struct kvaser_pciefd_irq_mask *irq_mask;
+       const struct kvaser_pciefd_dev_ops *ops;
+};
+
+struct kvaser_pciefd_fw_version {
+       u8 major;
+       u8 minor;
+       u16 build;
+};
+
+struct kvaser_pciefd_can {
+       struct can_priv can;
+       struct kvaser_pciefd *kv_pcie;
+       void __iomem *reg_base;
+       struct can_berr_counter bec;
+       u32 ioc;
+       u8 cmd_seq;
+       u8 tx_max_count;
+       u8 tx_idx;
+       u8 ack_idx;
+       int err_rep_cnt;
+       unsigned int completed_tx_pkts;
+       unsigned int completed_tx_bytes;
+       spinlock_t lock; /* Locks sensitive registers (e.g. MODE) */
+       struct timer_list bec_poll_timer;
+       struct completion start_comp, flush_comp;
+};
+
+struct kvaser_pciefd {
+       struct pci_dev *pci;
+       void __iomem *reg_base;
+       struct kvaser_pciefd_can *can[KVASER_PCIEFD_MAX_CAN_CHANNELS];
+       const struct kvaser_pciefd_driver_data *driver_data;
+       void *dma_data[KVASER_PCIEFD_DMA_COUNT];
+       u8 nr_channels;
+       u32 bus_freq;
+       u32 freq;
+       u32 freq_to_ticks_div;
+       struct kvaser_pciefd_fw_version fw_version;
+};
+
+#endif /* _KVASER_PCIEFD_H */
similarity index 97%
rename from drivers/net/can/kvaser_pciefd.c
rename to drivers/net/can/kvaser_pciefd/kvaser_pciefd_core.c
index 8dcb1d1c67e49a71826f90c246c16502c66dddee..97cbe07c4ee3fba2f2cbb919bcd8f9fe72a736ed 100644 (file)
@@ -5,6 +5,8 @@
  *  - PEAK linux canfd driver
  */
 
+#include "kvaser_pciefd.h"
+
 #include <linux/bitfield.h>
 #include <linux/can/dev.h>
 #include <linux/device.h>
@@ -27,10 +29,6 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
 #define KVASER_PCIEFD_WAIT_TIMEOUT msecs_to_jiffies(1000)
 #define KVASER_PCIEFD_BEC_POLL_FREQ (jiffies + msecs_to_jiffies(200))
 #define KVASER_PCIEFD_MAX_ERR_REP 256U
-#define KVASER_PCIEFD_CAN_TX_MAX_COUNT 17U
-#define KVASER_PCIEFD_MAX_CAN_CHANNELS 8UL
-#define KVASER_PCIEFD_DMA_COUNT 2U
-#define KVASER_PCIEFD_DMA_SIZE (4U * 1024U)
 
 #define KVASER_PCIEFD_VENDOR 0x1a07
 
@@ -296,41 +294,6 @@ static void kvaser_pciefd_write_dma_map_sf2(struct kvaser_pciefd *pcie,
 static void kvaser_pciefd_write_dma_map_xilinx(struct kvaser_pciefd *pcie,
                                               dma_addr_t addr, int index);
 
-struct kvaser_pciefd_address_offset {
-       u32 serdes;
-       u32 pci_ien;
-       u32 pci_irq;
-       u32 sysid;
-       u32 loopback;
-       u32 kcan_srb_fifo;
-       u32 kcan_srb;
-       u32 kcan_ch0;
-       u32 kcan_ch1;
-};
-
-struct kvaser_pciefd_dev_ops {
-       void (*kvaser_pciefd_write_dma_map)(struct kvaser_pciefd *pcie,
-                                           dma_addr_t addr, int index);
-};
-
-struct kvaser_pciefd_irq_mask {
-       u32 kcan_rx0;
-       u32 kcan_tx[KVASER_PCIEFD_MAX_CAN_CHANNELS];
-       u32 all;
-};
-
-struct kvaser_pciefd_driver_data {
-       const struct kvaser_pciefd_address_offset *address_offset;
-       const struct kvaser_pciefd_irq_mask *irq_mask;
-       const struct kvaser_pciefd_dev_ops *ops;
-};
-
-struct kvaser_pciefd_fw_version {
-       u8 major;
-       u8 minor;
-       u16 build;
-};
-
 static const struct kvaser_pciefd_address_offset kvaser_pciefd_altera_address_offset = {
        .serdes = 0x1000,
        .pci_ien = 0x50,
@@ -415,37 +378,6 @@ static const struct kvaser_pciefd_driver_data kvaser_pciefd_xilinx_driver_data =
        .ops = &kvaser_pciefd_xilinx_dev_ops,
 };
 
-struct kvaser_pciefd_can {
-       struct can_priv can;
-       struct kvaser_pciefd *kv_pcie;
-       void __iomem *reg_base;
-       struct can_berr_counter bec;
-       u32 ioc;
-       u8 cmd_seq;
-       u8 tx_max_count;
-       u8 tx_idx;
-       u8 ack_idx;
-       int err_rep_cnt;
-       unsigned int completed_tx_pkts;
-       unsigned int completed_tx_bytes;
-       spinlock_t lock; /* Locks sensitive registers (e.g. MODE) */
-       struct timer_list bec_poll_timer;
-       struct completion start_comp, flush_comp;
-};
-
-struct kvaser_pciefd {
-       struct pci_dev *pci;
-       void __iomem *reg_base;
-       struct kvaser_pciefd_can *can[KVASER_PCIEFD_MAX_CAN_CHANNELS];
-       const struct kvaser_pciefd_driver_data *driver_data;
-       void *dma_data[KVASER_PCIEFD_DMA_COUNT];
-       u8 nr_channels;
-       u32 bus_freq;
-       u32 freq;
-       u32 freq_to_ticks_div;
-       struct kvaser_pciefd_fw_version fw_version;
-};
-
 struct kvaser_pciefd_rx_packet {
        u32 header[2];
        u64 timestamp;