dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] nouveau_hwmon: migrate to hwmon_device_register_with_info
@ 2017-04-13  9:09 Oscar Salvador
  0 siblings, 0 replies; only message in thread
From: Oscar Salvador @ 2017-04-13  9:09 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

This patch creates special group attributes for special attrs like "*auto_point*".
We check if we need them, and if we do, we set them up in special_groups structure, that then
we pass to hwmon_device_register_with_info.

--- linux/drivers/gpu/drm/nouveau/nouveau_hwmon.c.orig	2017-04-13 10:13:26.331391326 +0200
+++ linux/drivers/gpu/drm/nouveau/nouveau_hwmon.c	2017-04-13 10:15:02.274073273 +0200
@@ -417,6 +417,23 @@ nouveau_hwmon_get_power1_crit(struct nou
 	return iccsense->power_w_crit;
 }
 
+static struct attribute *pwm_fan_sensor_attrs[] = {
+	&sensor_dev_attr_pwm1_min.dev_attr.attr,
+	&sensor_dev_attr_pwm1_max.dev_attr.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(pwm_fan_sensor);
+
+static struct attribute *temp1_auto_point_sensor_attrs[] = {
+	&sensor_dev_attr_temp1_auto_point1_pwm.dev_attr.attr,
+	&sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr,
+	&sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr,
+	NULL
+};
+ATTRIBUTE_GROUPS(temp1_auto_point_sensor);
+
+#define N_ATTR_GROUPS   3
+
 static const u32 nouveau_config_chip[] = {
 	HWMON_C_UPDATE_INTERVAL,
 	0
@@ -868,17 +885,27 @@ nouveau_hwmon_init(struct drm_device *de
 #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
+	const struct attribute_group *special_groups[N_ATTR_GROUPS];
 	struct nouveau_hwmon *hwmon;
 	struct device *hwmon_dev;
 	int ret = 0;
+	int i = 0;
 
 	hwmon = drm->hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL);
 	if (!hwmon)
 		return -ENOMEM;
 	hwmon->dev = dev;
 
+	if (therm && therm->attr_get && therm->attr_set) {
+		if (nvkm_therm_temp_get(therm) >= 0)
+			special_groups[i++] = &temp1_auto_point_sensor_group;
+		if (therm->fan_get && therm->fan_get(therm) >= 0)
+			special_groups[i++] = &pwm_fan_sensor_group;
+	}
+
+	special_groups[i] = 0;
 	hwmon_dev = hwmon_device_register_with_info(dev->dev, "nouveau", dev,
-						&nouveau_chip_info, NULL);
+					&nouveau_chip_info, special_groups);
 	if (IS_ERR(hwmon_dev)) {
 		ret = PTR_ERR(hwmon_dev);
 		NV_ERROR(drm, "Unable to register hwmon device: %d\n", ret);
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-13  9:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-13  9:09 [PATCH 3/4] nouveau_hwmon: migrate to hwmon_device_register_with_info Oscar Salvador

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox