* [patch] radeon: handle errors in radeon_hwmon_init()
@ 2010-08-07 22:20 Dan Carpenter
2010-08-07 22:25 ` Rafał Miłecki
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2010-08-07 22:20 UTC (permalink / raw)
To: David Airlie; +Cc: kernel-janitors, dri-devel, Dave Airlie, Matthew Garrett
Smatch complained that the ERR_PTR from hwmon_device_register() wasn't
handled. I added some error handling in radeon_hwmon_init() to silence
the warning.
Unfortunately errors from radeon_pm_init() aren't handled so this
doesn't really make a difference beyond silencing the warning.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 95f8b3a..965e0f1 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -472,9 +472,9 @@ static const struct attribute_group hwmon_attrgroup = {
.attrs = hwmon_attributes,
};
-static void radeon_hwmon_init(struct radeon_device *rdev)
+static int radeon_hwmon_init(struct radeon_device *rdev)
{
- int err;
+ int err = 0;
rdev->pm.int_hwmon_dev = NULL;
@@ -483,15 +483,24 @@ static void radeon_hwmon_init(struct radeon_device *rdev)
case THERMAL_TYPE_RV770:
case THERMAL_TYPE_EVERGREEN:
rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev);
+ if (IS_ERR(rdev->pm.int_hwmon_dev)) {
+ err = PTR_ERR(rdev->pm.int_hwmon_dev);
+ DRM_ERROR("Unable to register hwmon device: %d\n", err);
+ break;
+ }
dev_set_drvdata(rdev->pm.int_hwmon_dev, rdev->ddev);
err = sysfs_create_group(&rdev->pm.int_hwmon_dev->kobj,
&hwmon_attrgroup);
- if (err)
+ if (err) {
DRM_ERROR("Unable to create hwmon sysfs file: %d\n", err);
+ hwmon_device_unregister(rdev->dev);
+ }
break;
default:
break;
}
+
+ return err;
}
static void radeon_hwmon_fini(struct radeon_device *rdev)
@@ -540,6 +549,7 @@ void radeon_pm_resume(struct radeon_device *rdev)
int radeon_pm_init(struct radeon_device *rdev)
{
int ret;
+
/* default to profile method */
rdev->pm.pm_method = PM_METHOD_PROFILE;
rdev->pm.profile = PM_PROFILE_DEFAULT;
@@ -561,7 +571,9 @@ int radeon_pm_init(struct radeon_device *rdev)
}
/* set up the internal thermal sensor if applicable */
- radeon_hwmon_init(rdev);
+ ret = radeon_hwmon_init(rdev);
+ if (ret)
+ return ret;
if (rdev->pm.num_power_states > 1) {
/* where's the best place to put these? */
ret = device_create_file(rdev->dev, &dev_attr_power_profile);
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [patch] radeon: handle errors in radeon_hwmon_init()
2010-08-07 22:20 [patch] radeon: handle errors in radeon_hwmon_init() Dan Carpenter
@ 2010-08-07 22:25 ` Rafał Miłecki
2010-08-09 15:51 ` Alex Deucher
2010-08-09 19:59 ` [patch v2] " Dan Carpenter
0 siblings, 2 replies; 4+ messages in thread
From: Rafał Miłecki @ 2010-08-07 22:25 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors, dri-devel, Dave Airlie, Matthew Garrett
2010/8/8 Dan Carpenter <error27@gmail.com>:
> Smatch complained that the ERR_PTR from hwmon_device_register() wasn't
> handled. I added some error handling in radeon_hwmon_init() to silence
> the warning.
>
> Unfortunately errors from radeon_pm_init() aren't handled so this
> doesn't really make a difference beyond silencing the warning.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Didn't we try to switch from DRM_ERROR to dev_err? I think that's
preferred method.
--
Rafał
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] radeon: handle errors in radeon_hwmon_init()
2010-08-07 22:25 ` Rafał Miłecki
@ 2010-08-09 15:51 ` Alex Deucher
2010-08-09 19:59 ` [patch v2] " Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2010-08-09 15:51 UTC (permalink / raw)
To: Rafał Miłecki
Cc: Dan Carpenter, kernel-janitors, dri-devel, Dave Airlie,
Matthew Garrett
2010/8/7 Rafał Miłecki <zajec5@gmail.com>:
> 2010/8/8 Dan Carpenter <error27@gmail.com>:
>> Smatch complained that the ERR_PTR from hwmon_device_register() wasn't
>> handled. I added some error handling in radeon_hwmon_init() to silence
>> the warning.
>>
>> Unfortunately errors from radeon_pm_init() aren't handled so this
>> doesn't really make a difference beyond silencing the warning.
>>
>> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> Didn't we try to switch from DRM_ERROR to dev_err? I think that's
> preferred method.
Other than that, the patch looks fine.
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch v2] radeon: handle errors in radeon_hwmon_init()
2010-08-07 22:25 ` Rafał Miłecki
2010-08-09 15:51 ` Alex Deucher
@ 2010-08-09 19:59 ` Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2010-08-09 19:59 UTC (permalink / raw)
To: Rafał Miłecki
Cc: kernel-janitors, dri-devel, Dave Airlie, Matthew Garrett
Smatch complained that the ERR_PTR from hwmon_device_register() wasn't
handled. I added some error handling in radeon_hwmon_init() to silence
the warning.
Unfortunately errors from radeon_pm_init() aren't handled so this
doesn't really make a difference beyond silencing the warning.
Also I changed DRM_ERROR() to dev_err() which is the new preferred
method.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
V2: switched from DRM_ERROR() to dev_err()
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 95f8b3a..58038f5 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -472,9 +472,9 @@ static const struct attribute_group hwmon_attrgroup = {
.attrs = hwmon_attributes,
};
-static void radeon_hwmon_init(struct radeon_device *rdev)
+static int radeon_hwmon_init(struct radeon_device *rdev)
{
- int err;
+ int err = 0;
rdev->pm.int_hwmon_dev = NULL;
@@ -483,15 +483,26 @@ static void radeon_hwmon_init(struct radeon_device *rdev)
case THERMAL_TYPE_RV770:
case THERMAL_TYPE_EVERGREEN:
rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev);
+ if (IS_ERR(rdev->pm.int_hwmon_dev)) {
+ err = PTR_ERR(rdev->pm.int_hwmon_dev);
+ dev_err(rdev->dev,
+ "Unable to register hwmon device: %d\n", err);
+ break;
+ }
dev_set_drvdata(rdev->pm.int_hwmon_dev, rdev->ddev);
err = sysfs_create_group(&rdev->pm.int_hwmon_dev->kobj,
&hwmon_attrgroup);
- if (err)
- DRM_ERROR("Unable to create hwmon sysfs file: %d\n", err);
+ if (err) {
+ dev_err(rdev->dev,
+ "Unable to create hwmon sysfs file: %d\n", err);
+ hwmon_device_unregister(rdev->dev);
+ }
break;
default:
break;
}
+
+ return err;
}
static void radeon_hwmon_fini(struct radeon_device *rdev)
@@ -540,6 +551,7 @@ void radeon_pm_resume(struct radeon_device *rdev)
int radeon_pm_init(struct radeon_device *rdev)
{
int ret;
+
/* default to profile method */
rdev->pm.pm_method = PM_METHOD_PROFILE;
rdev->pm.profile = PM_PROFILE_DEFAULT;
@@ -561,7 +573,9 @@ int radeon_pm_init(struct radeon_device *rdev)
}
/* set up the internal thermal sensor if applicable */
- radeon_hwmon_init(rdev);
+ ret = radeon_hwmon_init(rdev);
+ if (ret)
+ return ret;
if (rdev->pm.num_power_states > 1) {
/* where's the best place to put these? */
ret = device_create_file(rdev->dev, &dev_attr_power_profile);
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-09 19:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-07 22:20 [patch] radeon: handle errors in radeon_hwmon_init() Dan Carpenter
2010-08-07 22:25 ` Rafał Miłecki
2010-08-09 15:51 ` Alex Deucher
2010-08-09 19:59 ` [patch v2] " Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox