Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3366711imu; Wed, 7 Nov 2018 09:13:23 -0800 (PST) X-Google-Smtp-Source: AJdET5dB1vlXXkWgeHSEqLTW9mtT+D1spEC7TltgOHYcCUC1OwHpUJa1tkv0fH68OneqAqF6spIH X-Received: by 2002:a62:e30a:: with SMTP id g10-v6mr1007574pfh.151.1541610803830; Wed, 07 Nov 2018 09:13:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541610803; cv=none; d=google.com; s=arc-20160816; b=U3wIs9/u/Y7PmWhMbQrnMmENvW7nJJand9XRtfXfCOIOnzXbasBdOmp/fi9+ehYsXk lgtgCtTlBjRPp8Meoe8a0PIxeekfXmbEVl5N1ZrUxftbjBLGTLxEp1tYVUu2pffaH1pj b0pgBW6xJD8CFubrdxYoNO8oRzfYSnT2Gqoc9LlE8vNg0lI6qjA2V9jM5DoYRkyNuV0Q 9lt0Z8p1/R3053sByJbO6+rC9Ww5iPfSDbfGeSo0Z/6VlNiwdFIb3d9tCuwBUWemLNYS HpDIp8/WtKfCfAzaD9CIfjBRTZWpsUZYcRKnUG+Oo9s257F3foVbmb8DvEYOpuK5PIfV XePA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=YL3IJQwlo5YNFrxIFkhGqiDAirUyPIfzICP0/e+gE7E=; b=vJMKXTTr+cbcDa46TpHWiEafaqNVKBvZOUCBWR/G/arRMFXyxfeIdvOk0bzEy81pEG JmHdtrX7Xkjs8VqvH8pTab0LcC8NdnJYPDFMCJymo2ayDHXUJrJrMShojBjkLLgQpXNf qmEZNhKxqK8hmw9kXWkB//WMBgbK3KiBeUhdmz3Sa5Qs81MXAbMQcs2LYIHfU33jpgUC i1m5uMXUzSnPqvkz93w9lqmpMmW1JOOSC+vBAlAjiADtl3OZGbyXbpXnpbK0Djnc3DNl 1w8W/Q+YWyBowvZZH0Rz57IzVXfYGXcuyWtKcfe2f7Hei4jculSOxEyjfGwc0qbga3ho P1bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gHqHAyTm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k69-v6si1141522pfc.161.2018.11.07.09.13.08; Wed, 07 Nov 2018 09:13:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gHqHAyTm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731575AbeKHCmz (ORCPT + 99 others); Wed, 7 Nov 2018 21:42:55 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54850 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731522AbeKHCl4 (ORCPT ); Wed, 7 Nov 2018 21:41:56 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181107171039euoutp012424c4b3dac7d4d8de13fb9f42cd69d0~k5rVpMkdl2252222522euoutp01V for ; Wed, 7 Nov 2018 17:10:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181107171039euoutp012424c4b3dac7d4d8de13fb9f42cd69d0~k5rVpMkdl2252222522euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541610639; bh=YL3IJQwlo5YNFrxIFkhGqiDAirUyPIfzICP0/e+gE7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gHqHAyTmvwvpTjRB2d9fNzoB2bGyZujVoBduhem9BTmpOgmw7KVYRyMgQBInYUziX 7CKRDs3NAhpqPxF6uXhaQC5kJ6RkuvMGFbmuNlyns+4HOpwlWiEf6JmA0cdVR+3oAZ ctI65kLxexHGHFzGIiV4hAMIHUJkqDseh8hTAreA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181107171038eucas1p292430d46f08d158b7215189ae6ca9dce~k5rU3DtQp2736727367eucas1p2P; Wed, 7 Nov 2018 17:10:38 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 0D.C9.04806.E8C13EB5; Wed, 7 Nov 2018 17:10:38 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20181107171037eucas1p1b475d186830d4401b50fcd2c16781f92~k5rUKMp8M2722727227eucas1p1o; Wed, 7 Nov 2018 17:10:37 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20181107171037eusmtrp1849f58adcee14907f134c1a1feeb8e5f~k5rT_RLFE2472724727eusmtrp1i; Wed, 7 Nov 2018 17:10:37 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-07-5be31c8ee8ce Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D9.23.04128.D8C13EB5; Wed, 7 Nov 2018 17:10:37 +0000 (GMT) Received: from AMDC3778.DIGITAL.local (unknown [106.120.51.20]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181107171036eusmtip2ca02211d4f808bc8c04f2b37a104af99~k5rTXwDg70341103411eusmtip2G; Wed, 7 Nov 2018 17:10:36 +0000 (GMT) From: Lukasz Luba To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, corbet@lwn.net, b.zolnierkie@samsung.com, krzk@kernel.org, Lukasz Luba Subject: [PATCH v2 03/11] thermal: add new sysfs file for irq-mode Date: Wed, 7 Nov 2018 18:09:45 +0100 Message-Id: <1541610593-28542-4-git-send-email-l.luba@partner.samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541610593-28542-1-git-send-email-l.luba@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSa0hTYRju29k5OxtOTrP0zcxgIVSQdvHHiaKLRJwSIoIIXFCnOqk0p+44 u0KD0qnpWiraRbdiWbnWxWVistTMtBlumqaWi24GZVjEKnWV5jyr/j3P+z6Xj5ePxBQ1eCSZ qsnitBpWrSRk4rq2cc8SY9Q71dLyfildc/YWTg81GxBt9s2jLa1unLb09uG0x3NbQr/QR9GO d1PsUu5lMd3TUEHQvqJWRFf1d4vonPutEnrojZFYF8rYzXbE3Dv/UsJYnR9FjMOWTzDePifB 3Ll8nLEaS3DmwWeniDHW2hDjc0RvlSXJVu/j1KnZnDZuzW5ZStlvRcaV6EMDr0pxPfoJBYgk gYoH1+mkAiQjFdQ1BCdv5IoE8g2BodBJCMSHwHH7q6QASacdlU3u4OIqgseDVuyfpehLuSiQ S1CxUG/LDMxnURcQ+BqtkgDBKC+CjtKAQ0qGUQnwbKwYD2AxFQMm1zgRMMupzXDBD0JbNDx3 50/LpVQimHtGpnOAapOAydxMCKINYLp7VizgMBhurw0+NQq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1Y+ihXhTEiurUovy44tKc1KLDzGaAt00kVlKNDkfGMF5JfGGpobm FpaG5sbmxmYWSuK85w0qo4QE0hNLUrNTUwtSi2D6mDg4pRoYr6pm3I/docDx/6PSugf6R/+5 vlk35cskxu4X0f9/fy+88IpJxuv43KN6d2fZhwXeKunZ1sYm+nm59lkt5z5LIdm1d9tuhbit 9RGzLZhxPfb6mj0rfX/01+wKCP8/SXhTxqfVMzvE7ZI/rZa4VO3Mu+fhzE3VP1Jc607yb/U1 WTB1/+flYstMdiixFGckGmoxFxUnAgDx6PwnqAIAAA== X-CMS-MailID: 20181107171037eucas1p1b475d186830d4401b50fcd2c16781f92 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181107171037eucas1p1b475d186830d4401b50fcd2c16781f92 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181107171037eucas1p1b475d186830d4401b50fcd2c16781f92 References: <1541610593-28542-1-git-send-email-l.luba@partner.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Patch adds show functions for irq-mode feature. It allocates new attributes and extends the old list. Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Signed-off-by: Lukasz Luba --- drivers/thermal/thermal_sysfs.c | 53 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 2241cea..372b439 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -21,6 +21,8 @@ #include "thermal_core.h" +#define TRIP_ATTR_NUM 4 + /* sys I/F for thermal zone */ static ssize_t @@ -167,6 +169,28 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr, } static ssize_t +trip_point_irq_mode_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct thermal_zone_device *tz = to_thermal_zone(dev); + int trip, ret; + bool mode; + + if (!tz->ops->get_trip_irq_mode) + return -EPERM; + + if (sscanf(attr->attr.name, "trip_point_%d_irq", &trip) != 1) + return -EINVAL; + + ret = tz->ops->get_trip_irq_mode(tz, trip, &mode); + + if (ret) + return ret; + + return sprintf(buf, "%d\n", mode); +} + +static ssize_t trip_point_hyst_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -520,10 +544,19 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) if (!tz->trip_type_attrs) return -ENOMEM; + tz->trip_irq_mode_attrs = kcalloc(tz->trips, + sizeof(*tz->trip_irq_mode_attrs), + GFP_KERNEL); + if (!tz->trip_irq_mode_attrs) { + kfree(tz->trip_type_attrs); + return -ENOMEM; + } + tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), GFP_KERNEL); if (!tz->trip_temp_attrs) { kfree(tz->trip_type_attrs); + kfree(tz->trip_irq_mode_attrs); return -ENOMEM; } @@ -533,14 +566,17 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) GFP_KERNEL); if (!tz->trip_hyst_attrs) { kfree(tz->trip_type_attrs); + kfree(tz->trip_irq_mode_attrs); kfree(tz->trip_temp_attrs); return -ENOMEM; } } - attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); + attrs = kcalloc(tz->trips * TRIP_ATTR_NUM + 1, sizeof(*attrs), + GFP_KERNEL); if (!attrs) { kfree(tz->trip_type_attrs); + kfree(tz->trip_irq_mode_attrs); kfree(tz->trip_temp_attrs); if (tz->ops->get_trip_hyst) kfree(tz->trip_hyst_attrs); @@ -559,6 +595,19 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) tz->trip_type_attrs[indx].attr.show = trip_point_type_show; attrs[indx] = &tz->trip_type_attrs[indx].attr.attr; + /* create trip irq_mode attribute */ + snprintf(tz->trip_irq_mode_attrs[indx].name, + THERMAL_NAME_LENGTH, "trip_point_%d_irq", indx); + + sysfs_attr_init(&tz->trip_irq_mode_attrs[indx].attr.attr); + tz->trip_irq_mode_attrs[indx].attr.attr.name = + tz->trip_irq_mode_attrs[indx].name; + tz->trip_irq_mode_attrs[indx].attr.attr.mode = S_IRUGO; + tz->trip_irq_mode_attrs[indx].attr.show = + trip_point_irq_mode_show; + attrs[indx + tz->trips * 3] = + &tz->trip_irq_mode_attrs[indx].attr.attr; + /* create trip temp attribute */ snprintf(tz->trip_temp_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_temp", indx); @@ -595,7 +644,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) attrs[indx + tz->trips * 2] = &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] = NULL; + attrs[tz->trips * TRIP_ATTR_NUM] = NULL; tz->trips_attribute_group.attrs = attrs; -- 2.7.4