* [PATCH] tc: Error handling clean-ups
@ 2014-04-06 19:52 Maciej W. Rozycki
2014-10-26 15:22 ` [PATCH RESEND] " Maciej W. Rozycki
0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-04-06 19:52 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
Rewrite TURBOchannel error handling to use a common failure path, making
sure put_device is called for devices that failed initialization. While
at it update printk calls to use pr_err rather than KERN_ERR.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
The checkpatch.pl warning deliberately ignored, I'm not going to go past
79 columns.
linux-mips-tc-init-fix.patch
Index: linux-20140329-4maxp64/drivers/tc/tc.c
===================================================================
--- linux-20140329-4maxp64.orig/drivers/tc/tc.c
+++ linux-20140329-4maxp64/drivers/tc/tc.c
@@ -83,8 +83,7 @@ static void __init tc_bus_add_devices(st
/* Found a board, allocate it an entry in the list */
tdev = kzalloc(sizeof(*tdev), GFP_KERNEL);
if (!tdev) {
- printk(KERN_ERR "tc%x: unable to allocate tc_dev\n",
- slot);
+ pr_err("tc%x: unable to allocate tc_dev\n", slot);
goto out_err;
}
dev_set_name(&tdev->dev, "tc%x", slot);
@@ -117,10 +116,10 @@ static void __init tc_bus_add_devices(st
tdev->resource.start = extslotaddr;
tdev->resource.end = extslotaddr + devsize - 1;
} else {
- printk(KERN_ERR "%s: Cannot provide slot space "
- "(%dMiB required, up to %dMiB supported)\n",
- dev_name(&tdev->dev), devsize >> 20,
- max(slotsize, extslotsize) >> 20);
+ pr_err("%s: Cannot provide slot space "
+ "(%ldMiB required, up to %ldMiB supported)\n",
+ dev_name(&tdev->dev), (long)(devsize >> 20),
+ (long)(max(slotsize, extslotsize) >> 20));
kfree(tdev);
goto out_err;
}
@@ -147,14 +146,12 @@ static int __init tc_init(void)
{
/* Initialize the TURBOchannel bus */
if (tc_bus_get_info(&tc_bus))
- return 0;
+ goto out_err;
INIT_LIST_HEAD(&tc_bus.devices);
dev_set_name(&tc_bus.dev, "tc");
- if (device_register(&tc_bus.dev)) {
- put_device(&tc_bus.dev);
- return 0;
- }
+ if (device_register(&tc_bus.dev))
+ goto out_err_device;
if (tc_bus.info.slot_size) {
unsigned int tc_clock = tc_get_speed(&tc_bus) / 100000;
@@ -172,8 +169,8 @@ static int __init tc_init(void)
tc_bus.resource[0].flags = IORESOURCE_MEM;
if (request_resource(&iomem_resource,
&tc_bus.resource[0]) < 0) {
- printk(KERN_ERR "tc: Cannot reserve resource\n");
- return 0;
+ pr_err("tc: Cannot reserve resource\n");
+ goto out_err_device;
}
if (tc_bus.ext_slot_size) {
tc_bus.resource[1].start = tc_bus.ext_slot_base;
@@ -184,10 +181,8 @@ static int __init tc_init(void)
tc_bus.resource[1].flags = IORESOURCE_MEM;
if (request_resource(&iomem_resource,
&tc_bus.resource[1]) < 0) {
- printk(KERN_ERR
- "tc: Cannot reserve resource\n");
- release_resource(&tc_bus.resource[0]);
- return 0;
+ pr_err("tc: Cannot reserve resource\n");
+ goto out_err_resource;
}
}
@@ -195,6 +190,13 @@ static int __init tc_init(void)
}
return 0;
+
+out_err_resource:
+ release_resource(&tc_bus.resource[0]);
+out_err_device:
+ put_device(&tc_bus.dev);
+out_err:
+ return 0;
}
subsys_initcall(tc_init);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH RESEND] tc: Error handling clean-ups
2014-04-06 19:52 [PATCH] tc: Error handling clean-ups Maciej W. Rozycki
@ 2014-10-26 15:22 ` Maciej W. Rozycki
2014-10-26 23:10 ` Stephen Rothwell
0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-10-26 15:22 UTC (permalink / raw)
To: Stephen Rothwell; +Cc: Ralf Baechle, linux-next, linux-kernel
Rewrite TURBOchannel error handling to use a common failure path, making
sure put_device is called for devices that failed initialization. While
at it update printk calls to use pr_err rather than KERN_ERR. Finally
avoid printk format warnings on resource_size_t type variables.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
The checkpatch.pl warning deliberately ignored, I'm not going to go past
79 columns.
Stephen,
I posted this fix originally to linux-mips@linux-mips.org back in April,
but it got lost and I don't want to give Ralf more stuff to handle than
absolutely necessary, he is really busy these days. Can you please take
it directly to linux-next then? There's nothing specific to MIPS in this
code really.
Thanks,
Maciej
linux-tc-init-fix.patch
Index: linux-20140329-4maxp64/drivers/tc/tc.c
===================================================================
--- linux-20140329-4maxp64.orig/drivers/tc/tc.c
+++ linux-20140329-4maxp64/drivers/tc/tc.c
@@ -83,8 +83,7 @@ static void __init tc_bus_add_devices(st
/* Found a board, allocate it an entry in the list */
tdev = kzalloc(sizeof(*tdev), GFP_KERNEL);
if (!tdev) {
- printk(KERN_ERR "tc%x: unable to allocate tc_dev\n",
- slot);
+ pr_err("tc%x: unable to allocate tc_dev\n", slot);
goto out_err;
}
dev_set_name(&tdev->dev, "tc%x", slot);
@@ -117,10 +116,10 @@ static void __init tc_bus_add_devices(st
tdev->resource.start = extslotaddr;
tdev->resource.end = extslotaddr + devsize - 1;
} else {
- printk(KERN_ERR "%s: Cannot provide slot space "
- "(%dMiB required, up to %dMiB supported)\n",
- dev_name(&tdev->dev), devsize >> 20,
- max(slotsize, extslotsize) >> 20);
+ pr_err("%s: Cannot provide slot space "
+ "(%ldMiB required, up to %ldMiB supported)\n",
+ dev_name(&tdev->dev), (long)(devsize >> 20),
+ (long)(max(slotsize, extslotsize) >> 20));
kfree(tdev);
goto out_err;
}
@@ -147,14 +146,12 @@ static int __init tc_init(void)
{
/* Initialize the TURBOchannel bus */
if (tc_bus_get_info(&tc_bus))
- return 0;
+ goto out_err;
INIT_LIST_HEAD(&tc_bus.devices);
dev_set_name(&tc_bus.dev, "tc");
- if (device_register(&tc_bus.dev)) {
- put_device(&tc_bus.dev);
- return 0;
- }
+ if (device_register(&tc_bus.dev))
+ goto out_err_device;
if (tc_bus.info.slot_size) {
unsigned int tc_clock = tc_get_speed(&tc_bus) / 100000;
@@ -172,8 +169,8 @@ static int __init tc_init(void)
tc_bus.resource[0].flags = IORESOURCE_MEM;
if (request_resource(&iomem_resource,
&tc_bus.resource[0]) < 0) {
- printk(KERN_ERR "tc: Cannot reserve resource\n");
- return 0;
+ pr_err("tc: Cannot reserve resource\n");
+ goto out_err_device;
}
if (tc_bus.ext_slot_size) {
tc_bus.resource[1].start = tc_bus.ext_slot_base;
@@ -184,10 +181,8 @@ static int __init tc_init(void)
tc_bus.resource[1].flags = IORESOURCE_MEM;
if (request_resource(&iomem_resource,
&tc_bus.resource[1]) < 0) {
- printk(KERN_ERR
- "tc: Cannot reserve resource\n");
- release_resource(&tc_bus.resource[0]);
- return 0;
+ pr_err("tc: Cannot reserve resource\n");
+ goto out_err_resource;
}
}
@@ -195,6 +190,13 @@ static int __init tc_init(void)
}
return 0;
+
+out_err_resource:
+ release_resource(&tc_bus.resource[0]);
+out_err_device:
+ put_device(&tc_bus.dev);
+out_err:
+ return 0;
}
subsys_initcall(tc_init);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] tc: Error handling clean-ups
2014-10-26 15:22 ` [PATCH RESEND] " Maciej W. Rozycki
@ 2014-10-26 23:10 ` Stephen Rothwell
2014-10-27 1:16 ` Maciej W. Rozycki
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Rothwell @ 2014-10-26 23:10 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: Ralf Baechle, linux-next, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 762 bytes --]
Hi Maciej,
On Sun, 26 Oct 2014 15:22:33 +0000 (GMT) "Maciej W. Rozycki" <macro@linux-mips.org> wrote:
>
> I posted this fix originally to linux-mips@linux-mips.org back in April,
> but it got lost and I don't want to give Ralf more stuff to handle than
> absolutely necessary, he is really busy these days. Can you please take
> it directly to linux-next then? There's nothing specific to MIPS in this
> code really.
I don't take patches directly into linux-next (unless they are very
specific bug fixes for things that affect my builds - and even then I
only keep them until a maintainer picks them up).
Sorry. You could try sending it to Linus or Andrew Morton.
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] tc: Error handling clean-ups
2014-10-26 23:10 ` Stephen Rothwell
@ 2014-10-27 1:16 ` Maciej W. Rozycki
2014-10-27 1:38 ` Ralf Baechle
0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-10-27 1:16 UTC (permalink / raw)
To: Stephen Rothwell, Andrew Morton; +Cc: Ralf Baechle, linux-kernel
Stephen, Andrew --
> > I posted this fix originally to linux-mips@linux-mips.org back in April,
> > but it got lost and I don't want to give Ralf more stuff to handle than
> > absolutely necessary, he is really busy these days. Can you please take
> > it directly to linux-next then? There's nothing specific to MIPS in this
> > code really.
>
> I don't take patches directly into linux-next (unless they are very
> specific bug fixes for things that affect my builds - and even then I
> only keep them until a maintainer picks them up).
Good to know, will remember, thanks, and apologies to bother you then.
As the maintainer of this bus subsystem I wasn't sure what to do given
the situation.
> Sorry. You could try sending it to Linus or Andrew Morton.
Andrew, can you please take the change from the LKML message heading
this thread, or shall I resend it somehow for you to pick it up? This
doesn't really fit anywhere.
Thanks,
Maciej
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] tc: Error handling clean-ups
2014-10-27 1:16 ` Maciej W. Rozycki
@ 2014-10-27 1:38 ` Ralf Baechle
2014-10-27 13:41 ` Maciej W. Rozycki
0 siblings, 1 reply; 6+ messages in thread
From: Ralf Baechle @ 2014-10-27 1:38 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: Stephen Rothwell, Andrew Morton, linux-kernel
On Mon, Oct 27, 2014 at 01:16:37AM +0000, Maciej W. Rozycki wrote:
> > > I posted this fix originally to linux-mips@linux-mips.org back in April,
> > > but it got lost and I don't want to give Ralf more stuff to handle than
> > > absolutely necessary, he is really busy these days. Can you please take
> > > it directly to linux-next then? There's nothing specific to MIPS in this
> > > code really.
> >
> > I don't take patches directly into linux-next (unless they are very
> > specific bug fixes for things that affect my builds - and even then I
> > only keep them until a maintainer picks them up).
>
> Good to know, will remember, thanks, and apologies to bother you then.
> As the maintainer of this bus subsystem I wasn't sure what to do given
> the situation.
>
> > Sorry. You could try sending it to Linus or Andrew Morton.
>
> Andrew, can you please take the change from the LKML message heading
> this thread, or shall I resend it somehow for you to pick it up? This
> doesn't really fit anywhere.
The original patch is marked as rejected in patchwork - but I don't recall
why and the patch does look good and applies, so I just applied it. Sorry,
probably fat fingered patchwork ...
Ralf
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] tc: Error handling clean-ups
2014-10-27 1:38 ` Ralf Baechle
@ 2014-10-27 13:41 ` Maciej W. Rozycki
0 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-10-27 13:41 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Stephen Rothwell, Andrew Morton, linux-kernel
On Mon, 27 Oct 2014, Ralf Baechle wrote:
> > Andrew, can you please take the change from the LKML message heading
> > this thread, or shall I resend it somehow for you to pick it up? This
> > doesn't really fit anywhere.
>
> The original patch is marked as rejected in patchwork - but I don't recall
> why and the patch does look good and applies, so I just applied it. Sorry,
> probably fat fingered patchwork ...
Great, thanks very much indeed, Ralf!
Maciej
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-27 13:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-06 19:52 [PATCH] tc: Error handling clean-ups Maciej W. Rozycki
2014-10-26 15:22 ` [PATCH RESEND] " Maciej W. Rozycki
2014-10-26 23:10 ` Stephen Rothwell
2014-10-27 1:16 ` Maciej W. Rozycki
2014-10-27 1:38 ` Ralf Baechle
2014-10-27 13:41 ` Maciej W. Rozycki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.