summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew F. Davis <afd@ti.com>2017-06-05 09:52:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-06-09 05:54:54 -0400
commitde0d6dbdbdb23ddb85f10d54a516e794f9a873e0 (patch)
tree835e0f7aca2983b9147913a228d8656d47aa6bc9
parentacb7e8f7448efef4ba1d86247cacbd201df733ab (diff)
w1: Add subsystem kernel public interface
Like other subsystems we should be able to define slave devices outside of the w1 directory. To do this we move public facing interface definitions to include/linux/w1.h and rename the internal definition file to w1_internal.h. As w1_family.h and w1_int.h contained almost entirely public driver interface definitions we simply removed these files and moved the remaining definitions into w1_internal.h. With this we can now start to move slave devices out of w1/slaves and into the subsystem based on the function they implement, again like other drivers. Signed-off-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Sebastian Reichel <sre@kernel.org> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--MAINTAINERS1
-rw-r--r--drivers/power/supply/ds2760_battery.c2
-rw-r--r--drivers/power/supply/ds2780_battery.c2
-rw-r--r--drivers/power/supply/ds2781_battery.c2
-rw-r--r--drivers/w1/masters/ds1wm.c3
-rw-r--r--drivers/w1/masters/ds2482.c3
-rw-r--r--drivers/w1/masters/ds2490.c3
-rw-r--r--drivers/w1/masters/matrox_w1.c3
-rw-r--r--drivers/w1/masters/mxc_w1.c3
-rw-r--r--drivers/w1/masters/omap_hdq.c3
-rw-r--r--drivers/w1/masters/w1-gpio.c3
-rw-r--r--drivers/w1/slaves/w1_bq27000.c6
-rw-r--r--drivers/w1/slaves/w1_ds2405.c5
-rw-r--r--drivers/w1/slaves/w1_ds2406.c6
-rw-r--r--drivers/w1/slaves/w1_ds2408.c6
-rw-r--r--drivers/w1/slaves/w1_ds2413.c6
-rw-r--r--drivers/w1/slaves/w1_ds2423.c6
-rw-r--r--drivers/w1/slaves/w1_ds2431.c6
-rw-r--r--drivers/w1/slaves/w1_ds2433.c6
-rw-r--r--drivers/w1/slaves/w1_ds2438.c5
-rw-r--r--drivers/w1/slaves/w1_ds2760.c7
-rw-r--r--drivers/w1/slaves/w1_ds2780.c7
-rw-r--r--drivers/w1/slaves/w1_ds2781.c7
-rw-r--r--drivers/w1/slaves/w1_ds28e04.c6
-rw-r--r--drivers/w1/slaves/w1_smem.c7
-rw-r--r--drivers/w1/slaves/w1_therm.c10
-rw-r--r--drivers/w1/w1.c6
-rw-r--r--drivers/w1/w1_family.c3
-rw-r--r--drivers/w1/w1_family.h98
-rw-r--r--drivers/w1/w1_int.c3
-rw-r--r--drivers/w1/w1_int.h27
-rw-r--r--drivers/w1/w1_internal.h87
-rw-r--r--drivers/w1/w1_io.c2
-rw-r--r--drivers/w1/w1_netlink.c2
-rw-r--r--drivers/w1/w1_netlink.h2
-rw-r--r--include/linux/w1.h (renamed from drivers/w1/w1.h)114
36 files changed, 208 insertions, 260 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 2dc114b9e7f7..2461e78b173f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13790,6 +13790,7 @@ M: Evgeniy Polyakov <zbr@ioremap.net>
13790S: Maintained 13790S: Maintained
13791F: Documentation/w1/ 13791F: Documentation/w1/
13792F: drivers/w1/ 13792F: drivers/w1/
13793F: include/linux/w1.h
13793 13794
13794W83791D HARDWARE MONITORING DRIVER 13795W83791D HARDWARE MONITORING DRIVER
13795M: Marc Hulsman <m.hulsman@tudelft.nl> 13796M: Marc Hulsman <m.hulsman@tudelft.nl>
diff --git a/drivers/power/supply/ds2760_battery.c b/drivers/power/supply/ds2760_battery.c
index 17225689e3f6..ae180dc929c9 100644
--- a/drivers/power/supply/ds2760_battery.c
+++ b/drivers/power/supply/ds2760_battery.c
@@ -28,7 +28,7 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/power_supply.h> 29#include <linux/power_supply.h>
30 30
31#include "../../w1/w1.h" 31#include <linux/w1.h>
32#include "../../w1/slaves/w1_ds2760.h" 32#include "../../w1/slaves/w1_ds2760.h"
33 33
34struct ds2760_device_info { 34struct ds2760_device_info {
diff --git a/drivers/power/supply/ds2780_battery.c b/drivers/power/supply/ds2780_battery.c
index 1b3b6fa89c28..8edd4aa5f475 100644
--- a/drivers/power/supply/ds2780_battery.c
+++ b/drivers/power/supply/ds2780_battery.c
@@ -21,7 +21,7 @@
21#include <linux/power_supply.h> 21#include <linux/power_supply.h>
22#include <linux/idr.h> 22#include <linux/idr.h>
23 23
24#include "../../w1/w1.h" 24#include <linux/w1.h>
25#include "../../w1/slaves/w1_ds2780.h" 25#include "../../w1/slaves/w1_ds2780.h"
26 26
27/* Current unit measurement in uA for a 1 milli-ohm sense resistor */ 27/* Current unit measurement in uA for a 1 milli-ohm sense resistor */
diff --git a/drivers/power/supply/ds2781_battery.c b/drivers/power/supply/ds2781_battery.c
index cc0149131f89..4400402f9ec5 100644
--- a/drivers/power/supply/ds2781_battery.c
+++ b/drivers/power/supply/ds2781_battery.c
@@ -19,7 +19,7 @@
19#include <linux/power_supply.h> 19#include <linux/power_supply.h>
20#include <linux/idr.h> 20#include <linux/idr.h>
21 21
22#include "../../w1/w1.h" 22#include <linux/w1.h>
23#include "../../w1/slaves/w1_ds2781.h" 23#include "../../w1/slaves/w1_ds2781.h"
24 24
25/* Current unit measurement in uA for a 1 milli-ohm sense resistor */ 25/* Current unit measurement in uA for a 1 milli-ohm sense resistor */
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index e0b8a4bc73df..fd2e9da27c4b 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -25,8 +25,7 @@
25 25
26#include <asm/io.h> 26#include <asm/io.h>
27 27
28#include "../w1.h" 28#include <linux/w1.h>
29#include "../w1_int.h"
30 29
31 30
32#define DS1WM_CMD 0x00 /* R/W 4 bits command */ 31#define DS1WM_CMD 0x00 /* R/W 4 bits command */
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
index e8730ea3e3aa..d49681cd29af 100644
--- a/drivers/w1/masters/ds2482.c
+++ b/drivers/w1/masters/ds2482.c
@@ -20,8 +20,7 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <asm/delay.h> 21#include <asm/delay.h>
22 22
23#include "../w1.h" 23#include <linux/w1.h>
24#include "../w1_int.h"
25 24
26/** 25/**
27 * Allow the active pullup to be disabled, default is enabled. 26 * Allow the active pullup to be disabled, default is enabled.
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index d748e34d4ce5..46ccb2fc4f60 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -25,8 +25,7 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27 27
28#include "../w1_int.h" 28#include <linux/w1.h>
29#include "../w1.h"
30 29
31/* USB Standard */ 30/* USB Standard */
32/* USB Control request vendor type */ 31/* USB Control request vendor type */
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index f20d03ecfd1d..d83d7c99d81d 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -34,8 +34,7 @@
34#include <linux/pci_ids.h> 34#include <linux/pci_ids.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36 36
37#include "../w1.h" 37#include <linux/w1.h>
38#include "../w1_int.h"
39 38
40/* 39/*
41 * Matrox G400 DDC registers. 40 * Matrox G400 DDC registers.
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
index a4621757a47f..74f2e6e6202a 100644
--- a/drivers/w1/masters/mxc_w1.c
+++ b/drivers/w1/masters/mxc_w1.c
@@ -19,8 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21 21
22#include "../w1.h" 22#include <linux/w1.h>
23#include "../w1_int.h"
24 23
25/* 24/*
26 * MXC W1 Register offsets 25 * MXC W1 Register offsets
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 3302cbd2344a..3612542b6044 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -19,8 +19,7 @@
19#include <linux/pm_runtime.h> 19#include <linux/pm_runtime.h>
20#include <linux/of.h> 20#include <linux/of.h>
21 21
22#include "../w1.h" 22#include <linux/w1.h>
23#include "../w1_int.h"
24 23
25#define MOD_NAME "OMAP_HDQ:" 24#define MOD_NAME "OMAP_HDQ:"
26 25
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index a373ae69d9f6..a90728ceec5a 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -20,8 +20,7 @@
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22 22
23#include "../w1.h" 23#include <linux/w1.h>
24#include "../w1_int.h"
25 24
26static u8 w1_gpio_set_pullup(void *data, int delay) 25static u8 w1_gpio_set_pullup(void *data, int delay)
27{ 26{
diff --git a/drivers/w1/slaves/w1_bq27000.c b/drivers/w1/slaves/w1_bq27000.c
index d480900a28ab..8046ac45381a 100644
--- a/drivers/w1/slaves/w1_bq27000.c
+++ b/drivers/w1/slaves/w1_bq27000.c
@@ -17,9 +17,9 @@
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/power/bq27xxx_battery.h> 18#include <linux/power/bq27xxx_battery.h>
19 19
20#include "../w1.h" 20#include <linux/w1.h>
21#include "../w1_int.h" 21
22#include "../w1_family.h" 22#define W1_FAMILY_BQ27000 0x01
23 23
24#define HDQ_CMD_READ (0) 24#define HDQ_CMD_READ (0)
25#define HDQ_CMD_WRITE (1<<7) 25#define HDQ_CMD_WRITE (1<<7)
diff --git a/drivers/w1/slaves/w1_ds2405.c b/drivers/w1/slaves/w1_ds2405.c
index d5d54876cb64..42a1e81060ce 100644
--- a/drivers/w1/slaves/w1_ds2405.c
+++ b/drivers/w1/slaves/w1_ds2405.c
@@ -24,8 +24,9 @@
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/types.h> 25#include <linux/types.h>
26 26
27#include "../w1.h" 27#include <linux/w1.h>
28#include "../w1_family.h" 28
29#define W1_FAMILY_DS2405 0x05
29 30
30MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
31MODULE_AUTHOR("Maciej S. Szmigiero <mail@maciej.szmigiero.name>"); 32MODULE_AUTHOR("Maciej S. Szmigiero <mail@maciej.szmigiero.name>");
diff --git a/drivers/w1/slaves/w1_ds2406.c b/drivers/w1/slaves/w1_ds2406.c
index 709bd5e02eed..fac266366ca3 100644
--- a/drivers/w1/slaves/w1_ds2406.c
+++ b/drivers/w1/slaves/w1_ds2406.c
@@ -17,9 +17,9 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/crc16.h> 18#include <linux/crc16.h>
19 19
20#include "../w1.h" 20#include <linux/w1.h>
21#include "../w1_int.h" 21
22#include "../w1_family.h" 22#define W1_FAMILY_DS2406 0x12
23 23
24#define W1_F12_FUNC_READ_STATUS 0xAA 24#define W1_F12_FUNC_READ_STATUS 0xAA
25#define W1_F12_FUNC_WRITE_STATUS 0x55 25#define W1_F12_FUNC_WRITE_STATUS 0x55
diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c
index e01d2b3997bc..b535d5ec35b6 100644
--- a/drivers/w1/slaves/w1_ds2408.c
+++ b/drivers/w1/slaves/w1_ds2408.c
@@ -15,9 +15,9 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17 17
18#include "../w1.h" 18#include <linux/w1.h>
19#include "../w1_int.h" 19
20#include "../w1_family.h" 20#define W1_FAMILY_DS2408 0x29
21 21
22#define W1_F29_RETRIES 3 22#define W1_F29_RETRIES 3
23 23
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c
index 9cc6f0bc2e95..492e3d010321 100644
--- a/drivers/w1/slaves/w1_ds2413.c
+++ b/drivers/w1/slaves/w1_ds2413.c
@@ -16,9 +16,9 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18 18
19#include "../w1.h" 19#include <linux/w1.h>
20#include "../w1_int.h" 20
21#include "../w1_family.h" 21#define W1_FAMILY_DS2413 0x3A
22 22
23#define W1_F3A_RETRIES 3 23#define W1_F3A_RETRIES 3
24#define W1_F3A_FUNC_PIO_ACCESS_READ 0xF5 24#define W1_F3A_FUNC_PIO_ACCESS_READ 0xF5
diff --git a/drivers/w1/slaves/w1_ds2423.c b/drivers/w1/slaves/w1_ds2423.c
index 306240fe496c..050407c53b16 100644
--- a/drivers/w1/slaves/w1_ds2423.c
+++ b/drivers/w1/slaves/w1_ds2423.c
@@ -30,9 +30,9 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/crc16.h> 31#include <linux/crc16.h>
32 32
33#include "../w1.h" 33#include <linux/w1.h>
34#include "../w1_int.h" 34
35#include "../w1_family.h" 35#define W1_COUNTER_DS2423 0x1D
36 36
37#define CRC16_VALID 0xb001 37#define CRC16_VALID 0xb001
38#define CRC16_INIT 0 38#define CRC16_INIT 0
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
index 20182d4a4b19..5adecd3face1 100644
--- a/drivers/w1/slaves/w1_ds2431.c
+++ b/drivers/w1/slaves/w1_ds2431.c
@@ -16,9 +16,9 @@
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18 18
19#include "../w1.h" 19#include <linux/w1.h>
20#include "../w1_int.h" 20
21#include "../w1_family.h" 21#define W1_EEPROM_DS2431 0x2D
22 22
23#define W1_F2D_EEPROM_SIZE 128 23#define W1_F2D_EEPROM_SIZE 128
24#define W1_F2D_PAGE_COUNT 4 24#define W1_F2D_PAGE_COUNT 4
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 86c30aceea3e..75ad70cfe8e8 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -22,9 +22,9 @@
22 22
23#endif 23#endif
24 24
25#include "../w1.h" 25#include <linux/w1.h>
26#include "../w1_int.h" 26
27#include "../w1_family.h" 27#define W1_EEPROM_DS2433 0x23
28 28
29#define W1_EEPROM_SIZE 512 29#define W1_EEPROM_SIZE 512
30#define W1_PAGE_COUNT 16 30#define W1_PAGE_COUNT 16
diff --git a/drivers/w1/slaves/w1_ds2438.c b/drivers/w1/slaves/w1_ds2438.c
index 5ededb4965e1..6487fb772a20 100644
--- a/drivers/w1/slaves/w1_ds2438.c
+++ b/drivers/w1/slaves/w1_ds2438.c
@@ -13,8 +13,9 @@
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15 15
16#include "../w1.h" 16#include <linux/w1.h>
17#include "../w1_family.h" 17
18#define W1_FAMILY_DS2438 0x26
18 19
19#define W1_DS2438_RETRIES 3 20#define W1_DS2438_RETRIES 3
20 21
diff --git a/drivers/w1/slaves/w1_ds2760.c b/drivers/w1/slaves/w1_ds2760.c
index f35d1e2ef9bb..26168abfb8b8 100644
--- a/drivers/w1/slaves/w1_ds2760.c
+++ b/drivers/w1/slaves/w1_ds2760.c
@@ -18,11 +18,12 @@
18#include <linux/idr.h> 18#include <linux/idr.h>
19#include <linux/gfp.h> 19#include <linux/gfp.h>
20 20
21#include "../w1.h" 21#include <linux/w1.h>
22#include "../w1_int.h" 22
23#include "../w1_family.h"
24#include "w1_ds2760.h" 23#include "w1_ds2760.h"
25 24
25#define W1_FAMILY_DS2760 0x30
26
26static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count, 27static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count,
27 int io) 28 int io)
28{ 29{
diff --git a/drivers/w1/slaves/w1_ds2780.c b/drivers/w1/slaves/w1_ds2780.c
index 292972212107..a60528131154 100644
--- a/drivers/w1/slaves/w1_ds2780.c
+++ b/drivers/w1/slaves/w1_ds2780.c
@@ -21,11 +21,12 @@
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/idr.h> 22#include <linux/idr.h>
23 23
24#include "../w1.h" 24#include <linux/w1.h>
25#include "../w1_int.h" 25
26#include "../w1_family.h"
27#include "w1_ds2780.h" 26#include "w1_ds2780.h"
28 27
28#define W1_FAMILY_DS2780 0x32
29
29static int w1_ds2780_do_io(struct device *dev, char *buf, int addr, 30static int w1_ds2780_do_io(struct device *dev, char *buf, int addr,
30 size_t count, int io) 31 size_t count, int io)
31{ 32{
diff --git a/drivers/w1/slaves/w1_ds2781.c b/drivers/w1/slaves/w1_ds2781.c
index a5d75067b230..645be6e0b24a 100644
--- a/drivers/w1/slaves/w1_ds2781.c
+++ b/drivers/w1/slaves/w1_ds2781.c
@@ -18,11 +18,12 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20 20
21#include "../w1.h" 21#include <linux/w1.h>
22#include "../w1_int.h" 22
23#include "../w1_family.h"
24#include "w1_ds2781.h" 23#include "w1_ds2781.h"
25 24
25#define W1_FAMILY_DS2781 0x3D
26
26static int w1_ds2781_do_io(struct device *dev, char *buf, int addr, 27static int w1_ds2781_do_io(struct device *dev, char *buf, int addr,
27 size_t count, int io) 28 size_t count, int io)
28{ 29{
diff --git a/drivers/w1/slaves/w1_ds28e04.c b/drivers/w1/slaves/w1_ds28e04.c
index c62858c05e8f..ec234b846eb3 100644
--- a/drivers/w1/slaves/w1_ds28e04.c
+++ b/drivers/w1/slaves/w1_ds28e04.c
@@ -20,9 +20,9 @@
20#define CRC16_INIT 0 20#define CRC16_INIT 0
21#define CRC16_VALID 0xb001 21#define CRC16_VALID 0xb001
22 22
23#include "../w1.h" 23#include <linux/w1.h>
24#include "../w1_int.h" 24
25#include "../w1_family.h" 25#define W1_FAMILY_DS28E04 0x1C
26 26
27/* Allow the strong pullup to be disabled, but default to enabled. 27/* Allow the strong pullup to be disabled, but default to enabled.
28 * If it was disabled a parasite powered device might not get the required 28 * If it was disabled a parasite powered device might not get the required
diff --git a/drivers/w1/slaves/w1_smem.c b/drivers/w1/slaves/w1_smem.c
index 99b03bfb9941..e556b0caff71 100644
--- a/drivers/w1/slaves/w1_smem.c
+++ b/drivers/w1/slaves/w1_smem.c
@@ -27,9 +27,10 @@
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/types.h> 28#include <linux/types.h>
29 29
30#include "../w1.h" 30#include <linux/w1.h>
31#include "../w1_int.h" 31
32#include "../w1_family.h" 32#define W1_FAMILY_SMEM_01 0x01
33#define W1_FAMILY_SMEM_81 0x81
33 34
34static struct w1_family w1_smem_family_01 = { 35static struct w1_family w1_smem_family_01 = {
35 .fid = W1_FAMILY_SMEM_01, 36 .fid = W1_FAMILY_SMEM_01,
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index ccaf29994a42..cb3fc3c6b0d1 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -30,9 +30,13 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32 32
33#include "../w1.h" 33#include <linux/w1.h>
34#include "../w1_int.h" 34
35#include "../w1_family.h" 35#define W1_THERM_DS18S20 0x10
36#define W1_THERM_DS1822 0x22
37#define W1_THERM_DS18B20 0x28
38#define W1_THERM_DS1825 0x3B
39#define W1_THERM_DS28EA00 0x42
36 40
37/* Allow the strong pullup to be disabled, but default to enabled. 41/* Allow the strong pullup to be disabled, but default to enabled.
38 * If it was disabled a parasite powered device might not get the require 42 * If it was disabled a parasite powered device might not get the require
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 8172dee5e23c..95ea7e6b1d99 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -28,11 +28,11 @@
28 28
29#include <linux/atomic.h> 29#include <linux/atomic.h>
30 30
31#include "w1.h" 31#include "w1_internal.h"
32#include "w1_int.h"
33#include "w1_family.h"
34#include "w1_netlink.h" 32#include "w1_netlink.h"
35 33
34#define W1_FAMILY_DEFAULT 0
35
36static int w1_timeout = 10; 36static int w1_timeout = 10;
37module_param_named(timeout, w1_timeout, int, 0); 37module_param_named(timeout, w1_timeout, int, 0);
38MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches"); 38MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches");
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
index 9759cdaf22f4..f14ab0b340b5 100644
--- a/drivers/w1/w1_family.c
+++ b/drivers/w1/w1_family.c
@@ -18,8 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/export.h> 19#include <linux/export.h>
20 20
21#include "w1_family.h" 21#include "w1_internal.h"
22#include "w1.h"
23 22
24DEFINE_SPINLOCK(w1_flock); 23DEFINE_SPINLOCK(w1_flock);
25static LIST_HEAD(w1_families); 24static LIST_HEAD(w1_families);
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
deleted file mode 100644
index 869a3ff87d29..000000000000
--- a/drivers/w1/w1_family.h
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __W1_FAMILY_H
16#define __W1_FAMILY_H
17
18#include <linux/types.h>
19#include <linux/device.h>
20#include <linux/atomic.h>
21
22#define W1_FAMILY_DEFAULT 0
23#define W1_FAMILY_BQ27000 0x01
24#define W1_FAMILY_SMEM_01 0x01
25#define W1_FAMILY_SMEM_81 0x81
26#define W1_FAMILY_DS2405 0x05
27#define W1_THERM_DS18S20 0x10
28#define W1_FAMILY_DS28E04 0x1C
29#define W1_COUNTER_DS2423 0x1D
30#define W1_THERM_DS1822 0x22
31#define W1_EEPROM_DS2433 0x23
32#define W1_FAMILY_DS2438 0x26
33#define W1_THERM_DS18B20 0x28
34#define W1_FAMILY_DS2408 0x29
35#define W1_EEPROM_DS2431 0x2D
36#define W1_FAMILY_DS2760 0x30
37#define W1_FAMILY_DS2780 0x32
38#define W1_FAMILY_DS2413 0x3A
39#define W1_FAMILY_DS2406 0x12
40#define W1_THERM_DS1825 0x3B
41#define W1_FAMILY_DS2781 0x3D
42#define W1_THERM_DS28EA00 0x42
43
44#define MAXNAMELEN 32
45
46struct w1_slave;
47
48/**
49 * struct w1_family_ops - operations for a family type
50 * @add_slave: add_slave
51 * @remove_slave: remove_slave
52 * @groups: sysfs group
53 */
54struct w1_family_ops
55{
56 int (* add_slave)(struct w1_slave *);
57 void (* remove_slave)(struct w1_slave *);
58 const struct attribute_group **groups;
59};
60
61/**
62 * struct w1_family - reference counted family structure.
63 * @family_entry: family linked list
64 * @fid: 8 bit family identifier
65 * @fops: operations for this family
66 * @refcnt: reference counter
67 */
68struct w1_family
69{
70 struct list_head family_entry;
71 u8 fid;
72
73 struct w1_family_ops *fops;
74
75 atomic_t refcnt;
76};
77
78extern spinlock_t w1_flock;
79
80void w1_family_put(struct w1_family *);
81void __w1_family_get(struct w1_family *);
82struct w1_family * w1_family_registered(u8);
83void w1_unregister_family(struct w1_family *);
84int w1_register_family(struct w1_family *);
85
86/**
87 * module_w1_driver() - Helper macro for registering a 1-Wire families
88 * @__w1_family: w1_family struct
89 *
90 * Helper macro for 1-Wire families which do not do anything special in module
91 * init/exit. This eliminates a lot of boilerplate. Each module may only
92 * use this macro once, and calling it replaces module_init() and module_exit()
93 */
94#define module_w1_family(__w1_family) \
95 module_driver(__w1_family, w1_register_family, \
96 w1_unregister_family)
97
98#endif /* __W1_FAMILY_H */
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 4439d10709bb..1c776178f598 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -21,9 +21,8 @@
21#include <linux/export.h> 21#include <linux/export.h>
22#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
23 23
24#include "w1.h" 24#include "w1_internal.h"
25#include "w1_netlink.h" 25#include "w1_netlink.h"
26#include "w1_int.h"
27 26
28static int w1_search_count = -1; /* Default is continual scan */ 27static int w1_search_count = -1; /* Default is continual scan */
29module_param_named(search_count, w1_search_count, int, 0); 28module_param_named(search_count, w1_search_count, int, 0);
diff --git a/drivers/w1/w1_int.h b/drivers/w1/w1_int.h
deleted file mode 100644
index 371989159216..000000000000
--- a/drivers/w1/w1_int.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __W1_INT_H
16#define __W1_INT_H
17
18#include <linux/kernel.h>
19#include <linux/device.h>
20
21#include "w1.h"
22
23int w1_add_master_device(struct w1_bus_master *);
24void w1_remove_master_device(struct w1_bus_master *);
25void __w1_remove_master_device(struct w1_master *);
26
27#endif /* __W1_INT_H */
diff --git a/drivers/w1/w1_internal.h b/drivers/w1/w1_internal.h
new file mode 100644
index 000000000000..1623e2fdccc7
--- /dev/null
+++ b/drivers/w1/w1_internal.h
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __W1_H
16#define __W1_H
17
18#include <linux/w1.h>
19
20#include <linux/completion.h>
21#include <linux/mutex.h>
22
23#define W1_SLAVE_ACTIVE 0
24#define W1_SLAVE_DETACH 1
25
26/**
27 * struct w1_async_cmd - execute callback from the w1_process kthread
28 * @async_entry: link entry
29 * @cb: callback function, must list_del and destroy this list before
30 * returning
31 *
32 * When inserted into the w1_master async_list, w1_process will execute
33 * the callback. Embed this into the structure with the command details.
34 */
35struct w1_async_cmd {
36 struct list_head async_entry;
37 void (*cb)(struct w1_master *dev, struct w1_async_cmd *async_cmd);
38};
39
40int w1_create_master_attributes(struct w1_master *master);
41void w1_destroy_master_attributes(struct w1_master *master);
42void w1_search(struct w1_master *dev, u8 search_type,
43 w1_slave_found_callback cb);
44void w1_search_devices(struct w1_master *dev, u8 search_type,
45 w1_slave_found_callback cb);
46/* call w1_unref_slave to release the reference counts w1_search_slave added */
47struct w1_slave *w1_search_slave(struct w1_reg_num *id);
48/*
49 * decrements the reference on sl->master and sl, and cleans up if zero
50 * returns the reference count after it has been decremented
51 */
52int w1_unref_slave(struct w1_slave *sl);
53void w1_slave_found(struct w1_master *dev, u64 rn);
54void w1_search_process_cb(struct w1_master *dev, u8 search_type,
55 w1_slave_found_callback cb);
56struct w1_slave *w1_slave_search_device(struct w1_master *dev,
57 struct w1_reg_num *rn);
58struct w1_master *w1_search_master_id(u32 id);
59
60/* Disconnect and reconnect devices in the given family. Used for finding
61 * unclaimed devices after a family has been registered or releasing devices
62 * after a family has been unregistered. Set attach to 1 when a new family
63 * has just been registered, to 0 when it has been unregistered.
64 */
65void w1_reconnect_slaves(struct w1_family *f, int attach);
66int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn);
67/* 0 success, otherwise EBUSY */
68int w1_slave_detach(struct w1_slave *sl);
69
70void __w1_remove_master_device(struct w1_master *dev);
71
72void w1_family_put(struct w1_family *f);
73void __w1_family_get(struct w1_family *f);
74struct w1_family *w1_family_registered(u8 fid);
75
76extern struct device_driver w1_master_driver;
77extern struct device w1_master_device;
78extern int w1_max_slave_count;
79extern int w1_max_slave_ttl;
80extern struct list_head w1_masters;
81extern struct mutex w1_mlock;
82extern spinlock_t w1_flock;
83
84int w1_process_callbacks(struct w1_master *dev);
85int w1_process(void *data);
86
87#endif /* __W1_H */
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 1134e6b1eb02..d191e1f80579 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -18,7 +18,7 @@
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21#include "w1.h" 21#include "w1_internal.h"
22 22
23static int w1_delay_parm = 1; 23static int w1_delay_parm = 1;
24module_param_named(delay_coef, w1_delay_parm, int, 0); 24module_param_named(delay_coef, w1_delay_parm, int, 0);
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index 027950f997d1..f2f099caeb77 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -17,7 +17,7 @@
17#include <linux/netlink.h> 17#include <linux/netlink.h>
18#include <linux/connector.h> 18#include <linux/connector.h>
19 19
20#include "w1.h" 20#include "w1_internal.h"
21#include "w1_netlink.h" 21#include "w1_netlink.h"
22 22
23#if defined(CONFIG_W1_CON) && (defined(CONFIG_CONNECTOR) || (defined(CONFIG_CONNECTOR_MODULE) && defined(CONFIG_W1_MODULE))) 23#if defined(CONFIG_W1_CON) && (defined(CONFIG_CONNECTOR) || (defined(CONFIG_CONNECTOR_MODULE) && defined(CONFIG_W1_MODULE)))
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index b389e5ff5fa5..a36661cd1f05 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -18,7 +18,7 @@
18#include <asm/types.h> 18#include <asm/types.h>
19#include <linux/connector.h> 19#include <linux/connector.h>
20 20
21#include "w1.h" 21#include "w1_internal.h"
22 22
23/** 23/**
24 * enum w1_cn_msg_flags - bitfield flags for struct cn_msg.flags 24 * enum w1_cn_msg_flags - bitfield flags for struct cn_msg.flags
diff --git a/drivers/w1/w1.h b/include/linux/w1.h
index 758a7a6322e9..90cbe7e65059 100644
--- a/drivers/w1/w1.h
+++ b/include/linux/w1.h
@@ -12,8 +12,10 @@
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 */ 13 */
14 14
15#ifndef __W1_H 15#ifndef __LINUX_W1_H
16#define __W1_H 16#define __LINUX_W1_H
17
18#include <linux/device.h>
17 19
18/** 20/**
19 * struct w1_reg_num - broken out slave device id 21 * struct w1_reg_num - broken out slave device id
@@ -22,8 +24,7 @@
22 * @id: along with family is the unique device id 24 * @id: along with family is the unique device id
23 * @crc: checksum of the other bytes 25 * @crc: checksum of the other bytes
24 */ 26 */
25struct w1_reg_num 27struct w1_reg_num {
26{
27#if defined(__LITTLE_ENDIAN_BITFIELD) 28#if defined(__LITTLE_ENDIAN_BITFIELD)
28 __u64 family:8, 29 __u64 family:8,
29 id:48, 30 id:48,
@@ -39,12 +40,6 @@ struct w1_reg_num
39 40
40#ifdef __KERNEL__ 41#ifdef __KERNEL__
41 42
42#include <linux/completion.h>
43#include <linux/device.h>
44#include <linux/mutex.h>
45
46#include "w1_family.h"
47
48#define W1_MAXNAMELEN 32 43#define W1_MAXNAMELEN 32
49 44
50#define W1_SEARCH 0xF0 45#define W1_SEARCH 0xF0
@@ -59,9 +54,6 @@ struct w1_reg_num
59#define W1_MATCH_ROM 0x55 54#define W1_MATCH_ROM 0x55
60#define W1_RESUME_CMD 0xA5 55#define W1_RESUME_CMD 0xA5
61 56
62#define W1_SLAVE_ACTIVE 0
63#define W1_SLAVE_DETACH 1
64
65/** 57/**
66 * struct w1_slave - holds a single slave device on the bus 58 * struct w1_slave - holds a single slave device on the bus
67 * 59 *
@@ -78,8 +70,7 @@ struct w1_reg_num
78 * @dev: kernel device identifier 70 * @dev: kernel device identifier
79 * 71 *
80 */ 72 */
81struct w1_slave 73struct w1_slave {
82{
83 struct module *owner; 74 struct module *owner;
84 unsigned char name[W1_MAXNAMELEN]; 75 unsigned char name[W1_MAXNAMELEN];
85 struct list_head w1_slave_entry; 76 struct list_head w1_slave_entry;
@@ -96,7 +87,6 @@ struct w1_slave
96 87
97typedef void (*w1_slave_found_callback)(struct w1_master *, u64); 88typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
98 89
99
100/** 90/**
101 * struct w1_bus_master - operations available on a bus master 91 * struct w1_bus_master - operations available on a bus master
102 * 92 *
@@ -142,8 +132,7 @@ typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
142 * reset_bus. 132 * reset_bus.
143 * 133 *
144 */ 134 */
145struct w1_bus_master 135struct w1_bus_master {
146{
147 void *data; 136 void *data;
148 137
149 u8 (*read_bit)(void *); 138 u8 (*read_bit)(void *);
@@ -209,8 +198,7 @@ enum w1_master_flags {
209 * @bus_master: io operations available 198 * @bus_master: io operations available
210 * @seq: sequence number used for netlink broadcasts 199 * @seq: sequence number used for netlink broadcasts
211 */ 200 */
212struct w1_master 201struct w1_master {
213{
214 struct list_head w1_master_entry; 202 struct list_head w1_master_entry;
215 struct module *owner; 203 struct module *owner;
216 unsigned char name[W1_MAXNAMELEN]; 204 unsigned char name[W1_MAXNAMELEN];
@@ -254,45 +242,51 @@ struct w1_master
254 u32 seq; 242 u32 seq;
255}; 243};
256 244
245int w1_add_master_device(struct w1_bus_master *master);
246void w1_remove_master_device(struct w1_bus_master *master);
247
257/** 248/**
258 * struct w1_async_cmd - execute callback from the w1_process kthread 249 * struct w1_family_ops - operations for a family type
259 * @async_entry: link entry 250 * @add_slave: add_slave
260 * @cb: callback function, must list_del and destroy this list before 251 * @remove_slave: remove_slave
261 * returning 252 * @groups: sysfs group
262 *
263 * When inserted into the w1_master async_list, w1_process will execute
264 * the callback. Embed this into the structure with the command details.
265 */ 253 */
266struct w1_async_cmd { 254struct w1_family_ops {
267 struct list_head async_entry; 255 int (*add_slave)(struct w1_slave *sl);
268 void (*cb)(struct w1_master *dev, struct w1_async_cmd *async_cmd); 256 void (*remove_slave)(struct w1_slave *sl);
257 const struct attribute_group **groups;
269}; 258};
270 259
271int w1_create_master_attributes(struct w1_master *); 260/**
272void w1_destroy_master_attributes(struct w1_master *master); 261 * struct w1_family - reference counted family structure.
273void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 262 * @family_entry: family linked list
274void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb); 263 * @fid: 8 bit family identifier
275/* call w1_unref_slave to release the reference counts w1_search_slave added */ 264 * @fops: operations for this family
276struct w1_slave *w1_search_slave(struct w1_reg_num *id); 265 * @refcnt: reference counter
277/* decrements the reference on sl->master and sl, and cleans up if zero 266 */
278 * returns the reference count after it has been decremented */ 267struct w1_family {
279int w1_unref_slave(struct w1_slave *sl); 268 struct list_head family_entry;
280void w1_slave_found(struct w1_master *dev, u64 rn); 269 u8 fid;
281void w1_search_process_cb(struct w1_master *dev, u8 search_type, 270
282 w1_slave_found_callback cb); 271 struct w1_family_ops *fops;
283struct w1_slave *w1_slave_search_device(struct w1_master *dev, 272
284 struct w1_reg_num *rn); 273 atomic_t refcnt;
285struct w1_master *w1_search_master_id(u32 id); 274};
286 275
287/* Disconnect and reconnect devices in the given family. Used for finding 276int w1_register_family(struct w1_family *family);
288 * unclaimed devices after a family has been registered or releasing devices 277void w1_unregister_family(struct w1_family *family);
289 * after a family has been unregistered. Set attach to 1 when a new family 278
290 * has just been registered, to 0 when it has been unregistered. 279/**
280 * module_w1_driver() - Helper macro for registering a 1-Wire families
281 * @__w1_family: w1_family struct
282 *
283 * Helper macro for 1-Wire families which do not do anything special in module
284 * init/exit. This eliminates a lot of boilerplate. Each module may only
285 * use this macro once, and calling it replaces module_init() and module_exit()
291 */ 286 */
292void w1_reconnect_slaves(struct w1_family *f, int attach); 287#define module_w1_family(__w1_family) \
293int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn); 288 module_driver(__w1_family, w1_register_family, \
294/* 0 success, otherwise EBUSY */ 289 w1_unregister_family)
295int w1_slave_detach(struct w1_slave *sl);
296 290
297u8 w1_triplet(struct w1_master *dev, int bdir); 291u8 w1_triplet(struct w1_master *dev, int bdir);
298void w1_write_8(struct w1_master *, u8); 292void w1_write_8(struct w1_master *, u8);
@@ -321,16 +315,6 @@ static inline struct w1_master* dev_to_w1_master(struct device *dev)
321 return container_of(dev, struct w1_master, dev); 315 return container_of(dev, struct w1_master, dev);
322} 316}
323 317
324extern struct device_driver w1_master_driver;
325extern struct device w1_master_device;
326extern int w1_max_slave_count;
327extern int w1_max_slave_ttl;
328extern struct list_head w1_masters;
329extern struct mutex w1_mlock;
330
331extern int w1_process_callbacks(struct w1_master *dev);
332extern int w1_process(void *);
333
334#endif /* __KERNEL__ */ 318#endif /* __KERNEL__ */
335 319
336#endif /* __W1_H */ 320#endif /* __LINUX_W1_H */