Skip to contentSkip to conversation

iommu: make return value consistence

PATCH In review Wang YanQing 2 participants 2 messages Dec 13, 2012 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: make return value consistence

if we don't define CONFIG_IOMMU_API the dummy functions alway return -ENODEV or -EINVAL except three function, so convert them to the same behavior to make consistence

---
 include/linux/iommu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/iommu.h +3 -3
index f4a49a6..16e84f6 100644
@@ -210,7 +210,7 @@ static inline bool iommu_present(struct bus_type *bus)
 
 static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline void iommu_domain_free(struct iommu_domain *domain)
@@ -275,7 +275,7 @@ static inline struct iommu_group *iommu_group_alloc(void)
 
 static inline void *iommu_group_get_iommudata(struct iommu_group *group)
 {
-	return NULL;
+	return ERR_PTR(-EINVAL);
 }
 
 static inline void iommu_group_set_iommudata(struct iommu_group *group,
@@ -309,7 +309,7 @@ static inline int iommu_group_for_each_dev(struct iommu_group *group,
 
 static inline struct iommu_group *iommu_group_get(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline void iommu_group_put(struct iommu_group *group)
Signature · 1 line
1.7.11.1.116.g8228a23
#1 lore raw
Quoted 4 lines · Wang YanQing

if we don't define CONFIG_IOMMU_API the dummy functions alway return -ENODEV or -EINVAL except three function, so convert them to the same behavior to make consistence

But if we do define CONFIG_IOMMU_API the actual functions return NULL instead of ERR_PTR, so any conversion needs to include the actual functions and update the callers as well. Thanks,

Alex

Quoted 36 lines
---
 include/linux/iommu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/iommu.h +3 -3
index f4a49a6..16e84f6 100644
@@ -210,7 +210,7 @@ static inline bool iommu_present(struct bus_type *bus)
 
 static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline void iommu_domain_free(struct iommu_domain *domain)
@@ -275,7 +275,7 @@ static inline struct iommu_group *iommu_group_alloc(void)
 
 static inline void *iommu_group_get_iommudata(struct iommu_group *group)
 {
-	return NULL;
+	return ERR_PTR(-EINVAL);
 }
 
 static inline void iommu_group_set_iommudata(struct iommu_group *group,
@@ -309,7 +309,7 @@ static inline int iommu_group_for_each_dev(struct iommu_group *group,
 
 static inline struct iommu_group *iommu_group_get(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 static inline void iommu_group_put(struct iommu_group *group)