powerpc: fix of_device __must_check warning
PATCH 1/1 powerpc: fix of_device __must_check warning
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
---
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
arch/powerpc/kernel/of_device.c +4 -2
@@ -196,9 +196,11 @@ int of_device_register(struct of_deviceif (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)
Quoted 4 lines · Ryusuke Konishi
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 attributewarn_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.
Hi,
Quoted 6 lines · Paul Mackerras
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_registerfrom performing its main function. With your patch,of_device_registerwill fail if we can't create the "devspec" file.
Quoted 6 lines
On the whole, I am inclined to think that it is useful for
of_device_registerto 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:
Quoted 16 lines
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.