Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fpga: dfl: move dfl bus related APIs to include/linux/dfl.h

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

[mdf@kernel.org: Fixed up header guards to match filename]

Reviewed-by: Tom Rix <trix@redhat.com>
Acked-by: Wu Hao <hao.wu@intel.com>
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
Link: https://lore.kernel.org/r/20210107043714.991646-7-mdf@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xu Yilun and committed by
Greg Kroah-Hartman
ecc1641a 4a224ace

+88 -72
+1
MAINTAINERS
··· 6957 6957 F: Documentation/ABI/testing/sysfs-bus-dfl 6958 6958 F: Documentation/fpga/dfl.rst 6959 6959 F: drivers/fpga/dfl* 6960 + F: include/linux/dfl.h 6960 6961 F: include/uapi/linux/fpga-dfl.h 6961 6962 6962 6963 FPGA MANAGER FRAMEWORK
+1
drivers/fpga/dfl.c
··· 10 10 * Wu Hao <hao.wu@intel.com> 11 11 * Xiao Guangrong <guangrong.xiao@linux.intel.com> 12 12 */ 13 + #include <linux/dfl.h> 13 14 #include <linux/fpga-dfl.h> 14 15 #include <linux/module.h> 15 16 #include <linux/uaccess.h>
-72
drivers/fpga/dfl.h
··· 517 517 struct dfl_feature *feature, 518 518 unsigned long arg); 519 519 520 - /** 521 - * enum dfl_id_type - define the DFL FIU types 522 - */ 523 - enum dfl_id_type { 524 - FME_ID = 0, 525 - PORT_ID = 1, 526 - DFL_ID_MAX, 527 - }; 528 - 529 - /** 530 - * struct dfl_device - represent an dfl device on dfl bus 531 - * 532 - * @dev: generic device interface. 533 - * @id: id of the dfl device. 534 - * @type: type of DFL FIU of the device. See enum dfl_id_type. 535 - * @feature_id: feature identifier local to its DFL FIU type. 536 - * @mmio_res: mmio resource of this dfl device. 537 - * @irqs: list of Linux IRQ numbers of this dfl device. 538 - * @num_irqs: number of IRQs supported by this dfl device. 539 - * @cdev: pointer to DFL FPGA container device this dfl device belongs to. 540 - * @id_entry: matched id entry in dfl driver's id table. 541 - */ 542 - struct dfl_device { 543 - struct device dev; 544 - int id; 545 - u16 type; 546 - u16 feature_id; 547 - struct resource mmio_res; 548 - int *irqs; 549 - unsigned int num_irqs; 550 - struct dfl_fpga_cdev *cdev; 551 - const struct dfl_device_id *id_entry; 552 - }; 553 - 554 - /** 555 - * struct dfl_driver - represent an dfl device driver 556 - * 557 - * @drv: driver model structure. 558 - * @id_table: pointer to table of device IDs the driver is interested in. 559 - * { } member terminated. 560 - * @probe: mandatory callback for device binding. 561 - * @remove: callback for device unbinding. 562 - */ 563 - struct dfl_driver { 564 - struct device_driver drv; 565 - const struct dfl_device_id *id_table; 566 - 567 - int (*probe)(struct dfl_device *dfl_dev); 568 - void (*remove)(struct dfl_device *dfl_dev); 569 - }; 570 - 571 - #define to_dfl_dev(d) container_of(d, struct dfl_device, dev) 572 - #define to_dfl_drv(d) container_of(d, struct dfl_driver, drv) 573 - 574 - /* 575 - * use a macro to avoid include chaining to get THIS_MODULE. 576 - */ 577 - #define dfl_driver_register(drv) \ 578 - __dfl_driver_register(drv, THIS_MODULE) 579 - int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner); 580 - void dfl_driver_unregister(struct dfl_driver *dfl_drv); 581 - 582 - /* 583 - * module_dfl_driver() - Helper macro for drivers that don't do 584 - * anything special in module init/exit. This eliminates a lot of 585 - * boilerplate. Each module may only use this macro once, and 586 - * calling it replaces module_init() and module_exit(). 587 - */ 588 - #define module_dfl_driver(__dfl_driver) \ 589 - module_driver(__dfl_driver, dfl_driver_register, \ 590 - dfl_driver_unregister) 591 - 592 520 #endif /* __FPGA_DFL_H */
+86
include/linux/dfl.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Header file for DFL driver and device API 4 + * 5 + * Copyright (C) 2020 Intel Corporation, Inc. 6 + */ 7 + 8 + #ifndef __LINUX_DFL_H 9 + #define __LINUX_DFL_H 10 + 11 + #include <linux/device.h> 12 + #include <linux/mod_devicetable.h> 13 + 14 + /** 15 + * enum dfl_id_type - define the DFL FIU types 16 + */ 17 + enum dfl_id_type { 18 + FME_ID = 0, 19 + PORT_ID = 1, 20 + DFL_ID_MAX, 21 + }; 22 + 23 + /** 24 + * struct dfl_device - represent an dfl device on dfl bus 25 + * 26 + * @dev: generic device interface. 27 + * @id: id of the dfl device. 28 + * @type: type of DFL FIU of the device. See enum dfl_id_type. 29 + * @feature_id: feature identifier local to its DFL FIU type. 30 + * @mmio_res: mmio resource of this dfl device. 31 + * @irqs: list of Linux IRQ numbers of this dfl device. 32 + * @num_irqs: number of IRQs supported by this dfl device. 33 + * @cdev: pointer to DFL FPGA container device this dfl device belongs to. 34 + * @id_entry: matched id entry in dfl driver's id table. 35 + */ 36 + struct dfl_device { 37 + struct device dev; 38 + int id; 39 + u16 type; 40 + u16 feature_id; 41 + struct resource mmio_res; 42 + int *irqs; 43 + unsigned int num_irqs; 44 + struct dfl_fpga_cdev *cdev; 45 + const struct dfl_device_id *id_entry; 46 + }; 47 + 48 + /** 49 + * struct dfl_driver - represent an dfl device driver 50 + * 51 + * @drv: driver model structure. 52 + * @id_table: pointer to table of device IDs the driver is interested in. 53 + * { } member terminated. 54 + * @probe: mandatory callback for device binding. 55 + * @remove: callback for device unbinding. 56 + */ 57 + struct dfl_driver { 58 + struct device_driver drv; 59 + const struct dfl_device_id *id_table; 60 + 61 + int (*probe)(struct dfl_device *dfl_dev); 62 + void (*remove)(struct dfl_device *dfl_dev); 63 + }; 64 + 65 + #define to_dfl_dev(d) container_of(d, struct dfl_device, dev) 66 + #define to_dfl_drv(d) container_of(d, struct dfl_driver, drv) 67 + 68 + /* 69 + * use a macro to avoid include chaining to get THIS_MODULE. 70 + */ 71 + #define dfl_driver_register(drv) \ 72 + __dfl_driver_register(drv, THIS_MODULE) 73 + int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner); 74 + void dfl_driver_unregister(struct dfl_driver *dfl_drv); 75 + 76 + /* 77 + * module_dfl_driver() - Helper macro for drivers that don't do 78 + * anything special in module init/exit. This eliminates a lot of 79 + * boilerplate. Each module may only use this macro once, and 80 + * calling it replaces module_init() and module_exit(). 81 + */ 82 + #define module_dfl_driver(__dfl_driver) \ 83 + module_driver(__dfl_driver, dfl_driver_register, \ 84 + dfl_driver_unregister) 85 + 86 + #endif /* __LINUX_DFL_H */