brcm2708: add linux 4.19 support
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0500-w1-ds2482-cosmetic-fixes-after-54865314f5a1.patch
1 From cf423c8b0d5d1fa5cc0c9427b5282aa888b5eaef Mon Sep 17 00:00:00 2001
2 From: Mariusz Bialonczyk <manio@skyboo.net>
3 Date: Mon, 4 Mar 2019 12:23:36 +0100
4 Subject: [PATCH 500/703] w1: ds2482: cosmetic fixes after 54865314f5a1
5
6 commit 5cb27d30fc3a281e830a2099d520b469e2b82008 upstream.
7
8 We have a helper function ds2482_calculate_config() which is calculating
9 the config value, so just use it instead of passing the same variable
10 in all calls to this function.
11
12 Also fixes the placement of module parameters to match with:
13 50fa2951bd74 (w1: Organize driver source to natural/common order)
14 by Andrew F. Davis
15
16 Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
17 Cc: Andrew Worsley <amworsley@gmail.com>
18 Cc: Andrew F. Davis <afd@ti.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 ---
21 drivers/w1/masters/ds2482.c | 18 +++++++++++-------
22 1 file changed, 11 insertions(+), 7 deletions(-)
23
24 --- a/drivers/w1/masters/ds2482.c
25 +++ b/drivers/w1/masters/ds2482.c
26 @@ -37,6 +37,11 @@ module_param_named(active_pullup, ds2482
27 MODULE_PARM_DESC(active_pullup, "Active pullup (apply to all buses): " \
28 "0-disable, 1-enable (default)");
29
30 +/* extra configurations - e.g. 1WS */
31 +static int extra_config;
32 +module_param(extra_config, int, S_IRUGO | S_IWUSR);
33 +MODULE_PARM_DESC(extra_config, "Extra Configuration settings 1=APU,2=PPM,3=SPU,8=1WS");
34 +
35 /**
36 * The DS2482 registers - there are 3 registers that are addressed by a read
37 * pointer. The read pointer is set by the last command executed.
38 @@ -70,8 +75,6 @@ MODULE_PARM_DESC(active_pullup, "Active
39 #define DS2482_REG_CFG_PPM 0x02 /* presence pulse masking */
40 #define DS2482_REG_CFG_APU 0x01 /* active pull-up */
41
42 -/* extra configurations - e.g. 1WS */
43 -static int extra_config;
44
45 /**
46 * Write and verify codes for the CHANNEL_SELECT command (DS2482-800 only).
47 @@ -130,6 +133,8 @@ struct ds2482_data {
48 */
49 static inline u8 ds2482_calculate_config(u8 conf)
50 {
51 + conf |= extra_config;
52 +
53 if (ds2482_active_pullup)
54 conf |= DS2482_REG_CFG_APU;
55
56 @@ -405,7 +410,7 @@ static u8 ds2482_w1_reset_bus(void *data
57 /* If the chip did reset since detect, re-config it */
58 if (err & DS2482_REG_STS_RST)
59 ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
60 - ds2482_calculate_config(extra_config));
61 + ds2482_calculate_config(0x00));
62 }
63
64 mutex_unlock(&pdev->access_lock);
65 @@ -431,7 +436,8 @@ static u8 ds2482_w1_set_pullup(void *dat
66 ds2482_wait_1wire_idle(pdev);
67 /* note: it seems like both SPU and APU have to be set! */
68 retval = ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
69 - ds2482_calculate_config(extra_config|DS2482_REG_CFG_SPU|DS2482_REG_CFG_APU));
70 + ds2482_calculate_config(DS2482_REG_CFG_SPU |
71 + DS2482_REG_CFG_APU));
72 ds2482_wait_1wire_idle(pdev);
73 }
74
75 @@ -484,7 +490,7 @@ static int ds2482_probe(struct i2c_clien
76
77 /* Set all config items to 0 (off) */
78 ds2482_send_cmd_data(data, DS2482_CMD_WRITE_CONFIG,
79 - ds2482_calculate_config(extra_config));
80 + ds2482_calculate_config(0x00));
81
82 mutex_init(&data->access_lock);
83
84 @@ -559,7 +565,5 @@ module_i2c_driver(ds2482_driver);
85
86 MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
87 MODULE_DESCRIPTION("DS2482 driver");
88 -module_param(extra_config, int, S_IRUGO | S_IWUSR);
89 -MODULE_PARM_DESC(extra_config, "Extra Configuration settings 1=APU,2=PPM,3=SPU,8=1WS");
90
91 MODULE_LICENSE("GPL");