mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 00:33:58 -04: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>
54 lines
1.6 KiB
C
54 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/* Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES
|
|
*/
|
|
#include "iommufd_private.h"
|
|
|
|
struct iommufd_object *_iommufd_object_alloc(struct iommufd_ctx *ictx,
|
|
size_t size,
|
|
enum iommufd_object_type type)
|
|
{
|
|
struct iommufd_object *obj;
|
|
int rc;
|
|
|
|
obj = kzalloc(size, GFP_KERNEL_ACCOUNT);
|
|
if (!obj)
|
|
return ERR_PTR(-ENOMEM);
|
|
obj->type = type;
|
|
/* Starts out bias'd by 1 until it is removed from the xarray */
|
|
refcount_set(&obj->shortterm_users, 1);
|
|
refcount_set(&obj->users, 1);
|
|
|
|
/*
|
|
* Reserve an ID in the xarray but do not publish the pointer yet since
|
|
* the caller hasn't initialized it yet. Once the pointer is published
|
|
* in the xarray and visible to other threads we can't reliably destroy
|
|
* it anymore, so the caller must complete all errorable operations
|
|
* before calling iommufd_object_finalize().
|
|
*/
|
|
rc = xa_alloc(&ictx->objects, &obj->id, XA_ZERO_ENTRY, xa_limit_31b,
|
|
GFP_KERNEL_ACCOUNT);
|
|
if (rc)
|
|
goto out_free;
|
|
return obj;
|
|
out_free:
|
|
kfree(obj);
|
|
return ERR_PTR(rc);
|
|
}
|
|
EXPORT_SYMBOL_NS_GPL(_iommufd_object_alloc, "IOMMUFD");
|
|
|
|
/* Caller should xa_lock(&viommu->vdevs) to protect the return value */
|
|
struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
|
|
unsigned long vdev_id)
|
|
{
|
|
struct iommufd_vdevice *vdev;
|
|
|
|
lockdep_assert_held(&viommu->vdevs.xa_lock);
|
|
|
|
vdev = xa_load(&viommu->vdevs, vdev_id);
|
|
return vdev ? vdev->dev : NULL;
|
|
}
|
|
EXPORT_SYMBOL_NS_GPL(iommufd_viommu_find_dev, "IOMMUFD");
|
|
|
|
MODULE_DESCRIPTION("iommufd code shared with builtin modules");
|
|
MODULE_LICENSE("GPL");
|