driver core: initialize a default DMA mask for platform device
We still treat devices without a DMA mask as defaulting to 32-bits for both mask, but a few releases ago we've started warning about such cases, as they require special cases to work around this sloppyness. Add a dma_mask field to struct platform_device so that we can initialize the dma_mask pointer in struct device and initialize both masks to 32-bits by default, replacing similar functionality in m68k and powerpc. The arch_setup_pdev_archdata hooks is now unused and removed. Note that the code looks a little odd with the various conditionals because we have to support platform_device structures that are statically allocated. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Link: https://lore.kernel.org/r/20190816062435.881-7-hch@lst.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
bd5defaee8
commit
cdfee56232
@@ -39,25 +39,6 @@ struct device platform_bus = {
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(platform_bus);
|
||||
|
||||
/**
|
||||
* arch_setup_pdev_archdata - Allow manipulation of archdata before its used
|
||||
* @pdev: platform device
|
||||
*
|
||||
* This is called before platform_device_add() such that any pdev_archdata may
|
||||
* be setup before the platform_notifier is called. So if a user needs to
|
||||
* manipulate any relevant information in the pdev_archdata they can do:
|
||||
*
|
||||
* platform_device_alloc()
|
||||
* ... manipulate ...
|
||||
* platform_device_add()
|
||||
*
|
||||
* And if they don't care they can just call platform_device_register() and
|
||||
* everything will just work out.
|
||||
*/
|
||||
void __weak arch_setup_pdev_archdata(struct platform_device *pdev)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* platform_get_resource - get a resource for a device
|
||||
* @dev: platform device
|
||||
@@ -264,6 +245,20 @@ struct platform_object {
|
||||
char name[];
|
||||
};
|
||||
|
||||
/*
|
||||
* Set up default DMA mask for platform devices if the they weren't
|
||||
* previously set by the architecture / DT.
|
||||
*/
|
||||
static void setup_pdev_dma_masks(struct platform_device *pdev)
|
||||
{
|
||||
if (!pdev->dev.coherent_dma_mask)
|
||||
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
|
||||
if (!pdev->dma_mask)
|
||||
pdev->dma_mask = DMA_BIT_MASK(32);
|
||||
if (!pdev->dev.dma_mask)
|
||||
pdev->dev.dma_mask = &pdev->dma_mask;
|
||||
};
|
||||
|
||||
/**
|
||||
* platform_device_put - destroy a platform device
|
||||
* @pdev: platform device to free
|
||||
@@ -310,7 +305,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
|
||||
pa->pdev.id = id;
|
||||
device_initialize(&pa->pdev.dev);
|
||||
pa->pdev.dev.release = platform_device_release;
|
||||
arch_setup_pdev_archdata(&pa->pdev);
|
||||
setup_pdev_dma_masks(&pa->pdev);
|
||||
}
|
||||
|
||||
return pa ? &pa->pdev : NULL;
|
||||
@@ -512,7 +507,7 @@ EXPORT_SYMBOL_GPL(platform_device_del);
|
||||
int platform_device_register(struct platform_device *pdev)
|
||||
{
|
||||
device_initialize(&pdev->dev);
|
||||
arch_setup_pdev_archdata(pdev);
|
||||
setup_pdev_dma_masks(pdev);
|
||||
return platform_device_add(pdev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(platform_device_register);
|
||||
|
Reference in New Issue
Block a user