[RFC/PATCH 2/7] OMAP3: beagle: don't touch omap_device internals
From: Russell King - ARM Linux <hidden>
Date: 2011-07-28 10:10:12
Also in:
linux-devicetree, linux-omap
From: Russell King - ARM Linux <hidden>
Date: 2011-07-28 10:10:12
Also in:
linux-devicetree, linux-omap
On Thu, Jul 28, 2011 at 12:53:47AM -0500, Nishanth Menon wrote:
+struct device *omap_hwmod_to_device(const char *oh_name)
+{
+ struct omap_hwmod *oh;
+
+ if (!oh_name) {
+ WARN(1, "%s: no hwmod name!\n", __func__);
+ return ERR_PTR(-EINVAL);
+ }
+
+ oh = _lookup(oh_name);
+ if (IS_ERR_OR_NULL(oh)) {
+ WARN(1, "%s: no hwmod for %s\n", __func__,
+ oh_name);
+ return ERR_PTR(-ENODEV);It is good practice to always propagate back the error codes from functions which failed. So you may need something like: return ERR_PTR(oh ? PTR_ERR(oh) : -ENODEV); here.
+ }
+ if (IS_ERR_OR_NULL(oh->od)) {
+ WARN(1, "%s: no omap_device for %s\n", __func__,
+ oh_name);
+ return ERR_PTR(-ENODEV);Same here.