User Tools

Site Tools


devm_ioremap_resource

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
devm_ioremap_resource [2018/07/31 10:34]
rpjday [struct resource]
devm_ioremap_resource [2018/07/31 11:59] (current)
rpjday [platform_get_resource()]
Line 1: Line 1:
 ===== Overview ===== ===== Overview =====
  
-Explain ''​devm_ioremap_resource()'',​ with examples. Add some links.+Explain ''​devm_ioremap_resource()'',​ with examples ​particularly related to memory regions. Add some links.
  
 ===== struct resource ===== ===== struct resource =====
Line 37: Line 37:
 </​code>​ </​code>​
  
-Here's a single example from ''​arch/​arm/​mach-davinci/​dm355.c'':​+Here's a single example from ''​arch/​arm/​mach-davinci/​dm355.c''​, defining an array of resources:
  
 <​code>​ <​code>​
Line 63: Line 63:
 ===== struct platform_device ===== ===== struct platform_device =====
  
-From ''​include/​linux/​platform_device.h'':​+From ''​include/​linux/​platform_device.h''​, showing how a ''​platform_device''​ can represent any number of resources:
  
 <​code>​ <​code>​
Line 93: Line 93:
 ===== platform_get_resource() ===== ===== platform_get_resource() =====
  
-From ''​drivers/​base/​platform.c'',​ given a platform device ​and a resource type, return that resource type or ''​NULL'':​+From ''​drivers/​base/​platform.c'',​ given a ''​struct platform_device *dev'' ​and a resource type, return that (numbered) ​resource type or ''​NULL'':​
  
 <​code>​ <​code>​
Line 116: Line 116:
  return NULL;  return NULL;
 } }
 +</​code>​
 +
 +You can also get a resource by an optional name:
 +
 +<​code>​
 +/**
 + * platform_get_resource_byname - get a resource for a device by name
 + * @dev: platform device
 + * @type: resource type
 + * @name: resource name
 + */
 +struct resource *platform_get_resource_byname(struct platform_device *dev,
 +                                              unsigned int type,
 +                                              const char *name)
 +{
 +        int i;
 +
 +        for (i = 0; i < dev->​num_resources;​ i++) {
 +                struct resource *r = &​dev->​resource[i];​
 +
 +                if (unlikely(!r->​name))
 +                        continue;
 +
 +                if (type == resource_type(r) && !strcmp(r->​name,​ name))
 +                        return r;
 +        }
 </​code>​ </​code>​
  
devm_ioremap_resource.1533033245.txt.gz ยท Last modified: 2018/07/31 10:34 by rpjday