* [PATCH 2.6.19-rc6] powerpc: fix of_device __must_check warning
@ 2006-11-29 5:07 Ryusuke Konishi
2006-11-29 8:35 ` Paul Mackerras
0 siblings, 1 reply; 3+ messages in thread
From: Ryusuke Konishi @ 2006-11-29 5:07 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev
This fixes the following compile warning:
arch/powerpc/kernel/of_device.c: In function 'of_device_register':
arch/powerpc/kernel/of_device.c:199: warning: ignoring return value of 'device_create_file', declared with attribute warn_unused_result
Signed-off-by: Ryusuke Konishi <ryusuke@osrg.net>
---
Hi,
This patch becomes useless when Benjamin's "powerpc: of_platform
improvements" work will be done. But, transiently, it helps to
reduce gcc warning arising on the latest Linus's tree.
Regards,
Ryusuke
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index 397c83e..8831f00 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -196,9 +196,11 @@ int of_device_register(struct of_device
if (rc)
return rc;
- device_create_file(&ofdev->dev, &dev_attr_devspec);
+ rc = device_create_file(&ofdev->dev, &dev_attr_devspec);
+ if (rc)
+ device_unregister(&ofdev->dev);
- return 0;
+ return rc;
}
void of_device_unregister(struct of_device *ofdev)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.19-rc6] powerpc: fix of_device __must_check warning
2006-11-29 5:07 [PATCH 2.6.19-rc6] powerpc: fix of_device __must_check warning Ryusuke Konishi
@ 2006-11-29 8:35 ` Paul Mackerras
2006-11-30 12:39 ` Ryusuke Konishi
0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2006-11-29 8:35 UTC (permalink / raw)
To: Ryusuke Konishi; +Cc: linuxppc-dev
Ryusuke Konishi writes:
> This fixes the following compile warning:
>
> arch/powerpc/kernel/of_device.c: In function 'of_device_register':
> arch/powerpc/kernel/of_device.c:199: warning: ignoring return value of 'device_create_file', declared with attribute warn_unused_result
Your patch also makes a policy change, though, in that without your
patch, a failure in creating the "devspec" file in sysfs doesn't
prevent of_device_register from performing its main function. With
your patch, of_device_register will fail if we can't create the
"devspec" file.
On the whole, I am inclined to think that it is useful for
of_device_register to succeed even if the devspec file can't be
created, since nothing in the kernel relies on the devspec file being
present.
Paul.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2.6.19-rc6] powerpc: fix of_device __must_check warning
2006-11-29 8:35 ` Paul Mackerras
@ 2006-11-30 12:39 ` Ryusuke Konishi
0 siblings, 0 replies; 3+ messages in thread
From: Ryusuke Konishi @ 2006-11-30 12:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
Hi,
Paul Mackerras wrote:
> Your patch also makes a policy change, though, in that without your
> patch, a failure in creating the "devspec" file in sysfs doesn't
> prevent of_device_register from performing its main function. With
> your patch, of_device_register will fail if we can't create the
> "devspec" file.
>
> On the whole, I am inclined to think that it is useful for
> of_device_register to succeed even if the devspec file can't be
> created, since nothing in the kernel relies on the devspec file being
> present.
>
> Paul.
Yes, you have a point there.
For the purpose of reference, I looked into other architectures.
Then, I found that sparc (and sparc64) had same of_device_register()
functions, and both are checking the result of device_create_file()
as follows.
in function arch/sparc/kernel/of_device.c:
>int of_device_register(struct of_device *ofdev)
>{
> int rc;
>
> BUG_ON(ofdev->node == NULL);
>
> rc = device_register(&ofdev->dev);
> if (rc)
> return rc;
>
> rc = device_create_file(&ofdev->dev, &dev_attr_devspec);
> if (rc)
> device_unregister(&ofdev->dev);
>
> return rc;
>}
But then, I'd like to respect your point of view,
and I won't stick to this case example.
Ryusuke.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-30 12:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-29 5:07 [PATCH 2.6.19-rc6] powerpc: fix of_device __must_check warning Ryusuke Konishi
2006-11-29 8:35 ` Paul Mackerras
2006-11-30 12:39 ` Ryusuke Konishi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).