- 论坛徽章:
- 0
|
在s3c2410fb.c中,在平台相关的设备探测函数中有这么一段code,请高手帮忙看看。
static int __init s3c2410fb_probe(struct platform_device *pdev)
{
……
static struct s3c2410fb_mach_info *mach_info;
……
mach_info = pdev->dev.platform_data;
if (mach_info == NULL)
{
dev_err(&pdev->dev,"no platform data for lcd, cannot attach\n");
return -EINVAL;
}
mregs = &mach_info->regs;
……
}
mach_info,platform_data和platform_device的声明如下:
struct s3c2410fb_mach_info {
unsigned char fixed_syncs; /* do not update sync/border */
/* Screen size */
int width;
int height;
/* Screen info */
struct s3c2410fb_val xres;
struct s3c2410fb_val yres;
struct s3c2410fb_val bpp;
/* lcd configuration registers */
struct s3c2410fb_hw regs;
/* GPIOs */
unsigned long gpcup;
unsigned long gpcup_mask;
unsigned long gpccon;
unsigned long gpccon_mask;
unsigned long gpdup;
unsigned long gpdup_mask;
unsigned long gpdcon;
unsigned long gpdcon_mask;
/* lpc3600 control register */
unsigned long lpcsel;
};
struct device {
struct klist klist_children;
struct klist_node knode_parent; /* node in sibling list */
struct klist_node knode_driver;
struct klist_node knode_bus;
struct device * parent;
struct kobject kobj;
char bus_id[BUS_ID_SIZE]; /* position on parent bus */
struct device_attribute uevent_attr;
struct semaphore sem; /* semaphore to synchronize calls to
* its driver.
*/
struct bus_type * bus; /* type of bus device is on */
struct device_driver *driver; /* which driver has allocated this
device */
void *driver_data; /* data private to the driver */
void *platform_data; /* Platform specific data, device
core doesn't touch it */
void *firmware_data; /* Firmware specific data (e.g. ACPI,
BIOS data),reserved for device core*/
struct dev_pm_info power;
u64 *dma_mask; /* dma mask (if dma'able device) */
u64 coherent_dma_mask;/* Like dma_mask, but for
alloc_coherent mappings as
not all hardware supports
64 bit addresses for consistent
allocations such descriptors. */
struct list_head dma_pools; /* dma pools (if dma'ble) */
struct dma_coherent_mem *dma_mem; /* internal for coherent mem
override */
void (*release)(struct device * dev);
};
struct platform_device {
const char * name;
u32 id;
struct device dev;
u32 num_resources;
struct resource * resource;
};
请问上面那段代码怎么理解?代码的细节可以参看内核源代码。fb核心是怎样用这么个void *得到设备信息的?
[ 本帖最后由 grep_one 于 2006-4-12 09:54 编辑 ] |
|