Platform device resource source code analysis questions-Linux general technology-Linux programming and kernel information, the following is a detailed reading. When studying the driver of the platform device today, view the source code of the kernel to obtain the resource function as follows/drivers/base/platform. c:
Struct resource * platform_get_resource (struct platform_device * dev,
Unsigned int type, unsigned int num)
{
Int I;
For (I = 0; I <dev-> num_resources; I ++ ){
Struct resource * r = & dev-> resource
;
If (type = resource_type (r) & num -- = 0) Return r; } Return NULL; } As marked in red above, I don't understand why I create pointer variables in the for () loop. if there are multiple loops, the same variables will be created again? Should it be changed: Struct resource * platform_get_resource (struct platform_device * dev, Unsigned int type, unsigned int num) { Int I; Struct resource * r;
For (I = 0; I <dev-> num_resources; I ++ ){ R = & dev-> resource;
If (type = resource_type (r) & num -- = 0) Return r; } Return NULL; }
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service