hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/dma/acpi-dma.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ACPI helpers for DMA request / controller
34 *
....@@ -6,13 +7,10 @@
67 * Copyright (C) 2013, Intel Corporation
78 * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
89 * Mika Westerberg <mika.westerberg@linux.intel.com>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License version 2 as
12
- * published by the Free Software Foundation.
1310 */
1411
1512 #include <linux/device.h>
13
+#include <linux/dma-mapping.h>
1614 #include <linux/err.h>
1715 #include <linux/module.h>
1816 #include <linux/kernel.h>
....@@ -89,6 +87,12 @@
8987 if (si->base_request_line == 0 && si->num_handshake_signals == 0)
9088 return 0;
9189
90
+ /* Set up DMA mask based on value from CSRT */
91
+ ret = dma_coerce_mask_and_coherent(&adev->dev,
92
+ DMA_BIT_MASK(si->dma_address_width));
93
+ if (ret)
94
+ return 0;
95
+
9296 adma->base_request_line = si->base_request_line;
9397 adma->end_request_line = si->base_request_line +
9498 si->num_handshake_signals - 1;
....@@ -149,7 +153,7 @@
149153 * @dev: struct device of DMA controller
150154 * @acpi_dma_xlate: translation function which converts a dma specifier
151155 * into a dma_chan structure
152
- * @data pointer to controller specific data to be used by
156
+ * @data: pointer to controller specific data to be used by
153157 * translation function
154158 *
155159 * Allocated memory should be freed with appropriate acpi_dma_controller_free()
....@@ -233,7 +237,7 @@
233237 * devm_acpi_dma_controller_register - resource managed acpi_dma_controller_register()
234238 * @dev: device that is registering this DMA controller
235239 * @acpi_dma_xlate: translation function
236
- * @data pointer to controller specific data
240
+ * @data: pointer to controller specific data
237241 *
238242 * Managed acpi_dma_controller_register(). DMA controller registered by this
239243 * function are automatically freed on driver detach. See
....@@ -266,6 +270,7 @@
266270
267271 /**
268272 * devm_acpi_dma_controller_free - resource managed acpi_dma_controller_free()
273
+ * @dev: device that is unregistering as DMA controller
269274 *
270275 * Unregister a DMA controller registered with
271276 * devm_acpi_dma_controller_register(). Normally this function will not need to
....@@ -359,19 +364,12 @@
359364 {
360365 struct acpi_dma_parser_data pdata;
361366 struct acpi_dma_spec *dma_spec = &pdata.dma_spec;
367
+ struct acpi_device *adev = ACPI_COMPANION(dev);
362368 struct list_head resource_list;
363
- struct acpi_device *adev;
364369 struct acpi_dma *adma;
365370 struct dma_chan *chan = NULL;
366371 int found;
367
-
368
- /* Check if the device was enumerated by ACPI */
369
- if (!dev)
370
- return ERR_PTR(-ENODEV);
371
-
372
- adev = ACPI_COMPANION(dev);
373
- if (!adev)
374
- return ERR_PTR(-ENODEV);
372
+ int ret;
375373
376374 memset(&pdata, 0, sizeof(pdata));
377375 pdata.index = index;
....@@ -381,9 +379,11 @@
381379 dma_spec->slave_id = -1;
382380
383381 INIT_LIST_HEAD(&resource_list);
384
- acpi_dev_get_resources(adev, &resource_list,
385
- acpi_dma_parse_fixed_dma, &pdata);
382
+ ret = acpi_dev_get_resources(adev, &resource_list,
383
+ acpi_dma_parse_fixed_dma, &pdata);
386384 acpi_dev_free_resource_list(&resource_list);
385
+ if (ret < 0)
386
+ return ERR_PTR(ret);
387387
388388 if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0)
389389 return ERR_PTR(-ENODEV);