From patchwork Tue May 16 21:18:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 9729695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F3B7602DB for ; Tue, 16 May 2017 21:18:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 425F728715 for ; Tue, 16 May 2017 21:18:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36F7C28A1F; Tue, 16 May 2017 21:18:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC66C28715 for ; Tue, 16 May 2017 21:18:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 181696E34F; Tue, 16 May 2017 21:18:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id D4CC56E341; Tue, 16 May 2017 21:18:21 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id y10so40932395wmh.0; Tue, 16 May 2017 14:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NivjaDC1zRugfYrZBGCV0CfEHJ//mXdnU8HH3hBa+aU=; b=qI3hknRqqZvevsjxuQ7JmJg3nBA1agpw9jD2DNmkksvLR7w/7xXYlRHegM/iBUXFK8 l61zgAetsrlhBVKTQmyw0b+U9YBxAs3GBcW0Bddmy5NUEmPyOL857cfQpJuVjCVsYVfN bEGoxqg2bMiNy57qoXdAvqEshcyVH91VlbN0sXAtzInIX81sAaP4atGDSPGD9zmWBWaM Lo0LCDnHb9q3rVLKxmA72DvmWuxUBh8KQDH06FgROFG2j0LZF49rCjrDo1GbLk89vtsT 2ElZRbxAiJLh1tSGtusO0/AEcXw2NmIzYGapjut5skOsjGVAzQ2YR2b5wCEPFt6k9svH j0Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NivjaDC1zRugfYrZBGCV0CfEHJ//mXdnU8HH3hBa+aU=; b=db3wQivbczn0rhozgDB96Whqgq6082NvOUMHfKd19AfX2XC1sgbQWneNohMu8KanM+ zgdbv2I2/uPb/6mJVEhnZdDIRa00v+gCrrmo7p2GPP+yZ92z2pTaqIkmSN8BGMo5VWYg vPKTSAuLfslWygq6CPWiUsarKzcVnkzGEuxP9X6ecWz1E8LZkDTZ+4736dgkGCRsj3hW 32vkgyXu5d4Bue5kEI0oehQnpNHKRCVFdraSLuZ1OgAbPYsrCq/npdEAAYFJsO7UoBt4 NvE1SjwXzNV3xrqiSxZcLK0b6dt8AOcE9aRWWylulzwoQKM4FvzWKgjobOQr+WZNghhZ 0rAA== X-Gm-Message-State: AODbwcBiBr+QLJqF3ZcbeLVOU9VJFogxsqcaLcqcmWQ7Zz7jiGP6tKki Ln94SgL8VzdKTA== X-Received: by 10.28.97.139 with SMTP id v133mr7765230wmb.93.1494969500464; Tue, 16 May 2017 14:18:20 -0700 (PDT) Received: from localhost.localdomain (ip5f5adb9b.dynamic.kabel-deutschland.de. [95.90.219.155]) by smtp.googlemail.com with ESMTPSA id v7sm2898509wrv.59.2017.05.16.14.18.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 May 2017 14:18:19 -0700 (PDT) From: Oscar Salvador To: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v7 4/5] nouveau/hwmon: expose the auto_point and pwm_min/max attrs Date: Tue, 16 May 2017 23:18:41 +0200 Message-Id: <1494969522-9834-5-git-send-email-osalvador.vilardaga@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1494969522-9834-1-git-send-email-osalvador.vilardaga@gmail.com> References: <1494969522-9834-1-git-send-email-osalvador.vilardaga@gmail.com> Cc: Oscar Salvador X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch creates a special group attributes for attrs like "*auto_point*". We check if we have support for them, and if we do, we gather them all in an attribute_group's structure which is the parameter regarding special groups of hwmon_device_register_with_info We also do the same for pwm_min/max attrs. Signed-off-by: Oscar Salvador Reviewed-by: Martin Peres --- drivers/gpu/drm/nouveau/nouveau_hwmon.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c index bd14d3b..53ad696 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c @@ -192,6 +192,23 @@ static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO | S_IWUSR, nouveau_hwmon_get_pwm1_max, nouveau_hwmon_set_pwm1_max, 0); +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 @@ -687,17 +704,28 @@ nouveau_hwmon_init(struct drm_device *dev) #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);