Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1085446ybt; Wed, 8 Jul 2020 20:56:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJAjfnfF6NArS88TpcU4/olAT88NufZ2NULblnkIfyYWMUVg0T+OGENftf+v5fbZ174sf4 X-Received: by 2002:a05:6402:13d0:: with SMTP id a16mr70175540edx.269.1594266967129; Wed, 08 Jul 2020 20:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594266967; cv=none; d=google.com; s=arc-20160816; b=woYmcW3uL4ucNC/POCjpEWHu3TsxuBtUpAvdA9Wsvg1VycvGVk0XmvwhOHVnyR7ggg JPLtQJ8oxcMEbZJ4L7lKVWAnSV2+fJpsDA2Q0KJRWyLgLbyRel64ULt/kLp/VLbxmKs9 /TFutT/FycE34umAGjq5qLNWARS/q4Tu71kTOcih1Wi7Pobl5nwL6/p5iqAhPGdFwj2n lJpxnOfLR5Y9cC3vRnWCQMZ8aptISb1OwLp1ypzPcXCJjlyEPBtOLBNvdaNAbLtdY2mL HCzSD0dn84q95Rx6CV7r+bV7LriP3ttIknBKoQMgJVkA2/SON4gQ5RcjvJ68M0s3TI80 O9tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=doo4Haru409S4cpuVxuKbZjVlwMb7fhAV7WXED8DFbA=; b=pEGQJoGqIjbQeAA5UzMarscJlhIAe7cOOp5vZeLCkDIvLQLHOAI/MwS+0hW0ITyCsF FSYClLmtQaYqVxjBYSd2g4eL4hTeYsmx7/hh6/oa3QbdwlQy+6ATV2RRCmBDRsQE9M1v qVb6ThU1W2Uri+2b7JMsbezLMRyyl4We5GnqSLAI6/d8AZfq/KP7o9Jv8+sHhhoNhc92 2AHJM/S6jf4IrEwaB25mHhb8Bs9lkfAMUAAz9yHSLn9aKkEq32Cx3pQddbcOjSRJpWhO DnFgvDdTMhEcF03mg4qvg7FFvX2X/Imu8rT7+gL9OgZYZh/546ktLkz5yHV7RTK6rgBN pkxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt2si1595773ejc.596.2020.07.08.20.55.44; Wed, 08 Jul 2020 20:56:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbgGIDzh (ORCPT + 99 others); Wed, 8 Jul 2020 23:55:37 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49342 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726119AbgGIDzg (ORCPT ); Wed, 8 Jul 2020 23:55:36 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9CxqdQplQZfXJUAAA--.714S3; Thu, 09 Jul 2020 11:55:31 +0800 (CST) From: Zhi Li To: chenhc@lemote.com, jiaxun.yang@flygoat.com, tsbogend@alpha.franken.de, lixuefeng@loongson.cn Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Tiezhu Yang Subject: [PATCH v3 1/3] MIPS: Loongson: Cleanup cpu_hwmon.c Date: Thu, 9 Jul 2020 11:55:19 +0800 Message-Id: <1594266921-28971-2-git-send-email-lizhi01@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1594266921-28971-1-git-send-email-lizhi01@loongson.cn> References: <1594266921-28971-1-git-send-email-lizhi01@loongson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IYs7 xG6r1I6r4UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_ Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUb2-OUUUUU= X-CM-SenderInfo: xol2xxqqr6z05rqj20fqof0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tiezhu Yang Fix the following checkpatch warnings and errors: ERROR: do not initialise statics to 0 +static int csr_temp_enable = 0; WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(name, S_IRUGO, get_hwmon_name, NULL, 0); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, get_cpu_temp, NULL, 1); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, cpu_temp_label, NULL, 1); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, get_cpu_temp, NULL, 2); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, cpu_temp_label, NULL, 2); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, get_cpu_temp, NULL, 3); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, cpu_temp_label, NULL, 3); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, get_cpu_temp, NULL, 4); WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. +static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, cpu_temp_label, NULL, 4); WARNING: Missing a blank line after declarations + int id = (to_sensor_dev_attr(attr))->index - 1; + return sprintf(buf, "CPU %d Temperature\n", id); WARNING: Missing a blank line after declarations + int value = loongson3_cpu_temp(id); + return sprintf(buf, "%d\n", value); ERROR: spaces required around that '=' (ctx:VxV) + for (i=0; i Signed-off-by: Zhi Li --- drivers/platform/mips/cpu_hwmon.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/platform/mips/cpu_hwmon.c b/drivers/platform/mips/cpu_hwmon.c index 0d27cb7..fa42b13 100644 --- a/drivers/platform/mips/cpu_hwmon.c +++ b/drivers/platform/mips/cpu_hwmon.c @@ -11,7 +11,7 @@ #include #include -static int csr_temp_enable = 0; +static int csr_temp_enable; /* * Loongson-3 series cpu has two sensors inside, @@ -44,7 +44,7 @@ int loongson3_cpu_temp(int cpu) case PRID_REV_LOONGSON3A_R3_0: case PRID_REV_LOONGSON3A_R3_1: default: - reg = (reg & 0xffff)*731/0x4000 - 273; + reg = (reg & 0xffff) * 731 / 0x4000 - 273; break; } @@ -57,7 +57,7 @@ static struct device *cpu_hwmon_dev; static ssize_t get_hwmon_name(struct device *dev, struct device_attribute *attr, char *buf); -static SENSOR_DEVICE_ATTR(name, S_IRUGO, get_hwmon_name, NULL, 0); +static SENSOR_DEVICE_ATTR(name, 0444, get_hwmon_name, NULL, 0); static struct attribute *cpu_hwmon_attributes[] = { &sensor_dev_attr_name.dev_attr.attr, @@ -81,14 +81,14 @@ static ssize_t get_cpu_temp(struct device *dev, static ssize_t cpu_temp_label(struct device *dev, struct device_attribute *attr, char *buf); -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, get_cpu_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, cpu_temp_label, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, get_cpu_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, cpu_temp_label, NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, get_cpu_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, cpu_temp_label, NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, get_cpu_temp, NULL, 4); -static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, cpu_temp_label, NULL, 4); +static SENSOR_DEVICE_ATTR(temp1_input, 0444, get_cpu_temp, NULL, 1); +static SENSOR_DEVICE_ATTR(temp1_label, 0444, cpu_temp_label, NULL, 1); +static SENSOR_DEVICE_ATTR(temp2_input, 0444, get_cpu_temp, NULL, 2); +static SENSOR_DEVICE_ATTR(temp2_label, 0444, cpu_temp_label, NULL, 2); +static SENSOR_DEVICE_ATTR(temp3_input, 0444, get_cpu_temp, NULL, 3); +static SENSOR_DEVICE_ATTR(temp3_label, 0444, cpu_temp_label, NULL, 3); +static SENSOR_DEVICE_ATTR(temp4_input, 0444, get_cpu_temp, NULL, 4); +static SENSOR_DEVICE_ATTR(temp4_label, 0444, cpu_temp_label, NULL, 4); static const struct attribute *hwmon_cputemp[4][3] = { { @@ -117,6 +117,7 @@ static ssize_t cpu_temp_label(struct device *dev, struct device_attribute *attr, char *buf) { int id = (to_sensor_dev_attr(attr))->index - 1; + return sprintf(buf, "CPU %d Temperature\n", id); } @@ -125,6 +126,7 @@ static ssize_t get_cpu_temp(struct device *dev, { int id = (to_sensor_dev_attr(attr))->index - 1; int value = loongson3_cpu_temp(id); + return sprintf(buf, "%d\n", value); } @@ -132,7 +134,7 @@ static int create_sysfs_cputemp_files(struct kobject *kobj) { int i, ret = 0; - for (i=0; i temp_max) temp_max = value; @@ -172,7 +174,8 @@ static int __init loongson_hwmon_init(void) pr_info("Loongson Hwmon Enter...\n"); if (cpu_has_csr()) - csr_temp_enable = csr_readl(LOONGSON_CSR_FEATURES) & LOONGSON_CSRF_TEMP; + csr_temp_enable = csr_readl(LOONGSON_CSR_FEATURES) & + LOONGSON_CSRF_TEMP; cpu_hwmon_dev = hwmon_device_register(NULL); if (IS_ERR(cpu_hwmon_dev)) { -- 2.1.0