drm/radeon: simplify driver data retrieval
Subsystems (2)
PATCH 1/2 drm/radeon: simplify driver data retrieval
You can get the driver data from struct device directly, there's no need to get the PCI device first.
--- drivers/gpu/drm/radeon/radeon_pm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/radeon/radeon_pm.c +9 -9
@@ -333,7 +333,7 @@ static ssize_t radeon_get_pm_profile(strstruct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev);struct radeon_device *rdev = ddev->dev_private;int cp = rdev->pm.profile;
@@ -349,7 +349,7 @@ static ssize_t radeon_set_pm_profile(str const char *buf, size_t count) { -struct drm_device *ddev =pci_get_drvdata (to_pci_dev (dev)); +struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;mutex_lock (&rdev->pm.mutex);
@@ -383,7 +383,7 @@ static ssize_t radeon_get_pm_method(strustruct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev);struct radeon_device *rdev = ddev->dev_private;int pm = rdev->pm.pm_method;
@@ -397,7 +397,7 @@ static ssize_t radeon_set_pm_method(stru const char *buf, size_t count) { -struct drm_device *ddev =pci_get_drvdata (to_pci_dev (dev)); +struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;/* we don't support the legacy modes with dpm */
@@ -433,7 +433,7 @@ static ssize_t radeon_get_dpm_state(strustruct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev);struct radeon_device *rdev = ddev->dev_private;enum radeon_pm_state_type pm = rdev->pm.dpm.user_state;
@@ -447,7 +447,7 @@ static ssize_t radeon_set_dpm_state(stru const char *buf, size_t count) { -struct drm_device *ddev =pci_get_drvdata (to_pci_dev (dev)); +struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;mutex_lock (&rdev->pm.mutex);
@@ -472,7 +472,7 @@ static ssize_t radeon_get_dpm_forced_perstruct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev);struct radeon_device *rdev = ddev->dev_private;enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level;
@@ -486,7 +486,7 @@ static ssize_t radeon_set_dpm_forced_per const char *buf, size_t count) { -struct drm_device *ddev =pci_get_drvdata (to_pci_dev (dev)); +struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;enum radeon_dpm_forced_level level;int ret =0 ;
@@ -524,7 +524,7 @@ static ssize_t radeon_hwmon_show_temp(ststruct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev);struct radeon_device *rdev = ddev->dev_private;int temp;
Signature · 2 lines
Jean Delvare Suse L3
PATCH 2/2 drm/radeon: expose DPM thermal thresholds through sysfs
The hwmon sysfs interface allows exposing temperature limits. The "max" and "min" thresholds will be exposed as a critical high limit and its hysteresis value, respectively. This gives the user a better idea of how well cooling is doing and whether it is sufficient.
--- drivers/gpu/drm/radeon/radeon_pm.c | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/gpu/drm/radeon/radeon_pm.c +38 -0
@@ -536,6 +536,23 @@ static ssize_t radeon_hwmon_show_temp(streturn snprintf (buf,PAGE_SIZE ,"%d\n" , temp); } +static ssize_t radeon_hwmon_show_temp_thresh (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct radeon_device *rdev = ddev->dev_private; +int hyst =to_sensor_dev_attr (attr)->index; +int temp; + +if (hyst) + temp = rdev->pm.dpm.thermal.min_temp; +else + temp = rdev->pm.dpm.thermal.max_temp; + +return snprintf (buf,PAGE_SIZE ,"%d\n" , temp); +} +static ssize_t radeon_hwmon_show_name (struct device *dev,struct device_attribute *attr,char *buf)
@@ -544,16 +561,37 @@ static ssize_t radeon_hwmon_show_name(st } static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); +static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); +static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0);static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp1_crit.dev_attr.attr, + &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, &sensor_dev_attr_name.dev_attr.attr,NULL }; +static umode_t hwmon_attributes_visible (struct kobject *kobj, +struct attribute *attr,int index) +{ + struct device *dev = container_of(kobj, struct device, kobj); +struct drm_device *ddev =dev_get_drvdata (dev); +struct radeon_device *rdev = ddev->dev_private; + +/* Skip limit attributes if DPM is not enabled */ +if (rdev->pm.pm_method !=PM_METHOD_DPM && + (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr || + attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr)) +return 0 ; + +return attr->mode; +} +static const struct attribute_group hwmon_attrgroup = { .attrs = hwmon_attributes, + .is_visible = hwmon_attributes_visible, };static int radeon_hwmon_init (struct radeon_device *rdev)
Signature · 2 lines
Jean Delvare Suse L3
Alex Deucher
AppliedQuoted 6 lines · Jean Delvare
You can get the driver data from struct device directly, there's no need to get the PCI device first.
Signed-off-by Jean Delvare <[email protected]>Cc David Airlie <[email protected]>Cc Alex Deucher <[email protected]>
Applied. thanks!
Alex
Quoted 96 lines
--- drivers/gpu/drm/radeon/radeon_pm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/radeon/radeon_pm.c 2013-09-03 09:20:41.850518596 +0200 renamed from drivers/gpu/drm/radeon/radeon_pm.c 2013-09-02 22:06:28.569606289 +0200 +9
-10@@ -333,7 +333,7 @@ static ssize_t radeon_get_pm_profile(str struct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; int cp = rdev->pm.profile;@@ -349,7 +349,7 @@ static ssize_t radeon_set_pm_profile(str const char *buf, size_t count) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; mutex_lock(&rdev->pm.mutex);@@ -383,7 +383,7 @@ static ssize_t radeon_get_pm_method(stru struct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; int pm = rdev->pm.pm_method;@@ -397,7 +397,7 @@ static ssize_t radeon_set_pm_method(stru const char *buf, size_t count) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; /* we don't support the legacy modes with dpm */@@ -433,7 +433,7 @@ static ssize_t radeon_get_dpm_state(stru struct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; enum radeon_pm_state_type pm = rdev->pm.dpm.user_state;@@ -447,7 +447,7 @@ static ssize_t radeon_set_dpm_state(stru const char *buf, size_t count) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; mutex_lock(&rdev->pm.mutex);@@ -472,7 +472,7 @@ static ssize_t radeon_get_dpm_forced_per struct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level;@@ -486,7 +486,7 @@ static ssize_t radeon_set_dpm_forced_per const char *buf, size_t count) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; enum radeon_dpm_forced_level level; int ret = 0;@@ -524,7 +524,7 @@ static ssize_t radeon_hwmon_show_temp(st struct device_attribute *attr, char *buf) { - struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); + struct drm_device *ddev = dev_get_drvdata(dev); struct radeon_device *rdev = ddev->dev_private; int temp; --Jean Delvare
Suse L3_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel