| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com |
|---|
| 3 | 4 | * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 7 | | - * published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | 5 | */ |
|---|
| 10 | 6 | #include <linux/slab.h> |
|---|
| 11 | 7 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 137 | 133 | const struct of_device_id *match; |
|---|
| 138 | 134 | struct device_node *dma_node; |
|---|
| 139 | 135 | struct ti_am335x_xbar_data *xbar; |
|---|
| 140 | | - struct resource *res; |
|---|
| 141 | 136 | void __iomem *iomem; |
|---|
| 142 | 137 | int i, ret; |
|---|
| 143 | 138 | |
|---|
| .. | .. |
|---|
| 177 | 172 | xbar->xbar_events = TI_AM335X_XBAR_LINES; |
|---|
| 178 | 173 | } |
|---|
| 179 | 174 | |
|---|
| 180 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 181 | | - iomem = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 175 | + iomem = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 182 | 176 | if (IS_ERR(iomem)) |
|---|
| 183 | 177 | return PTR_ERR(iomem); |
|---|
| 184 | 178 | |
|---|
| .. | .. |
|---|
| 251 | 245 | if (dma_spec->args[0] >= xbar->xbar_requests) { |
|---|
| 252 | 246 | dev_err(&pdev->dev, "Invalid XBAR request number: %d\n", |
|---|
| 253 | 247 | dma_spec->args[0]); |
|---|
| 248 | + put_device(&pdev->dev); |
|---|
| 254 | 249 | return ERR_PTR(-EINVAL); |
|---|
| 255 | 250 | } |
|---|
| 256 | 251 | |
|---|
| .. | .. |
|---|
| 258 | 253 | dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); |
|---|
| 259 | 254 | if (!dma_spec->np) { |
|---|
| 260 | 255 | dev_err(&pdev->dev, "Can't get DMA master\n"); |
|---|
| 256 | + put_device(&pdev->dev); |
|---|
| 261 | 257 | return ERR_PTR(-EINVAL); |
|---|
| 262 | 258 | } |
|---|
| 263 | 259 | |
|---|
| 264 | 260 | map = kzalloc(sizeof(*map), GFP_KERNEL); |
|---|
| 265 | 261 | if (!map) { |
|---|
| 266 | 262 | of_node_put(dma_spec->np); |
|---|
| 263 | + put_device(&pdev->dev); |
|---|
| 267 | 264 | return ERR_PTR(-ENOMEM); |
|---|
| 268 | 265 | } |
|---|
| 269 | 266 | |
|---|
| .. | .. |
|---|
| 274 | 271 | mutex_unlock(&xbar->mutex); |
|---|
| 275 | 272 | dev_err(&pdev->dev, "Run out of free DMA requests\n"); |
|---|
| 276 | 273 | kfree(map); |
|---|
| 274 | + of_node_put(dma_spec->np); |
|---|
| 275 | + put_device(&pdev->dev); |
|---|
| 277 | 276 | return ERR_PTR(-ENOMEM); |
|---|
| 278 | 277 | } |
|---|
| 279 | 278 | set_bit(map->xbar_out, xbar->dma_inuse); |
|---|
| .. | .. |
|---|
| 327 | 326 | struct device_node *dma_node; |
|---|
| 328 | 327 | struct ti_dra7_xbar_data *xbar; |
|---|
| 329 | 328 | struct property *prop; |
|---|
| 330 | | - struct resource *res; |
|---|
| 331 | 329 | u32 safe_val; |
|---|
| 332 | 330 | int sz; |
|---|
| 333 | 331 | void __iomem *iomem; |
|---|
| .. | .. |
|---|
| 407 | 405 | kfree(rsv_events); |
|---|
| 408 | 406 | } |
|---|
| 409 | 407 | |
|---|
| 410 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 411 | | - iomem = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 408 | + iomem = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 412 | 409 | if (IS_ERR(iomem)) |
|---|
| 413 | 410 | return PTR_ERR(iomem); |
|---|
| 414 | 411 | |
|---|