// SPDX-License-Identifier: GPL-2.0/* * platform.c - platform 'pseudo' bus for legacy devices * * Copyright (c) 2002-3 Patrick Mochel * Copyright (c) 2002-3 Open Source Development Labs * * Please see Documentation/driver-api/driver-model/platform.rst for more * information. */#include<linux/string.h>#include<linux/platform_device.h>#include<linux/of_device.h>#include<linux/of_irq.h>#include<linux/module.h>#include<linux/init.h>#include<linux/dma-mapping.h>#include<linux/memblock.h>#include<linux/err.h>#include<linux/slab.h>#include<linux/pm_runtime.h>#include<linux/pm_domain.h>#include<linux/idr.h>#include<linux/acpi.h>#include<linux/clk/clk-conf.h>#include<linux/limits.h>#include<linux/property.h>#include<linux/kmemleak.h>#include<linux/types.h>#include"base.h"#include"power/power.h"/* For automatically allocated device IDs */staticDEFINE_IDA(platform_devid_ida);structdeviceplatform_bus={.init_name="platform",};EXPORT_SYMBOL_GPL(platform_bus);/** * platform_get_resource - get a resource for a device * @dev: platform device * @type: resource type * @num: resource index * * Return: a pointer to the resource or NULL on failure. */structresource*platform_get_resource(structplatform_device*dev,unsignedinttype,unsignedintnum){u32i;for(i=0;i<dev->num_resources;i++){structresource*r=&dev->resource[i];if(type==resource_type(r)&&num--==0)returnr;}returnNULL;}EXPORT_SYMBOL_GPL(platform_get_resource);#ifdef CONFIG_HAS_IOMEM/** * devm_platform_get_and_ioremap_resource - call devm_ioremap_resource() for a * platform device and get resource * * @pdev: platform device to use both for memory resource lookup as well as * resource management * @index: resource index * @res: optional output parameter to store a pointer to the obtained resource. * * Return: a pointer to the remapped memory or an ERR_PTR() encoded error code * on failure. */void__iomem*devm_platform_get_and_ioremap_resource(