Skip to content

Commit 9495b7e

Browse files
storulfgregkh
authored andcommitted
driver core: platform: Initialize dma_parms for platform devices
It's currently the platform driver's responsibility to initialize the pointer, dma_parms, for its corresponding struct device. The benefit with this approach allows us to avoid the initialization and to not waste memory for the struct device_dma_parameters, as this can be decided on a case by case basis. However, it has turned out that this approach is not very practical. Not only does it lead to open coding, but also to real errors. In principle callers of dma_set_max_seg_size() doesn't check the error code, but just assumes it succeeds. For these reasons, let's do the initialization from the common platform bus at the device registration point. This also follows the way the PCI devices are being managed, see pci_device_add(). Suggested-by: Christoph Hellwig <[email protected]> Cc: <[email protected]> Tested-by: Haibo Chen <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Ulf Hansson <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6a8b55e commit 9495b7e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

drivers/base/platform.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ struct platform_object {
380380
*/
381381
static void setup_pdev_dma_masks(struct platform_device *pdev)
382382
{
383+
pdev->dev.dma_parms = &pdev->dma_parms;
384+
383385
if (!pdev->dev.coherent_dma_mask)
384386
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
385387
if (!pdev->dev.dma_mask) {

include/linux/platform_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct platform_device {
2525
bool id_auto;
2626
struct device dev;
2727
u64 platform_dma_mask;
28+
struct device_dma_parameters dma_parms;
2829
u32 num_resources;
2930
struct resource *resource;
3031

0 commit comments

Comments
 (0)