-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dmaengine: dsa: move dsa_bus_type out of idxd driver to standalone
In preparation for dsa_drv compat support to be built-in, move the bus code to its own compilation unit. A follow-on patch adds the compat implementation. Recall that the compat implementation allows for the deprecated / omnibus dsa_drv binding scheme rather than the idiomatic organization of a full fledged bus driver per driver type. Reviewed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/162637468142.744545.2811632736881720857.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
- Loading branch information
Dave Jiang
authored and
Vinod Koul
committed
Jul 21, 2021
1 parent
448c3de
commit d9e5481
Showing
6 changed files
with
103 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=IDXD | ||
|
||
obj-$(CONFIG_INTEL_IDXD) += idxd.o | ||
idxd-y := init.o irq.o device.o sysfs.o submit.o dma.o cdev.o | ||
|
||
idxd-$(CONFIG_INTEL_IDXD_PERFMON) += perfmon.o | ||
|
||
obj-$(CONFIG_INTEL_IDXD_BUS) += idxd_bus.o | ||
idxd_bus-y := bus.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright(c) 2021 Intel Corporation. All rights rsvd. */ | ||
#include <linux/init.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/device.h> | ||
#include "idxd.h" | ||
|
||
|
||
int __idxd_driver_register(struct idxd_device_driver *idxd_drv, struct module *owner, | ||
const char *mod_name) | ||
{ | ||
struct device_driver *drv = &idxd_drv->drv; | ||
|
||
if (!idxd_drv->type) { | ||
pr_debug("driver type not set (%ps)\n", __builtin_return_address(0)); | ||
return -EINVAL; | ||
} | ||
|
||
drv->name = idxd_drv->name; | ||
drv->bus = &dsa_bus_type; | ||
drv->owner = owner; | ||
drv->mod_name = mod_name; | ||
|
||
return driver_register(drv); | ||
} | ||
EXPORT_SYMBOL_GPL(__idxd_driver_register); | ||
|
||
void idxd_driver_unregister(struct idxd_device_driver *idxd_drv) | ||
{ | ||
driver_unregister(&idxd_drv->drv); | ||
} | ||
EXPORT_SYMBOL_GPL(idxd_driver_unregister); | ||
|
||
static int idxd_config_bus_match(struct device *dev, | ||
struct device_driver *drv) | ||
{ | ||
struct idxd_device_driver *idxd_drv = | ||
container_of(drv, struct idxd_device_driver, drv); | ||
struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); | ||
int i = 0; | ||
|
||
while (idxd_drv->type[i] != IDXD_DEV_NONE) { | ||
if (idxd_dev->type == idxd_drv->type[i]) | ||
return 1; | ||
i++; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static int idxd_config_bus_probe(struct device *dev) | ||
{ | ||
struct idxd_device_driver *idxd_drv = | ||
container_of(dev->driver, struct idxd_device_driver, drv); | ||
struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); | ||
|
||
return idxd_drv->probe(idxd_dev); | ||
} | ||
|
||
static int idxd_config_bus_remove(struct device *dev) | ||
{ | ||
struct idxd_device_driver *idxd_drv = | ||
container_of(dev->driver, struct idxd_device_driver, drv); | ||
struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); | ||
|
||
idxd_drv->remove(idxd_dev); | ||
return 0; | ||
} | ||
|
||
struct bus_type dsa_bus_type = { | ||
.name = "dsa", | ||
.match = idxd_config_bus_match, | ||
.probe = idxd_config_bus_probe, | ||
.remove = idxd_config_bus_remove, | ||
}; | ||
EXPORT_SYMBOL_GPL(dsa_bus_type); | ||
|
||
static int __init dsa_bus_init(void) | ||
{ | ||
return bus_register(&dsa_bus_type); | ||
} | ||
module_init(dsa_bus_init); | ||
|
||
static void __exit dsa_bus_exit(void) | ||
{ | ||
bus_unregister(&dsa_bus_type); | ||
} | ||
module_exit(dsa_bus_exit); | ||
|
||
MODULE_DESCRIPTION("IDXD driver dsa_bus_type driver"); | ||
MODULE_LICENSE("GPL v2"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters