spi: pxa2xx: Extract pxa2xx_spi_platform_*() callbacks
In preparation of the extracting platform driver from spi-pxa2xx.c split the probe and remove functions so we have bus independent and platform device ones. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://msgid.link/r/20240530151117.1130792-10-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
75bfdccaec
commit
20ade9b977
@ -1413,30 +1413,16 @@ static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi)
|
|||||||
return MAX_DMA_LEN;
|
return MAX_DMA_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pxa2xx_spi_probe(struct platform_device *pdev)
|
static int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
|
||||||
struct pxa2xx_spi_controller *platform_info;
|
struct pxa2xx_spi_controller *platform_info;
|
||||||
struct spi_controller *controller;
|
struct spi_controller *controller;
|
||||||
struct driver_data *drv_data;
|
struct driver_data *drv_data;
|
||||||
struct ssp_device *ssp;
|
|
||||||
const struct lpss_config *config;
|
const struct lpss_config *config;
|
||||||
int status;
|
int status;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
|
|
||||||
platform_info = dev_get_platdata(dev);
|
platform_info = dev_get_platdata(dev);
|
||||||
if (!platform_info) {
|
|
||||||
platform_info = pxa2xx_spi_init_pdata(pdev);
|
|
||||||
if (IS_ERR(platform_info))
|
|
||||||
return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ssp = pxa2xx_spi_ssp_request(pdev);
|
|
||||||
if (IS_ERR(ssp))
|
|
||||||
return PTR_ERR(ssp);
|
|
||||||
if (!ssp)
|
|
||||||
ssp = &platform_info->ssp;
|
|
||||||
|
|
||||||
if (platform_info->is_target)
|
if (platform_info->is_target)
|
||||||
controller = devm_spi_alloc_target(dev, sizeof(*drv_data));
|
controller = devm_spi_alloc_target(dev, sizeof(*drv_data));
|
||||||
else
|
else
|
||||||
@ -1628,9 +1614,8 @@ out_error_dma_irq_alloc:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pxa2xx_spi_remove(struct platform_device *pdev)
|
static void pxa2xx_spi_remove(struct device *dev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
|
||||||
struct driver_data *drv_data = dev_get_drvdata(dev);
|
struct driver_data *drv_data = dev_get_drvdata(dev);
|
||||||
struct ssp_device *ssp = drv_data->ssp;
|
struct ssp_device *ssp = drv_data->ssp;
|
||||||
|
|
||||||
@ -1708,6 +1693,35 @@ static const struct dev_pm_ops pxa2xx_spi_pm_ops = {
|
|||||||
RUNTIME_PM_OPS(pxa2xx_spi_runtime_suspend, pxa2xx_spi_runtime_resume, NULL)
|
RUNTIME_PM_OPS(pxa2xx_spi_runtime_suspend, pxa2xx_spi_runtime_resume, NULL)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int pxa2xx_spi_platform_probe(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct pxa2xx_spi_controller *platform_info;
|
||||||
|
struct device *dev = &pdev->dev;
|
||||||
|
struct ssp_device *ssp;
|
||||||
|
|
||||||
|
platform_info = dev_get_platdata(dev);
|
||||||
|
if (!platform_info) {
|
||||||
|
platform_info = pxa2xx_spi_init_pdata(pdev);
|
||||||
|
if (IS_ERR(platform_info))
|
||||||
|
return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n");
|
||||||
|
|
||||||
|
dev->platform_data = platform_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssp = pxa2xx_spi_ssp_request(pdev);
|
||||||
|
if (IS_ERR(ssp))
|
||||||
|
return PTR_ERR(ssp);
|
||||||
|
if (!ssp)
|
||||||
|
ssp = &platform_info->ssp;
|
||||||
|
|
||||||
|
return pxa2xx_spi_probe(dev, ssp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pxa2xx_spi_platform_remove(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
pxa2xx_spi_remove(&pdev->dev);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct acpi_device_id pxa2xx_spi_acpi_match[] = {
|
static const struct acpi_device_id pxa2xx_spi_acpi_match[] = {
|
||||||
{ "80860F0E" },
|
{ "80860F0E" },
|
||||||
{ "8086228E" },
|
{ "8086228E" },
|
||||||
@ -1732,8 +1746,8 @@ static struct platform_driver driver = {
|
|||||||
.acpi_match_table = pxa2xx_spi_acpi_match,
|
.acpi_match_table = pxa2xx_spi_acpi_match,
|
||||||
.of_match_table = pxa2xx_spi_of_match,
|
.of_match_table = pxa2xx_spi_of_match,
|
||||||
},
|
},
|
||||||
.probe = pxa2xx_spi_probe,
|
.probe = pxa2xx_spi_platform_probe,
|
||||||
.remove_new = pxa2xx_spi_remove,
|
.remove_new = pxa2xx_spi_platform_remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init pxa2xx_spi_init(void)
|
static int __init pxa2xx_spi_init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user