mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-21 06:50:25 +00:00

Clean up the existing export namespace code along the same lines of
commit 33def8498f
("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
106 lines
2.5 KiB
C
106 lines
2.5 KiB
C
// 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 <linux/device/bus.h>
|
|
#include "idxd.h"
|
|
|
|
extern void device_driver_detach(struct device *dev);
|
|
|
|
#define DRIVER_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \
|
|
struct driver_attribute driver_attr_##_name = \
|
|
__ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store)
|
|
|
|
static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t count)
|
|
{
|
|
const struct bus_type *bus = drv->bus;
|
|
struct device *dev;
|
|
int rc = -ENODEV;
|
|
|
|
dev = bus_find_device_by_name(bus, NULL, buf);
|
|
if (dev && dev->driver) {
|
|
device_driver_detach(dev);
|
|
rc = count;
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
|
|
|
|
static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
|
|
{
|
|
const struct bus_type *bus = drv->bus;
|
|
struct device *dev;
|
|
struct device_driver *alt_drv = NULL;
|
|
int rc = -ENODEV;
|
|
struct idxd_dev *idxd_dev;
|
|
|
|
dev = bus_find_device_by_name(bus, NULL, buf);
|
|
if (!dev || dev->driver || drv != &dsa_drv.drv)
|
|
return -ENODEV;
|
|
|
|
idxd_dev = confdev_to_idxd_dev(dev);
|
|
if (is_idxd_dev(idxd_dev)) {
|
|
alt_drv = driver_find("idxd", bus);
|
|
} else if (is_idxd_wq_dev(idxd_dev)) {
|
|
struct idxd_wq *wq = confdev_to_wq(dev);
|
|
|
|
if (is_idxd_wq_kernel(wq))
|
|
alt_drv = driver_find("dmaengine", bus);
|
|
else if (is_idxd_wq_user(wq))
|
|
alt_drv = driver_find("user", bus);
|
|
}
|
|
if (!alt_drv)
|
|
return -ENODEV;
|
|
|
|
rc = device_driver_attach(alt_drv, dev);
|
|
if (rc < 0)
|
|
return rc;
|
|
|
|
return count;
|
|
}
|
|
static DRIVER_ATTR_IGNORE_LOCKDEP(bind, 0200, NULL, bind_store);
|
|
|
|
static struct attribute *dsa_drv_compat_attrs[] = {
|
|
&driver_attr_bind.attr,
|
|
&driver_attr_unbind.attr,
|
|
NULL,
|
|
};
|
|
|
|
static const struct attribute_group dsa_drv_compat_attr_group = {
|
|
.attrs = dsa_drv_compat_attrs,
|
|
};
|
|
|
|
static const struct attribute_group *dsa_drv_compat_groups[] = {
|
|
&dsa_drv_compat_attr_group,
|
|
NULL,
|
|
};
|
|
|
|
static int idxd_dsa_drv_probe(struct idxd_dev *idxd_dev)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static void idxd_dsa_drv_remove(struct idxd_dev *idxd_dev)
|
|
{
|
|
}
|
|
|
|
static enum idxd_dev_type dev_types[] = {
|
|
IDXD_DEV_NONE,
|
|
};
|
|
|
|
struct idxd_device_driver dsa_drv = {
|
|
.name = "dsa",
|
|
.probe = idxd_dsa_drv_probe,
|
|
.remove = idxd_dsa_drv_remove,
|
|
.type = dev_types,
|
|
.drv = {
|
|
.suppress_bind_attrs = true,
|
|
.groups = dsa_drv_compat_groups,
|
|
},
|
|
};
|
|
|
|
module_idxd_driver(dsa_drv);
|
|
MODULE_IMPORT_NS("IDXD");
|