dev-audio declares two devices:
struct platform_device s5pv210_device_iis0 = {
63 .name = "samsung-i2s",
64 .id = 0,
65 .num_resources = ARRAY_SIZE(s5pv210_iis0_resource),
66 .resource = s5pv210_iis0_resource,
67 .dev = {
68 .platform_data = &i2sv5_pdata,
69 },
70 };
76 static struct resource s5pv210_iis1_resource[] = {
77 [0] = DEFINE_RES_MEM(S5PV210_PA_IIS1, SZ_256),
78 [1] = DEFINE_RES_DMA(DMACH_I2S1_TX),
79 [2] = DEFINE_RES_DMA(DMACH_I2S1_RX),
80 };
81
82 struct platform_device s5pv210_device_iis1 = {
83 .name = "samsung-i2s",
84 .id = 1,
85 .num_resources = ARRAY_SIZE(s5pv210_iis1_resource),
86 .resource = s5pv210_iis1_resource,
87 .dev = {
88 .platform_data = &i2sv3_pdata,
89 },
90 };
91
92 static struct resource s5pv210_iis2_resource[] = {
93 [0] = DEFINE_RES_MEM(S5PV210_PA_IIS2, SZ_256),
94 [1] = DEFINE_RES_DMA(DMACH_I2S2_TX),
95 [2] = DEFINE_RES_DMA(DMACH_I2S2_RX),
96 };
The two devices are 2 instances of the i2s driver.
Assuming I add a function EXPORT_SYMBOL in i2s driver, which will be used by 2 different kernel modules.
How can I declare and use such an exported function doing the following:
if (called from kernel module 1):
i2s_rxctrl the device id=0
elif (called from kernel module 2):
i2s_rxctrl the device id=1
There is one-to-one mapping of a kernel module to device id.
So basically what I ask is how to make the exported symbol to be Object oriented style so for each instance it will execute code specific to the device. I thought to give the kernel module an handle to *pdev but it seems to be a violation.