aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2012-07-25 16:54:29 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-16 13:02:33 -0400
commitd2323cf77308d6aa13a3a5287310ef93c4919d1e (patch)
treedf5fa99b5a9376386ed8deb842da90277f5cef53 /drivers/w1
parent5f3d1382e3ca39a54032784414f0ad4e7078b37e (diff)
onewire: w1-gpio: add ext_pullup_enable pin in platform data
In the process of porting boards to devicetree implemenation, we should keep information about external circuitry where they belong - the individual drivers. This patch adds a way to specify a GPIO to drive the (optional) external pull-up logic, rather than using a function pointer for that. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Acked-by: Ville Syrjälä <syrjala@sci.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/masters/w1-gpio.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index f01c336233da..6012c4ea3206 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -104,6 +104,13 @@ static int __init w1_gpio_probe(struct platform_device *pdev)
104 if (err) 104 if (err)
105 goto free_master; 105 goto free_master;
106 106
107 if (gpio_is_valid(pdata->ext_pullup_enable_pin)) {
108 err = gpio_request_one(pdata->ext_pullup_enable_pin,
109 GPIOF_INIT_LOW, "w1 pullup");
110 if (err < 0)
111 goto free_gpio;
112 }
113
107 master->data = pdata; 114 master->data = pdata;
108 master->read_bit = w1_gpio_read_bit; 115 master->read_bit = w1_gpio_read_bit;
109 116
@@ -117,15 +124,21 @@ static int __init w1_gpio_probe(struct platform_device *pdev)
117 124
118 err = w1_add_master_device(master); 125 err = w1_add_master_device(master);
119 if (err) 126 if (err)
120 goto free_gpio; 127 goto free_gpio_ext_pu;
121 128
122 if (pdata->enable_external_pullup) 129 if (pdata->enable_external_pullup)
123 pdata->enable_external_pullup(1); 130 pdata->enable_external_pullup(1);
124 131
132 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
133 gpio_set_value(pdata->ext_pullup_enable_pin, 1);
134
125 platform_set_drvdata(pdev, master); 135 platform_set_drvdata(pdev, master);
126 136
127 return 0; 137 return 0;
128 138
139 free_gpio_ext_pu:
140 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
141 gpio_free(pdata->ext_pullup_enable_pin);
129 free_gpio: 142 free_gpio:
130 gpio_free(pdata->pin); 143 gpio_free(pdata->pin);
131 free_master: 144 free_master:
@@ -142,6 +155,9 @@ static int __exit w1_gpio_remove(struct platform_device *pdev)
142 if (pdata->enable_external_pullup) 155 if (pdata->enable_external_pullup)
143 pdata->enable_external_pullup(0); 156 pdata->enable_external_pullup(0);
144 157
158 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
159 gpio_set_value(pdata->ext_pullup_enable_pin, 0);
160
145 w1_remove_master_device(master); 161 w1_remove_master_device(master);
146 gpio_free(pdata->pin); 162 gpio_free(pdata->pin);
147 kfree(master); 163 kfree(master);