diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2013-02-17 20:15:03 -0500 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-03-13 04:28:15 -0400 |
commit | 810d601f07ce2481ff776e049c0733ded2abbcc1 (patch) | |
tree | 976c48ddc58dd542569d892b09af8f4ae11531c0 /drivers/extcon | |
parent | f6161aa153581da4a3867a2d1a7caf4be19b6ec9 (diff) |
extcon: max8997: Check the pointer of platform data to protect null pointer error
This patch check the pointer of platform data to protect
kernel panic when platform data is not used and code clean.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-max8997.c | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index e636d950ad6c..69641bcae325 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c | |||
@@ -712,29 +712,45 @@ static int max8997_muic_probe(struct platform_device *pdev) | |||
712 | goto err_irq; | 712 | goto err_irq; |
713 | } | 713 | } |
714 | 714 | ||
715 | /* Initialize registers according to platform data */ | ||
716 | if (pdata->muic_pdata) { | 715 | if (pdata->muic_pdata) { |
717 | struct max8997_muic_platform_data *mdata = info->muic_pdata; | 716 | struct max8997_muic_platform_data *muic_pdata |
718 | 717 | = pdata->muic_pdata; | |
719 | for (i = 0; i < mdata->num_init_data; i++) { | 718 | |
720 | max8997_write_reg(info->muic, mdata->init_data[i].addr, | 719 | /* Initialize registers according to platform data */ |
721 | mdata->init_data[i].data); | 720 | for (i = 0; i < muic_pdata->num_init_data; i++) { |
721 | max8997_write_reg(info->muic, | ||
722 | muic_pdata->init_data[i].addr, | ||
723 | muic_pdata->init_data[i].data); | ||
722 | } | 724 | } |
723 | } | ||
724 | 725 | ||
725 | /* | 726 | /* |
726 | * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB | 727 | * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB |
727 | * h/w path of COMP2/COMN1 on CONTROL1 register. | 728 | * h/w path of COMP2/COMN1 on CONTROL1 register. |
728 | */ | 729 | */ |
729 | if (pdata->muic_pdata->path_uart) | 730 | if (muic_pdata->path_uart) |
730 | info->path_uart = pdata->muic_pdata->path_uart; | 731 | info->path_uart = muic_pdata->path_uart; |
731 | else | 732 | else |
732 | info->path_uart = CONTROL1_SW_UART; | 733 | info->path_uart = CONTROL1_SW_UART; |
733 | 734 | ||
734 | if (pdata->muic_pdata->path_usb) | 735 | if (muic_pdata->path_usb) |
735 | info->path_usb = pdata->muic_pdata->path_usb; | 736 | info->path_usb = muic_pdata->path_usb; |
736 | else | 737 | else |
738 | info->path_usb = CONTROL1_SW_USB; | ||
739 | |||
740 | /* | ||
741 | * Default delay time for detecting cable state | ||
742 | * after certain time. | ||
743 | */ | ||
744 | if (muic_pdata->detcable_delay_ms) | ||
745 | delay_jiffies = | ||
746 | msecs_to_jiffies(muic_pdata->detcable_delay_ms); | ||
747 | else | ||
748 | delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); | ||
749 | } else { | ||
750 | info->path_uart = CONTROL1_SW_UART; | ||
737 | info->path_usb = CONTROL1_SW_USB; | 751 | info->path_usb = CONTROL1_SW_USB; |
752 | delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); | ||
753 | } | ||
738 | 754 | ||
739 | /* Set initial path for UART */ | 755 | /* Set initial path for UART */ |
740 | max8997_muic_set_path(info, info->path_uart, true); | 756 | max8997_muic_set_path(info, info->path_uart, true); |
@@ -751,10 +767,6 @@ static int max8997_muic_probe(struct platform_device *pdev) | |||
751 | * driver should notify cable state to upper layer. | 767 | * driver should notify cable state to upper layer. |
752 | */ | 768 | */ |
753 | INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq); | 769 | INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq); |
754 | if (pdata->muic_pdata->detcable_delay_ms) | ||
755 | delay_jiffies = msecs_to_jiffies(pdata->muic_pdata->detcable_delay_ms); | ||
756 | else | ||
757 | delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); | ||
758 | schedule_delayed_work(&info->wq_detcable, delay_jiffies); | 770 | schedule_delayed_work(&info->wq_detcable, delay_jiffies); |
759 | 771 | ||
760 | return 0; | 772 | return 0; |