[PATCH v2 12/12] w1: fix typo in comment

2018-10-28 Thread Steffen Vogel
Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 1326bd52888a..94747eeff0fa 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1196,7 +1196,7 @@ int w1_process(void *data)
 
__set_current_state(TASK_INTERRUPTIBLE);
 
-   /* hold list_mutex until after interruptible to prevent loosing
+   /* hold list_mutex until after interruptible to prevent losing
 * the wakeup signal when async_cmd is added.
 */
mutex_unlock(>list_mutex);
-- 
2.11.0



[PATCH v2 12/12] w1: fix typo in comment

2018-10-28 Thread Steffen Vogel
Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 1326bd52888a..94747eeff0fa 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1196,7 +1196,7 @@ int w1_process(void *data)
 
__set_current_state(TASK_INTERRUPTIBLE);
 
-   /* hold list_mutex until after interruptible to prevent loosing
+   /* hold list_mutex until after interruptible to prevent losing
 * the wakeup signal when async_cmd is added.
 */
mutex_unlock(>list_mutex);
-- 
2.11.0



[PATCH v2 08/12] w1: improve code-style of struct declarations

2018-10-28 Thread Steffen Vogel
Among improving the readability of the struct declarations,
this fixes a warning about incorrect brace placement
raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_netlink.h | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 08cbf08f3649..7873eb54352e 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -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
-{
-   __u8type;
-   __u8status;
-   __u16   len;
+struct w1_netlink_msg {
+   __u8 type;
+   __u8 status;
+   __u16 len;
union {
-   __u8id[8];
+   __u8 id[8];
struct w1_mst {
-   __u32   id;
-   __u32   res;
+   __u32 id;
+   __u32 res;
} mst;
} id;
-   __u8data[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
-{
-   __u8cmd;
-   __u8res;
-   __u16   len;
-   __u8data[0];
+struct w1_netlink_cmd {
+   __u8 cmd;
+   __u8 res;
+   __u16 len;
+   __u8 data[0];
 };
 
 #ifdef __KERNEL__
-- 
2.11.0



[PATCH v2 08/12] w1: improve code-style of struct declarations

2018-10-28 Thread Steffen Vogel
Among improving the readability of the struct declarations,
this fixes a warning about incorrect brace placement
raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_netlink.h | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 08cbf08f3649..7873eb54352e 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -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
-{
-   __u8type;
-   __u8status;
-   __u16   len;
+struct w1_netlink_msg {
+   __u8 type;
+   __u8 status;
+   __u16 len;
union {
-   __u8id[8];
+   __u8 id[8];
struct w1_mst {
-   __u32   id;
-   __u32   res;
+   __u32 id;
+   __u32 res;
} mst;
} id;
-   __u8data[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
-{
-   __u8cmd;
-   __u8res;
-   __u16   len;
-   __u8data[0];
+struct w1_netlink_cmd {
+   __u8 cmd;
+   __u8 res;
+   __u16 len;
+   __u8 data[0];
 };
 
 #ifdef __KERNEL__
-- 
2.11.0



[PATCH v2 00/11] w1: coding style and checkpatch fixes

2018-10-28 Thread Steffen Vogel
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.

Cheers,
Steffen

---

Changes since v1:
  - addressed comments from Joe Perches:
  - re-ran checkpatch.pl in --strict mode
  - fixed commit messages to reflect more precisly
the checkpatch warnings

Steffen Vogel (12):
  w1: add SPDX identifiers
  w1: improve code-style by adhering tp 80 columns per line limit
  w1: add newlines after declarations
  w1: cleanup whitespaces according to coding style document
  w1: use octal numbers instead of macros for file mode
  w1: do not log errors about failed memory allocations
  w1: use __func__ for logging the function name
  w1: improve code-style of struct declarations
  w1: using linux instead of asm prefix for includes
  w1: use pointers instead of types to determine size of allocs
  w1: replace non-standard %LX format-string by %llX
  w1: fix typo in comment

 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| 272 +++--
 drivers/w1/w1_family.c |  15 +--
 drivers/w1/w1_int.c|  34 ++
 drivers/w1/w1_internal.h   |  11 +-
 drivers/w1/w1_io.c |  86 ++---
 drivers/w1/w1_netlink.c|  64 +-
 drivers/w1/w1_netlink.h|  39 +++---
 29 files changed, 283 insertions(+), 411 deletions(-)

-- 
2.11.0



[PATCH v2 10/12] w1: use pointers instead of types to determine size of allocs

2018-10-28 Thread Steffen Vogel
Get size of allocation based on pointer not type.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 2 +-
 drivers/w1/w1_int.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 4cbe1849fbfc..87094d99ccbe 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -756,7 +756,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
int err;
struct w1_netlink_msg msg;
 
-   sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL);
+   sl = kzalloc(sizeof(*sl), GFP_KERNEL);
if (!sl)
return -ENOMEM;
 
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index a5230c0d49e3..2bf7631ac24f 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -31,7 +31,7 @@ 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) +
+   dev = kzalloc(sizeof(*dev) +
sizeof(struct w1_bus_master), GFP_KERNEL);
if (!dev)
return NULL;
-- 
2.11.0



[PATCH v2 00/11] w1: coding style and checkpatch fixes

2018-10-28 Thread Steffen Vogel
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.

Cheers,
Steffen

---

Changes since v1:
  - addressed comments from Joe Perches:
  - re-ran checkpatch.pl in --strict mode
  - fixed commit messages to reflect more precisly
the checkpatch warnings

Steffen Vogel (12):
  w1: add SPDX identifiers
  w1: improve code-style by adhering tp 80 columns per line limit
  w1: add newlines after declarations
  w1: cleanup whitespaces according to coding style document
  w1: use octal numbers instead of macros for file mode
  w1: do not log errors about failed memory allocations
  w1: use __func__ for logging the function name
  w1: improve code-style of struct declarations
  w1: using linux instead of asm prefix for includes
  w1: use pointers instead of types to determine size of allocs
  w1: replace non-standard %LX format-string by %llX
  w1: fix typo in comment

 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| 272 +++--
 drivers/w1/w1_family.c |  15 +--
 drivers/w1/w1_int.c|  34 ++
 drivers/w1/w1_internal.h   |  11 +-
 drivers/w1/w1_io.c |  86 ++---
 drivers/w1/w1_netlink.c|  64 +-
 drivers/w1/w1_netlink.h|  39 +++---
 29 files changed, 283 insertions(+), 411 deletions(-)

-- 
2.11.0



[PATCH v2 10/12] w1: use pointers instead of types to determine size of allocs

2018-10-28 Thread Steffen Vogel
Get size of allocation based on pointer not type.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 2 +-
 drivers/w1/w1_int.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 4cbe1849fbfc..87094d99ccbe 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -756,7 +756,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
int err;
struct w1_netlink_msg msg;
 
-   sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL);
+   sl = kzalloc(sizeof(*sl), GFP_KERNEL);
if (!sl)
return -ENOMEM;
 
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index a5230c0d49e3..2bf7631ac24f 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -31,7 +31,7 @@ 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) +
+   dev = kzalloc(sizeof(*dev) +
sizeof(struct w1_bus_master), GFP_KERNEL);
if (!dev)
return NULL;
-- 
2.11.0



[PATCH v2 03/12] w1: add newlines after declarations

2018-10-28 Thread Steffen Vogel
This satisfies a checkpatch warning

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 23 +++
 drivers/w1/w1_netlink.c |  7 +++
 2 files changed, 30 insertions(+)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 6b3cdc5a09fb..48c20639f75f 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -128,6 +128,7 @@ static ssize_t rw_write(struct file *filp, struct kobject 
*kobj,
 
 out_up:
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -140,6 +141,7 @@ static ssize_t rw_read(struct file *filp, struct kobject 
*kobj,
mutex_lock(>master->mutex);
w1_read_block(sl->master, buf, count);
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -296,6 +298,7 @@ static ssize_t w1_master_attribute_show_pointer(struct 
device *dev,
mutex_lock(>mutex);
count = sprintf(buf, "0x%p\n", md->bus_master);
mutex_unlock(>mutex);
+
return count;
 }
 
@@ -304,7 +307,9 @@ static ssize_t w1_master_attribute_show_timeout(struct 
device *dev,
char *buf)
 {
ssize_t count;
+
count = sprintf(buf, "%d\n", w1_timeout);
+
return count;
 }
 
@@ -313,7 +318,9 @@ static ssize_t w1_master_attribute_show_timeout_us(struct 
device *dev,
   char *buf)
 {
ssize_t count;
+
count = sprintf(buf, "%d\n", w1_timeout_us);
+
return count;
 }
 
@@ -375,6 +382,7 @@ static ssize_t w1_master_attribute_show_slave_count(struct 
device *dev,
mutex_lock(>mutex);
count = sprintf(buf, "%d\n", md->slave_count);
mutex_unlock(>mutex);
+
return count;
 }
 
@@ -407,8 +415,10 @@ static ssize_t w1_master_attribute_show_add(struct device 
*dev,
char *buf)
 {
int c = PAGE_SIZE;
+
c -= snprintf(buf+PAGE_SIZE - c, c,
"write device id xx- to add slave\n");
+
return PAGE_SIZE - c;
 }
 
@@ -457,6 +467,7 @@ struct w1_slave *w1_slave_search_device(struct w1_master 
*dev,
struct w1_reg_num *rn)
 {
struct w1_slave *sl;
+
mutex_lock(>list_mutex);
list_for_each_entry(sl, >slist, w1_slave_entry) {
if (sl->reg_num.family == rn->family &&
@@ -467,6 +478,7 @@ struct w1_slave *w1_slave_search_device(struct w1_master 
*dev,
}
}
mutex_unlock(>list_mutex);
+
return NULL;
 }
 
@@ -504,8 +516,10 @@ static ssize_t w1_master_attribute_show_remove(struct 
device *dev,
   char *buf)
 {
int c = PAGE_SIZE;
+
c -= snprintf(buf+PAGE_SIZE - c, c,
"write device id xx- to remove slave\n");
+
return PAGE_SIZE - c;
 }
 
@@ -684,6 +698,7 @@ static int w1_family_notify(unsigned long action, struct 
w1_slave *sl)
sysfs_remove_groups(>dev.kobj, fops->groups);
break;
}
+
return 0;
 }
 
@@ -719,6 +734,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
"Device registration [%s] failed. err=%d\n",
dev_name(>dev), err);
put_device(>dev);
+
return err;
}
w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl);
@@ -787,6 +803,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
w1_family_put(sl->family);
atomic_dec(>master->refcnt);
kfree(sl);
+
return err;
}
 
@@ -803,6 +820,7 @@ int w1_unref_slave(struct w1_slave *sl)
 {
struct w1_master *dev = sl->master;
int refcnt;
+
mutex_lock(>list_mutex);
refcnt = atomic_sub_return(1, >refcnt);
if (refcnt == 0) {
@@ -827,6 +845,7 @@ int w1_unref_slave(struct w1_slave *sl)
}
atomic_dec(>refcnt);
mutex_unlock(>list_mutex);
+
return refcnt;
 }
 
@@ -834,6 +853,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(>master->list_mutex);
destroy_now = !test_bit(W1_SLAVE_DETACH, >flags);
set_bit(W1_SLAVE_DETACH, >flags);
@@ -841,6 +861,7 @@ int w1_slave_detach(struct w1_slave *sl)
 
if (destroy_now)
destroy_now = !w1_unref_slave(sl);
+
return destroy_now ? 0 : -EBUSY;
 }
 
@@ -1006,6 +1027,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

[PATCH v2 03/12] w1: add newlines after declarations

2018-10-28 Thread Steffen Vogel
This satisfies a checkpatch warning

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 23 +++
 drivers/w1/w1_netlink.c |  7 +++
 2 files changed, 30 insertions(+)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 6b3cdc5a09fb..48c20639f75f 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -128,6 +128,7 @@ static ssize_t rw_write(struct file *filp, struct kobject 
*kobj,
 
 out_up:
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -140,6 +141,7 @@ static ssize_t rw_read(struct file *filp, struct kobject 
*kobj,
mutex_lock(>master->mutex);
w1_read_block(sl->master, buf, count);
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -296,6 +298,7 @@ static ssize_t w1_master_attribute_show_pointer(struct 
device *dev,
mutex_lock(>mutex);
count = sprintf(buf, "0x%p\n", md->bus_master);
mutex_unlock(>mutex);
+
return count;
 }
 
@@ -304,7 +307,9 @@ static ssize_t w1_master_attribute_show_timeout(struct 
device *dev,
char *buf)
 {
ssize_t count;
+
count = sprintf(buf, "%d\n", w1_timeout);
+
return count;
 }
 
@@ -313,7 +318,9 @@ static ssize_t w1_master_attribute_show_timeout_us(struct 
device *dev,
   char *buf)
 {
ssize_t count;
+
count = sprintf(buf, "%d\n", w1_timeout_us);
+
return count;
 }
 
@@ -375,6 +382,7 @@ static ssize_t w1_master_attribute_show_slave_count(struct 
device *dev,
mutex_lock(>mutex);
count = sprintf(buf, "%d\n", md->slave_count);
mutex_unlock(>mutex);
+
return count;
 }
 
@@ -407,8 +415,10 @@ static ssize_t w1_master_attribute_show_add(struct device 
*dev,
char *buf)
 {
int c = PAGE_SIZE;
+
c -= snprintf(buf+PAGE_SIZE - c, c,
"write device id xx- to add slave\n");
+
return PAGE_SIZE - c;
 }
 
@@ -457,6 +467,7 @@ struct w1_slave *w1_slave_search_device(struct w1_master 
*dev,
struct w1_reg_num *rn)
 {
struct w1_slave *sl;
+
mutex_lock(>list_mutex);
list_for_each_entry(sl, >slist, w1_slave_entry) {
if (sl->reg_num.family == rn->family &&
@@ -467,6 +478,7 @@ struct w1_slave *w1_slave_search_device(struct w1_master 
*dev,
}
}
mutex_unlock(>list_mutex);
+
return NULL;
 }
 
@@ -504,8 +516,10 @@ static ssize_t w1_master_attribute_show_remove(struct 
device *dev,
   char *buf)
 {
int c = PAGE_SIZE;
+
c -= snprintf(buf+PAGE_SIZE - c, c,
"write device id xx- to remove slave\n");
+
return PAGE_SIZE - c;
 }
 
@@ -684,6 +698,7 @@ static int w1_family_notify(unsigned long action, struct 
w1_slave *sl)
sysfs_remove_groups(>dev.kobj, fops->groups);
break;
}
+
return 0;
 }
 
@@ -719,6 +734,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
"Device registration [%s] failed. err=%d\n",
dev_name(>dev), err);
put_device(>dev);
+
return err;
}
w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl);
@@ -787,6 +803,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
w1_family_put(sl->family);
atomic_dec(>master->refcnt);
kfree(sl);
+
return err;
}
 
@@ -803,6 +820,7 @@ int w1_unref_slave(struct w1_slave *sl)
 {
struct w1_master *dev = sl->master;
int refcnt;
+
mutex_lock(>list_mutex);
refcnt = atomic_sub_return(1, >refcnt);
if (refcnt == 0) {
@@ -827,6 +845,7 @@ int w1_unref_slave(struct w1_slave *sl)
}
atomic_dec(>refcnt);
mutex_unlock(>list_mutex);
+
return refcnt;
 }
 
@@ -834,6 +853,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(>master->list_mutex);
destroy_now = !test_bit(W1_SLAVE_DETACH, >flags);
set_bit(W1_SLAVE_DETACH, >flags);
@@ -841,6 +861,7 @@ int w1_slave_detach(struct w1_slave *sl)
 
if (destroy_now)
destroy_now = !w1_unref_slave(sl);
+
return destroy_now ? 0 : -EBUSY;
 }
 
@@ -1006,6 +1027,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

[PATCH v2 01/12] w1: add SPDX identifiers

2018-10-28 Thread Steffen Vogel
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.

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index f661695fb589..83a991a3e3bd 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -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 
  * Copyright (c) 2004-2007, Matt Reimer 
- *
- * 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 
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
index 8b5e598ffdb3..d9bb021eca7e 100644
--- a/drivers/w1/masters/ds2482.c
+++ b/drivers/w1/masters/ds2482.c
@@ -1,4 +1,5 @@
-/**
+// SPDX-License-Identifier: GPL-2.0
+/*
  * ds2482.c - provides i2c to w1-master bridge(s)
  * Copyright (C) 2005  Ben Gardner 
  *
@@ -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 
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 0f4ecfcdb549..7bd9862ef337 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * ds2490.c  USB to one wire bridge
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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 
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index d83d7c99d81d..be131c04ee63 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * matrox_w1.c
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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

[PATCH v2 04/12] w1: cleanup whitespaces according to coding style document

2018-10-28 Thread Steffen Vogel
These changes fix several warnings emitted by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 38 +++---
 drivers/w1/w1_family.c  |  2 +-
 drivers/w1/w1_io.c  | 40 +---
 drivers/w1/w1_netlink.c |  8 
 4 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 48c20639f75f..184df1fe216b 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -416,7 +416,7 @@ static ssize_t w1_master_attribute_show_add(struct device 
*dev,
 {
int c = PAGE_SIZE;
 
-   c -= snprintf(buf+PAGE_SIZE - c, c,
+   c -= snprintf(buf + PAGE_SIZE - c, c,
"write device id xx- to add slave\n");
 
return PAGE_SIZE - c;
@@ -517,7 +517,7 @@ static ssize_t w1_master_attribute_show_remove(struct 
device *dev,
 {
int c = PAGE_SIZE;
 
-   c -= snprintf(buf+PAGE_SIZE - c, c,
+   c -= snprintf(buf + PAGE_SIZE - c, c,
"write device id xx- to remove slave\n");
 
return PAGE_SIZE - c;
@@ -785,7 +785,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
spin_lock(_flock);
f = w1_family_registered(rn->family);
if (!f) {
-   f= _default_family;
+   f = _default_family;
dev_info(>dev, "Family %x for %02x.%012llx.%02x is not 
registered.\n",
 rn->family, rn->family,
 (unsigned long long)rn->id, rn->crc);
@@ -880,7 +880,7 @@ struct w1_master *w1_search_master_id(u32 id)
}
mutex_unlock(_mlock);
 
-   return (found)?dev:NULL;
+   return found ? dev : NULL;
 }
 
 struct w1_slave *w1_search_slave(struct w1_reg_num *id)
@@ -909,7 +909,7 @@ struct w1_slave *w1_search_slave(struct w1_reg_num *id)
}
mutex_unlock(_mlock);
 
-   return (found)?sl:NULL;
+   return found ? sl : NULL;
 }
 
 void w1_reconnect_slaves(struct w1_family *f, int attach)
@@ -960,7 +960,7 @@ void w1_slave_found(struct w1_master *dev, u64 rn)
 
atomic_inc(>refcnt);
 
-   tmp = (struct w1_reg_num *) 
+   tmp = (struct w1_reg_num *)
 
sl = w1_slave_search_device(dev, tmp);
if (sl) {
@@ -1007,12 +1007,11 @@ 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;
 
-   /*
-* Reset bus and all 1-wire device state machines
+   /* Reset bus and all 1-wire device state machines
 * so they can respond to our requests.
 *
 * Return 0 - device(s) present, 1 - no devices present.
@@ -1059,7 +1058,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 */
@@ -1078,13 +1077,14 @@ void w1_search(struct w1_master *dev, u8 search_type,
}
mutex_unlock(>bus_mutex);
 
-   if ( (triplet_ret & 0x03) != 0x03 ) {
-   if ((desc_bit == last_zero) || (last_zero < 0)) {
+   if ((triplet_ret & 0x03) != 0x03) {
+   if (desc_bit == last_zero || last_zero < 0) {
last_device = 1;
dev->search_id = 0;
} else {
dev->search_id = rn;
}
+
desc_bit = last_zero;
cb(dev, rn);
}
@@ -1123,9 +1123,9 @@ void w1_search_process_cb(struct w1_master *dev, u8 
search_type,
mutex_unlock(>list_mutex);
w1_slave_detach(sl);
mutex_lock(>list_mutex);
-   }
-   else if (test_bit(W1_SLAVE_ACTIVE, >flags))
+   } else if (test_bit(W1_SLAVE_ACTIVE, >flags)) {
sl->ttl = dev->slave_ttl;
+   }
}
mutex_unlock(>list_mutex);
 
@@ -1156,7 +1156,8 @@ int w1_process_callbacks(struct w1_master *dev)
list_for_each_entry_safe(async_cmd, async_n, >async_list,
 async_entry) {
/* drop the lock, if it is a search it can take a long
-

[PATCH v2 01/12] w1: add SPDX identifiers

2018-10-28 Thread Steffen Vogel
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.

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index f661695fb589..83a991a3e3bd 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -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 
  * Copyright (c) 2004-2007, Matt Reimer 
- *
- * 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 
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
index 8b5e598ffdb3..d9bb021eca7e 100644
--- a/drivers/w1/masters/ds2482.c
+++ b/drivers/w1/masters/ds2482.c
@@ -1,4 +1,5 @@
-/**
+// SPDX-License-Identifier: GPL-2.0
+/*
  * ds2482.c - provides i2c to w1-master bridge(s)
  * Copyright (C) 2005  Ben Gardner 
  *
@@ -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 
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 0f4ecfcdb549..7bd9862ef337 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * ds2490.c  USB to one wire bridge
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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 
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index d83d7c99d81d..be131c04ee63 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * matrox_w1.c
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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

[PATCH v2 04/12] w1: cleanup whitespaces according to coding style document

2018-10-28 Thread Steffen Vogel
These changes fix several warnings emitted by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 38 +++---
 drivers/w1/w1_family.c  |  2 +-
 drivers/w1/w1_io.c  | 40 +---
 drivers/w1/w1_netlink.c |  8 
 4 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 48c20639f75f..184df1fe216b 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -416,7 +416,7 @@ static ssize_t w1_master_attribute_show_add(struct device 
*dev,
 {
int c = PAGE_SIZE;
 
-   c -= snprintf(buf+PAGE_SIZE - c, c,
+   c -= snprintf(buf + PAGE_SIZE - c, c,
"write device id xx- to add slave\n");
 
return PAGE_SIZE - c;
@@ -517,7 +517,7 @@ static ssize_t w1_master_attribute_show_remove(struct 
device *dev,
 {
int c = PAGE_SIZE;
 
-   c -= snprintf(buf+PAGE_SIZE - c, c,
+   c -= snprintf(buf + PAGE_SIZE - c, c,
"write device id xx- to remove slave\n");
 
return PAGE_SIZE - c;
@@ -785,7 +785,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
spin_lock(_flock);
f = w1_family_registered(rn->family);
if (!f) {
-   f= _default_family;
+   f = _default_family;
dev_info(>dev, "Family %x for %02x.%012llx.%02x is not 
registered.\n",
 rn->family, rn->family,
 (unsigned long long)rn->id, rn->crc);
@@ -880,7 +880,7 @@ struct w1_master *w1_search_master_id(u32 id)
}
mutex_unlock(_mlock);
 
-   return (found)?dev:NULL;
+   return found ? dev : NULL;
 }
 
 struct w1_slave *w1_search_slave(struct w1_reg_num *id)
@@ -909,7 +909,7 @@ struct w1_slave *w1_search_slave(struct w1_reg_num *id)
}
mutex_unlock(_mlock);
 
-   return (found)?sl:NULL;
+   return found ? sl : NULL;
 }
 
 void w1_reconnect_slaves(struct w1_family *f, int attach)
@@ -960,7 +960,7 @@ void w1_slave_found(struct w1_master *dev, u64 rn)
 
atomic_inc(>refcnt);
 
-   tmp = (struct w1_reg_num *) 
+   tmp = (struct w1_reg_num *)
 
sl = w1_slave_search_device(dev, tmp);
if (sl) {
@@ -1007,12 +1007,11 @@ 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;
 
-   /*
-* Reset bus and all 1-wire device state machines
+   /* Reset bus and all 1-wire device state machines
 * so they can respond to our requests.
 *
 * Return 0 - device(s) present, 1 - no devices present.
@@ -1059,7 +1058,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 */
@@ -1078,13 +1077,14 @@ void w1_search(struct w1_master *dev, u8 search_type,
}
mutex_unlock(>bus_mutex);
 
-   if ( (triplet_ret & 0x03) != 0x03 ) {
-   if ((desc_bit == last_zero) || (last_zero < 0)) {
+   if ((triplet_ret & 0x03) != 0x03) {
+   if (desc_bit == last_zero || last_zero < 0) {
last_device = 1;
dev->search_id = 0;
} else {
dev->search_id = rn;
}
+
desc_bit = last_zero;
cb(dev, rn);
}
@@ -1123,9 +1123,9 @@ void w1_search_process_cb(struct w1_master *dev, u8 
search_type,
mutex_unlock(>list_mutex);
w1_slave_detach(sl);
mutex_lock(>list_mutex);
-   }
-   else if (test_bit(W1_SLAVE_ACTIVE, >flags))
+   } else if (test_bit(W1_SLAVE_ACTIVE, >flags)) {
sl->ttl = dev->slave_ttl;
+   }
}
mutex_unlock(>list_mutex);
 
@@ -1156,7 +1156,8 @@ int w1_process_callbacks(struct w1_master *dev)
list_for_each_entry_safe(async_cmd, async_n, >async_list,
 async_entry) {
/* drop the lock, if it is a search it can take a long
-

[PATCH v2 05/12] w1: use octal numbers instead of macros for file mode

2018-10-28 Thread Steffen Vogel
This satifies a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 184df1fe216b..a8ead2350521 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -563,18 +563,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[] = {
_master_attribute_name.attr,
-- 
2.11.0



[PATCH v2 09/12] w1: using linux instead of asm prefix for includes

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 688778cccf65..65384b332a5a 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -3,7 +3,7 @@
  * Copyright (c) 2004 Evgeniy Polyakov 
  */
 
-#include 
+#include 
 
 #include 
 #include 
-- 
2.11.0



[PATCH v2 02/12] w1: improve code-style by adhering tp 80 columns per line limit

2018-10-28 Thread Steffen Vogel
Furthermore indentation of broken lines has been fixed.
This fixes several warnings raised by the checkpatch.pl script.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 160 +++-
 drivers/w1/w1_family.c  |   2 +-
 drivers/w1/w1_int.c |  15 ++---
 drivers/w1/w1_io.c  |  33 ++
 drivers/w1/w1_netlink.c |  42 -
 5 files changed, 145 insertions(+), 107 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 2c64655b603c..6b3cdc5a09fb 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -45,13 +45,11 @@ MODULE_PARM_DESC(timeout_us,
  */
 int w1_max_slave_count = 64;
 module_param_named(max_slave_count, w1_max_slave_count, int, 0);
-MODULE_PARM_DESC(max_slave_count,
-   "maximum number of slaves detected in a search");
+MODULE_PARM_DESC(max_slave_count, "maximum number of slaves detected in a 
search");
 
 int w1_max_slave_ttl = 10;
 module_param_named(slave_ttl, w1_max_slave_ttl, int, 0);
-MODULE_PARM_DESC(slave_ttl,
-   "Number of searches not seeing a slave before it will be removed");
+MODULE_PARM_DESC(slave_ttl, "Number of searches not seeing a slave before it 
will be removed");
 
 DEFINE_MUTEX(w1_mlock);
 LIST_HEAD(w1_masters);
@@ -85,7 +83,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);
 
@@ -94,7 +93,7 @@ static ssize_t name_show(struct device *dev, struct 
device_attribute *attr, char
 static DEVICE_ATTR_RO(name);
 
 static ssize_t id_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
+  struct device_attribute *attr, char *buf)
 {
struct w1_slave *sl = dev_to_w1_slave(dev);
ssize_t count = sizeof(sl->reg_num);
@@ -203,9 +202,10 @@ struct device w1_slave_device = {
.driver = _slave_driver,
.release = _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 +217,9 @@ static ssize_t w1_master_attribute_show_name(struct device 
*dev, struct device_a
return 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 +286,9 @@ 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 +299,9 @@ static ssize_t w1_master_attribute_show_pointer(struct 
device *dev, struct devic
return 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);
@@ -305,7 +309,8 @@ static ssize_t w1_master_attribute_show_timeout(struct 
device *dev, struct devic
 }
 
 static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
-   struct device_attribute *attr, char *buf)
+  struct device_attribute 
*attr,
+  char *buf)
 {
ssize_t count;
count = sprintf(buf, "%d\n", w1_timeout_us);
@@ -313,7 +318,9 @@ static ssize_t w1_master_attribute_show_timeout_us(struct 
device *dev,
 }
 
 static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev,
-   struct device_attribute *attr, const char *buf, size_t count)
+struct 
device_attribute *attr,
+  

[PATCH v2 06/12] w1: do not log errors about failed memory allocations

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 7 +--
 drivers/w1/w1_int.c | 6 +-
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index a8ead2350521..cbfc3f7012de 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -757,13 +757,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,
-"%s: failed to allocate new slave device.\n",
-__func__);
+   if (!sl)
return -ENOMEM;
-   }
-
 
sl->owner = THIS_MODULE;
sl->master = dev;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index efe03b9e23f5..a6c011e57c90 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
 
-- 
2.11.0



[PATCH v2 05/12] w1: use octal numbers instead of macros for file mode

2018-10-28 Thread Steffen Vogel
This satifies a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 184df1fe216b..a8ead2350521 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -563,18 +563,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[] = {
_master_attribute_name.attr,
-- 
2.11.0



[PATCH v2 09/12] w1: using linux instead of asm prefix for includes

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 688778cccf65..65384b332a5a 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -3,7 +3,7 @@
  * Copyright (c) 2004 Evgeniy Polyakov 
  */
 
-#include 
+#include 
 
 #include 
 #include 
-- 
2.11.0



[PATCH v2 02/12] w1: improve code-style by adhering tp 80 columns per line limit

2018-10-28 Thread Steffen Vogel
Furthermore indentation of broken lines has been fixed.
This fixes several warnings raised by the checkpatch.pl script.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 160 +++-
 drivers/w1/w1_family.c  |   2 +-
 drivers/w1/w1_int.c |  15 ++---
 drivers/w1/w1_io.c  |  33 ++
 drivers/w1/w1_netlink.c |  42 -
 5 files changed, 145 insertions(+), 107 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 2c64655b603c..6b3cdc5a09fb 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -45,13 +45,11 @@ MODULE_PARM_DESC(timeout_us,
  */
 int w1_max_slave_count = 64;
 module_param_named(max_slave_count, w1_max_slave_count, int, 0);
-MODULE_PARM_DESC(max_slave_count,
-   "maximum number of slaves detected in a search");
+MODULE_PARM_DESC(max_slave_count, "maximum number of slaves detected in a 
search");
 
 int w1_max_slave_ttl = 10;
 module_param_named(slave_ttl, w1_max_slave_ttl, int, 0);
-MODULE_PARM_DESC(slave_ttl,
-   "Number of searches not seeing a slave before it will be removed");
+MODULE_PARM_DESC(slave_ttl, "Number of searches not seeing a slave before it 
will be removed");
 
 DEFINE_MUTEX(w1_mlock);
 LIST_HEAD(w1_masters);
@@ -85,7 +83,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);
 
@@ -94,7 +93,7 @@ static ssize_t name_show(struct device *dev, struct 
device_attribute *attr, char
 static DEVICE_ATTR_RO(name);
 
 static ssize_t id_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
+  struct device_attribute *attr, char *buf)
 {
struct w1_slave *sl = dev_to_w1_slave(dev);
ssize_t count = sizeof(sl->reg_num);
@@ -203,9 +202,10 @@ struct device w1_slave_device = {
.driver = _slave_driver,
.release = _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 +217,9 @@ static ssize_t w1_master_attribute_show_name(struct device 
*dev, struct device_a
return 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 +286,9 @@ 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 +299,9 @@ static ssize_t w1_master_attribute_show_pointer(struct 
device *dev, struct devic
return 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);
@@ -305,7 +309,8 @@ static ssize_t w1_master_attribute_show_timeout(struct 
device *dev, struct devic
 }
 
 static ssize_t w1_master_attribute_show_timeout_us(struct device *dev,
-   struct device_attribute *attr, char *buf)
+  struct device_attribute 
*attr,
+  char *buf)
 {
ssize_t count;
count = sprintf(buf, "%d\n", w1_timeout_us);
@@ -313,7 +318,9 @@ static ssize_t w1_master_attribute_show_timeout_us(struct 
device *dev,
 }
 
 static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev,
-   struct device_attribute *attr, const char *buf, size_t count)
+struct 
device_attribute *attr,
+  

[PATCH v2 06/12] w1: do not log errors about failed memory allocations

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 7 +--
 drivers/w1/w1_int.c | 6 +-
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index a8ead2350521..cbfc3f7012de 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -757,13 +757,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,
-"%s: failed to allocate new slave device.\n",
-__func__);
+   if (!sl)
return -ENOMEM;
-   }
-
 
sl->owner = THIS_MODULE;
sl->master = dev;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index efe03b9e23f5..a6c011e57c90 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
 
-- 
2.11.0



[PATCH v2 07/12] w1: use __func__ for logging the function name

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 5 +++--
 drivers/w1/w1_int.c | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index cbfc3f7012de..4cbe1849fbfc 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1066,7 +1066,8 @@ void w1_search(struct w1_master *dev, u8 search_type,
 
if (test_bit(W1_ABORT_SEARCH, >flags)) {
mutex_unlock(>bus_mutex);
-   dev_dbg(>dev, "Abort w1_search\n");
+   dev_dbg(>dev, "Abort %s\n", __func__);
+
return;
}
}
@@ -1094,7 +1095,7 @@ void w1_search(struct w1_master *dev, u8 search_type,
 * bus).
 */
dev_info(>dev, "%s: max_slave_count %d reached, 
will continue next search.\n",
-   __func__, dev->max_slave_count);
+__func__, dev->max_slave_count);
set_bit(W1_WARN_MAX_COUNT, >flags);
}
}
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index a6c011e57c90..a5230c0d49e3 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
}
 
-- 
2.11.0



[PATCH v2 11/12] w1: replace non-standard %LX format-string by %llX

2018-10-28 Thread Steffen Vogel
As indicated by checkpatch.pl script.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 87094d99ccbe..1326bd52888a 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -636,7 +636,7 @@ static int w1_uevent(struct device *dev, struct 
kobj_uevent_env *env)
if (err)
goto end;
 
-   err = add_uevent_var(env, "W1_SLAVE_ID=%024LX",
+   err = add_uevent_var(env, "W1_SLAVE_ID=%024llX",
 (unsigned long long)sl->reg_num.id);
 end:
return err;
-- 
2.11.0



[PATCH v2 07/12] w1: use __func__ for logging the function name

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 5 +++--
 drivers/w1/w1_int.c | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index cbfc3f7012de..4cbe1849fbfc 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1066,7 +1066,8 @@ void w1_search(struct w1_master *dev, u8 search_type,
 
if (test_bit(W1_ABORT_SEARCH, >flags)) {
mutex_unlock(>bus_mutex);
-   dev_dbg(>dev, "Abort w1_search\n");
+   dev_dbg(>dev, "Abort %s\n", __func__);
+
return;
}
}
@@ -1094,7 +1095,7 @@ void w1_search(struct w1_master *dev, u8 search_type,
 * bus).
 */
dev_info(>dev, "%s: max_slave_count %d reached, 
will continue next search.\n",
-   __func__, dev->max_slave_count);
+__func__, dev->max_slave_count);
set_bit(W1_WARN_MAX_COUNT, >flags);
}
}
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index a6c011e57c90..a5230c0d49e3 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
}
 
-- 
2.11.0



[PATCH v2 11/12] w1: replace non-standard %LX format-string by %llX

2018-10-28 Thread Steffen Vogel
As indicated by checkpatch.pl script.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 87094d99ccbe..1326bd52888a 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -636,7 +636,7 @@ static int w1_uevent(struct device *dev, struct 
kobj_uevent_env *env)
if (err)
goto end;
 
-   err = add_uevent_var(env, "W1_SLAVE_ID=%024LX",
+   err = add_uevent_var(env, "W1_SLAVE_ID=%024llX",
 (unsigned long long)sl->reg_num.id);
 end:
return err;
-- 
2.11.0



Re: [PATCH 8/9] w1: fix whitespaces of struct declarations

2018-10-28 Thread 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.

On Sun, Oct 28, 2018 at 06:52:23PM -0700, Joe Perches wrote:
> On Sun, 2018-10-28 at 23:09 +0100, Steffen Vogel wrote:
> > 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

2018-10-28 Thread 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.

On Sun, Oct 28, 2018 at 06:52:23PM -0700, Joe Perches wrote:
> On Sun, 2018-10-28 at 23:09 +0100, Steffen Vogel wrote:
> > 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: w1: coding style and checkpatch fixes

2018-10-28 Thread Steffen Vogel
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

> 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

> 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

On Sun, Oct 28, 2018 at 03:53:07PM -0700, Linus Torvalds wrote:
> [ This is not about your patch series per se, only about your email settings ]
> 
> On Sun, Oct 28, 2018 at 3:20 PM Steffen Vogel  wrote:
> >
> > 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


Re: w1: coding style and checkpatch fixes

2018-10-28 Thread Steffen Vogel
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

> 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

> 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

On Sun, Oct 28, 2018 at 03:53:07PM -0700, Linus Torvalds wrote:
> [ This is not about your patch series per se, only about your email settings ]
> 
> On Sun, Oct 28, 2018 at 3:20 PM Steffen Vogel  wrote:
> >
> > 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


[PATCH 8/9] w1: fix whitespaces of struct declarations

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_netlink.h | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 08cbf08f3649..7873eb54352e 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -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
-{
-   __u8type;
-   __u8status;
-   __u16   len;
+struct w1_netlink_msg {
+   __u8 type;
+   __u8 status;
+   __u16 len;
union {
-   __u8id[8];
+   __u8 id[8];
struct w1_mst {
-   __u32   id;
-   __u32   res;
+   __u32 id;
+   __u32 res;
} mst;
} id;
-   __u8data[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
-{
-   __u8cmd;
-   __u8res;
-   __u16   len;
-   __u8data[0];
+struct w1_netlink_cmd {
+   __u8 cmd;
+   __u8 res;
+   __u16 len;
+   __u8 data[0];
 };
 
 #ifdef __KERNEL__
-- 
2.11.0



[PATCH 8/9] w1: fix whitespaces of struct declarations

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_netlink.h | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 08cbf08f3649..7873eb54352e 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -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
-{
-   __u8type;
-   __u8status;
-   __u16   len;
+struct w1_netlink_msg {
+   __u8 type;
+   __u8 status;
+   __u16 len;
union {
-   __u8id[8];
+   __u8 id[8];
struct w1_mst {
-   __u32   id;
-   __u32   res;
+   __u32 id;
+   __u32 res;
} mst;
} id;
-   __u8data[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
-{
-   __u8cmd;
-   __u8res;
-   __u16   len;
-   __u8data[0];
+struct w1_netlink_cmd {
+   __u8 cmd;
+   __u8 res;
+   __u16 len;
+   __u8 data[0];
 };
 
 #ifdef __KERNEL__
-- 
2.11.0



[PATCH 5/9] w1: use octal numbers instead of macros for file mode

2018-10-28 Thread Steffen Vogel
This satifies a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index f64da16dbec9..bad2ee26cd4e 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -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[] = {
_master_attribute_name.attr,
-- 
2.11.0



[PATCH 9/9] w1: using linux instead of asm prefix for includes

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 283c89708c7c..b18d82cde71e 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -3,7 +3,7 @@
  * Copyright (c) 2004 Evgeniy Polyakov 
  */
 
-#include 
+#include 
 
 #include 
 #include 
-- 
2.11.0



[PATCH 4/9] w1: cleanup whitespaces according to coding style document

2018-10-28 Thread Steffen Vogel
These changes fix several warnings emitted by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 812186ce35d6..f64da16dbec9 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -775,7 +775,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
spin_lock(_flock);
f = w1_family_registered(rn->family);
if (!f) {
-   f= _default_family;
+   f = _default_family;
dev_info(>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(>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(>list_mutex);
w1_slave_detach(sl);
mutex_lock(>list_mutex);
-   }
-   else if (test_bit(W1_SLAVE_ACTIVE, >flags))
+   } else if (test_bit(W1_SLAVE_ACTIVE, >flags))
sl->ttl = dev->slave_ttl;
}
mutex_unlock(>list_mutex);
@@ -1142,7 +1140,8 @@ int w1_process_callbacks(struct w1_master *dev)
list_for_each_entry_safe(async_cmd, async_n, >async_list,
async_entry) {
/* drop the lock, if it is a search it can take a long
-* time */
+* time
+*/
mutex_unlock(>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();
}
 
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
index ee90a6733472..5abbeb86de6e 100644
--- a/drivers/w1/w1_family.c
+++ b/drivers/w1/w1_family.c
@@ -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;
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 2626a61852e9..283c89708c7c 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -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)
r

[PATCH 7/9] w1: use __func__ for logging the function name

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 3 ++-
 drivers/w1/w1_int.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index e8ce97e066ec..c790c79352a0 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1053,7 +1053,8 @@ void w1_search(struct w1_master *dev, u8 search_type,
 
if (test_bit(W1_ABORT_SEARCH, >flags)) {
mutex_unlock(>bus_mutex);
-   dev_dbg(>dev, "Abort w1_search\n");
+   dev_dbg(>dev, "Abort %s\n", __func__);
+
return;
}
}
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index dd34d6a33f50..694b61ca1f85 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
}
 
-- 
2.11.0



[PATCH 1/9] w1: add SPDX identifiers

2018-10-28 Thread Steffen Vogel
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.

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index f661695fb589..83a991a3e3bd 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -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 
  * Copyright (c) 2004-2007, Matt Reimer 
- *
- * 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 
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
index 8b5e598ffdb3..d9bb021eca7e 100644
--- a/drivers/w1/masters/ds2482.c
+++ b/drivers/w1/masters/ds2482.c
@@ -1,4 +1,5 @@
-/**
+// SPDX-License-Identifier: GPL-2.0
+/*
  * ds2482.c - provides i2c to w1-master bridge(s)
  * Copyright (C) 2005  Ben Gardner 
  *
@@ -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 
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 0f4ecfcdb549..7bd9862ef337 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * ds2490.c  USB to one wire bridge
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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 
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index d83d7c99d81d..be131c04ee63 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * matrox_w1.c
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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

[PATCH 2/9] w1: improve coding style by following strict 80 column line limit

2018-10-28 Thread Steffen Vogel
This satisfies a checkpatch warning

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 2c64655b603c..bd95dfe4041d 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -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 = _slave_driver,
.release = _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_a
return 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 devic
return 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, stru
mutex_lock(>mutex);
count = sprintf(buf, "%d\n", md->max_slave_count);
mutex_unlock(>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 devi
mutex_lock(>mutex);
count = sprintf(buf, "%lu\n", md->attempts);
mutex_unlock(>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-\n";
+   const char *error_msg = "bad slave string format, expecting 
ff-\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(_mlock);
lis

[PATCH 5/9] w1: use octal numbers instead of macros for file mode

2018-10-28 Thread Steffen Vogel
This satifies a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index f64da16dbec9..bad2ee26cd4e 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -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[] = {
_master_attribute_name.attr,
-- 
2.11.0



[PATCH 9/9] w1: using linux instead of asm prefix for includes

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 283c89708c7c..b18d82cde71e 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -3,7 +3,7 @@
  * Copyright (c) 2004 Evgeniy Polyakov 
  */
 
-#include 
+#include 
 
 #include 
 #include 
-- 
2.11.0



[PATCH 4/9] w1: cleanup whitespaces according to coding style document

2018-10-28 Thread Steffen Vogel
These changes fix several warnings emitted by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 812186ce35d6..f64da16dbec9 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -775,7 +775,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct 
w1_reg_num *rn)
spin_lock(_flock);
f = w1_family_registered(rn->family);
if (!f) {
-   f= _default_family;
+   f = _default_family;
dev_info(>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(>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(>list_mutex);
w1_slave_detach(sl);
mutex_lock(>list_mutex);
-   }
-   else if (test_bit(W1_SLAVE_ACTIVE, >flags))
+   } else if (test_bit(W1_SLAVE_ACTIVE, >flags))
sl->ttl = dev->slave_ttl;
}
mutex_unlock(>list_mutex);
@@ -1142,7 +1140,8 @@ int w1_process_callbacks(struct w1_master *dev)
list_for_each_entry_safe(async_cmd, async_n, >async_list,
async_entry) {
/* drop the lock, if it is a search it can take a long
-* time */
+* time
+*/
mutex_unlock(>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();
}
 
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
index ee90a6733472..5abbeb86de6e 100644
--- a/drivers/w1/w1_family.c
+++ b/drivers/w1/w1_family.c
@@ -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;
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 2626a61852e9..283c89708c7c 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -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)
r

[PATCH 7/9] w1: use __func__ for logging the function name

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 3 ++-
 drivers/w1/w1_int.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index e8ce97e066ec..c790c79352a0 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1053,7 +1053,8 @@ void w1_search(struct w1_master *dev, u8 search_type,
 
if (test_bit(W1_ABORT_SEARCH, >flags)) {
mutex_unlock(>bus_mutex);
-   dev_dbg(>dev, "Abort w1_search\n");
+   dev_dbg(>dev, "Abort %s\n", __func__);
+
return;
}
}
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index dd34d6a33f50..694b61ca1f85 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
}
 
-- 
2.11.0



[PATCH 1/9] w1: add SPDX identifiers

2018-10-28 Thread Steffen Vogel
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.

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index f661695fb589..83a991a3e3bd 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -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 
  * Copyright (c) 2004-2007, Matt Reimer 
- *
- * 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 
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
index 8b5e598ffdb3..d9bb021eca7e 100644
--- a/drivers/w1/masters/ds2482.c
+++ b/drivers/w1/masters/ds2482.c
@@ -1,4 +1,5 @@
-/**
+// SPDX-License-Identifier: GPL-2.0
+/*
  * ds2482.c - provides i2c to w1-master bridge(s)
  * Copyright (C) 2005  Ben Gardner 
  *
@@ -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 
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 0f4ecfcdb549..7bd9862ef337 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * ds2490.c  USB to one wire bridge
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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 
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index d83d7c99d81d..be131c04ee63 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -1,22 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * matrox_w1.c
  *
  * Copyright (c) 2004 Evgeniy Polyakov 
- *
- *
- * 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

[PATCH 2/9] w1: improve coding style by following strict 80 column line limit

2018-10-28 Thread Steffen Vogel
This satisfies a checkpatch warning

Signed-off-by: Steffen Vogel 
---
 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(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 2c64655b603c..bd95dfe4041d 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -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 = _slave_driver,
.release = _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_a
return 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 devic
return 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, stru
mutex_lock(>mutex);
count = sprintf(buf, "%d\n", md->max_slave_count);
mutex_unlock(>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 devi
mutex_lock(>mutex);
count = sprintf(buf, "%lu\n", md->attempts);
mutex_unlock(>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-\n";
+   const char *error_msg = "bad slave string format, expecting 
ff-\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(_mlock);
lis

w1: coding style and checkpatch fixes

2018-10-28 Thread Steffen Vogel
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 6/9] w1: do not log errors about failed memory allocations

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 7 +--
 drivers/w1/w1_int.c | 6 +-
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index bad2ee26cd4e..e8ce97e066ec 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -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,
-"%s: failed to allocate new slave device.\n",
-__func__);
+   if (!sl)
return -ENOMEM;
-   }
-
 
sl->owner = THIS_MODULE;
sl->master = dev;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 72b9392d9551..dd34d6a33f50 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
 
-- 
2.11.0



[PATCH 3/9] w1: add newlines after declarations

2018-10-28 Thread Steffen Vogel
This satisfies a checkpatch warning

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 23 +++
 drivers/w1/w1_netlink.c |  7 +++
 2 files changed, 30 insertions(+)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index bd95dfe4041d..812186ce35d6 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -130,6 +130,7 @@ static ssize_t rw_write(struct file *filp, struct kobject 
*kobj,
 
 out_up:
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -142,6 +143,7 @@ static ssize_t rw_read(struct file *filp, struct kobject 
*kobj,
mutex_lock(>master->mutex);
w1_read_block(sl->master, buf, count);
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -297,6 +299,7 @@ static ssize_t w1_master_attribute_show_pointer(struct 
device *dev,
mutex_lock(>mutex);
count = sprintf(buf, "0x%p\n", md->bus_master);
mutex_unlock(>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(>mutex);
count = sprintf(buf, "%d\n", md->slave_count);
mutex_unlock(>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- 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(>list_mutex);
list_for_each_entry(sl, >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(>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- 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(>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(>dev), err);
put_device(>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(>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(>list_mutex);
refcnt = atomic_sub_return(1, >refcnt);
if (refcnt == 0) {
@@ -817,6 +835,7 @@ int w1_unref_slave(struct w1_slave *sl)
}
atomic_dec(>refcnt);
mutex_unlock(>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(>master->list_mutex);
destroy_now = !test_bit(W1_SLAVE_DETACH, >flags);
set_bit(W1_SLAVE_DETACH, >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(

w1: coding style and checkpatch fixes

2018-10-28 Thread Steffen Vogel
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 6/9] w1: do not log errors about failed memory allocations

2018-10-28 Thread Steffen Vogel
This fixes a warning raised by the checkpatch tool.

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 7 +--
 drivers/w1/w1_int.c | 6 +-
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index bad2ee26cd4e..e8ce97e066ec 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -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,
-"%s: failed to allocate new slave device.\n",
-__func__);
+   if (!sl)
return -ENOMEM;
-   }
-
 
sl->owner = THIS_MODULE;
sl->master = dev;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 72b9392d9551..dd34d6a33f50 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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);
 
-- 
2.11.0



[PATCH 3/9] w1: add newlines after declarations

2018-10-28 Thread Steffen Vogel
This satisfies a checkpatch warning

Signed-off-by: Steffen Vogel 
---
 drivers/w1/w1.c | 23 +++
 drivers/w1/w1_netlink.c |  7 +++
 2 files changed, 30 insertions(+)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index bd95dfe4041d..812186ce35d6 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -130,6 +130,7 @@ static ssize_t rw_write(struct file *filp, struct kobject 
*kobj,
 
 out_up:
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -142,6 +143,7 @@ static ssize_t rw_read(struct file *filp, struct kobject 
*kobj,
mutex_lock(>master->mutex);
w1_read_block(sl->master, buf, count);
mutex_unlock(>master->mutex);
+
return count;
 }
 
@@ -297,6 +299,7 @@ static ssize_t w1_master_attribute_show_pointer(struct 
device *dev,
mutex_lock(>mutex);
count = sprintf(buf, "0x%p\n", md->bus_master);
mutex_unlock(>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(>mutex);
count = sprintf(buf, "%d\n", md->slave_count);
mutex_unlock(>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- 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(>list_mutex);
list_for_each_entry(sl, >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(>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- 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(>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(>dev), err);
put_device(>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(>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(>list_mutex);
refcnt = atomic_sub_return(1, >refcnt);
if (refcnt == 0) {
@@ -817,6 +835,7 @@ int w1_unref_slave(struct w1_slave *sl)
}
atomic_dec(>refcnt);
mutex_unlock(>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(>master->list_mutex);
destroy_now = !test_bit(W1_SLAVE_DETACH, >flags);
set_bit(W1_SLAVE_DETACH, >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(