Commit c64eb62c authored by Yangtao Li's avatar Yangtao Li Committed by Michael S. Tsirkin

virtio-mmio: convert to devm_platform_ioremap_resource

Use devm_platform_ioremap_resource() to simplify code, which
contains platform_get_resource, devm_request_mem_region and
devm_ioremap.
Signed-off-by: default avatarYangtao Li <tiny.windzz@gmail.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent d5226fa6
...@@ -531,18 +531,9 @@ static void virtio_mmio_release_dev(struct device *_d) ...@@ -531,18 +531,9 @@ static void virtio_mmio_release_dev(struct device *_d)
static int virtio_mmio_probe(struct platform_device *pdev) static int virtio_mmio_probe(struct platform_device *pdev)
{ {
struct virtio_mmio_device *vm_dev; struct virtio_mmio_device *vm_dev;
struct resource *mem;
unsigned long magic; unsigned long magic;
int rc; int rc;
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem)
return -EINVAL;
if (!devm_request_mem_region(&pdev->dev, mem->start,
resource_size(mem), pdev->name))
return -EBUSY;
vm_dev = devm_kzalloc(&pdev->dev, sizeof(*vm_dev), GFP_KERNEL); vm_dev = devm_kzalloc(&pdev->dev, sizeof(*vm_dev), GFP_KERNEL);
if (!vm_dev) if (!vm_dev)
return -ENOMEM; return -ENOMEM;
...@@ -554,9 +545,9 @@ static int virtio_mmio_probe(struct platform_device *pdev) ...@@ -554,9 +545,9 @@ static int virtio_mmio_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&vm_dev->virtqueues); INIT_LIST_HEAD(&vm_dev->virtqueues);
spin_lock_init(&vm_dev->lock); spin_lock_init(&vm_dev->lock);
vm_dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); vm_dev->base = devm_platform_ioremap_resource(pdev, 0);
if (vm_dev->base == NULL) if (IS_ERR(vm_dev->base))
return -EFAULT; return PTR_ERR(vm_dev->base);
/* Check magic value */ /* Check magic value */
magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE); magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment