看看底部的补丁。C静态内联函数调用外部函数动机
---
drivers/iommu/iommu.c | 4 ++--
drivers/iommu/msm_iommu_domains.c | 2 +-
include/linux/iommu.h | 6 +++++-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 7848f47..c2f694c 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -670,7 +670,7 @@ void iommu_set_fault_handler(struct iommu_domain *domain,
}
EXPORT_SYMBOL_GPL(iommu_set_fault_handler);
-struct iommu_domain *iommu_domain_alloc(struct bus_type *bus, int flags)
+struct iommu_domain *iommu_domain_alloc_flags(struct bus_type *bus, int flags)
{
struct iommu_domain *domain;
int ret;
@@ -695,7 +695,7 @@ out_free:
return NULL;
}
-EXPORT_SYMBOL_GPL(iommu_domain_alloc);
+EXPORT_SYMBOL_GPL(iommu_domain_alloc_flags);
void iommu_domain_free(struct iommu_domain *domain)
{
diff --git a/drivers/iommu/msm_iommu_domains.c b/drivers/iommu/msm_iommu_domains.c
index 26a3f85..7619e66 100644
--- a/drivers/iommu/msm_iommu_domains.c
+++ b/drivers/iommu/msm_iommu_domains.c
@@ -506,7 +506,7 @@ int msm_register_domain(struct msm_iova_layout *layout)
if (data->domain_num < 0)
goto free_pools;
- data->domain = iommu_domain_alloc(bus, layout->domain_flags);
+ data->domain = iommu_domain_alloc_flags(bus, layout->domain_flags);
if (!data->domain)
goto free_domain_num;
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index fb1efec..8bd9d3f 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -131,7 +131,11 @@ struct iommu_ops {
extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops);
extern bool iommu_present(struct bus_type *bus);
-extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus, int flags);
+extern struct iommu_domain *iommu_domain_alloc_flags(struct bus_type *bus, int flags);
+static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
+{
+ return iommu_domain_alloc_flags(bus, 0);
+}
extern struct iommu_group *iommu_group_get_by_id(int id);
extern void iommu_domain_free(struct iommu_domain *domain);
extern int iommu_attach_device(struct iommu_domain *domain,
--
这个补丁有什么好处,即是否有任何性能胜利?
inline
static
函数调用extern
是不是很好的编程习惯?
如果extern
意味着外部连接,即函数定义在其他地方,那么在static
函数中使用它是安全的,该函数说“此函数只能在该翻译单元中可见”?
通过这样的回答来看:Inline functions and external linkage
所以 “外部链接” 和 “内联” 是不是唯一的; “external linkage”意思是该功能可以在任何翻译单位中参考,“inline”意味着它必须在调用它的任何翻译单位 中定义。
inline
和external
显然不是在打架,但static
存在是什么困扰着我。
感谢
'static'停止它定义与外部链接功能的副本。 –