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

ARM: pxa: propagate errors from regulator_enable() to pxamci

The em_x270_mci_setpower() and em_x270_usb_hub_init() functions
call regulator_enable(), which may return an error that must
be checked.

This changes the em_x270_usb_hub_init() function to bail out
if it fails, and changes the pxamci_platform_data->setpower
callback so that the a failed em_x270_mci_setpower call
can be propagated by the pxamci driver into the mmc core.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Mike Rapoport <mike@compulab.co.il>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Acked-by: Chris Ball <cjb@laptop.org>
[olof: fixed order of regulator_enable() and test in em_x270_usb_hub_init]
Signed-off-by: Olof Johansson <olof@lixom.net>

authored by

Arnd Bergmann and committed by
Olof Johansson
a829abf8 fe08bf9f

+27 -11
+13 -4
arch/arm/mach-pxa/em-x270.c
··· 477 477 /* USB Hub power-on and reset */ 478 478 gpio_direction_output(usb_hub_reset, 1); 479 479 gpio_direction_output(GPIO9_USB_VBUS_EN, 0); 480 - regulator_enable(em_x270_usb_ldo); 480 + err = regulator_enable(em_x270_usb_ldo); 481 + if (err) 482 + goto err_free_rst_gpio; 483 + 481 484 gpio_set_value(usb_hub_reset, 0); 482 485 gpio_set_value(usb_hub_reset, 1); 483 486 regulator_disable(em_x270_usb_ldo); 484 - regulator_enable(em_x270_usb_ldo); 487 + err = regulator_enable(em_x270_usb_ldo); 488 + if (err) 489 + goto err_free_rst_gpio; 490 + 485 491 gpio_set_value(usb_hub_reset, 0); 486 492 gpio_set_value(GPIO9_USB_VBUS_EN, 1); 487 493 488 494 return 0; 489 495 496 + err_free_rst_gpio: 497 + gpio_free(usb_hub_reset); 490 498 err_free_vbus_gpio: 491 499 gpio_free(GPIO9_USB_VBUS_EN); 492 500 err_free_usb_ldo: ··· 600 592 return err; 601 593 } 602 594 603 - static void em_x270_mci_setpower(struct device *dev, unsigned int vdd) 595 + static int em_x270_mci_setpower(struct device *dev, unsigned int vdd) 604 596 { 605 597 struct pxamci_platform_data* p_d = dev->platform_data; 606 598 ··· 608 600 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000; 609 601 610 602 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV); 611 - regulator_enable(em_x270_sdio_ldo); 603 + return regulator_enable(em_x270_sdio_ldo); 612 604 } else { 613 605 regulator_disable(em_x270_sdio_ldo); 614 606 } 607 + return 0; 615 608 } 616 609 617 610 static void em_x270_mci_exit(struct device *dev, void *data)
+2 -1
arch/arm/mach-pxa/mainstone.c
··· 408 408 return err; 409 409 } 410 410 411 - static void mainstone_mci_setpower(struct device *dev, unsigned int vdd) 411 + static int mainstone_mci_setpower(struct device *dev, unsigned int vdd) 412 412 { 413 413 struct pxamci_platform_data* p_d = dev->platform_data; 414 414 ··· 420 420 printk(KERN_DEBUG "%s: off\n", __func__); 421 421 MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON; 422 422 } 423 + return 0; 423 424 } 424 425 425 426 static void mainstone_mci_exit(struct device *dev, void *data)
+2 -1
arch/arm/mach-pxa/pcm990-baseboard.c
··· 335 335 return err; 336 336 } 337 337 338 - static void pcm990_mci_setpower(struct device *dev, unsigned int vdd) 338 + static int pcm990_mci_setpower(struct device *dev, unsigned int vdd) 339 339 { 340 340 struct pxamci_platform_data *p_d = dev->platform_data; 341 341 u8 val; ··· 348 348 val &= ~PCM990_CTRL_MMC2PWR; 349 349 350 350 pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5); 351 + return 0; 351 352 } 352 353 353 354 static void pcm990_mci_exit(struct device *dev, void *data)
+3 -1
arch/arm/mach-pxa/poodle.c
··· 258 258 return err; 259 259 } 260 260 261 - static void poodle_mci_setpower(struct device *dev, unsigned int vdd) 261 + static int poodle_mci_setpower(struct device *dev, unsigned int vdd) 262 262 { 263 263 struct pxamci_platform_data* p_d = dev->platform_data; 264 264 ··· 270 270 gpio_set_value(POODLE_GPIO_SD_PWR1, 0); 271 271 gpio_set_value(POODLE_GPIO_SD_PWR, 0); 272 272 } 273 + 274 + return 0; 273 275 } 274 276 275 277 static void poodle_mci_exit(struct device *dev, void *data)
+3 -1
arch/arm/mach-pxa/spitz.c
··· 598 598 * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to 599 599 * give the card a chance to fully insert/eject. 600 600 */ 601 - static void spitz_mci_setpower(struct device *dev, unsigned int vdd) 601 + static int spitz_mci_setpower(struct device *dev, unsigned int vdd) 602 602 { 603 603 struct pxamci_platform_data* p_d = dev->platform_data; 604 604 ··· 606 606 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V); 607 607 else 608 608 spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0); 609 + 610 + return 0; 609 611 } 610 612 611 613 static struct pxamci_platform_data spitz_mci_platform_data = {
+2 -1
arch/arm/mach-pxa/stargate2.c
··· 734 734 * 735 735 * Very simple control. Either it is on or off and is controlled by 736 736 * a gpio pin */ 737 - static void stargate2_mci_setpower(struct device *dev, unsigned int vdd) 737 + static int stargate2_mci_setpower(struct device *dev, unsigned int vdd) 738 738 { 739 739 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd); 740 + return 0; 740 741 } 741 742 742 743 static void stargate2_mci_exit(struct device *dev, void *data)
+1 -1
drivers/mmc/host/pxamci.c
··· 128 128 !!on ^ host->pdata->gpio_power_invert); 129 129 } 130 130 if (!host->vcc && host->pdata && host->pdata->setpower) 131 - host->pdata->setpower(mmc_dev(host->mmc), vdd); 131 + return host->pdata->setpower(mmc_dev(host->mmc), vdd); 132 132 133 133 return 0; 134 134 }
+1 -1
include/linux/platform_data/mmc-pxamci.h
··· 12 12 unsigned long detect_delay_ms; /* delay in millisecond before detecting cards after interrupt */ 13 13 int (*init)(struct device *, irq_handler_t , void *); 14 14 int (*get_ro)(struct device *); 15 - void (*setpower)(struct device *, unsigned int); 15 + int (*setpower)(struct device *, unsigned int); 16 16 void (*exit)(struct device *, void *); 17 17 int gpio_card_detect; /* gpio detecting card insertion */ 18 18 int gpio_card_ro; /* gpio detecting read only toggle */