2019-01-18 14:06:35

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 0/7] hwmon: adm1029: Fix most style problem

Hello

Thirteen years later, coding style have change a bit.
This patch series fixes the gap.

This patch serie was tested on my precious so rare real hardware.

Regards

Corentin Labbe (7):
hwmon: adm1029: Remove write to FFF paragraph
hwmon: adm1029: Add SPDX header
hwmon: adm1029: replace S_IXXX macros by their numeric values
hwmon: adm1029: Add blank line after declarations
hwmon: adm1029: Fix Logical continuations should be on the previous
line checkpatch warning
hwmon: adm1029: Fix function alignment
hwmon: adm1029: Add a comment for locking mutex

drivers/hwmon/adm1029.c | 67 +++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 36 deletions(-)

--
2.19.2



2019-01-18 14:05:41

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 1/7] hwmon: adm1029: Remove write to FFF paragraph

As suggested by checkpatch, remove the "write to FFF" paragraph.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/hwmon/adm1029.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 8c5cdb560258..3dd4c84ec89e 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -19,10 +19,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <linux/module.h>
--
2.19.2


2019-01-18 14:05:56

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 5/7] hwmon: adm1029: Fix Logical continuations should be on the previous line checkpatch warning

This patchs fix the "Logical continuations should be on the previous line" checkpatch warning.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/hwmon/adm1029.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index f9f4f1f4a4c7..4339f6b864a1 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -131,8 +131,7 @@ static struct adm1029_data *adm1029_update_device(struct device *dev)
* Use the "cache" Luke, don't recheck values
* if there are already checked not a long time later
*/
- if (time_after(jiffies, data->last_updated + HZ * 2)
- || !data->valid) {
+ if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int nr;

dev_dbg(&client->dev, "Updating adm1029 data\n");
@@ -182,9 +181,9 @@ show_fan(struct device *dev, struct device_attribute *devattr, char *buf)
struct adm1029_data *data = adm1029_update_device(dev);
u16 val;

- if (data->fan[attr->index] == 0
- || (data->fan_div[attr->index] & 0xC0) == 0
- || data->fan[attr->index] == 255) {
+ if (data->fan[attr->index] == 0 ||
+ (data->fan_div[attr->index] & 0xC0) == 0 ||
+ data->fan[attr->index] == 255) {
return sprintf(buf, "0\n");
}

@@ -325,8 +324,8 @@ static int adm1029_detect(struct i2c_client *client,
nb_fan_support = i2c_smbus_read_byte_data(client,
ADM1029_REG_NB_FAN_SUPPORT);
/* 0x41 is Analog Devices */
- if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01
- || nb_fan_support != 0x03)
+ if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01 ||
+ nb_fan_support != 0x03)
return -ENODEV;

if ((chip_id & 0xF0) != 0x00) {
--
2.19.2


2019-01-18 14:05:56

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 7/7] hwmon: adm1029: Add a comment for locking mutex

Checkpatch complains that mutex does not have any comment.
This patch fix that.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/hwmon/adm1029.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index e9fe4fc3489e..e561279aea21 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -108,7 +108,7 @@ static const u8 ADM1029_REG_FAN_DIV[] = {

struct adm1029_data {
struct i2c_client *client;
- struct mutex update_lock;
+ struct mutex update_lock; /* protect register access */
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */

--
2.19.2


2019-01-18 14:05:59

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 4/7] hwmon: adm1029: Add blank line after declarations

As requested by checkpatch, this patch adds a blank line after declarations

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/hwmon/adm1029.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 092f16ad774f..f9f4f1f4a4c7 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -171,6 +171,7 @@ show_temp(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct adm1029_data *data = adm1029_update_device(dev);
+
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
}

@@ -180,6 +181,7 @@ show_fan(struct device *dev, struct device_attribute *devattr, char *buf)
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct adm1029_data *data = adm1029_update_device(dev);
u16 val;
+
if (data->fan[attr->index] == 0
|| (data->fan_div[attr->index] & 0xC0) == 0
|| data->fan[attr->index] == 255) {
@@ -196,6 +198,7 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct adm1029_data *data = adm1029_update_device(dev);
+
if ((data->fan_div[attr->index] & 0xC0) == 0)
return sprintf(buf, "0\n");
return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index]));
@@ -210,6 +213,7 @@ static ssize_t set_fan_div(struct device *dev,
u8 reg;
long val;
int ret = kstrtol(buf, 10, &val);
+
if (ret < 0)
return ret;

--
2.19.2


2019-01-18 14:06:02

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 6/7] hwmon: adm1029: Fix function alignment

This patch fix the "Alignment should match open parenthesis" checkpatch
warning.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/hwmon/adm1029.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 4339f6b864a1..e9fe4fc3489e 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -203,8 +203,8 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)
return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index]));
}

-static ssize_t set_fan_div(struct device *dev,
- struct device_attribute *devattr, const char *buf, size_t count)
+static ssize_t set_fan_div(struct device *dev, struct device_attribute *devattr,
+ const char *buf, size_t count)
{
struct adm1029_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
@@ -322,7 +322,7 @@ static int adm1029_detect(struct i2c_client *client,
temp_devices_installed = i2c_smbus_read_byte_data(client,
ADM1029_REG_TEMP_DEVICES_INSTALLED);
nb_fan_support = i2c_smbus_read_byte_data(client,
- ADM1029_REG_NB_FAN_SUPPORT);
+ ADM1029_REG_NB_FAN_SUPPORT);
/* 0x41 is Analog Devices */
if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01 ||
nb_fan_support != 0x03)
--
2.19.2


2019-01-18 14:06:43

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 3/7] hwmon: adm1029: replace S_IXXX macros by their numeric values

As requested by checkpatch, this patch replace S_IXXX macros by their numeric values.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/hwmon/adm1029.c | 37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 381bfae6b04b..092f16ad774f 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -250,32 +250,27 @@ static ssize_t set_fan_div(struct device *dev,
return count;
}

-/*
- * Access rights on sysfs. S_IRUGO: Is Readable by User, Group and Others
- * S_IWUSR: Is Writable by User.
- */
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
-static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
+/* Access rights on sysfs. */
+static SENSOR_DEVICE_ATTR(temp1_input, 0444, show_temp, NULL, 0);
+static SENSOR_DEVICE_ATTR(temp2_input, 0444, show_temp, NULL, 1);
+static SENSOR_DEVICE_ATTR(temp3_input, 0444, show_temp, NULL, 2);

-static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 3);
-static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO, show_temp, NULL, 4);
-static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO, show_temp, NULL, 5);
+static SENSOR_DEVICE_ATTR(temp1_max, 0444, show_temp, NULL, 3);
+static SENSOR_DEVICE_ATTR(temp2_max, 0444, show_temp, NULL, 4);
+static SENSOR_DEVICE_ATTR(temp3_max, 0444, show_temp, NULL, 5);

-static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO, show_temp, NULL, 6);
-static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO, show_temp, NULL, 7);
-static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO, show_temp, NULL, 8);
+static SENSOR_DEVICE_ATTR(temp1_min, 0444, show_temp, NULL, 6);
+static SENSOR_DEVICE_ATTR(temp2_min, 0444, show_temp, NULL, 7);
+static SENSOR_DEVICE_ATTR(temp3_min, 0444, show_temp, NULL, 8);

-static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
-static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
+static SENSOR_DEVICE_ATTR(fan1_input, 0444, show_fan, NULL, 0);
+static SENSOR_DEVICE_ATTR(fan2_input, 0444, show_fan, NULL, 1);

-static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, show_fan, NULL, 2);
-static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO, show_fan, NULL, 3);
+static SENSOR_DEVICE_ATTR(fan1_min, 0444, show_fan, NULL, 2);
+static SENSOR_DEVICE_ATTR(fan2_min, 0444, show_fan, NULL, 3);

-static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR,
- show_fan_div, set_fan_div, 0);
-static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
- show_fan_div, set_fan_div, 1);
+static SENSOR_DEVICE_ATTR(fan1_div, 0644, show_fan_div, set_fan_div, 0);
+static SENSOR_DEVICE_ATTR(fan2_div, 0644, show_fan_div, set_fan_div, 1);

static struct attribute *adm1029_attrs[] = {
&sensor_dev_attr_temp1_input.dev_attr.attr,
--
2.19.2


2019-01-18 14:07:14

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 2/7] hwmon: adm1029: Add SPDX header

This patch addes SPDX header to adm1029

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/hwmon/adm1029.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 3dd4c84ec89e..381bfae6b04b 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* adm1029.c - Part of lm_sensors, Linux kernel modules for hardware monitoring
*
--
2.19.2


2019-01-18 14:23:28

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 0/7] hwmon: adm1029: Fix most style problem

On Fri, Jan 18, 2019 at 03:03:22PM +0100, Corentin Labbe wrote:
> Hello
>
> Thirteen years later, coding style have change a bit.
> This patch series fixes the gap.
>
> This patch serie was tested on my precious so rare real hardware.
>
Series applied to hwmon-next.

Thanks,
Guenter

> Regards
>
> Corentin Labbe (7):
> hwmon: adm1029: Remove write to FFF paragraph
> hwmon: adm1029: Add SPDX header
> hwmon: adm1029: replace S_IXXX macros by their numeric values
> hwmon: adm1029: Add blank line after declarations
> hwmon: adm1029: Fix Logical continuations should be on the previous
> line checkpatch warning
> hwmon: adm1029: Fix function alignment
> hwmon: adm1029: Add a comment for locking mutex
>
> drivers/hwmon/adm1029.c | 67 +++++++++++++++++++----------------------
> 1 file changed, 31 insertions(+), 36 deletions(-)
>
> --
> 2.19.2
>