From patchwork Mon May 8 21:20:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 9716707 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 8EE1E60385 for ; Mon, 8 May 2017 21:20:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DF77252D5 for ; Mon, 8 May 2017 21:20:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52E5226B39; Mon, 8 May 2017 21:20:42 +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 EF64F252D5 for ; Mon, 8 May 2017 21:20:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F4196E2B4; Mon, 8 May 2017 21:20:37 +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 46E296E2B5; Mon, 8 May 2017 21:20:36 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id u65so18186718wmu.3; Mon, 08 May 2017 14:20:36 -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=7Pwwse9bCSV+aXw38pmCz+4HlkvUre6yYYIgJbZxpt4=; b=qbmghdQ27TCApzWk6GVXeTOokwbN8nUw0V8nMJo0+Rhe7EZBJ8puSy2E6PZ7IA2w/n FuNeAhp8qxqmakdWGF7Sk0m1/NPP9So4eL3efa1rOhlpmTafr1wMYED1qN2rXFRJfDV5 wRfrdj2CoH45IhCnvvx/VZMQwgcD0LTSQrED8xuFV7hjHNBUgyoyYr9pwzc2RYPRMwm6 DzD/g7wXG7kc61Pjhl6/k5U3KxrScMcCkG+RzDV1iGJ9BuUji0XtSXXs6oU9/Hnuv80u eot5O2UbExrMbnVMgG7OqRH8GjdwPAXUpn4jWPbBb4FfcewBekYRp/g71Gox7F+LhNfO 2+Jg== 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=7Pwwse9bCSV+aXw38pmCz+4HlkvUre6yYYIgJbZxpt4=; b=oUaBuCh8CG+G6RybXG9kXfb+Rxl0n3uwqZmcfyb/b9DwD6bnkij7COXXZZTlHSD9Mf qTZknsVv5gZd2QVBky+DOflcK5YK6XivSvctQe6bxwwlFuCp9h41goocHmBOhsnmhhRc TIx0G4mN3POmIwJyYOdXjvvZNy2UF+cax+OoepkAQZ1/2Gzu/WkaU+dF2G0LG68ipfF0 ShaxbnzspSCI7YIQBRTDAFEOqqFAJf+mo7exaPaWO13VNT9KN6C6cMg8VBEa0ULIyEjE jN+xFyIfslDx7MzRQ73I2vacYf3497+YC66SRlpL8VcURQylEPNXcqu8uH8nEQ7jSh6Q 9rqQ== X-Gm-Message-State: AODbwcD5bcInvgDiKjFj3DYNDLtjfxEfxFxPgVldCMwsRAaMfhI+LTkg f5+LYvtu08s+OQ== X-Received: by 10.28.174.131 with SMTP id x125mr1554312wme.32.1494278434847; Mon, 08 May 2017 14:20:34 -0700 (PDT) Received: from localhost.localdomain (ip5f5adba3.dynamic.kabel-deutschland.de. [95.90.219.163]) by smtp.googlemail.com with ESMTPSA id v69sm4808199wmv.3.2017.05.08.14.20.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 14:20:34 -0700 (PDT) From: Oscar Salvador To: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v6 4/5] nouveau/hwmon: expose the auto_point and pwm_min/max attrs Date: Mon, 8 May 2017 23:20:49 +0200 Message-Id: <1494278450-11021-5-git-send-email-osalvador.vilardaga@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1494278450-11021-1-git-send-email-osalvador.vilardaga@gmail.com> References: <1494278450-11021-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 01e7440..dac589f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c @@ -340,6 +340,23 @@ nouveau_hwmon_get_power1_crit(struct nouveau_drm *drm) 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 @@ -808,17 +825,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);