lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1600966801-30586-6-git-send-email-yilun.xu@intel.com>
Date:   Fri, 25 Sep 2020 01:00:01 +0800
From:   Xu Yilun <yilun.xu@...el.com>
To:     mdf@...nel.org, linux-fpga@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     trix@...hat.com, lgoncalv@...hat.com, yilun.xu@...el.com,
        hao.wu@...el.com
Subject: [PATCH v3 5/5] fpga: dfl: move fpga dfl bus related APIs to include/linux/fpga/dfl.h

Now the fpga dfl drivers could be made as independent modules and put
in different folders according to their functionalities. In order for
scattered fpga dfl device drivers to include fpga dfl bus APIs, move the
fpga dfl bus APIs to a new header file in the public folder.

[mdf@...nel.org: Fixed up MAINTAINERS entry merge]
Signed-off-by: Xu Yilun <yilun.xu@...el.com>
Reviewed-by: Tom Rix <trix@...hat.com>
Acked-by: Wu Hao <hao.wu@...el.com>
Signed-off-by: Moritz Fischer <mdf@...nel.org>
---
v2: updated the MAINTAINERS under FPGA DFL DRIVERS
    improve the comments
    rename the dfl-bus.h to dfl.h
v3: rebase the patch for previous changes
---
 MAINTAINERS              |  1 +
 drivers/fpga/dfl.c       |  1 +
 drivers/fpga/dfl.h       | 73 ----------------------------------------
 include/linux/fpga/dfl.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 73 deletions(-)
 create mode 100644 include/linux/fpga/dfl.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 48c0859..01c3c84 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6842,6 +6842,7 @@ S:	Maintained
 F:	Documentation/ABI/testing/sysfs-bus-fpga-dfl
 F:	Documentation/fpga/dfl.rst
 F:	drivers/fpga/dfl*
+F:	include/linux/fpga/dfl.h
 F:	include/uapi/linux/fpga-dfl.h
 
 FPGA MANAGER FRAMEWORK
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index a906fa7..d045344b 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -11,6 +11,7 @@
  *   Xiao Guangrong <guangrong.xiao@...ux.intel.com>
  */
 #include <linux/fpga-dfl.h>
+#include <linux/fpga/dfl.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
 
diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h
index 4a42d26..97a81b6 100644
--- a/drivers/fpga/dfl.h
+++ b/drivers/fpga/dfl.h
@@ -517,77 +517,4 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev,
 			       struct dfl_feature *feature,
 			       unsigned long arg);
 
-/**
- * enum fpga_dfl_id_type - define the FPGA DFL FIU types
- */
-enum fpga_dfl_id_type {
-	FPGA_DFL_FME_ID = 0,
-	FPGA_DFL_PORT_ID = 1,
-	FPGA_DFL_ID_MAX,
-};
-
-/**
- * struct fpga_dfl_device - represent an fpga dfl device on fpga dfl bus
- *
- * @dev: generic device interface.
- * @id: id of the fpga dfl device.
- * @type: FPGA DFL FIU type of the device, see enum fpga_dfl_id_type.
- * @feature_id: feature identifier local to its FPGA DFL FIU type.
- * @mmio_res: mmio resource of this fpga dfl device.
- * @irqs: list of Linux IRQ numbers of this fpga dfl device.
- * @num_irqs: number of IRQs supported by this fpga dfl device.
- * @cdev: pointer to DFL FPGA container device this fpga dfl device belongs to.
- * @id_entry: matched id entry in fpga dfl driver's id table.
- */
-struct fpga_dfl_device {
-	struct device dev;
-	int id;
-	u16 type;
-	u16 feature_id;
-	struct resource mmio_res;
-	int *irqs;
-	unsigned int num_irqs;
-	struct dfl_fpga_cdev *cdev;
-	const struct fpga_dfl_device_id *id_entry;
-};
-
-/**
- * struct fpga_dfl_driver - represent a fpga dfl device driver
- *
- * @drv: driver model structure.
- * @id_table: pointer to table of device IDs the driver is interested in.
- *	      { } member terminated.
- * @probe: mandatory callback for device binding.
- * @remove: callback for device unbinding.
- */
-struct fpga_dfl_driver {
-	struct device_driver drv;
-	const struct fpga_dfl_device_id *id_table;
-
-	int (*probe)(struct fpga_dfl_device *fddev);
-	void (*remove)(struct fpga_dfl_device *fddev);
-};
-
-#define to_fpga_dfl_dev(d) container_of(d, struct fpga_dfl_device, dev)
-#define to_fpga_dfl_drv(d) container_of(d, struct fpga_dfl_driver, drv)
-
-/*
- * use a macro to avoid include chaining to get THIS_MODULE.
- */
-#define fpga_dfl_driver_register(drv) \
-	__fpga_dfl_driver_register(drv, THIS_MODULE)
-int __fpga_dfl_driver_register(struct fpga_dfl_driver *fddrv,
-			       struct module *owner);
-void fpga_dfl_driver_unregister(struct fpga_dfl_driver *fddrv);
-
-/*
- * module_fpga_dfl_driver() - Helper macro for drivers that don't do
- * anything special in module init/exit.  This eliminates a lot of
- * boilerplate.  Each module may only use this macro once, and
- * calling it replaces module_init() and module_exit().
- */
-#define module_fpga_dfl_driver(__fpga_dfl_driver) \
-	module_driver(__fpga_dfl_driver, fpga_dfl_driver_register, \
-		      fpga_dfl_driver_unregister)
-
 #endif /* __FPGA_DFL_H */
diff --git a/include/linux/fpga/dfl.h b/include/linux/fpga/dfl.h
new file mode 100644
index 0000000..0715d0a
--- /dev/null
+++ b/include/linux/fpga/dfl.h
@@ -0,0 +1,87 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Header file for FPGA DFL driver and device API
+ *
+ * Copyright (C) 2020 Intel Corporation, Inc.
+ */
+
+#ifndef __LINUX_FPGA_DFL_H
+#define __LINUX_FPGA_DFL_H
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+
+/**
+ * enum fpga_dfl_id_type - define the FPGA DFL FIU types
+ */
+enum fpga_dfl_id_type {
+	FPGA_DFL_FME_ID = 0,
+	FPGA_DFL_PORT_ID = 1,
+	FPGA_DFL_ID_MAX,
+};
+
+/**
+ * struct fpga_dfl_device - represent an fpga dfl device on fpga dfl bus
+ *
+ * @dev: generic device interface.
+ * @id: id of the fpga dfl device.
+ * @type: FPGA DFL FIU type of the device, see enum fpga_dfl_id_type.
+ * @feature_id: feature identifier local to its FPGA DFL FIU type.
+ * @mmio_res: mmio resource of this fpga dfl device.
+ * @irqs: list of Linux IRQ numbers of this fpga dfl device.
+ * @num_irqs: number of IRQs supported by this fpga dfl device.
+ * @cdev: pointer to DFL FPGA container device this fpga dfl device belongs to.
+ * @id_entry: matched id entry in fpga dfl driver's id table.
+ */
+struct fpga_dfl_device {
+	struct device dev;
+	int id;
+	u16 type;
+	u16 feature_id;
+	struct resource mmio_res;
+	int *irqs;
+	unsigned int num_irqs;
+	struct dfl_fpga_cdev *cdev;
+	const struct fpga_dfl_device_id *id_entry;
+};
+
+/**
+ * struct fpga_dfl_driver - represent a fpga dfl device driver
+ *
+ * @drv: driver model structure.
+ * @id_table: pointer to table of device IDs the driver is interested in.
+ *	      { } member terminated.
+ * @probe: mandatory callback for device binding.
+ * @remove: callback for device unbinding.
+ */
+struct fpga_dfl_driver {
+	struct device_driver drv;
+	const struct fpga_dfl_device_id *id_table;
+
+	int (*probe)(struct fpga_dfl_device *fddev);
+	void (*remove)(struct fpga_dfl_device *fddev);
+};
+
+#define to_fpga_dfl_dev(d) container_of(d, struct fpga_dfl_device, dev)
+#define to_fpga_dfl_drv(d) container_of(d, struct fpga_dfl_driver, drv)
+
+/*
+ * use a macro to avoid include chaining to get THIS_MODULE.
+ */
+#define fpga_dfl_driver_register(drv) \
+	__fpga_dfl_driver_register(drv, THIS_MODULE)
+int __fpga_dfl_driver_register(struct fpga_dfl_driver *fddrv,
+			       struct module *owner);
+void fpga_dfl_driver_unregister(struct fpga_dfl_driver *fddrv);
+
+/*
+ * module_fpga_dfl_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces module_init() and module_exit().
+ */
+#define module_fpga_dfl_driver(__fpga_dfl_driver) \
+	module_driver(__fpga_dfl_driver, fpga_dfl_driver_register, \
+		      fpga_dfl_driver_unregister)
+
+#endif /* __LINUX_FPGA_DFL_H */
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ