extcon: max77693: Fix bug of wrong pointer when platform data is not used
This patch fix wrong pointer of platform data. If each machine set platform data for h/w path or delay time of workqueue, this driver happen kernel panic related to null pointer. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
This commit is contained in:
parent
810d601f07
commit
190d7cfc86
@ -1045,7 +1045,6 @@ static int max77693_muic_probe(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
|
struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
|
||||||
struct max77693_platform_data *pdata = dev_get_platdata(max77693->dev);
|
struct max77693_platform_data *pdata = dev_get_platdata(max77693->dev);
|
||||||
struct max77693_muic_platform_data *muic_pdata = pdata->muic_data;
|
|
||||||
struct max77693_muic_info *info;
|
struct max77693_muic_info *info;
|
||||||
int delay_jiffies;
|
int delay_jiffies;
|
||||||
int ret;
|
int ret;
|
||||||
@ -1145,44 +1144,63 @@ static int max77693_muic_probe(struct platform_device *pdev)
|
|||||||
goto err_irq;
|
goto err_irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize MUIC register by using platform data */
|
if (pdata->muic_data) {
|
||||||
for (i = 0 ; i < muic_pdata->num_init_data ; i++) {
|
struct max77693_muic_platform_data *muic_pdata = pdata->muic_data;
|
||||||
enum max77693_irq_source irq_src = MAX77693_IRQ_GROUP_NR;
|
|
||||||
|
|
||||||
max77693_write_reg(info->max77693->regmap_muic,
|
/* Initialize MUIC register by using platform data */
|
||||||
muic_pdata->init_data[i].addr,
|
for (i = 0 ; i < muic_pdata->num_init_data ; i++) {
|
||||||
muic_pdata->init_data[i].data);
|
enum max77693_irq_source irq_src
|
||||||
|
= MAX77693_IRQ_GROUP_NR;
|
||||||
|
|
||||||
switch (muic_pdata->init_data[i].addr) {
|
max77693_write_reg(info->max77693->regmap_muic,
|
||||||
case MAX77693_MUIC_REG_INTMASK1:
|
muic_pdata->init_data[i].addr,
|
||||||
irq_src = MUIC_INT1;
|
muic_pdata->init_data[i].data);
|
||||||
break;
|
|
||||||
case MAX77693_MUIC_REG_INTMASK2:
|
switch (muic_pdata->init_data[i].addr) {
|
||||||
irq_src = MUIC_INT2;
|
case MAX77693_MUIC_REG_INTMASK1:
|
||||||
break;
|
irq_src = MUIC_INT1;
|
||||||
case MAX77693_MUIC_REG_INTMASK3:
|
break;
|
||||||
irq_src = MUIC_INT3;
|
case MAX77693_MUIC_REG_INTMASK2:
|
||||||
break;
|
irq_src = MUIC_INT2;
|
||||||
|
break;
|
||||||
|
case MAX77693_MUIC_REG_INTMASK3:
|
||||||
|
irq_src = MUIC_INT3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irq_src < MAX77693_IRQ_GROUP_NR)
|
||||||
|
info->max77693->irq_masks_cur[irq_src]
|
||||||
|
= muic_pdata->init_data[i].data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irq_src < MAX77693_IRQ_GROUP_NR)
|
/*
|
||||||
info->max77693->irq_masks_cur[irq_src]
|
* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
|
||||||
= muic_pdata->init_data[i].data;
|
* h/w path of COMP2/COMN1 on CONTROL1 register.
|
||||||
}
|
*/
|
||||||
|
if (muic_pdata->path_uart)
|
||||||
|
info->path_uart = muic_pdata->path_uart;
|
||||||
|
else
|
||||||
|
info->path_uart = CONTROL1_SW_UART;
|
||||||
|
|
||||||
/*
|
if (muic_pdata->path_usb)
|
||||||
* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
|
info->path_usb = muic_pdata->path_usb;
|
||||||
* h/w path of COMP2/COMN1 on CONTROL1 register.
|
else
|
||||||
*/
|
info->path_usb = CONTROL1_SW_USB;
|
||||||
if (muic_pdata->path_uart)
|
|
||||||
info->path_uart = muic_pdata->path_uart;
|
|
||||||
else
|
|
||||||
info->path_uart = CONTROL1_SW_UART;
|
|
||||||
|
|
||||||
if (muic_pdata->path_usb)
|
/*
|
||||||
info->path_usb = muic_pdata->path_usb;
|
* Default delay time for detecting cable state
|
||||||
else
|
* after certain time.
|
||||||
|
*/
|
||||||
|
if (muic_pdata->detcable_delay_ms)
|
||||||
|
delay_jiffies =
|
||||||
|
msecs_to_jiffies(muic_pdata->detcable_delay_ms);
|
||||||
|
else
|
||||||
|
delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
|
||||||
|
} else {
|
||||||
info->path_usb = CONTROL1_SW_USB;
|
info->path_usb = CONTROL1_SW_USB;
|
||||||
|
info->path_uart = CONTROL1_SW_UART;
|
||||||
|
delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set initial path for UART */
|
/* Set initial path for UART */
|
||||||
max77693_muic_set_path(info, info->path_uart, true);
|
max77693_muic_set_path(info, info->path_uart, true);
|
||||||
@ -1208,10 +1226,6 @@ static int max77693_muic_probe(struct platform_device *pdev)
|
|||||||
* driver should notify cable state to upper layer.
|
* driver should notify cable state to upper layer.
|
||||||
*/
|
*/
|
||||||
INIT_DELAYED_WORK(&info->wq_detcable, max77693_muic_detect_cable_wq);
|
INIT_DELAYED_WORK(&info->wq_detcable, max77693_muic_detect_cable_wq);
|
||||||
if (muic_pdata->detcable_delay_ms)
|
|
||||||
delay_jiffies = msecs_to_jiffies(muic_pdata->detcable_delay_ms);
|
|
||||||
else
|
|
||||||
delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
|
|
||||||
schedule_delayed_work(&info->wq_detcable, delay_jiffies);
|
schedule_delayed_work(&info->wq_detcable, delay_jiffies);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user