mfd: ti_tscadc: deal with partial activation
Fix the mfd device in the case where a subdevice might not be activated. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
此提交包含在:

提交者
Sebastian Andrzej Siewior

父節點
c80df483f6
當前提交
24d5c82f82
@@ -107,11 +107,14 @@ static int ti_tscadc_probe(struct platform_device *pdev)
|
||||
of_property_read_u32(node, "ti,adc-channels", &adc_channels);
|
||||
|
||||
total_channels = tsc_wires + adc_channels;
|
||||
|
||||
if (total_channels > 8) {
|
||||
dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (total_channels == 0) {
|
||||
dev_err(&pdev->dev, "Need atleast one channel.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res) {
|
||||
@@ -202,28 +205,37 @@ static int ti_tscadc_probe(struct platform_device *pdev)
|
||||
ctrl |= CNTRLREG_TSCSSENB;
|
||||
tscadc_writel(tscadc, REG_CTRL, ctrl);
|
||||
|
||||
tscadc->used_cells = 0;
|
||||
tscadc->tsc_cell = -1;
|
||||
tscadc->adc_cell = -1;
|
||||
|
||||
/* TSC Cell */
|
||||
cell = &tscadc->cells[TSC_CELL];
|
||||
cell->name = "tsc";
|
||||
cell->of_compatible = "ti,am3359-tsc";
|
||||
cell->platform_data = &tscadc;
|
||||
cell->pdata_size = sizeof(tscadc);
|
||||
if (tsc_wires > 0) {
|
||||
tscadc->tsc_cell = tscadc->used_cells;
|
||||
cell = &tscadc->cells[tscadc->used_cells++];
|
||||
cell->name = "tsc";
|
||||
cell->of_compatible = "ti,am3359-tsc";
|
||||
cell->platform_data = &tscadc;
|
||||
cell->pdata_size = sizeof(tscadc);
|
||||
}
|
||||
|
||||
/* ADC Cell */
|
||||
cell = &tscadc->cells[ADC_CELL];
|
||||
cell->name = "tiadc";
|
||||
cell->of_compatible = "ti,am3359-adc";
|
||||
cell->platform_data = &tscadc;
|
||||
cell->pdata_size = sizeof(tscadc);
|
||||
if (adc_channels > 0) {
|
||||
tscadc->adc_cell = tscadc->used_cells;
|
||||
cell = &tscadc->cells[tscadc->used_cells++];
|
||||
cell->name = "tiadc";
|
||||
cell->of_compatible = "ti,am3359-adc";
|
||||
cell->platform_data = &tscadc;
|
||||
cell->pdata_size = sizeof(tscadc);
|
||||
}
|
||||
|
||||
err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells,
|
||||
TSCADC_CELLS, NULL, 0, NULL);
|
||||
tscadc->used_cells, NULL, 0, NULL);
|
||||
if (err < 0)
|
||||
goto err_disable_clk;
|
||||
|
||||
device_init_wakeup(&pdev->dev, true);
|
||||
platform_set_drvdata(pdev, tscadc);
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable_clk:
|
||||
|
新增問題並參考
封鎖使用者