w1: coding style and checkpatch fixes
Subsystems (2)
Hi,
This is my first series of patches for the Linux kernel. I started by familiarizing myself with coding style and satisfying my inner OCD by cleaning the 1-wire subsystem.
Steffen
PATCH 1/9 w1: add SPDX identifiers
This satisfies a checkpatch warning and is the preferred method for notating the license.
The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text.
--- drivers/w1/masters/ds1wm.c | 5 +---- drivers/w1/masters/ds2482.c | 7 ++----- drivers/w1/masters/ds2490.c | 16 +--------------- drivers/w1/masters/matrox_w1.c | 16 +--------------- drivers/w1/masters/mxc_w1.c | 10 +--------- drivers/w1/masters/omap_hdq.c | 7 ++----- drivers/w1/masters/w1-gpio.c | 5 +---- drivers/w1/slaves/w1_ds2405.c | 12 +----------- drivers/w1/slaves/w1_ds2406.c | 4 +--- drivers/w1/slaves/w1_ds2408.c | 4 +--- drivers/w1/slaves/w1_ds2413.c | 4 +--- drivers/w1/slaves/w1_ds2423.c | 15 +-------------- drivers/w1/slaves/w1_ds2431.c | 4 +--- drivers/w1/slaves/w1_ds2433.c | 4 +--- drivers/w1/slaves/w1_ds2438.c | 4 +--- drivers/w1/slaves/w1_ds2780.c | 6 +----- drivers/w1/slaves/w1_ds2781.c | 6 +----- drivers/w1/slaves/w1_ds2805.c | 4 +--- drivers/w1/slaves/w1_ds28e04.c | 4 +--- drivers/w1/slaves/w1_ds28e17.c | 4 +--- drivers/w1/slaves/w1_smem.c | 16 +--------------- drivers/w1/slaves/w1_therm.c | 16 +--------------- drivers/w1/w1.c | 11 +---------- drivers/w1/w1_family.c | 11 +---------- drivers/w1/w1_int.c | 11 +---------- drivers/w1/w1_internal.h | 11 +---------- drivers/w1/w1_io.c | 11 +---------- drivers/w1/w1_netlink.c | 11 +---------- drivers/w1/w1_netlink.h | 11 +---------- 29 files changed, 31 insertions(+), 219 deletions(-)
drivers/w1/masters/ds1wm.c +1 -4
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * 1-wire busmaster driver for DS1WM and ASICs with embedded DS1WMs * such as HP iPAQs (including h5xxx, h2200, and devices with ASIC3
@@ -5,10 +6,6 @@* * Copyright (c) 2004-2005, Szabolcs Gyurko <[email protected]> * Copyright (c) 2004-2007, Matt Reimer <[email protected]> -* -* Use consistent with the GNU GPL is permitted, -* provided that this copyright notice is -* preserved in its entirety in all copies and derived works. */ #include <linux/module.h>
drivers/w1/masters/ds2482.c +2 -5
@@ -1,4 +1,5 @@ -/** +// SPDX-License-Identifier: GPL-2.0 +/* * ds2482.c - provides i2c to w1-master bridge(s) * Copyright (C) 2005 Ben Gardner <[email protected]> *
@@ -7,10 +8,6 @@* There are two variations: -100 and -800, which have 1 or 8 1-wire ports. * The complete datasheet can be obtained from MAXIM's website at: * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4382 -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; version 2 of the License. */ #include <linux/module.h>
drivers/w1/masters/ds2490.c +1 -15
@@ -1,22 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * ds2490.c USB to one wire bridge * * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/module.h>
drivers/w1/masters/matrox_w1.c +1 -15
@@ -1,22 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * matrox_w1.c * * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <asm/types.h>
drivers/w1/masters/mxc_w1.c +1 -9
@@ -1,15 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2005-2008 Freescale Semiconductor, Inc. All Rights Reserved. * Copyright 2008 Luotao Fu, [email protected] -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* This program is distributed in the hope that it will be useful, -* 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. */ #include <linux/clk.h>
drivers/w1/masters/omap_hdq.c +2 -5
@@ -1,13 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* * drivers/w1/masters/omap_hdq.c * * Copyright (C) 2007,2012 Texas Instruments, Inc. -* -* This file is licensed under the terms of the GNU General Public License -* version 2. This program is licensed "as is" without any warranty of any -* kind, whether express or implied. -* */ +#include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h>
drivers/w1/masters/w1-gpio.c +1 -4
@@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1-gpio - GPIO w1 bus master driver * * Copyright (C) 2007 Ville Syrjala <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 -* as published by the Free Software Foundation. */ #include <linux/init.h>
drivers/w1/slaves/w1_ds2405.c +1 -11
@@ -1,19 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * w1_ds2405.c * * Copyright (c) 2017 Maciej S. Szmigiero <[email protected]> * Based on w1_therm.c copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* -* This program is free software; you can redistribute it and/or modify -* it under the therms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #include <linux/device.h>
drivers/w1/slaves/w1_ds2406.c +1 -3
@@ -1,11 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds2406.c - w1 family 12 (DS2406) driver * based on w1_ds2413.c by Mariusz Bialonczyk <[email protected]> * * Copyright (c) 2014 Scott Alfter <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2408.c +1 -3
@@ -1,10 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds2408.c - w1 family 29 (DS2408) driver * * Copyright (c) 2010 Jean-Francois Dagenais <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2413.c +1 -3
@@ -1,11 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds2413.c - w1 family 3a (DS2413) driver * based on w1_ds2408.c by Jean-Francois Dagenais <[email protected]> * * Copyright (c) 2013 Mariusz Bialonczyk <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2423.c +1 -14
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * w1_ds2423.c *
@@ -6,20 +7,6 @@* This driver will read and write the value of 4 counters to w1_slave file in * sys filesystem. * Inspired by the w1_therm and w1_ds2431 drivers. -* -* This program is free software; you can redistribute it and/or modify -* it under the therms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2431.c +1 -3
@@ -1,12 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds2431.c - w1 family 2d (DS2431) driver * * Copyright (c) 2008 Bernhard Weirich <[email protected]> * * Heavily inspired by w1_DS2433 driver from Ben Gardner <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2433.c +1 -3
@@ -1,10 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds2433.c - w1 family 23 (DS2433) driver * * Copyright (c) 2005 Ben Gardner <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2438.c +1 -3
@@ -1,10 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * 1-Wire implementation for the ds2438 chip * * Copyright (c) 2017 Mariusz Bialonczyk <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2780.c +1 -5
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * 1-Wire implementation for the ds2780 chip *
@@ -6,11 +7,6 @@* Author: Clifton Barnes <[email protected]> * * Based on w1-ds2760 driver -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2781.c +1 -5
@@ -1,14 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* * 1-Wire implementation for the ds2781 chip * * Author: Renata Sayakhova <[email protected]> * * Based on w1-ds2780 driver -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds2805.c +1 -3
@@ -1,10 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds2805 - w1 family 0d (DS28E05) driver * * Copyright (c) 2016 Andrew Worsley [email protected] -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds28e04.c +1 -3
@@ -1,10 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds28e04.c - w1 family 1C (DS28E04) driver * * Copyright (c) 2012 Markus Franke <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/kernel.h>
drivers/w1/slaves/w1_ds28e17.c +1 -3
@@ -1,10 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * w1_ds28e17.c - w1 family 19 (DS28E17) driver * * Copyright (c) 2016 Jan Kandziora <[email protected]> -* -* This source code is licensed under the GNU General Public License, -* Version 2. See the file COPYING for more details. */ #include <linux/crc16.h>
drivers/w1/slaves/w1_smem.c +1 -15
@@ -1,22 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * w1_smem.c * * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* -* This program is free software; you can redistribute it and/or modify -* it under the smems of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <asm/types.h>
drivers/w1/slaves/w1_therm.c +1 -15
@@ -1,22 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * w1_therm.c * * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* -* This program is free software; you can redistribute it and/or modify -* it under the therms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <asm/types.h>
drivers/w1/w1.c +1 -10
@@ -1,15 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #include <linux/delay.h>
drivers/w1/w1_family.c +1 -10
@@ -1,15 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #include <linux/spinlock.h>
drivers/w1/w1_int.c +1 -10
@@ -1,15 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #include <linux/kernel.h>
drivers/w1/w1_internal.h +1 -10
@@ -1,15 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #ifndef __W1_H
drivers/w1/w1_io.c +1 -10
@@ -1,15 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2004 Evgeniy Polyakov <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #include <asm/io.h>
drivers/w1/w1_netlink.c +1 -10
@@ -1,15 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2003 Evgeniy Polyakov <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #include <linux/slab.h>
drivers/w1/w1_netlink.h +1 -10
@@ -1,15 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (c) 2003 Evgeniy Polyakov <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* 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. */ #ifndef __W1_NETLINK_H
Signature · 1 line
2.11.0
PATCH 2/9 w1: improve coding style by following strict 80 column line limit
In reply to Steffen VogelThis satisfies a checkpatch warning
--- drivers/w1/w1.c | 56 +++++++++++++++++++++++++++++-------------------- drivers/w1/w1_int.c | 3 ++- drivers/w1/w1_io.c | 29 +++++++++++++++---------- drivers/w1/w1_netlink.c | 16 +++++++++----- 4 files changed, 64 insertions(+), 40 deletions(-)
drivers/w1/w1.c +33 -23
@@ -85,7 +85,8 @@ static void w1_slave_release(struct device *dev) sl->master->slave_count--; } -static ssize_t name_show (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t name_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct w1_slave *sl =dev_to_w1_slave (dev);
@@ -203,9 +204,10 @@ struct device w1_slave_device = { .driver = &w1_slave_driver, .release = &w1_slave_release }; -#endif /* 0 */ +#endif -static ssize_t w1_master_attribute_show_name (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t w1_master_attribute_show_name (struct device *dev, +struct device_attribute *attr,char *buf) {struct w1_master *md =dev_to_w1_master (dev);ssize_t count;
@@ -217,9 +219,9 @@ static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_areturn count; } -static ssize_t w1_master_attribute_store_search (struct device * dev, +static ssize_t w1_master_attribute_store_search (struct device *dev,struct device_attribute *attr, -const char * buf,size_t count) +const char *buf,size_t count) {long tmp;struct w1_master *md =dev_to_w1_master (dev);
@@ -286,7 +288,8 @@ static ssize_t w1_master_attribute_show_pullup(struct device *dev,return count; } -static ssize_t w1_master_attribute_show_pointer (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t w1_master_attribute_show_pointer (struct device *dev, +struct device_attribute *attr,char *buf) {struct w1_master *md =dev_to_w1_master (dev);ssize_t count;
@@ -297,7 +300,8 @@ static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct devicreturn count; } -static ssize_t w1_master_attribute_show_timeout (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t w1_master_attribute_show_timeout (struct device *dev, +struct device_attribute *attr,char *buf) {ssize_t count; count =sprintf (buf,"%d\n" , w1_timeout);
@@ -330,7 +334,8 @@ static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev,return count; } -static ssize_t w1_master_attribute_show_max_slave_count (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t w1_master_attribute_show_max_slave_count (struct device *dev, +struct device_attribute *attr,char *buf) {struct w1_master *md =dev_to_w1_master (dev);ssize_t count;
@@ -338,10 +343,12 @@ static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, strumutex_lock (&md->mutex); count =sprintf (buf,"%d\n" , md->max_slave_count);mutex_unlock (&md->mutex); +return count; } -static ssize_t w1_master_attribute_show_attempts (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t w1_master_attribute_show_attempts (struct device *dev, +struct device_attribute *attr,char *buf) {struct w1_master *md =dev_to_w1_master (dev);ssize_t count;
@@ -349,10 +356,12 @@ static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct devimutex_lock (&md->mutex); count =sprintf (buf,"%lu\n" , md->attempts);mutex_unlock (&md->mutex); +return count; } -static ssize_t w1_master_attribute_show_slave_count (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t w1_master_attribute_show_slave_count (struct device *dev, +struct device_attribute *attr,char *buf) {struct w1_master *md =dev_to_w1_master (dev);ssize_t count;
@@ -408,8 +417,7 @@ static int w1_atoreg_num(struct device *dev, const char *buf, size_t count,* print it either. It would be unreasonable for the user to then * provide it. */ -const char *error_msg ="bad slave string format, expecting " -"ff-dddddddddddd\n" ; +const char *error_msg ="bad slave string format, expecting ff-dddddddddddd\n" ;if (buf[2 ] !='-' ) {dev_err (dev,"%s" , error_msg);
@@ -880,8 +888,8 @@ void w1_reconnect_slaves(struct w1_family *f, int attach)mutex_lock (&w1_mlock);list_for_each_entry (dev, &w1_masters, w1_master_entry) { -dev_dbg (&dev->dev,"Reconnecting slaves in device %s " -"for family %02x.\n" , dev->name, f->fid); +dev_dbg (&dev->dev,"Reconnecting slaves in device %s for family %02x.\n" , + dev->name, f->fid);mutex_lock (&dev->mutex);mutex_lock (&dev->list_mutex);list_for_each_entry_safe (sl, sln, &dev->slist, w1_slave_entry) {
@@ -905,8 +913,8 @@ void w1_reconnect_slaves(struct w1_family *f, int attach)mutex_lock (&dev->list_mutex); } } -dev_dbg (&dev->dev,"Reconnecting slaves in device %s " -"has been finished.\n" , dev->name); +dev_dbg (&dev->dev,"Reconnecting slaves in device %s has been finished.\n" , + dev->name);mutex_unlock (&dev->list_mutex);mutex_unlock (&dev->mutex); }
@@ -951,7 +959,8 @@ void w1_slave_found(struct w1_master *dev, u64 rn)* See "Application note 187 1-wire search algorithm" at www.maxim-ic.com * */ -void w1_search (struct w1_master *dev,u8 search_type,w1_slave_found_callback cb) +void w1_search (struct w1_master *dev,u8 search_type, +w1_slave_found_callback cb) {u64 last_rn, rn, tmp64;int i, slave_count =0 ;
@@ -1002,9 +1011,11 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cbfor (i =0 ; i <64 ; ++i) {/* Determine the direction/search bit */ if (i == desc_bit) - search_bit =1 ;/* took the 0 path last time, so take the 1 path */ +/* took the 0 path last time, so take the 1 path */ + search_bit =1 ;else if (i > desc_bit) - search_bit =0 ;/* take the 0 path on the next branch */ +/* take the 0 path on the next branch */ + search_bit =0 ;else search_bit = ((last_rn >> i) &0x1 );
@@ -1015,7 +1026,7 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cbif ( (triplet_ret &0x03 ) ==0x03 )break ; -/* If both directions were valid, and we took the 0 path... */ +/* If both directions were valid, and we took the 0 path */ if (triplet_ret ==0 ) last_zero = i;
@@ -1051,9 +1062,8 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb* last id as the first id (provided it is still on the * bus). */ -dev_info (&dev->dev,"%s: max_slave_count %d reached, " -"will continue next search.\n" , __func__, - dev->max_slave_count); +dev_info (&dev->dev,"%s: max_slave_count %d reached, will continue next search.\n" , + __func__, dev->max_slave_count);set_bit (W1_WARN_MAX_COUNT , &dev->flags); } }
drivers/w1/w1_int.c +2 -1
@@ -31,7 +31,8 @@ static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,/* * We are in process context(kernel thread), so can sleep. */ - dev =kzalloc (sizeof (struct w1_master ) +sizeof (struct w1_bus_master ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct w1_master ) + +sizeof (struct w1_bus_master ),GFP_KERNEL );if (!dev) {pr_err ("Failed to allocate %zd bytes for new w1 device.\n" ,sizeof (struct w1_master ));
drivers/w1/w1_io.c +18 -11
@@ -73,7 +73,8 @@ static void w1_write_bit(struct w1_master *dev, int bit) {unsigned long flags =0 ; -if (w1_disable_irqs)local_irq_save (flags); +if (w1_disable_irqs) +local_irq_save (flags);if (bit) { dev->bus_master->write_bit (dev->bus_master->data,0 );
@@ -87,7 +88,8 @@ static void w1_write_bit(struct w1_master *dev, int bit)w1_delay (10 ); } -if (w1_disable_irqs)local_irq_restore (flags); +if (w1_disable_irqs) +local_irq_restore (flags); }/**
@@ -192,9 +194,10 @@ static u8 w1_read_bit(struct w1_master *dev)*/ u8 w1_triplet (struct w1_master *dev,int bdir) { -if (dev->bus_master->triplet) -return dev->bus_master->triplet (dev->bus_master->data, bdir); -else { +if (dev->bus_master->triplet) { +return dev->bus_master->triplet (dev->bus_master->data, + bdir); + }else {u8 id_bit =w1_touch_bit (dev,1 );u8 comp_bit =w1_touch_bit (dev,1 );u8 retval;
@@ -298,9 +301,10 @@ u8 w1_read_block(struct w1_master *dev, u8 *buf, int len)int i;u8 ret; -if (dev->bus_master->read_block) - ret = dev->bus_master->read_block (dev->bus_master->data, buf, len); -else { +if (dev->bus_master->read_block) { + ret = dev->bus_master->read_block (dev->bus_master->data, + buf, len); + }else {for (i =0 ; i < len; ++i) buf[i] =w1_read_8 (dev); ret = len;
@@ -320,7 +324,8 @@ int w1_reset_bus(struct w1_master *dev)int result;unsigned long flags =0 ; -if (w1_disable_irqs)local_irq_save (flags); +if (w1_disable_irqs) +local_irq_save (flags);if (dev->bus_master->reset_bus) result = dev->bus_master->reset_bus (dev->bus_master->data) &0x1 ;
@@ -346,7 +351,8 @@ int w1_reset_bus(struct w1_master *dev)msleep (1 ); } -if (w1_disable_irqs)local_irq_restore (flags); +if (w1_disable_irqs) +local_irq_restore (flags);return result; }
@@ -363,7 +369,8 @@ u8 w1_calc_crc8(u8 * data, int len) }EXPORT_SYMBOL_GPL (w1_calc_crc8); -void w1_search_devices (struct w1_master *dev,u8 search_type,w1_slave_found_callback cb) +void w1_search_devices (struct w1_master *dev,u8 search_type, +w1_slave_found_callback cb) { dev->attempts++;if (dev->bus_master->search)
drivers/w1/w1_netlink.c +11 -5
@@ -82,8 +82,10 @@ static void w1_unref_block(struct w1_cb_block *block)static void w1_reply_make_space (struct w1_cb_block *block,u16 space) {u16 len =w1_reply_len (block); +if (len + space >= block->maxlen) { -cn_netlink_send_mult (block->first_cn, len, block->portid,0 ,GFP_KERNEL ); +cn_netlink_send_mult (block->first_cn, len, + block->portid,0 ,GFP_KERNEL ); block->first_cn->len =0 ; block->cn =NULL ; block->msg =NULL ;
@@ -110,7 +112,8 @@ static void w1_netlink_check_send(struct w1_cb_block *block)static void w1_netlink_setup_msg (struct w1_cb_block *block,u32 ack) {if (block->cn && block->cn->ack == ack) { - block->msg = (struct w1_netlink_msg *)(block->cn->data + block->cn->len); + block->msg = (struct w1_netlink_msg *) + (block->cn->data + block->cn->len); }else {/* advance or set to data */ if (block->cn)
@@ -170,7 +173,9 @@ static void w1_netlink_queue_status(struct w1_cb_block *block, block->msg->len =0 ; block->msg->status = (u8)-error;if (req_cmd) { -struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)block->msg->data; +struct w1_netlink_cmd *cmd = + (struct w1_netlink_cmd *) block->msg->data; +memcpy (cmd, req_cmd,sizeof (*cmd)); block->cn->len +=sizeof (*cmd); block->msg->len +=sizeof (*cmd);
@@ -388,8 +393,9 @@ static int w1_process_command_slave(struct w1_slave *sl, struct w1_netlink_cmd *cmd) {dev_dbg (&sl->master->dev,"%s: %02x.%012llx.%02x: cmd=%02x, len=%u.\n" , - __func__, sl->reg_num.family, (unsigned long long )sl->reg_num.id, - sl->reg_num.crc, cmd->cmd, cmd->len); + __func__, sl->reg_num.family, + (unsigned long long ) sl->reg_num.id, sl->reg_num.crc, cmd->cmd, + cmd->len);return w1_process_command_io (sl->master, cmd); }
Signature · 1 line
2.11.0
Re: [PATCH 2/9] w1: improve coding style by following strict 80 column line limit
Quoted 1 line · Steffen Vogel
This satisfies a checkpatch warning
Perhaps run your patches through checkpatch with --strict
drivers/w1/w1.c
Quoted 1 line
drivers/w1/w1.c +0
-0
[]
drivers/w1/w1.c static void w1_slave_release(struct device *dev) · line 89
Quoted 7 lines
drivers/w1/w1.c +2
-1@@ -85,7 +85,8 @@ static void w1_slave_release(struct device *dev) sl->master->slave_count--; } -static ssize_t name_show (struct device *dev,struct device_attribute *attr,char *buf) +static ssize_t name_show (struct device *dev, +struct device_attribute *attr,char *buf)
atypical alignment.
drivers/w1/w1.c static void w1_netlink_queue_status(struct w1_cb_block *block, · line 177
Quoted 9 lines
[]
drivers/w1/w1.c +2
-1@@ -170,7 +173,9 @@ static void w1_netlink_queue_status(struct w1_cb_block *block, block->msg->len =0 ; block->msg->status = (u8)-error;if (req_cmd) { -struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)block->msg->data; +struct w1_netlink_cmd *cmd = + (struct w1_netlink_cmd *) block->msg->data;
unnecessary space after cast
PATCH 3/9 w1: add newlines after declarations
In reply to Steffen VogelThis satisfies a checkpatch warning
--- drivers/w1/w1.c | 23 +++++++++++++++++++++++ drivers/w1/w1_netlink.c | 7 +++++++ 2 files changed, 30 insertions(+)
drivers/w1/w1.c +23 -0
@@ -130,6 +130,7 @@ static ssize_t rw_write(struct file *filp, struct kobject *kobj, out_up:mutex_unlock (&sl->master->mutex); +return count; }
@@ -142,6 +143,7 @@ static ssize_t rw_read(struct file *filp, struct kobject *kobj,mutex_lock (&sl->master->mutex);w1_read_block (sl->master, buf, count);mutex_unlock (&sl->master->mutex); +return count; }
@@ -297,6 +299,7 @@ static ssize_t w1_master_attribute_show_pointer(struct device *dev,mutex_lock (&md->mutex); count =sprintf (buf,"0x%p\n" , md->bus_master);mutex_unlock (&md->mutex); +return count; }
@@ -304,7 +307,9 @@ static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct device_attribute *attr, char *buf) { ssize_t count; + count =sprintf (buf,"%d\n" , w1_timeout); +return count; }
@@ -312,7 +317,9 @@ static ssize_t w1_master_attribute_show_timeout_us(struct device *dev, struct device_attribute *attr, char *buf) { ssize_t count; + count =sprintf (buf,"%d\n" , w1_timeout_us); +return count; }
@@ -369,6 +376,7 @@ static ssize_t w1_master_attribute_show_slave_count(struct device *dev,mutex_lock (&md->mutex); count =sprintf (buf,"%d\n" , md->slave_count);mutex_unlock (&md->mutex); +return count; }
@@ -399,8 +407,10 @@ static ssize_t w1_master_attribute_show_add(struct device *dev, struct device_attribute *attr, char *buf) { int c = PAGE_SIZE; + c -=snprintf (buf+PAGE_SIZE - c, c,"write device id xx-xxxxxxxxxxxx to add slave\n" ); +return PAGE_SIZE - c; }
@@ -449,6 +459,7 @@ struct w1_slave *w1_slave_search_device(struct w1_master *dev, struct w1_reg_num *rn) {struct w1_slave *sl; +mutex_lock (&dev->list_mutex);list_for_each_entry (sl, &dev->slist, w1_slave_entry) { if (sl->reg_num.family == rn->family &&
@@ -459,6 +470,7 @@ struct w1_slave *w1_slave_search_device(struct w1_master *dev, } }mutex_unlock (&dev->list_mutex); +return NULL ; }
@@ -495,8 +507,10 @@ static ssize_t w1_master_attribute_show_remove(struct device *dev, struct device_attribute *attr, char *buf) { int c = PAGE_SIZE; + c -=snprintf (buf+PAGE_SIZE - c, c,"write device id xx-xxxxxxxxxxxx to remove slave\n" ); +return PAGE_SIZE - c; }
@@ -674,6 +688,7 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl)sysfs_remove_groups (&sl->dev.kobj, fops->groups);break ; } +return 0 ; }
@@ -709,6 +724,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)"Device registration [%s] failed. err=%d\n" , dev_name(&sl->dev), err);put_device (&sl->dev); +return err; }w1_family_notify (BUS_NOTIFY_ADD_DEVICE , sl);
@@ -777,6 +793,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)w1_family_put (sl->family);atomic_dec (&sl->master->refcnt);kfree (sl); +return err; }
@@ -793,6 +810,7 @@ int w1_unref_slave(struct w1_slave *sl) {struct w1_master *dev = sl->master;int refcnt; +mutex_lock (&dev->list_mutex); refcnt =atomic_sub_return (1 , &sl->refcnt);if (refcnt ==0 ) {
@@ -817,6 +835,7 @@ int w1_unref_slave(struct w1_slave *sl) }atomic_dec (&dev->refcnt);mutex_unlock (&dev->list_mutex); +return refcnt; }
@@ -824,6 +843,7 @@ int w1_slave_detach(struct w1_slave *sl) {/* Only detach a slave once as it decreases the refcnt each time. */ int destroy_now; +mutex_lock (&sl->master->list_mutex); destroy_now = !test_bit (W1_SLAVE_DETACH , &sl->flags);set_bit (W1_SLAVE_DETACH , &sl->flags);
@@ -831,6 +851,7 @@ int w1_slave_detach(struct w1_slave *sl)if (destroy_now) destroy_now = !w1_unref_slave (sl); +return destroy_now ?0 : -EBUSY ; }
@@ -996,6 +1017,7 @@ void w1_search(struct w1_master *dev, u8 search_type,/* Do fast search on single slave bus */ if (dev->max_slave_count ==1 ) {int rv; +w1_write_8 (dev,W1_READ_ROM ); rv =w1_read_block (dev, (u8 *)&rn,8 );mutex_unlock (&dev->bus_mutex);
@@ -1127,6 +1149,7 @@ int w1_process_callbacks(struct w1_master *dev)mutex_lock (&dev->list_mutex); } } +return ret; }
drivers/w1/w1_netlink.c +7 -0
@@ -63,6 +63,7 @@ static void w1_unref_block(struct w1_cb_block *block) {if (atomic_sub_return (1 , &block->refcnt) ==0 ) {u16 len =w1_reply_len (block); +if (len) {cn_netlink_send_mult (block->first_cn, len, block->portid,0 ,GFP_KERNEL );
@@ -137,6 +138,7 @@ static void w1_netlink_queue_cmd(struct w1_cb_block *block, struct w1_netlink_cmd *cmd) {u32 space; +w1_reply_make_space (block,sizeof (struct cn_msg ) +sizeof (struct w1_netlink_msg ) +sizeof (*cmd) + cmd->len);
@@ -165,6 +167,7 @@ static void w1_netlink_queue_status(struct w1_cb_block *block, int error) {u16 space =sizeof (struct cn_msg ) +sizeof (*req_msg) +sizeof (*req_cmd); +w1_reply_make_space (block, space);w1_netlink_setup_msg (block, block->request_cn.ack);
@@ -276,6 +279,7 @@ static int w1_get_slaves(struct w1_master *dev, struct w1_netlink_cmd *req_cmd)if (req_cmd->cmd ==W1_CMD_LIST_SLAVES ) {u64 rn; +mutex_lock (&dev->list_mutex);list_for_each_entry (sl, &dev->slist, w1_slave_entry) {memcpy (&rn, &sl->reg_num,sizeof (rn));
@@ -508,6 +512,7 @@ static void w1_list_count_cmds(struct w1_netlink_msg *msg, int *cmd_count,u16 mlen = msg->len;u16 len;int slave_list =0 ; +while (mlen) {if (cmd->len +sizeof (struct w1_netlink_cmd ) > mlen)break ;
@@ -526,6 +531,7 @@ static void w1_list_count_cmds(struct w1_netlink_msg *msg, int *cmd_count,if (slave_list) {struct w1_master *dev =w1_search_master_id (msg->id.mst.id); +if (dev) {/* Bytes, and likely an overstimate, and if it isn't * the results can still be split between packets.
@@ -586,6 +592,7 @@ static void w1_cn_callback(struct cn_msg *cn, struct netlink_skb_parms *nsp)if (node_count) {int size;int reply_size =sizeof (*cn) + cn->len + slave_len; +if (cn->flags &W1_CN_BUNDLE ) {/* bundling duplicats some of the messages */ reply_size += 2 * cmd_count * (sizeof(struct cn_msg) +
Signature · 1 line
2.11.0
PATCH 4/9 w1: cleanup whitespaces according to coding style document
In reply to Steffen VogelThese changes fix several warnings emitted by the checkpatch tool.
--- drivers/w1/w1.c | 20 +++++++++----------- drivers/w1/w1_family.c | 2 +- drivers/w1/w1_io.c | 17 +++++++++-------- drivers/w1/w1_netlink.c | 2 +- 4 files changed, 20 insertions(+), 21 deletions(-)
drivers/w1/w1.c +9 -11
@@ -775,7 +775,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)spin_lock (&w1_flock); f =w1_family_registered (rn->family);if (!f) { - f= &w1_default_family; + f = &w1_default_family;dev_info (&dev->dev,"Family %x for %02x.%012llx.%02x is not registered.\n" , rn->family, rn->family, (unsigned long long )rn->id, rn->crc);
@@ -997,7 +997,7 @@ void w1_search(struct w1_master *dev, u8 search_type, desc_bit =64 ; -while ( !last_device && (slave_count++ < dev->max_slave_count) ) { +while (!last_device && (slave_count++ < dev->max_slave_count)) { last_rn = rn; rn =0 ;
@@ -1045,7 +1045,7 @@ void w1_search(struct w1_master *dev, u8 search_type, triplet_ret =w1_triplet (dev, search_bit);/* quit if no device responded */ -if ( (triplet_ret &0x03 ) ==0x03 ) +if ((triplet_ret &0x03 ) ==0x03 )break ;/* If both directions were valid, and we took the 0 path */
@@ -1064,13 +1064,12 @@ void w1_search(struct w1_master *dev, u8 search_type, }mutex_unlock (&dev->bus_mutex); -if ( (triplet_ret &0x03 ) !=0x03 ) { +if ((triplet_ret &0x03 ) !=0x03 ) {if ((desc_bit == last_zero) || (last_zero <0 )) { last_device =1 ; dev->search_id =0 ; - }else { + }else dev->search_id = rn; - } desc_bit = last_zero;cb (dev, rn); }
@@ -1109,8 +1108,7 @@ void w1_search_process_cb(struct w1_master *dev, u8 search_type,mutex_unlock (&dev->list_mutex);w1_slave_detach (sl);mutex_lock (&dev->list_mutex); - } -else if (test_bit (W1_SLAVE_ACTIVE , &sl->flags)) + }else if (test_bit (W1_SLAVE_ACTIVE , &sl->flags)) sl->ttl = dev->slave_ttl; }mutex_unlock (&dev->list_mutex);
@@ -1142,7 +1140,8 @@ int w1_process_callbacks(struct w1_master *dev)list_for_each_entry_safe (async_cmd, async_n, &dev->async_list, async_entry) {/* drop the lock, if it is a search it can take a long -* time */ +* time +*/ mutex_unlock (&dev->list_mutex); async_cmd->cb (dev, async_cmd); ret =1 ;
@@ -1199,8 +1198,7 @@ int w1_process(void *data)if (!jremain) jremain = jtime; jremain =schedule_timeout (jremain); - } -else + }else schedule (); }
drivers/w1/w1_family.c +1 -1
@@ -83,7 +83,7 @@ EXPORT_SYMBOL(w1_unregister_family);/* * Should be called under w1_flock held. */ -struct w1_family *w1_family_registered (u8 fid) +struct w1_family *w1_family_registered (u8 fid) {struct list_head *ent, *n;struct w1_family *f =NULL ;
drivers/w1/w1_io.c +9 -8
@@ -140,13 +140,13 @@ void w1_write_8(struct w1_master *dev, u8 byte)if (dev->bus_master->write_byte) {w1_pre_write (dev); dev->bus_master->write_byte (dev->bus_master->data, byte); - } -else + }else {for (i =0 ; i <8 ; ++i) {if (i ==7 )w1_pre_write (dev);w1_touch_bit (dev, (byte >> i) &0x1 ); } + }w1_post_write (dev); }EXPORT_SYMBOL_GPL (w1_write_8);
@@ -236,9 +236,10 @@ u8 w1_read_8(struct w1_master *dev)if (dev->bus_master->read_byte) res = dev->bus_master->read_byte (dev->bus_master->data); -else +else {for (i =0 ; i <8 ; ++i) - res |= (w1_touch_bit (dev,1 ) << i); + res |= (w1_touch_bit (dev,1 ) << i); + }return res; }
@@ -257,10 +258,10 @@ void w1_write_block(struct w1_master *dev, const u8 *buf, int len)if (dev->bus_master->write_block) {w1_pre_write (dev); dev->bus_master->write_block (dev->bus_master->data, buf, len); - } -else + }else {for (i =0 ; i < len; ++i)w1_write_8 (dev, buf[i]);/* calls w1_pre_write */ + }w1_post_write (dev); }EXPORT_SYMBOL_GPL (w1_write_block);
@@ -358,7 +359,7 @@ int w1_reset_bus(struct w1_master *dev) }EXPORT_SYMBOL_GPL (w1_reset_bus); -u8 w1_calc_crc8 (u8 * data,int len) +u8 w1_calc_crc8 (u8 *data,int len) {u8 crc =0 ;
@@ -400,7 +401,7 @@ int w1_reset_select_slave(struct w1_slave *sl)w1_write_8 (sl->master,W1_SKIP_ROM ); else {u8 match[9 ] = {W1_MATCH_ROM , }; -u64 rn =le64_to_cpu (*((u64 *)&sl->reg_num)); +u64 rn =le64_to_cpu (*((u64 *)&sl->reg_num));memcpy (&match[1 ], &rn,8 );w1_write_block (sl->master, match,9 );
drivers/w1/w1_netlink.c +1 -1
@@ -606,7 +606,7 @@ static void w1_cn_callback(struct cn_msg *cn, struct netlink_skb_parms *nsp)* space for replies which is the original message size plus * space for any list slave data and status messages * cn->len doesn't include itself which is part of the block -* */ +*/ size =/* block + original message */ sizeof(struct w1_cb_block) + sizeof(*cn) + cn->len +/* space for nodes */
Signature · 1 line
2.11.0
PATCH 5/9 w1: use octal numbers instead of macros for file mode
In reply to Steffen VogelThis satifies a warning raised by the checkpatch tool.
--- drivers/w1/w1.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/w1/w1.c +12 -12
@@ -554,18 +554,18 @@ static ssize_t w1_master_attribute_store_remove(struct device *dev, w1_master_attribute_show_##_name, \ w1_master_attribute_store_##_name) -static W1_MASTER_ATTR_RO(name, S_IRUGO); -static W1_MASTER_ATTR_RO(slaves, S_IRUGO); -static W1_MASTER_ATTR_RO(slave_count, S_IRUGO); -static W1_MASTER_ATTR_RW(max_slave_count, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RO(attempts, S_IRUGO); -static W1_MASTER_ATTR_RO(timeout, S_IRUGO); -static W1_MASTER_ATTR_RO(timeout_us, S_IRUGO); -static W1_MASTER_ATTR_RO(pointer, S_IRUGO); -static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RW(add, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RW(remove, S_IRUGO | S_IWUSR | S_IWGRP); +static W1_MASTER_ATTR_RO(name, 0444); +static W1_MASTER_ATTR_RO(slaves, 0444); +static W1_MASTER_ATTR_RO(slave_count, 0444); +static W1_MASTER_ATTR_RW(max_slave_count, 0664); +static W1_MASTER_ATTR_RO(attempts, 0444); +static W1_MASTER_ATTR_RO(timeout, 0444); +static W1_MASTER_ATTR_RO(timeout_us, 0444); +static W1_MASTER_ATTR_RO(pointer, 0444); +static W1_MASTER_ATTR_RW(search, 0664); +static W1_MASTER_ATTR_RW(pullup, 0664); +static W1_MASTER_ATTR_RW(add, 0664); +static W1_MASTER_ATTR_RW(remove, 0664);static struct attribute *w1_master_default_attrs[] = { &w1_master_attribute_name.attr,
Signature · 1 line
2.11.0
Re: [PATCH 5/9] w1: use octal numbers instead of macros for file mode
Hi,
Quoted 29 lines · Steffen Vogel
This satifies a warning raised by the checkpatch tool.
Signed-off-by Steffen Vogel <[email protected]>--- drivers/w1/w1.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)drivers/w1/w1.c +2
-12@@ -554,18 +554,18 @@ static ssize_t w1_master_attribute_store_remove(struct device *dev, w1_master_attribute_show_##_name, \ w1_master_attribute_store_##_name) -static W1_MASTER_ATTR_RO(name, S_IRUGO); -static W1_MASTER_ATTR_RO(slaves, S_IRUGO); -static W1_MASTER_ATTR_RO(slave_count, S_IRUGO); -static W1_MASTER_ATTR_RW(max_slave_count, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RO(attempts, S_IRUGO); -static W1_MASTER_ATTR_RO(timeout, S_IRUGO); -static W1_MASTER_ATTR_RO(timeout_us, S_IRUGO); -static W1_MASTER_ATTR_RO(pointer, S_IRUGO); -static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RW(pullup, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RW(add, S_IRUGO | S_IWUSR | S_IWGRP); -static W1_MASTER_ATTR_RW(remove, S_IRUGO | S_IWUSR | S_IWGRP); +static W1_MASTER_ATTR_RO(name, 0444); +static W1_MASTER_ATTR_RO(slaves, 0444);
drivers/w1/w1.c static ssize_t w1_master_attribute_store_remove(struct device *dev, · line 568
Quoted 10 lines
drivers/w1/w1.c +10
-0+static W1_MASTER_ATTR_RO(slave_count, 0444); +static W1_MASTER_ATTR_RW(max_slave_count, 0664); +static W1_MASTER_ATTR_RO(attempts, 0444); +static W1_MASTER_ATTR_RO(timeout, 0444); +static W1_MASTER_ATTR_RO(timeout_us, 0444); +static W1_MASTER_ATTR_RO(pointer, 0444); +static W1_MASTER_ATTR_RW(search, 0664); +static W1_MASTER_ATTR_RW(pullup, 0664); +static W1_MASTER_ATTR_RW(add, 0664); +static W1_MASTER_ATTR_RW(remove, 0664);
Since the permissions are the same for all instances, the macros could be simplified further (e.g. W1_MASTER_ATTR_RW(remove)).
-- Sebastian
PATCH 6/9 w1: do not log errors about failed memory allocations
In reply to Steffen VogelThis fixes a warning raised by the checkpatch tool.
--- drivers/w1/w1.c | 7 +------ drivers/w1/w1_int.c | 6 +----- 2 files changed, 2 insertions(+), 11 deletions(-)
drivers/w1/w1.c +1 -6
@@ -747,13 +747,8 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)struct w1_netlink_msg msg; sl =kzalloc (sizeof (struct w1_slave ),GFP_KERNEL ); -if (!sl) { -dev_err (&dev->dev, -"%s: failed to allocate new slave device.\n" , - __func__); +if (!sl)return -ENOMEM ; - } - sl->owner =THIS_MODULE ; sl->master = dev;
drivers/w1/w1_int.c +1 -5
@@ -33,12 +33,8 @@ static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,*/ dev =kzalloc (sizeof (struct w1_master ) +sizeof (struct w1_bus_master ),GFP_KERNEL ); -if (!dev) { -pr_err ("Failed to allocate %zd bytes for new w1 device.\n" , -sizeof (struct w1_master )); +if (!dev)return NULL ; - } - dev->bus_master = (struct w1_bus_master *)(dev +1 );
Signature · 1 line
2.11.0
PATCH 7/9 w1: use __func__ for logging the function name
In reply to Steffen VogelThis fixes a warning raised by the checkpatch tool.
--- drivers/w1/w1.c | 3 ++- drivers/w1/w1_int.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/w1/w1.c +2 -1
@@ -1053,7 +1053,8 @@ void w1_search(struct w1_master *dev, u8 search_type,if (test_bit (W1_ABORT_SEARCH , &dev->flags)) {mutex_unlock (&dev->bus_mutex); -dev_dbg (&dev->dev,"Abort w1_search\n" ); +dev_dbg (&dev->dev,"Abort %s\n" , __func__); +return ; } }
drivers/w1/w1_int.c +1 -1
@@ -98,7 +98,7 @@ int w1_add_master_device(struct w1_bus_master *master)if (!(master->touch_bit && master->reset_bus) && !(master->write_bit && master->read_bit) && !(master->write_byte && master->read_byte && master->reset_bus)) { -pr_err ("w1_add_master_device: invalid function set\n" ); +pr_err ("%s: invalid function set\n" , __func__);return (-EINVAL ); }
Signature · 1 line
2.11.0
PATCH 8/9 w1: fix whitespaces of struct declarations
In reply to Steffen VogelThis fixes a warning raised by the checkpatch tool.
--- drivers/w1/w1_netlink.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/w1/w1_netlink.h +13 -15
@@ -61,19 +61,18 @@ enum w1_netlink_message_types {* The netlink connector data sequence is, struct nlmsghdr, struct cn_msg, * then one or more struct w1_netlink_msg (each with optional data). */ -struct w1_netlink_msg -{ -__u8 type; -__u8 status; -__u16 len; +struct w1_netlink_msg { +__u8 type; +__u8 status; +__u16 len;union { -__u8 id[8 ]; +__u8 id[8 ];struct w1_mst { -__u32 id; -__u32 res; +__u32 id; +__u32 res; } mst; } id; -__u8 data[0 ]; +__u8 data[0 ]; };/**
@@ -117,12 +116,11 @@ enum w1_commands {* One or more struct w1_netlink_cmd is placed starting at w1_netlink_msg.data * each with optional data. */ -struct w1_netlink_cmd -{ -__u8 cmd; -__u8 res; -__u16 len; -__u8 data[0 ]; +struct w1_netlink_cmd { +__u8 cmd; +__u8 res; +__u16 len; +__u8 data[0 ]; };#ifdef __KERNEL__
Signature · 1 line
2.11.0
Re: [PATCH 8/9] w1: fix whitespaces of struct declarations
Quoted 1 line · Steffen Vogel
This fixes a warning raised by the checkpatch tool.
checkpatch does not raise any whitespace errors on this file.
It does suggest that braces could be moved.
$ ./scripts/checkpatch.pl -f --strict drivers/w1/w1_netlink.h WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #1: FILE: drivers/w1/w1_netlink.h:1: +/*
ERROR: open brace '{' following struct go on the same line #74: FILE: drivers/w1/w1_netlink.h:74:
+struct w1_netlink_msg
+{
ERROR: open brace '{' following struct go on the same line #130: FILE: drivers/w1/w1_netlink.h:130:
+struct w1_netlink_cmd
+{
total: 2 errors, 1 warnings, 0 checks, 144 lines checked
Quoted 55 lines
Signed-off-by Steffen Vogel <[email protected]>--- drivers/w1/w1_netlink.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)drivers/w1/w1_netlink.h +13
-15@@ -61,19 +61,18 @@ enum w1_netlink_message_types {* The netlink connector data sequence is, struct nlmsghdr, struct cn_msg, * then one or more struct w1_netlink_msg (each with optional data). */ -struct w1_netlink_msg does n -{ -__u8 type; -__u8 status; -__u16 len; +struct w1_netlink_msg { +__u8 type; +__u8 status; +__u16 len;union { -__u8 id[8 ]; +__u8 id[8 ];struct w1_mst { -__u32 id; -__u32 res; +__u32 id; +__u32 res; } mst; } id; -__u8 data[0 ]; +__u8 data[0 ]; };/** @@ -117,12 +116,11 @@ enum w1_commands {* One or more struct w1_netlink_cmd is placed starting at w1_netlink_msg.data * each with optional data. */ -struct w1_netlink_cmd -{ -__u8 cmd; -__u8 res; -__u16 len; -__u8 data[0 ]; +struct w1_netlink_cmd { +__u8 cmd; +__u8 res; +__u16 len; +__u8 data[0 ]; };#ifdef __KERNEL__
Re: [PATCH 8/9] w1: fix whitespaces of struct declarations
Hi Joe,
v2 of this patch set is almost ready.
I reran checkpatch.pl with '--strict'. So more warnings will be fixed by the second version.
See my comments below.
Quoted 7 lines · Joe Perches
Quoted 1 line · Steffen Vogel
This fixes a warning raised by the checkpatch tool.
checkpatch does not raise any whitespace errors on this file.
It does suggest that braces could be moved.
Ah okay, I considered moving a brace also a whitespace change. Do you prefer the original indention of the struct members? I dont see it very often in kernel code.
Cheers,
Steffen
Re: [PATCH 8/9] w1: fix whitespaces of struct declarations
Quoted 12 lines · Steffen Vogel
Hi Joe,
v2 of this patch set is almost ready.
I reran checkpatch.pl with '--strict'. So more warnings will be fixed by the second version.See my comments below.
Quoted 3 lines · Joe Perches
Quoted 1 line · Steffen Vogel
This fixes a warning raised by the checkpatch tool.
Quoted 8 lines
Quoted 4 lines
checkpatch does not raise any whitespace errors on this file.
It does suggest that braces could be moved.
Ah okay, I considered moving a brace also a whitespace change. Do you prefer the original indention of the struct members? I dont see it very often in kernel code.
The indentation doesn't matter to me.
The commit message description of a checkpatch warning that does not exist is incorrect.
PATCH 9/9 w1: using linux instead of asm prefix for includes
In reply to Steffen VogelThis fixes a warning raised by the checkpatch tool
--- drivers/w1/w1_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/w1/w1_io.c +1 -1
@@ -3,7 +3,7 @@* Copyright (c) 2004 Evgeniy Polyakov <[email protected]> */ -#include <asm/io.h> +#include <linux/io.h> #include <linux/delay.h> #include <linux/moduleparam.h>
Signature · 1 line
2.11.0
[ This is not about your patch series per se, only about your email settings ]
Quoted 4 lines · Steffen Vogel
This is my first series of patches for the Linux kernel. I started by familiarizing myself with coding style and satisfying my inner OCD by cleaning the 1-wire subsystem.
Sadly, your DKIM setup is wrong, causing all the emails to be marked as spam when they go through a mailing list.
Your DKIM header looks like this:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=steffenvogel.de;
s=2017; t=1540764601;
h=from:from:sender:reply-to:subject:subject:date:date:
message-id:message-id:to:to:cc:cc:mime-version:mime-version:
content-type:content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;and the problem with that is the "sender" field in there.
A good mailing list will not change the contents of your email, or most of the other headers, but it *will* set the sender field to the mailing list.
End result: the DKIM signature is guaranteed to fail after the email has gone through a mailing list.
In other words, putting the sender field as part of the DKIM-checked headers is just wrong. It's a somewhat common mistake, but it's still wrong. I wonder where people get their setups from, because I think there is some DKIM guide on the internet that is actively spreading this bad behavior.
You do have a few other oddities in there (the duplication of the common fields), but they shouldn't matter.
Linus
Hi Linus,
Thanks! Its hopefully fixed now.
For those who are interested. Rspamd, by default, includes the sender address into the list of signed headers:
https://www.rspamd.com/doc/modules/dkim_signing.html#default-sign_headers-after-173
Quoted 2 lines
End result: the DKIM signature is guaranteed to fail after the email has gone through a mailing list.
There is RFC6377 which discusses this problem. On possible solution is a mailing list service which understands DKIM and can check/sign the messages.
See: https://tools.ietf.org/html/rfc6377
Quoted 2 lines
You do have a few other oddities in there (the duplication of the common fields), but they shouldn't matter.
This is actually according to RFC. Listing signed header-fields multiple times prohibits them from beeing modified and resigned my other MTAs.
Thanks again,
Steffen
Quoted 35 lines · Linus Torvalds
[ This is not about your patch series per se, only about your email settings ]
Quoted 4 lines · Steffen Vogel
This is my first series of patches for the Linux kernel. I started by familiarizing myself with coding style and satisfying my inner OCD by cleaning the 1-wire subsystem.
Sadly, your DKIM setup is wrong, causing all the emails to be marked as spam when they go through a mailing list.
Your DKIM header looks like this:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=steffenvogel.de; s=2017; t=1540764601; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references;and the problem with that is the "sender" field in there.
A good mailing list will not change the contents of your email, or most of the other headers, but it *will* set the sender field to the mailing list.
In other words, putting the sender field as part of the DKIM-checked headers is just wrong. It's a somewhat common mistake, but it's still wrong. I wonder where people get their setups from, because I think there is some DKIM guide on the internet that is actively spreading this bad behavior.
Linus
Quoted 3 lines · Steffen Vogel
For those who are interested. Rspamd, by default, includes the sender address into the list of signed headers:
Ugh. That's just broken.
Quoted 3 lines
There is RFC6377 which discusses this problem. On possible solution is a mailing list service which understands DKIM and can check/sign the messages.
I think that is almost purely historical.
People figured it out. The actual solution was that mailing lists just don't rewrite headers or bodies, but they do set that "sender" line (and add various new ones, like "List-ID" etc unsubscribe information).
And that was exactly so that dkim would just work, without the list having to then add its own signing that just causes even more problems.
[ And no, lkml isn't actually great at this - it will mess up whitespace on headers, so it only works with a relaxed/relaxed dkim signature.
But honestly, if you use strict/strict, you're doing something
wrong. It's a bad idea. Smtp was never whitespace-strict ]
Quoted 3 lines
This is actually according to RFC. Listing signed header-fields multiple times prohibits them from beeing modified and resigned my other MTAs.
Again, that is mostly historical baggage. I don't think anybody actually does that.
So yes, you'll find a lot of "what ifs" from ten years ago when people weren't actually using dkim and mailing lists didn't try to work with it. Mostly theoretical "this is how it could work".
I've seen some truly horrendous suggestions for mailing lists, like always rewriting "From" headers etc exactly so that you can then make a new dkim signature. That would make for a really bad mailing list.
.. and yes, I'm sure such bad mailing lists exist.
Linus