Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wl1251: move power GPIO handling into the driver

Move the power GPIO handling from the board code into
the driver. This is a dependency for device tree support.

Signed-off-by: Sebastian Reichel <sre@debian.org>
Reviewed-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Sebastian Reichel and committed by
John W. Linville
1d207cd3 946651cb

+43 -28
+2
arch/arm/mach-omap2/board-omap3pandora.c
··· 541 541 542 542 memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata)); 543 543 544 + pandora_wl1251_pdata.power_gpio = -1; 545 + 544 546 ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq"); 545 547 if (ret < 0) 546 548 goto fail;
+2 -9
arch/arm/mach-omap2/board-rx51-peripherals.c
··· 1173 1173 1174 1174 #endif 1175 1175 1176 - static void rx51_wl1251_set_power(bool enable) 1177 - { 1178 - gpio_set_value(RX51_WL1251_POWER_GPIO, enable); 1179 - } 1180 - 1181 1176 static struct gpio rx51_wl1251_gpios[] __initdata = { 1182 - { RX51_WL1251_POWER_GPIO, GPIOF_OUT_INIT_LOW, "wl1251 power" }, 1183 1177 { RX51_WL1251_IRQ_GPIO, GPIOF_IN, "wl1251 irq" }, 1184 1178 }; 1185 1179 ··· 1190 1196 if (irq < 0) 1191 1197 goto err_irq; 1192 1198 1193 - wl1251_pdata.set_power = rx51_wl1251_set_power; 1199 + wl1251_pdata.power_gpio = RX51_WL1251_POWER_GPIO; 1194 1200 rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq; 1195 1201 1196 1202 return; 1197 1203 1198 1204 err_irq: 1199 1205 gpio_free(RX51_WL1251_IRQ_GPIO); 1200 - gpio_free(RX51_WL1251_POWER_GPIO); 1201 1206 error: 1202 1207 printk(KERN_ERR "wl1251 board initialisation failed\n"); 1203 - wl1251_pdata.set_power = NULL; 1208 + wl1251_pdata.power_gpio = -1; 1204 1209 1205 1210 /* 1206 1211 * Now rx51_peripherals_spi_board_info[1].irq is zero and
+16 -5
drivers/net/wireless/ti/wl1251/sdio.c
··· 28 28 #include <linux/wl12xx.h> 29 29 #include <linux/irq.h> 30 30 #include <linux/pm_runtime.h> 31 + #include <linux/gpio.h> 31 32 32 33 #include "wl1251.h" 33 34 ··· 183 182 * callback in case it wants to do any additional setup, 184 183 * for example enabling clock buffer for the module. 185 184 */ 186 - if (wl->set_power) 187 - wl->set_power(true); 185 + if (gpio_is_valid(wl->power_gpio)) 186 + gpio_set_value(wl->power_gpio, true); 187 + 188 188 189 189 ret = pm_runtime_get_sync(&func->dev); 190 190 if (ret < 0) { ··· 205 203 if (ret < 0) 206 204 goto out; 207 205 208 - if (wl->set_power) 209 - wl->set_power(false); 206 + if (gpio_is_valid(wl->power_gpio)) 207 + gpio_set_value(wl->power_gpio, false); 210 208 } 211 209 212 210 out: ··· 258 256 259 257 wl1251_board_data = wl1251_get_platform_data(); 260 258 if (!IS_ERR(wl1251_board_data)) { 261 - wl->set_power = wl1251_board_data->set_power; 259 + wl->power_gpio = wl1251_board_data->power_gpio; 262 260 wl->irq = wl1251_board_data->irq; 263 261 wl->use_eeprom = wl1251_board_data->use_eeprom; 262 + } 263 + 264 + if (gpio_is_valid(wl->power_gpio)) { 265 + ret = devm_gpio_request(&func->dev, wl->power_gpio, 266 + "wl1251 power"); 267 + if (ret) { 268 + wl1251_error("Failed to request gpio: %d\n", ret); 269 + goto disable; 270 + } 264 271 } 265 272 266 273 if (wl->irq) {
+21 -12
drivers/net/wireless/ti/wl1251/spi.c
··· 26 26 #include <linux/crc7.h> 27 27 #include <linux/spi/spi.h> 28 28 #include <linux/wl12xx.h> 29 + #include <linux/gpio.h> 29 30 30 31 #include "wl1251.h" 31 32 #include "reg.h" ··· 222 221 223 222 static int wl1251_spi_set_power(struct wl1251 *wl, bool enable) 224 223 { 225 - if (wl->set_power) 226 - wl->set_power(enable); 224 + if (gpio_is_valid(wl->power_gpio)) 225 + gpio_set_value(wl->power_gpio, enable); 227 226 228 227 return 0; 229 228 } ··· 272 271 goto out_free; 273 272 } 274 273 275 - wl->set_power = pdata->set_power; 276 - if (!wl->set_power) { 277 - wl1251_error("set power function missing in platform data"); 278 - return -ENODEV; 274 + wl->power_gpio = pdata->power_gpio; 275 + 276 + if (gpio_is_valid(wl->power_gpio)) { 277 + ret = devm_gpio_request_one(&spi->dev, wl->power_gpio, 278 + GPIOF_OUT_INIT_LOW, "wl1251 power"); 279 + if (ret) { 280 + wl1251_error("Failed to request gpio: %d\n", ret); 281 + goto out_free; 282 + } 283 + } else { 284 + wl1251_error("set power gpio missing in platform data"); 285 + ret = -ENODEV; 286 + goto out_free; 279 287 } 280 288 281 289 wl->irq = spi->irq; 282 290 if (wl->irq < 0) { 283 291 wl1251_error("irq missing in platform data"); 284 - return -ENODEV; 292 + ret = -ENODEV; 293 + goto out_free; 285 294 } 286 295 287 296 wl->use_eeprom = pdata->use_eeprom; 288 297 289 298 irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); 290 - ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); 299 + ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0, 300 + DRIVER_NAME, wl); 291 301 if (ret < 0) { 292 302 wl1251_error("request_irq() failed: %d", ret); 293 303 goto out_free; ··· 308 296 309 297 ret = wl1251_init_ieee80211(wl); 310 298 if (ret) 311 - goto out_irq; 299 + goto out_free; 312 300 313 301 return 0; 314 - 315 - out_irq: 316 - free_irq(wl->irq, wl); 317 302 318 303 out_free: 319 304 ieee80211_free_hw(hw);
+1 -1
drivers/net/wireless/ti/wl1251/wl1251.h
··· 276 276 void *if_priv; 277 277 const struct wl1251_if_operations *if_ops; 278 278 279 - void (*set_power)(bool enable); 279 + int power_gpio; 280 280 int irq; 281 281 bool use_eeprom; 282 282
+1 -1
include/linux/wl12xx.h
··· 49 49 }; 50 50 51 51 struct wl1251_platform_data { 52 - void (*set_power)(bool enable); 52 + int power_gpio; 53 53 /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */ 54 54 int irq; 55 55 bool use_eeprom;