Lines Matching +full:device +full:- +full:addr

1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/device.h>
19 void devm_ioremap_release(struct device *dev, void *res)
24 static int devm_ioremap_match(struct device *dev, void *res, void *match_data)
29 static void __iomem *__devm_ioremap(struct device *dev, resource_size_t offset,
33 void __iomem **ptr, *addr = NULL;
42 addr = ioremap(offset, size);
45 addr = ioremap_uc(offset, size);
48 addr = ioremap_wc(offset, size);
51 addr = ioremap_np(offset, size);
55 if (addr) {
56 *ptr = addr;
61 return addr;
65 * devm_ioremap - Managed ioremap()
66 * @dev: Generic device to remap IO address for
72 void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
80 * devm_ioremap_uc - Managed ioremap_uc()
81 * @dev: Generic device to remap IO address for
87 void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset,
95 * devm_ioremap_wc - Managed ioremap_wc()
96 * @dev: Generic device to remap IO address for
102 void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
110 * devm_iounmap - Managed iounmap()
111 * @dev: Generic device to unmap for
112 * @addr: Address to unmap
114 * Managed iounmap(). @addr must have been mapped using devm_ioremap*().
116 void devm_iounmap(struct device *dev, void __iomem *addr)
119 (__force void *)addr));
120 iounmap(addr);
125 __devm_ioremap_resource(struct device *dev, const struct resource *res,
136 ret = dev_err_probe(dev, -EINVAL, "invalid resource %pR\n", res);
140 if (type == DEVM_IOREMAP && res->flags & IORESOURCE_MEM_NONPOSTED)
145 if (res->name)
147 dev_name(dev), res->name);
151 ret = dev_err_probe(dev, -ENOMEM, "can't generate pretty name for resource %pR\n", res);
155 if (!devm_request_mem_region(dev, res->start, size, pretty_name)) {
156 ret = dev_err_probe(dev, -EBUSY, "can't request region for resource %pR\n", res);
160 dest_ptr = __devm_ioremap(dev, res->start, size, type);
162 devm_release_mem_region(dev, res->start, size);
163 ret = dev_err_probe(dev, -ENOMEM, "ioremap failed for resource %pR\n", res);
171 * devm_ioremap_resource() - check, request region, and ioremap resource
172 * @dev: generic device to handle the resource for
182 * base = devm_ioremap_resource(&pdev->dev, res);
189 void __iomem *devm_ioremap_resource(struct device *dev,
197 * devm_ioremap_resource_wc() - write-combined variant of
199 * @dev: generic device to handle the resource for
205 void __iomem *devm_ioremap_resource_wc(struct device *dev,
212 * devm_of_iomap - Requests a resource and maps the memory mapped IO
213 * for a given device_node managed by a given device
217 * on driver detach of the device.
219 * This is to be used when a device requests/maps resources described
220 * by other device tree nodes (children or otherwise).
222 * @dev: The device "managing" the resource
223 * @node: The device-tree node where the resource resides
229 * base = devm_of_iomap(&pdev->dev, node, 0, NULL);
233 * Please Note: This is not a one-to-one replacement for of_iomap() because the
236 * but the devm_of_iomap() function will return -EBUSY.
241 void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index,
247 return IOMEM_ERR_PTR(-EINVAL);
258 static void devm_ioport_map_release(struct device *dev, void *res)
263 static int devm_ioport_map_match(struct device *dev, void *res,
270 * devm_ioport_map - Managed ioport_map()
271 * @dev: Generic device to map ioport for
280 void __iomem *devm_ioport_map(struct device *dev, unsigned long port,
283 void __iomem **ptr, *addr;
290 addr = ioport_map(port, nr);
291 if (addr) {
292 *ptr = addr;
297 return addr;
302 * devm_ioport_unmap - Managed ioport_unmap()
303 * @dev: Generic device to unmap for
304 * @addr: Address to unmap
306 * Managed ioport_unmap(). @addr must have been mapped using
309 void devm_ioport_unmap(struct device *dev, void __iomem *addr)
311 ioport_unmap(addr);
313 devm_ioport_map_match, (__force void *)addr));
318 static void devm_arch_phys_ac_add_release(struct device *dev, void *res)
324 * devm_arch_phys_wc_add - Managed arch_phys_wc_add()
325 * @dev: Managed device
332 int devm_arch_phys_wc_add(struct device *dev, unsigned long base, unsigned long size)
340 return -ENOMEM;
360 static void devm_arch_io_free_memtype_wc_release(struct device *dev, void *res)
364 arch_io_free_memtype_wc(this->start, this->size);
368 * devm_arch_io_reserve_memtype_wc - Managed arch_io_reserve_memtype_wc()
369 * @dev: Managed device
377 int devm_arch_io_reserve_memtype_wc(struct device *dev, resource_size_t start,
386 return -ENOMEM;
394 dr->start = start;
395 dr->size = size;