aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-04 20:31:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-04 20:31:11 -0400
commit27703bb4a66df49ff16b44b864d307d2eb71774c (patch)
tree356ce249a0af9775b3291a93fc56e466ffc5d1f8
parent6f3bc58d84e9e4c4ed8584e020365f996a26a153 (diff)
parentad151d544475df40ee0d18be7d5c945e29c1b545 (diff)
Merge tag 'PTR_RET-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull PTR_RET() removal patches from Rusty Russell: "PTR_RET() is a weird name, and led to some confusing usage. We ended up with PTR_ERR_OR_ZERO(), and replacing or fixing all the usages. This has been sitting in linux-next for a whole cycle" [ There are still some PTR_RET users scattered about, with some of them possibly being new, but most of them existing in Rusty's tree too. We have that #define PTR_RET(p) PTR_ERR_OR_ZERO(p) thing in <linux/err.h>, so they continue to work for now - Linus ] * tag 'PTR_RET-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: GFS2: Replace PTR_RET with PTR_ERR_OR_ZERO Btrfs: volume: Replace PTR_RET with PTR_ERR_OR_ZERO drm/cma: Replace PTR_RET with PTR_ERR_OR_ZERO sh_veu: Replace PTR_RET with PTR_ERR_OR_ZERO dma-buf: Replace PTR_RET with PTR_ERR_OR_ZERO drivers/rtc: Replace PTR_RET with PTR_ERR_OR_ZERO mm/oom_kill: remove weird use of ERR_PTR()/PTR_ERR(). staging/zcache: don't use PTR_RET(). remoteproc: don't use PTR_RET(). pinctrl: don't use PTR_RET(). acpi: Replace weird use of PTR_RET. s390: Replace weird use of PTR_RET. PTR_RET is now PTR_ERR_OR_ZERO(): Replace most. PTR_RET is now PTR_ERR_OR_ZERO
-rw-r--r--arch/arm/mach-omap2/i2c.c2
-rw-r--r--arch/m68k/amiga/platform.c2
-rw-r--r--arch/m68k/kernel/time.c2
-rw-r--r--arch/m68k/q40/config.c2
-rw-r--r--arch/powerpc/kernel/iommu.c2
-rw-r--r--arch/powerpc/kernel/time.c2
-rw-r--r--arch/powerpc/platforms/ps3/time.c2
-rw-r--r--arch/powerpc/sysdev/rtc_cmos_setup.c2
-rw-r--r--arch/s390/hypfs/hypfs_dbfs.c2
-rw-r--r--arch/s390/kvm/gaccess.h12
-rw-r--r--drivers/acpi/acpi_pad.c13
-rw-r--r--drivers/base/dma-buf.c2
-rw-r--r--drivers/char/tile-srom.c2
-rw-r--r--drivers/gpu/drm/drm_gem_cma_helper.c2
-rw-r--r--drivers/infiniband/core/cma.c2
-rw-r--r--drivers/media/platform/sh_veu.c2
-rw-r--r--drivers/net/appletalk/cops.c2
-rw-r--r--drivers/net/appletalk/ltpc.c2
-rw-r--r--drivers/net/ethernet/amd/atarilance.c2
-rw-r--r--drivers/net/ethernet/amd/mvme147.c2
-rw-r--r--drivers/net/ethernet/amd/ni65.c2
-rw-r--r--drivers/net/ethernet/amd/sun3lance.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/debug.c2
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-dove.c2
-rw-r--r--drivers/platform/x86/samsung-q10.c2
-rw-r--r--drivers/regulator/fan53555.c2
-rw-r--r--drivers/remoteproc/da8xx_remoteproc.c2
-rw-r--r--drivers/rtc/rtc-da9052.c2
-rw-r--r--drivers/rtc/rtc-isl12022.c2
-rw-r--r--drivers/rtc/rtc-m48t35.c2
-rw-r--r--drivers/rtc/rtc-pcf8563.c2
-rw-r--r--drivers/rtc/rtc-pcf8583.c2
-rw-r--r--drivers/spi/spi-fsl-spi.c2
-rw-r--r--drivers/spi/spidev.c2
-rw-r--r--drivers/video/omap2/dss/core.c2
-rw-r--r--fs/btrfs/dev-replace.c2
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/btrfs/volumes.c2
-rw-r--r--include/linux/err.h5
-rw-r--r--mm/oom_kill.c6
-rw-r--r--net/bluetooth/hci_sysfs.c2
-rw-r--r--net/bridge/netfilter/ebtable_broute.c2
-rw-r--r--net/bridge/netfilter/ebtable_filter.c2
-rw-r--r--net/bridge/netfilter/ebtable_nat.c2
-rw-r--r--net/ipv4/netfilter/arptable_filter.c2
-rw-r--r--net/ipv4/netfilter/iptable_filter.c2
-rw-r--r--net/ipv4/netfilter/iptable_mangle.c2
-rw-r--r--net/ipv4/netfilter/iptable_nat.c2
-rw-r--r--net/ipv4/netfilter/iptable_raw.c2
-rw-r--r--net/ipv4/netfilter/iptable_security.c2
-rw-r--r--net/ipv6/netfilter/ip6table_filter.c2
-rw-r--r--net/ipv6/netfilter/ip6table_mangle.c2
-rw-r--r--net/ipv6/netfilter/ip6table_nat.c2
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c2
-rw-r--r--net/ipv6/netfilter/ip6table_security.c2
-rw-r--r--scripts/coccinelle/api/ptr_ret.cocci10
-rw-r--r--sound/soc/soc-io.c2
58 files changed, 81 insertions, 71 deletions
diff --git a/arch/arm/mach-omap2/i2c.c b/arch/arm/mach-omap2/i2c.c
index d940e53dd9f2..b456b4471f35 100644
--- a/arch/arm/mach-omap2/i2c.c
+++ b/arch/arm/mach-omap2/i2c.c
@@ -181,7 +181,7 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
181 sizeof(struct omap_i2c_bus_platform_data)); 181 sizeof(struct omap_i2c_bus_platform_data));
182 WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name); 182 WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name);
183 183
184 return PTR_RET(pdev); 184 return PTR_ERR_OR_ZERO(pdev);
185} 185}
186 186
187static int __init omap_i2c_cmdline(void) 187static int __init omap_i2c_cmdline(void)
diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c
index 6083088c0cca..dacd9f911f71 100644
--- a/arch/m68k/amiga/platform.c
+++ b/arch/m68k/amiga/platform.c
@@ -56,7 +56,7 @@ static int __init amiga_init_bus(void)
56 n = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2; 56 n = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
57 pdev = platform_device_register_simple("amiga-zorro", -1, 57 pdev = platform_device_register_simple("amiga-zorro", -1,
58 zorro_resources, n); 58 zorro_resources, n);
59 return PTR_RET(pdev); 59 return PTR_ERR_OR_ZERO(pdev);
60} 60}
61 61
62subsys_initcall(amiga_init_bus); 62subsys_initcall(amiga_init_bus);
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index bea6bcf8f9b8..7eb9792009f8 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -90,7 +90,7 @@ static int __init rtc_init(void)
90 return -ENODEV; 90 return -ENODEV;
91 91
92 pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); 92 pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
93 return PTR_RET(pdev); 93 return PTR_ERR_OR_ZERO(pdev);
94} 94}
95 95
96module_init(rtc_init); 96module_init(rtc_init);
diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c
index 658542b914fc..078bb744b5fe 100644
--- a/arch/m68k/q40/config.c
+++ b/arch/m68k/q40/config.c
@@ -338,6 +338,6 @@ static __init int q40_add_kbd_device(void)
338 return -ENODEV; 338 return -ENODEV;
339 339
340 pdev = platform_device_register_simple("q40kbd", -1, NULL, 0); 340 pdev = platform_device_register_simple("q40kbd", -1, NULL, 0);
341 return PTR_RET(pdev); 341 return PTR_ERR_OR_ZERO(pdev);
342} 342}
343arch_initcall(q40_add_kbd_device); 343arch_initcall(q40_add_kbd_device);
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index b20ff173a671..0adab06ce5c0 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -105,7 +105,7 @@ static int __init fail_iommu_debugfs(void)
105 struct dentry *dir = fault_create_debugfs_attr("fail_iommu", 105 struct dentry *dir = fault_create_debugfs_attr("fail_iommu",
106 NULL, &fail_iommu); 106 NULL, &fail_iommu);
107 107
108 return PTR_RET(dir); 108 return PTR_ERR_OR_ZERO(dir);
109} 109}
110late_initcall(fail_iommu_debugfs); 110late_initcall(fail_iommu_debugfs);
111 111
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 65ab9e909377..cdcc156865ef 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -1049,7 +1049,7 @@ static int __init rtc_init(void)
1049 1049
1050 pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); 1050 pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
1051 1051
1052 return PTR_RET(pdev); 1052 return PTR_ERR_OR_ZERO(pdev);
1053} 1053}
1054 1054
1055module_init(rtc_init); 1055module_init(rtc_init);
diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c
index cba1e6be68e5..ce73ce865613 100644
--- a/arch/powerpc/platforms/ps3/time.c
+++ b/arch/powerpc/platforms/ps3/time.c
@@ -90,7 +90,7 @@ static int __init ps3_rtc_init(void)
90 90
91 pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0); 91 pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0);
92 92
93 return PTR_RET(pdev); 93 return PTR_ERR_OR_ZERO(pdev);
94} 94}
95 95
96module_init(ps3_rtc_init); 96module_init(ps3_rtc_init);
diff --git a/arch/powerpc/sysdev/rtc_cmos_setup.c b/arch/powerpc/sysdev/rtc_cmos_setup.c
index af79e1ea74b6..af0f9beddca9 100644
--- a/arch/powerpc/sysdev/rtc_cmos_setup.c
+++ b/arch/powerpc/sysdev/rtc_cmos_setup.c
@@ -62,7 +62,7 @@ static int __init add_rtc(void)
62 pd = platform_device_register_simple("rtc_cmos", -1, 62 pd = platform_device_register_simple("rtc_cmos", -1,
63 &res[0], num_res); 63 &res[0], num_res);
64 64
65 return PTR_RET(pd); 65 return PTR_ERR_OR_ZERO(pd);
66} 66}
67fs_initcall(add_rtc); 67fs_initcall(add_rtc);
68 68
diff --git a/arch/s390/hypfs/hypfs_dbfs.c b/arch/s390/hypfs/hypfs_dbfs.c
index bb5dd496614f..17ab8b7b53cc 100644
--- a/arch/s390/hypfs/hypfs_dbfs.c
+++ b/arch/s390/hypfs/hypfs_dbfs.c
@@ -105,7 +105,7 @@ void hypfs_dbfs_remove_file(struct hypfs_dbfs_file *df)
105int hypfs_dbfs_init(void) 105int hypfs_dbfs_init(void)
106{ 106{
107 dbfs_dir = debugfs_create_dir("s390_hypfs", NULL); 107 dbfs_dir = debugfs_create_dir("s390_hypfs", NULL);
108 return PTR_RET(dbfs_dir); 108 return PTR_ERR_OR_ZERO(dbfs_dir);
109} 109}
110 110
111void hypfs_dbfs_exit(void) 111void hypfs_dbfs_exit(void)
diff --git a/arch/s390/kvm/gaccess.h b/arch/s390/kvm/gaccess.h
index 302e0e52b009..99d789e8a018 100644
--- a/arch/s390/kvm/gaccess.h
+++ b/arch/s390/kvm/gaccess.h
@@ -42,9 +42,11 @@ static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
42({ \ 42({ \
43 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\ 43 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\
44 int __mask = sizeof(__typeof__(*(gptr))) - 1; \ 44 int __mask = sizeof(__typeof__(*(gptr))) - 1; \
45 int __ret = PTR_RET((void __force *)__uptr); \ 45 int __ret; \
46 \ 46 \
47 if (!__ret) { \ 47 if (IS_ERR((void __force *)__uptr)) { \
48 __ret = PTR_ERR((void __force *)__uptr); \
49 } else { \
48 BUG_ON((unsigned long)__uptr & __mask); \ 50 BUG_ON((unsigned long)__uptr & __mask); \
49 __ret = get_user(x, __uptr); \ 51 __ret = get_user(x, __uptr); \
50 } \ 52 } \
@@ -55,9 +57,11 @@ static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
55({ \ 57({ \
56 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\ 58 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\
57 int __mask = sizeof(__typeof__(*(gptr))) - 1; \ 59 int __mask = sizeof(__typeof__(*(gptr))) - 1; \
58 int __ret = PTR_RET((void __force *)__uptr); \ 60 int __ret; \
59 \ 61 \
60 if (!__ret) { \ 62 if (IS_ERR((void __force *)__uptr)) { \
63 __ret = PTR_ERR((void __force *)__uptr); \
64 } else { \
61 BUG_ON((unsigned long)__uptr & __mask); \ 65 BUG_ON((unsigned long)__uptr & __mask); \
62 __ret = put_user(x, __uptr); \ 66 __ret = put_user(x, __uptr); \
63 } \ 67 } \
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 6230637054c6..fc6008fbce35 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -231,16 +231,19 @@ static struct task_struct *ps_tsks[NR_CPUS];
231static unsigned int ps_tsk_num; 231static unsigned int ps_tsk_num;
232static int create_power_saving_task(void) 232static int create_power_saving_task(void)
233{ 233{
234 int rc = -ENOMEM; 234 int rc;
235 235
236 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, 236 ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread,
237 (void *)(unsigned long)ps_tsk_num, 237 (void *)(unsigned long)ps_tsk_num,
238 "acpi_pad/%d", ps_tsk_num); 238 "acpi_pad/%d", ps_tsk_num);
239 rc = PTR_RET(ps_tsks[ps_tsk_num]); 239
240 if (!rc) 240 if (IS_ERR(ps_tsks[ps_tsk_num])) {
241 ps_tsk_num++; 241 rc = PTR_ERR(ps_tsks[ps_tsk_num]);
242 else
243 ps_tsks[ps_tsk_num] = NULL; 242 ps_tsks[ps_tsk_num] = NULL;
243 } else {
244 rc = 0;
245 ps_tsk_num++;
246 }
244 247
245 return rc; 248 return rc;
246} 249}
diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 6687ba741879..1219ab7c3107 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -680,7 +680,7 @@ int dma_buf_debugfs_create_file(const char *name,
680 d = debugfs_create_file(name, S_IRUGO, dma_buf_debugfs_dir, 680 d = debugfs_create_file(name, S_IRUGO, dma_buf_debugfs_dir,
681 write, &dma_buf_debug_fops); 681 write, &dma_buf_debug_fops);
682 682
683 return PTR_RET(d); 683 return PTR_ERR_OR_ZERO(d);
684} 684}
685#else 685#else
686static inline int dma_buf_init_debugfs(void) 686static inline int dma_buf_init_debugfs(void)
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index ae82933883bd..0e506bad1986 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -353,7 +353,7 @@ static int srom_setup_minor(struct srom_dev *srom, int index)
353 353
354 dev = device_create(srom_class, &platform_bus, 354 dev = device_create(srom_class, &platform_bus,
355 MKDEV(srom_major, index), srom, "%d", index); 355 MKDEV(srom_major, index), srom, "%d", index);
356 return PTR_RET(dev); 356 return PTR_ERR_OR_ZERO(dev);
357} 357}
358 358
359/** srom_init() - Initialize the driver's module. */ 359/** srom_init() - Initialize the driver's module. */
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index ece72a8ac245..61c1d17f870c 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -215,7 +215,7 @@ int drm_gem_cma_dumb_create(struct drm_file *file_priv,
215 215
216 cma_obj = drm_gem_cma_create_with_handle(file_priv, dev, 216 cma_obj = drm_gem_cma_create_with_handle(file_priv, dev,
217 args->size, &args->handle); 217 args->size, &args->handle);
218 return PTR_RET(cma_obj); 218 return PTR_ERR_OR_ZERO(cma_obj);
219} 219}
220EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create); 220EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_create);
221 221
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 7c0f9535fb7d..6bd197f34b59 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3208,7 +3208,7 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv,
3208 id_priv->id.port_num, &rec, 3208 id_priv->id.port_num, &rec,
3209 comp_mask, GFP_KERNEL, 3209 comp_mask, GFP_KERNEL,
3210 cma_ib_mc_handler, mc); 3210 cma_ib_mc_handler, mc);
3211 return PTR_RET(mc->multicast.ib); 3211 return PTR_ERR_OR_ZERO(mc->multicast.ib);
3212} 3212}
3213 3213
3214static void iboe_mcast_work_handler(struct work_struct *work) 3214static void iboe_mcast_work_handler(struct work_struct *work)
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
index aa4cca371cbf..744e43b480bc 100644
--- a/drivers/media/platform/sh_veu.c
+++ b/drivers/media/platform/sh_veu.c
@@ -359,7 +359,7 @@ static int sh_veu_context_init(struct sh_veu_dev *veu)
359 veu->m2m_ctx = v4l2_m2m_ctx_init(veu->m2m_dev, veu, 359 veu->m2m_ctx = v4l2_m2m_ctx_init(veu->m2m_dev, veu,
360 sh_veu_queue_init); 360 sh_veu_queue_init);
361 361
362 return PTR_RET(veu->m2m_ctx); 362 return PTR_ERR_OR_ZERO(veu->m2m_ctx);
363} 363}
364 364
365static int sh_veu_querycap(struct file *file, void *priv, 365static int sh_veu_querycap(struct file *file, void *priv,
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index cff6f023c03a..7f2a032c354c 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -996,7 +996,7 @@ static int __init cops_module_init(void)
996 printk(KERN_WARNING "%s: You shouldn't autoprobe with insmod\n", 996 printk(KERN_WARNING "%s: You shouldn't autoprobe with insmod\n",
997 cardname); 997 cardname);
998 cops_dev = cops_probe(-1); 998 cops_dev = cops_probe(-1);
999 return PTR_RET(cops_dev); 999 return PTR_ERR_OR_ZERO(cops_dev);
1000} 1000}
1001 1001
1002static void __exit cops_module_exit(void) 1002static void __exit cops_module_exit(void)
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index b5782cdf0bca..01e2ac55c137 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -1243,7 +1243,7 @@ static int __init ltpc_module_init(void)
1243 "ltpc: Autoprobing is not recommended for modules\n"); 1243 "ltpc: Autoprobing is not recommended for modules\n");
1244 1244
1245 dev_ltpc = ltpc_probe(); 1245 dev_ltpc = ltpc_probe();
1246 return PTR_RET(dev_ltpc); 1246 return PTR_ERR_OR_ZERO(dev_ltpc);
1247} 1247}
1248module_init(ltpc_module_init); 1248module_init(ltpc_module_init);
1249#endif 1249#endif
diff --git a/drivers/net/ethernet/amd/atarilance.c b/drivers/net/ethernet/amd/atarilance.c
index e8d0ef508f48..10ceca523fc0 100644
--- a/drivers/net/ethernet/amd/atarilance.c
+++ b/drivers/net/ethernet/amd/atarilance.c
@@ -1147,7 +1147,7 @@ static struct net_device *atarilance_dev;
1147static int __init atarilance_module_init(void) 1147static int __init atarilance_module_init(void)
1148{ 1148{
1149 atarilance_dev = atarilance_probe(-1); 1149 atarilance_dev = atarilance_probe(-1);
1150 return PTR_RET(atarilance_dev); 1150 return PTR_ERR_OR_ZERO(atarilance_dev);
1151} 1151}
1152 1152
1153static void __exit atarilance_module_exit(void) 1153static void __exit atarilance_module_exit(void)
diff --git a/drivers/net/ethernet/amd/mvme147.c b/drivers/net/ethernet/amd/mvme147.c
index a51497c9d2af..e108e911da05 100644
--- a/drivers/net/ethernet/amd/mvme147.c
+++ b/drivers/net/ethernet/amd/mvme147.c
@@ -188,7 +188,7 @@ static struct net_device *dev_mvme147_lance;
188int __init init_module(void) 188int __init init_module(void)
189{ 189{
190 dev_mvme147_lance = mvme147lance_probe(-1); 190 dev_mvme147_lance = mvme147lance_probe(-1);
191 return PTR_RET(dev_mvme147_lance); 191 return PTR_ERR_OR_ZERO(dev_mvme147_lance);
192} 192}
193 193
194void __exit cleanup_module(void) 194void __exit cleanup_module(void)
diff --git a/drivers/net/ethernet/amd/ni65.c b/drivers/net/ethernet/amd/ni65.c
index 26fc0ce0faa3..1cf33addd15e 100644
--- a/drivers/net/ethernet/amd/ni65.c
+++ b/drivers/net/ethernet/amd/ni65.c
@@ -1238,7 +1238,7 @@ MODULE_PARM_DESC(dma, "ni6510 ISA DMA channel (ignored for some cards)");
1238int __init init_module(void) 1238int __init init_module(void)
1239{ 1239{
1240 dev_ni65 = ni65_probe(-1); 1240 dev_ni65 = ni65_probe(-1);
1241 return PTR_RET(dev_ni65); 1241 return PTR_ERR_OR_ZERO(dev_ni65);
1242} 1242}
1243 1243
1244void __exit cleanup_module(void) 1244void __exit cleanup_module(void)
diff --git a/drivers/net/ethernet/amd/sun3lance.c b/drivers/net/ethernet/amd/sun3lance.c
index 4375abe61da1..d6b20296b8e4 100644
--- a/drivers/net/ethernet/amd/sun3lance.c
+++ b/drivers/net/ethernet/amd/sun3lance.c
@@ -940,7 +940,7 @@ static struct net_device *sun3lance_dev;
940int __init init_module(void) 940int __init init_module(void)
941{ 941{
942 sun3lance_dev = sun3lance_probe(-1); 942 sun3lance_dev = sun3lance_probe(-1);
943 return PTR_RET(sun3lance_dev); 943 return PTR_ERR_OR_ZERO(sun3lance_dev);
944} 944}
945 945
946void __exit cleanup_module(void) 946void __exit cleanup_module(void)
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.c
index c37b9d68e458..0f9e9057e7dd 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.c
@@ -50,7 +50,7 @@ int brcmf_debugfs_attach(struct brcmf_pub *drvr)
50 return -ENODEV; 50 return -ENODEV;
51 51
52 drvr->dbgfs_dir = debugfs_create_dir(dev_name(dev), root_folder); 52 drvr->dbgfs_dir = debugfs_create_dir(dev_name(dev), root_folder);
53 return PTR_RET(drvr->dbgfs_dir); 53 return PTR_ERR_OR_ZERO(drvr->dbgfs_dir);
54} 54}
55 55
56void brcmf_debugfs_detach(struct brcmf_pub *drvr) 56void brcmf_debugfs_detach(struct brcmf_pub *drvr)
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
index 9761deb46204..a5d4add26f41 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
@@ -56,7 +56,7 @@ int brcms_debugfs_attach(struct brcms_pub *drvr)
56 56
57 drvr->dbgfs_dir = debugfs_create_dir( 57 drvr->dbgfs_dir = debugfs_create_dir(
58 dev_name(&drvr->wlc->hw->d11core->dev), root_folder); 58 dev_name(&drvr->wlc->hw->d11core->dev), root_folder);
59 return PTR_RET(drvr->dbgfs_dir); 59 return PTR_ERR_OR_ZERO(drvr->dbgfs_dir);
60} 60}
61 61
62void brcms_debugfs_detach(struct brcms_pub *drvr) 62void brcms_debugfs_detach(struct brcms_pub *drvr)
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index 048ae80adabd..29f7e4fc7ca5 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -785,7 +785,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
785 clk = devm_clk_get(&pdev->dev, NULL); 785 clk = devm_clk_get(&pdev->dev, NULL);
786 if (IS_ERR(clk)) { 786 if (IS_ERR(clk)) {
787 dev_err(&pdev->dev, "Unable to get pdma clock"); 787 dev_err(&pdev->dev, "Unable to get pdma clock");
788 return PTR_RET(clk); 788 return PTR_ERR(clk);
789 } 789 }
790 clk_prepare_enable(clk); 790 clk_prepare_enable(clk);
791 791
diff --git a/drivers/platform/x86/samsung-q10.c b/drivers/platform/x86/samsung-q10.c
index 1a90b62a71c6..4430b8c1369d 100644
--- a/drivers/platform/x86/samsung-q10.c
+++ b/drivers/platform/x86/samsung-q10.c
@@ -176,7 +176,7 @@ static int __init samsungq10_init(void)
176 samsungq10_probe, 176 samsungq10_probe,
177 NULL, 0, NULL, 0); 177 NULL, 0, NULL, 0);
178 178
179 return PTR_RET(samsungq10_device); 179 return PTR_ERR_OR_ZERO(samsungq10_device);
180} 180}
181 181
182static void __exit samsungq10_exit(void) 182static void __exit samsungq10_exit(void)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index a32b44272a05..70b7220c587f 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -219,7 +219,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
219 rdesc->owner = THIS_MODULE; 219 rdesc->owner = THIS_MODULE;
220 220
221 di->rdev = regulator_register(&di->desc, config); 221 di->rdev = regulator_register(&di->desc, config);
222 return PTR_RET(di->rdev); 222 return PTR_ERR_OR_ZERO(di->rdev);
223 223
224} 224}
225 225
diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 9b2e60afa1a6..129f7b997866 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -165,7 +165,7 @@ static int reset_assert(struct device *dev)
165 dsp_clk = clk_get(dev, NULL); 165 dsp_clk = clk_get(dev, NULL);
166 if (IS_ERR(dsp_clk)) { 166 if (IS_ERR(dsp_clk)) {
167 dev_err(dev, "clk_get error: %ld\n", PTR_ERR(dsp_clk)); 167 dev_err(dev, "clk_get error: %ld\n", PTR_ERR(dsp_clk));
168 return PTR_RET(dsp_clk); 168 return PTR_ERR(dsp_clk);
169 } 169 }
170 170
171 davinci_clk_reset_assert(dsp_clk); 171 davinci_clk_reset_assert(dsp_clk);
diff --git a/drivers/rtc/rtc-da9052.c b/drivers/rtc/rtc-da9052.c
index 9c8c19441cc6..4385ca4503da 100644
--- a/drivers/rtc/rtc-da9052.c
+++ b/drivers/rtc/rtc-da9052.c
@@ -250,7 +250,7 @@ static int da9052_rtc_probe(struct platform_device *pdev)
250 250
251 rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, 251 rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
252 &da9052_rtc_ops, THIS_MODULE); 252 &da9052_rtc_ops, THIS_MODULE);
253 return PTR_RET(rtc->rtc); 253 return PTR_ERR_OR_ZERO(rtc->rtc);
254} 254}
255 255
256static struct platform_driver da9052_rtc_driver = { 256static struct platform_driver da9052_rtc_driver = {
diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c
index 5dbdc4405718..03b891129428 100644
--- a/drivers/rtc/rtc-isl12022.c
+++ b/drivers/rtc/rtc-isl12022.c
@@ -268,7 +268,7 @@ static int isl12022_probe(struct i2c_client *client,
268 isl12022->rtc = devm_rtc_device_register(&client->dev, 268 isl12022->rtc = devm_rtc_device_register(&client->dev,
269 isl12022_driver.driver.name, 269 isl12022_driver.driver.name,
270 &isl12022_rtc_ops, THIS_MODULE); 270 &isl12022_rtc_ops, THIS_MODULE);
271 return PTR_RET(isl12022->rtc); 271 return PTR_ERR_OR_ZERO(isl12022->rtc);
272} 272}
273 273
274static const struct i2c_device_id isl12022_id[] = { 274static const struct i2c_device_id isl12022_id[] = {
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c
index 23c3779a5f2b..411adb3f86a1 100644
--- a/drivers/rtc/rtc-m48t35.c
+++ b/drivers/rtc/rtc-m48t35.c
@@ -175,7 +175,7 @@ static int m48t35_probe(struct platform_device *pdev)
175 175
176 priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35", 176 priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35",
177 &m48t35_ops, THIS_MODULE); 177 &m48t35_ops, THIS_MODULE);
178 return PTR_RET(priv->rtc); 178 return PTR_ERR_OR_ZERO(priv->rtc);
179} 179}
180 180
181static struct platform_driver m48t35_platform_driver = { 181static struct platform_driver m48t35_platform_driver = {
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 710c3a5aa6ff..63b558c48196 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -264,7 +264,7 @@ static int pcf8563_probe(struct i2c_client *client,
264 pcf8563_driver.driver.name, 264 pcf8563_driver.driver.name,
265 &pcf8563_rtc_ops, THIS_MODULE); 265 &pcf8563_rtc_ops, THIS_MODULE);
266 266
267 return PTR_RET(pcf8563->rtc); 267 return PTR_ERR_OR_ZERO(pcf8563->rtc);
268} 268}
269 269
270static const struct i2c_device_id pcf8563_id[] = { 270static const struct i2c_device_id pcf8563_id[] = {
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c
index 843a745c42f3..c2639845186b 100644
--- a/drivers/rtc/rtc-pcf8583.c
+++ b/drivers/rtc/rtc-pcf8583.c
@@ -285,7 +285,7 @@ static int pcf8583_probe(struct i2c_client *client,
285 pcf8583_driver.driver.name, 285 pcf8583_driver.driver.name,
286 &pcf8583_rtc_ops, THIS_MODULE); 286 &pcf8583_rtc_ops, THIS_MODULE);
287 287
288 return PTR_RET(pcf8583->rtc); 288 return PTR_ERR_OR_ZERO(pcf8583->rtc);
289} 289}
290 290
291static const struct i2c_device_id pcf8583_id[] = { 291static const struct i2c_device_id pcf8583_id[] = {
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index bbc94294891c..2129fcd1c31b 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -902,7 +902,7 @@ static int plat_mpc8xxx_spi_probe(struct platform_device *pdev)
902 return -EINVAL; 902 return -EINVAL;
903 903
904 master = fsl_spi_probe(&pdev->dev, mem, irq); 904 master = fsl_spi_probe(&pdev->dev, mem, irq);
905 return PTR_RET(master); 905 return PTR_ERR_OR_ZERO(master);
906} 906}
907 907
908static int plat_mpc8xxx_spi_remove(struct platform_device *pdev) 908static int plat_mpc8xxx_spi_remove(struct platform_device *pdev)
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 911e9e0711d2..ca5bcfe874d0 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -603,7 +603,7 @@ static int spidev_probe(struct spi_device *spi)
603 dev = device_create(spidev_class, &spi->dev, spidev->devt, 603 dev = device_create(spidev_class, &spi->dev, spidev->devt,
604 spidev, "spidev%d.%d", 604 spidev, "spidev%d.%d",
605 spi->master->bus_num, spi->chip_select); 605 spi->master->bus_num, spi->chip_select);
606 status = PTR_RET(dev); 606 status = PTR_ERR_OR_ZERO(dev);
607 } else { 607 } else {
608 dev_dbg(&spi->dev, "no minor number available!\n"); 608 dev_dbg(&spi->dev, "no minor number available!\n");
609 status = -ENODEV; 609 status = -ENODEV;
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 1aeb274e30fc..a7ce26c090dd 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -189,7 +189,7 @@ int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
189 d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir, 189 d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir,
190 write, &dss_debug_fops); 190 write, &dss_debug_fops);
191 191
192 return PTR_RET(d); 192 return PTR_ERR_OR_ZERO(d);
193} 193}
194#else /* CONFIG_OMAP2_DSS_DEBUGFS */ 194#else /* CONFIG_OMAP2_DSS_DEBUGFS */
195static inline int dss_initialize_debugfs(void) 195static inline int dss_initialize_debugfs(void)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 4253ad580e39..5f8f3341c099 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -747,7 +747,7 @@ int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
747 WARN_ON(atomic_xchg( 747 WARN_ON(atomic_xchg(
748 &fs_info->mutually_exclusive_operation_running, 1)); 748 &fs_info->mutually_exclusive_operation_running, 1));
749 task = kthread_run(btrfs_dev_replace_kthread, fs_info, "btrfs-devrepl"); 749 task = kthread_run(btrfs_dev_replace_kthread, fs_info, "btrfs-devrepl");
750 return PTR_RET(task); 750 return PTR_ERR_OR_ZERO(task);
751} 751}
752 752
753static int btrfs_dev_replace_kthread(void *data) 753static int btrfs_dev_replace_kthread(void *data)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 021694c08181..7bdc83d04d54 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3174,7 +3174,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
3174 found_key.type = BTRFS_INODE_ITEM_KEY; 3174 found_key.type = BTRFS_INODE_ITEM_KEY;
3175 found_key.offset = 0; 3175 found_key.offset = 0;
3176 inode = btrfs_iget(root->fs_info->sb, &found_key, root, NULL); 3176 inode = btrfs_iget(root->fs_info->sb, &found_key, root, NULL);
3177 ret = PTR_RET(inode); 3177 ret = PTR_ERR_OR_ZERO(inode);
3178 if (ret && ret != -ESTALE) 3178 if (ret && ret != -ESTALE)
3179 goto out; 3179 goto out;
3180 3180
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 78b871753cb6..67a085381845 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3302,7 +3302,7 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info)
3302 } 3302 }
3303 3303
3304 tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); 3304 tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance");
3305 return PTR_RET(tsk); 3305 return PTR_ERR_OR_ZERO(tsk);
3306} 3306}
3307 3307
3308int btrfs_recover_balance(struct btrfs_fs_info *fs_info) 3308int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
diff --git a/include/linux/err.h b/include/linux/err.h
index 221fcfb676c4..15f92e072450 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -52,7 +52,7 @@ static inline void * __must_check ERR_CAST(__force const void *ptr)
52 return (void *) ptr; 52 return (void *) ptr;
53} 53}
54 54
55static inline int __must_check PTR_RET(__force const void *ptr) 55static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
56{ 56{
57 if (IS_ERR(ptr)) 57 if (IS_ERR(ptr))
58 return PTR_ERR(ptr); 58 return PTR_ERR(ptr);
@@ -60,6 +60,9 @@ static inline int __must_check PTR_RET(__force const void *ptr)
60 return 0; 60 return 0;
61} 61}
62 62
63/* Deprecated */
64#define PTR_RET(p) PTR_ERR_OR_ZERO(p)
65
63#endif 66#endif
64 67
65#endif /* _LINUX_ERR_H */ 68#endif /* _LINUX_ERR_H */
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 79e451a78c9e..98e75f2ac7bc 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -288,7 +288,7 @@ enum oom_scan_t oom_scan_process_thread(struct task_struct *task,
288 288
289/* 289/*
290 * Simple selection loop. We chose the process with the highest 290 * Simple selection loop. We chose the process with the highest
291 * number of 'points'. 291 * number of 'points'. Returns -1 on scan abort.
292 * 292 *
293 * (not docbooked, we don't want this one cluttering up the manual) 293 * (not docbooked, we don't want this one cluttering up the manual)
294 */ 294 */
@@ -314,7 +314,7 @@ static struct task_struct *select_bad_process(unsigned int *ppoints,
314 continue; 314 continue;
315 case OOM_SCAN_ABORT: 315 case OOM_SCAN_ABORT:
316 rcu_read_unlock(); 316 rcu_read_unlock();
317 return ERR_PTR(-1UL); 317 return (struct task_struct *)(-1UL);
318 case OOM_SCAN_OK: 318 case OOM_SCAN_OK:
319 break; 319 break;
320 }; 320 };
@@ -657,7 +657,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
657 dump_header(NULL, gfp_mask, order, NULL, mpol_mask); 657 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
658 panic("Out of memory and no killable processes...\n"); 658 panic("Out of memory and no killable processes...\n");
659 } 659 }
660 if (PTR_ERR(p) != -1UL) { 660 if (p != (void *)-1UL) {
661 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL, 661 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
662 nodemask, "Out of memory"); 662 nodemask, "Out of memory");
663 killed = 1; 663 killed = 1;
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 7ad6ecf36f20..edf623a29043 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -590,7 +590,7 @@ int __init bt_sysfs_init(void)
590 590
591 bt_class = class_create(THIS_MODULE, "bluetooth"); 591 bt_class = class_create(THIS_MODULE, "bluetooth");
592 592
593 return PTR_RET(bt_class); 593 return PTR_ERR_OR_ZERO(bt_class);
594} 594}
595 595
596void bt_sysfs_cleanup(void) 596void bt_sysfs_cleanup(void)
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index 70f656ce0f4a..dbd1c783431b 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -64,7 +64,7 @@ static int ebt_broute(struct sk_buff *skb)
64static int __net_init broute_net_init(struct net *net) 64static int __net_init broute_net_init(struct net *net)
65{ 65{
66 net->xt.broute_table = ebt_register_table(net, &broute_table); 66 net->xt.broute_table = ebt_register_table(net, &broute_table);
67 return PTR_RET(net->xt.broute_table); 67 return PTR_ERR_OR_ZERO(net->xt.broute_table);
68} 68}
69 69
70static void __net_exit broute_net_exit(struct net *net) 70static void __net_exit broute_net_exit(struct net *net)
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 3c2e9dced9e0..94b2b700cff8 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -100,7 +100,7 @@ static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
100static int __net_init frame_filter_net_init(struct net *net) 100static int __net_init frame_filter_net_init(struct net *net)
101{ 101{
102 net->xt.frame_filter = ebt_register_table(net, &frame_filter); 102 net->xt.frame_filter = ebt_register_table(net, &frame_filter);
103 return PTR_RET(net->xt.frame_filter); 103 return PTR_ERR_OR_ZERO(net->xt.frame_filter);
104} 104}
105 105
106static void __net_exit frame_filter_net_exit(struct net *net) 106static void __net_exit frame_filter_net_exit(struct net *net)
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index 10871bc77908..322555acdd40 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -100,7 +100,7 @@ static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
100static int __net_init frame_nat_net_init(struct net *net) 100static int __net_init frame_nat_net_init(struct net *net)
101{ 101{
102 net->xt.frame_nat = ebt_register_table(net, &frame_nat); 102 net->xt.frame_nat = ebt_register_table(net, &frame_nat);
103 return PTR_RET(net->xt.frame_nat); 103 return PTR_ERR_OR_ZERO(net->xt.frame_nat);
104} 104}
105 105
106static void __net_exit frame_nat_net_exit(struct net *net) 106static void __net_exit frame_nat_net_exit(struct net *net)
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index eadab1ed6500..a865f6f94013 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -48,7 +48,7 @@ static int __net_init arptable_filter_net_init(struct net *net)
48 net->ipv4.arptable_filter = 48 net->ipv4.arptable_filter =
49 arpt_register_table(net, &packet_filter, repl); 49 arpt_register_table(net, &packet_filter, repl);
50 kfree(repl); 50 kfree(repl);
51 return PTR_RET(net->ipv4.arptable_filter); 51 return PTR_ERR_OR_ZERO(net->ipv4.arptable_filter);
52} 52}
53 53
54static void __net_exit arptable_filter_net_exit(struct net *net) 54static void __net_exit arptable_filter_net_exit(struct net *net)
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
index 6b3da5cf54e9..50af5b45c050 100644
--- a/net/ipv4/netfilter/iptable_filter.c
+++ b/net/ipv4/netfilter/iptable_filter.c
@@ -69,7 +69,7 @@ static int __net_init iptable_filter_net_init(struct net *net)
69 net->ipv4.iptable_filter = 69 net->ipv4.iptable_filter =
70 ipt_register_table(net, &packet_filter, repl); 70 ipt_register_table(net, &packet_filter, repl);
71 kfree(repl); 71 kfree(repl);
72 return PTR_RET(net->ipv4.iptable_filter); 72 return PTR_ERR_OR_ZERO(net->ipv4.iptable_filter);
73} 73}
74 74
75static void __net_exit iptable_filter_net_exit(struct net *net) 75static void __net_exit iptable_filter_net_exit(struct net *net)
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index cba5658ec82c..0d8cd82e0fad 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -107,7 +107,7 @@ static int __net_init iptable_mangle_net_init(struct net *net)
107 net->ipv4.iptable_mangle = 107 net->ipv4.iptable_mangle =
108 ipt_register_table(net, &packet_mangler, repl); 108 ipt_register_table(net, &packet_mangler, repl);
109 kfree(repl); 109 kfree(repl);
110 return PTR_RET(net->ipv4.iptable_mangle); 110 return PTR_ERR_OR_ZERO(net->ipv4.iptable_mangle);
111} 111}
112 112
113static void __net_exit iptable_mangle_net_exit(struct net *net) 113static void __net_exit iptable_mangle_net_exit(struct net *net)
diff --git a/net/ipv4/netfilter/iptable_nat.c b/net/ipv4/netfilter/iptable_nat.c
index 6383273d54e1..683bfaffed65 100644
--- a/net/ipv4/netfilter/iptable_nat.c
+++ b/net/ipv4/netfilter/iptable_nat.c
@@ -292,7 +292,7 @@ static int __net_init iptable_nat_net_init(struct net *net)
292 return -ENOMEM; 292 return -ENOMEM;
293 net->ipv4.nat_table = ipt_register_table(net, &nf_nat_ipv4_table, repl); 293 net->ipv4.nat_table = ipt_register_table(net, &nf_nat_ipv4_table, repl);
294 kfree(repl); 294 kfree(repl);
295 return PTR_RET(net->ipv4.nat_table); 295 return PTR_ERR_OR_ZERO(net->ipv4.nat_table);
296} 296}
297 297
298static void __net_exit iptable_nat_net_exit(struct net *net) 298static void __net_exit iptable_nat_net_exit(struct net *net)
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 03d9696d3c6e..1f82aea11df6 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -48,7 +48,7 @@ static int __net_init iptable_raw_net_init(struct net *net)
48 net->ipv4.iptable_raw = 48 net->ipv4.iptable_raw =
49 ipt_register_table(net, &packet_raw, repl); 49 ipt_register_table(net, &packet_raw, repl);
50 kfree(repl); 50 kfree(repl);
51 return PTR_RET(net->ipv4.iptable_raw); 51 return PTR_ERR_OR_ZERO(net->ipv4.iptable_raw);
52} 52}
53 53
54static void __net_exit iptable_raw_net_exit(struct net *net) 54static void __net_exit iptable_raw_net_exit(struct net *net)
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c
index b283d8e2601a..f867a8d38bf7 100644
--- a/net/ipv4/netfilter/iptable_security.c
+++ b/net/ipv4/netfilter/iptable_security.c
@@ -66,7 +66,7 @@ static int __net_init iptable_security_net_init(struct net *net)
66 net->ipv4.iptable_security = 66 net->ipv4.iptable_security =
67 ipt_register_table(net, &security_table, repl); 67 ipt_register_table(net, &security_table, repl);
68 kfree(repl); 68 kfree(repl);
69 return PTR_RET(net->ipv4.iptable_security); 69 return PTR_ERR_OR_ZERO(net->ipv4.iptable_security);
70} 70}
71 71
72static void __net_exit iptable_security_net_exit(struct net *net) 72static void __net_exit iptable_security_net_exit(struct net *net)
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index beb5777d2043..29b44b14c5ea 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -61,7 +61,7 @@ static int __net_init ip6table_filter_net_init(struct net *net)
61 net->ipv6.ip6table_filter = 61 net->ipv6.ip6table_filter =
62 ip6t_register_table(net, &packet_filter, repl); 62 ip6t_register_table(net, &packet_filter, repl);
63 kfree(repl); 63 kfree(repl);
64 return PTR_RET(net->ipv6.ip6table_filter); 64 return PTR_ERR_OR_ZERO(net->ipv6.ip6table_filter);
65} 65}
66 66
67static void __net_exit ip6table_filter_net_exit(struct net *net) 67static void __net_exit ip6table_filter_net_exit(struct net *net)
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index e075399d8b72..c705907ae6ab 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -101,7 +101,7 @@ static int __net_init ip6table_mangle_net_init(struct net *net)
101 net->ipv6.ip6table_mangle = 101 net->ipv6.ip6table_mangle =
102 ip6t_register_table(net, &packet_mangler, repl); 102 ip6t_register_table(net, &packet_mangler, repl);
103 kfree(repl); 103 kfree(repl);
104 return PTR_RET(net->ipv6.ip6table_mangle); 104 return PTR_ERR_OR_ZERO(net->ipv6.ip6table_mangle);
105} 105}
106 106
107static void __net_exit ip6table_mangle_net_exit(struct net *net) 107static void __net_exit ip6table_mangle_net_exit(struct net *net)
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c
index 6383f90efda8..9b076d2d3a7b 100644
--- a/net/ipv6/netfilter/ip6table_nat.c
+++ b/net/ipv6/netfilter/ip6table_nat.c
@@ -293,7 +293,7 @@ static int __net_init ip6table_nat_net_init(struct net *net)
293 return -ENOMEM; 293 return -ENOMEM;
294 net->ipv6.ip6table_nat = ip6t_register_table(net, &nf_nat_ipv6_table, repl); 294 net->ipv6.ip6table_nat = ip6t_register_table(net, &nf_nat_ipv6_table, repl);
295 kfree(repl); 295 kfree(repl);
296 return PTR_RET(net->ipv6.ip6table_nat); 296 return PTR_ERR_OR_ZERO(net->ipv6.ip6table_nat);
297} 297}
298 298
299static void __net_exit ip6table_nat_net_exit(struct net *net) 299static void __net_exit ip6table_nat_net_exit(struct net *net)
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index 60d1bddff7a0..9a626d86720f 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -40,7 +40,7 @@ static int __net_init ip6table_raw_net_init(struct net *net)
40 net->ipv6.ip6table_raw = 40 net->ipv6.ip6table_raw =
41 ip6t_register_table(net, &packet_raw, repl); 41 ip6t_register_table(net, &packet_raw, repl);
42 kfree(repl); 42 kfree(repl);
43 return PTR_RET(net->ipv6.ip6table_raw); 43 return PTR_ERR_OR_ZERO(net->ipv6.ip6table_raw);
44} 44}
45 45
46static void __net_exit ip6table_raw_net_exit(struct net *net) 46static void __net_exit ip6table_raw_net_exit(struct net *net)
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c
index db155351339c..ce88d1d7e525 100644
--- a/net/ipv6/netfilter/ip6table_security.c
+++ b/net/ipv6/netfilter/ip6table_security.c
@@ -58,7 +58,7 @@ static int __net_init ip6table_security_net_init(struct net *net)
58 net->ipv6.ip6table_security = 58 net->ipv6.ip6table_security =
59 ip6t_register_table(net, &security_table, repl); 59 ip6t_register_table(net, &security_table, repl);
60 kfree(repl); 60 kfree(repl);
61 return PTR_RET(net->ipv6.ip6table_security); 61 return PTR_ERR_OR_ZERO(net->ipv6.ip6table_security);
62} 62}
63 63
64static void __net_exit ip6table_security_net_exit(struct net *net) 64static void __net_exit ip6table_security_net_exit(struct net *net)
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
index 2274638d005b..e18f8402e37c 100644
--- a/scripts/coccinelle/api/ptr_ret.cocci
+++ b/scripts/coccinelle/api/ptr_ret.cocci
@@ -1,5 +1,5 @@
1/// 1///
2/// Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR 2/// Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
3/// 3///
4// Confidence: High 4// Confidence: High
5// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. 5// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
@@ -7,7 +7,7 @@
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Options: --no-includes --include-headers 8// Options: --no-includes --include-headers
9// 9//
10// Keywords: ERR_PTR, PTR_ERR, PTR_RET 10// Keywords: ERR_PTR, PTR_ERR, PTR_RET, PTR_ERR_OR_ZERO
11// Version min: 2.6.39 11// Version min: 2.6.39
12// 12//
13 13
@@ -21,21 +21,21 @@ expression ptr;
21@@ 21@@
22 22
23- if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; 23- if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
24+ return PTR_RET(ptr); 24+ return PTR_ERR_OR_ZERO(ptr);
25 25
26@depends on patch@ 26@depends on patch@
27expression ptr; 27expression ptr;
28@@ 28@@
29 29
30- if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; 30- if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
31+ return PTR_RET(ptr); 31+ return PTR_ERR_OR_ZERO(ptr);
32 32
33@depends on patch@ 33@depends on patch@
34expression ptr; 34expression ptr;
35@@ 35@@
36 36
37- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) 37- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
38+ PTR_RET(ptr) 38+ PTR_ERR_OR_ZERO(ptr)
39 39
40@r1 depends on !patch@ 40@r1 depends on !patch@
41expression ptr; 41expression ptr;
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index 8ca9ecc5ac57..122c0c18b9dd 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -158,7 +158,7 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
158 return -EINVAL; 158 return -EINVAL;
159 } 159 }
160 160
161 return PTR_RET(codec->control_data); 161 return PTR_ERR_OR_ZERO(codec->control_data);
162} 162}
163EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io); 163EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io);
164#else 164#else