Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp208470ybk; Sat, 9 May 2020 00:14:53 -0700 (PDT) X-Google-Smtp-Source: APiQypIgBs3B2VlQLsth760eW8YE9cebZ50Nyh0a14b5xbQ7G3I4jxs+xtdMpwbgNeYsCA9iH1vd X-Received: by 2002:aa7:d0d8:: with SMTP id u24mr5507886edo.138.1589008493820; Sat, 09 May 2020 00:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589008493; cv=none; d=google.com; s=arc-20160816; b=pEac2XVZiNBX+C7qY2PcWXzAY912b7zHpMqb7AuO48uLxm5tP++UM0V56Zuv1+QcWk mz4WjwfUuGVS3pMPXFUea9lJYRcIV9AOx2haA31jIjofxkv06OUHlJ5AJAzSoM/VvJ1z qbiLNT0O6x7KpywOzvZiWxv6Ht7QHVKq2EyvuvKsSa6GiIKzsuC5Y33z717BdT+Y5+YW Qdm0RMb7YU0nT8msky9fJxjLLtYahEeO3N4MGYq8xJUuT6nIJHUmo4P3AEdGppGLYzoP I986ROm/Tff7Ymk0cbt6yIGXesiA7XSEF8IkqYIUEoe0z9zh7sEVGwHfMpLYFoyTVRDg vVPw== 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=JrIFlBL0nEeZLXs+Gx2uTHkRqrXmXLyrvg1QXMZc1t8=; b=QzsajUuqYcV0f7+amst0vxXissz2YwWw1fvhsCUqXQmwcFf7CAupgNXJf+7Dbez8uy 5yzWNX4x/+XBmtrmODApxEH0XSI0pl3YNDTrK1uexZedcLRgx9rQldBkHGV+tKkVv8Ts OHizpoJlySYfFtb64BVxeaK3o8PUXgV/WRcqYmMKYd3577DoUIOQxQd5Rgq8YGRbDKav kSPiRBOvC3qcU82cofvDJK1ka9Ogs7xxDOhHQJUtBKF94b84TJ6jcE2JJV9vsRkbSvfX 89tmmm8ppUpZe9EKBlNW0kVCgb26O0DDLbk/ebA8lZxvkmQCOZ8TchDKnmuytLREYfQM ivQQ== 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 u3si2448402edp.525.2020.05.09.00.14.27; Sat, 09 May 2020 00:14:53 -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 S1728884AbgEIHM7 (ORCPT + 99 others); Sat, 9 May 2020 03:12:59 -0400 Received: from mail.loongson.cn ([114.242.206.163]:44591 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728625AbgEIHM7 (ORCPT ); Sat, 9 May 2020 03:12:59 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxf93sV7ZeMnUyAA--.1S3; Sat, 09 May 2020 15:12:46 +0800 (CST) From: Tiezhu Yang To: Thomas Bogendoerfer , Huacai Chen , Jiaxun Yang Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH v2 1/2] MIPS: Loongson: Cleanup cpu_hwmon.c Date: Sat, 9 May 2020 15:12:43 +0800 Message-Id: <1589008364-2294-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1589008364-2294-1-git-send-email-yangtiezhu@loongson.cn> References: <1589008364-2294-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9Dxf93sV7ZeMnUyAA--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r4UJbIYCTnIWIevJa73UjIFyTuYvjfU8NtIDUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the following checkpatch warnings and errors: ERROR: do not initialise statics to 0 #14: FILE: drivers/platform/mips/cpu_hwmon.c:14: +static int csr_temp_enable = 0; WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. #60: FILE: drivers/platform/mips/cpu_hwmon.c:60: +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'. #84: FILE: drivers/platform/mips/cpu_hwmon.c:84: +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'. #85: FILE: drivers/platform/mips/cpu_hwmon.c:85: +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'. #86: FILE: drivers/platform/mips/cpu_hwmon.c:86: +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'. #87: FILE: drivers/platform/mips/cpu_hwmon.c:87: +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'. #88: FILE: drivers/platform/mips/cpu_hwmon.c:88: +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'. #89: FILE: drivers/platform/mips/cpu_hwmon.c:89: +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'. #90: FILE: drivers/platform/mips/cpu_hwmon.c:90: +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'. #91: FILE: drivers/platform/mips/cpu_hwmon.c:91: +static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, cpu_temp_label, NULL, 4); WARNING: Missing a blank line after declarations #120: FILE: drivers/platform/mips/cpu_hwmon.c:120: + int id = (to_sensor_dev_attr(attr))->index - 1; + return sprintf(buf, "CPU %d Temperature\n", id); WARNING: Missing a blank line after declarations #128: FILE: drivers/platform/mips/cpu_hwmon.c:128: + int value = loongson3_cpu_temp(id); + return sprintf(buf, "%d\n", value); ERROR: spaces required around that '=' (ctx:VxV) #135: FILE: drivers/platform/mips/cpu_hwmon.c:135: + for (i=0; i --- 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