Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| devm_ioremap_resource [2018/07/30 16:40] – [Broadcom Cygnus] rpjday | devm_ioremap_resource [2018/07/31 11:59] (current) – [platform_get_resource()] rpjday | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Overview ===== | ===== Overview ===== | ||
| - | Explain '' | + | Explain '' |
| - | ===== Let's talk about resources ===== | + | ===== struct resource |
| - | + | ||
| - | ==== struct resource ==== | + | |
| From '' | From '' | ||
| Line 24: | Line 22: | ||
| </ | </ | ||
| - | + | In particular, one resource | |
| - | A small sample of resource | + | |
| < | < | ||
| Line 40: | Line 37: | ||
| </ | </ | ||
| - | ==== struct platform_device ==== | + | Here's a single example from '' |
| - | From '' | + | < |
| + | static struct resource edma_resources[] = { | ||
| + | { | ||
| + | .name = " | ||
| + | .start | ||
| + | .end = 0x01c00000 + SZ_64K - 1, | ||
| + | .flags | ||
| + | }, | ||
| + | { | ||
| + | .name = " | ||
| + | .start | ||
| + | .end = 0x01c10000 + SZ_1K - 1, | ||
| + | .flags | ||
| + | }, | ||
| + | { | ||
| + | .name = " | ||
| + | .start | ||
| + | .end = 0x01c10400 + SZ_1K - 1, | ||
| + | .flags | ||
| + | }, | ||
| + | ... snip ... | ||
| + | </ | ||
| + | ===== struct platform_device ===== | ||
| + | |||
| + | From '' | ||
| < | < | ||
| Line 72: | Line 93: | ||
| ===== platform_get_resource() ===== | ===== platform_get_resource() ===== | ||
| - | From '' | + | From '' |
| < | < | ||
| Line 95: | Line 116: | ||
| return NULL; | return NULL; | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | You can also get a resource by an optional name: | ||
| + | |||
| + | < | ||
| + | /** | ||
| + | * 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-> | ||
| + | struct resource *r = & | ||
| + | |||
| + | if (unlikely(!r-> | ||
| + | continue; | ||
| + | |||
| + | if (type == resource_type(r) && !strcmp(r-> | ||
| + | return r; | ||
| + | } | ||
| </ | </ | ||