Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * FIXME: Properly make this race free with refcounting etc... |
| 4 | * |
| 5 | * FIXME: LOCKING !!! |
| 6 | */ |
| 7 | |
| 8 | #include <linux/config.h> |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/delay.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/spinlock.h> |
| 13 | #include <linux/module.h> |
| 14 | |
| 15 | #include <asm/semaphore.h> |
| 16 | #include <asm/prom.h> |
| 17 | #include <asm/pmac_pfunc.h> |
| 18 | |
| 19 | /* Debug */ |
| 20 | #define LOG_PARSE(fmt...) |
| 21 | #define LOG_ERROR(fmt...) printk(fmt) |
| 22 | #define LOG_BLOB(t,b,c) |
Paul Mackerras | 76a0ee3 | 2006-03-03 20:50:29 +1100 | [diff] [blame] | 23 | |
| 24 | #undef DEBUG |
| 25 | #ifdef DEBUG |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 26 | #define DBG(fmt...) printk(fmt) |
Paul Mackerras | 76a0ee3 | 2006-03-03 20:50:29 +1100 | [diff] [blame] | 27 | #else |
| 28 | #define DBG(fmt...) |
| 29 | #endif |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 30 | |
| 31 | /* Command numbers */ |
| 32 | #define PMF_CMD_LIST 0 |
| 33 | #define PMF_CMD_WRITE_GPIO 1 |
| 34 | #define PMF_CMD_READ_GPIO 2 |
| 35 | #define PMF_CMD_WRITE_REG32 3 |
| 36 | #define PMF_CMD_READ_REG32 4 |
| 37 | #define PMF_CMD_WRITE_REG16 5 |
| 38 | #define PMF_CMD_READ_REG16 6 |
| 39 | #define PMF_CMD_WRITE_REG8 7 |
| 40 | #define PMF_CMD_READ_REG8 8 |
| 41 | #define PMF_CMD_DELAY 9 |
| 42 | #define PMF_CMD_WAIT_REG32 10 |
| 43 | #define PMF_CMD_WAIT_REG16 11 |
| 44 | #define PMF_CMD_WAIT_REG8 12 |
| 45 | #define PMF_CMD_READ_I2C 13 |
| 46 | #define PMF_CMD_WRITE_I2C 14 |
| 47 | #define PMF_CMD_RMW_I2C 15 |
| 48 | #define PMF_CMD_GEN_I2C 16 |
| 49 | #define PMF_CMD_SHIFT_BYTES_RIGHT 17 |
| 50 | #define PMF_CMD_SHIFT_BYTES_LEFT 18 |
| 51 | #define PMF_CMD_READ_CFG 19 |
| 52 | #define PMF_CMD_WRITE_CFG 20 |
| 53 | #define PMF_CMD_RMW_CFG 21 |
| 54 | #define PMF_CMD_READ_I2C_SUBADDR 22 |
| 55 | #define PMF_CMD_WRITE_I2C_SUBADDR 23 |
| 56 | #define PMF_CMD_SET_I2C_MODE 24 |
| 57 | #define PMF_CMD_RMW_I2C_SUBADDR 25 |
| 58 | #define PMF_CMD_READ_REG32_MASK_SHR_XOR 26 |
| 59 | #define PMF_CMD_READ_REG16_MASK_SHR_XOR 27 |
| 60 | #define PMF_CMD_READ_REG8_MASK_SHR_XOR 28 |
| 61 | #define PMF_CMD_WRITE_REG32_SHL_MASK 29 |
| 62 | #define PMF_CMD_WRITE_REG16_SHL_MASK 30 |
| 63 | #define PMF_CMD_WRITE_REG8_SHL_MASK 31 |
| 64 | #define PMF_CMD_MASK_AND_COMPARE 32 |
| 65 | #define PMF_CMD_COUNT 33 |
| 66 | |
| 67 | /* This structure holds the state of the parser while walking through |
| 68 | * a function definition |
| 69 | */ |
| 70 | struct pmf_cmd { |
| 71 | const void *cmdptr; |
| 72 | const void *cmdend; |
| 73 | struct pmf_function *func; |
| 74 | void *instdata; |
| 75 | struct pmf_args *args; |
| 76 | int error; |
| 77 | }; |
| 78 | |
| 79 | #if 0 |
| 80 | /* Debug output */ |
| 81 | static void print_blob(const char *title, const void *blob, int bytes) |
| 82 | { |
| 83 | printk("%s", title); |
| 84 | while(bytes--) { |
| 85 | printk("%02x ", *((u8 *)blob)); |
| 86 | blob += 1; |
| 87 | } |
| 88 | printk("\n"); |
| 89 | } |
| 90 | #endif |
| 91 | |
| 92 | /* |
| 93 | * Parser helpers |
| 94 | */ |
| 95 | |
| 96 | static u32 pmf_next32(struct pmf_cmd *cmd) |
| 97 | { |
| 98 | u32 value; |
| 99 | if ((cmd->cmdend - cmd->cmdptr) < 4) { |
| 100 | cmd->error = 1; |
| 101 | return 0; |
| 102 | } |
| 103 | value = *((u32 *)cmd->cmdptr); |
| 104 | cmd->cmdptr += 4; |
| 105 | return value; |
| 106 | } |
| 107 | |
| 108 | static const void* pmf_next_blob(struct pmf_cmd *cmd, int count) |
| 109 | { |
| 110 | const void *value; |
| 111 | if ((cmd->cmdend - cmd->cmdptr) < count) { |
| 112 | cmd->error = 1; |
| 113 | return NULL; |
| 114 | } |
| 115 | value = cmd->cmdptr; |
| 116 | cmd->cmdptr += count; |
| 117 | return value; |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * Individual command parsers |
| 122 | */ |
| 123 | |
| 124 | #define PMF_PARSE_CALL(name, cmd, handlers, p...) \ |
| 125 | do { \ |
| 126 | if (cmd->error) \ |
| 127 | return -ENXIO; \ |
| 128 | if (handlers == NULL) \ |
| 129 | return 0; \ |
| 130 | if (handlers->name) \ |
| 131 | return handlers->name(cmd->func, cmd->instdata, \ |
| 132 | cmd->args, p); \ |
| 133 | return -1; \ |
| 134 | } while(0) \ |
| 135 | |
| 136 | |
| 137 | static int pmf_parser_write_gpio(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 138 | { |
| 139 | u8 value = (u8)pmf_next32(cmd); |
| 140 | u8 mask = (u8)pmf_next32(cmd); |
| 141 | |
| 142 | LOG_PARSE("pmf: write_gpio(value: %02x, mask: %02x)\n", value, mask); |
| 143 | |
| 144 | PMF_PARSE_CALL(write_gpio, cmd, h, value, mask); |
| 145 | } |
| 146 | |
| 147 | static int pmf_parser_read_gpio(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 148 | { |
| 149 | u8 mask = (u8)pmf_next32(cmd); |
| 150 | int rshift = (int)pmf_next32(cmd); |
| 151 | u8 xor = (u8)pmf_next32(cmd); |
| 152 | |
| 153 | LOG_PARSE("pmf: read_gpio(mask: %02x, rshift: %d, xor: %02x)\n", |
| 154 | mask, rshift, xor); |
| 155 | |
| 156 | PMF_PARSE_CALL(read_gpio, cmd, h, mask, rshift, xor); |
| 157 | } |
| 158 | |
| 159 | static int pmf_parser_write_reg32(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 160 | { |
| 161 | u32 offset = pmf_next32(cmd); |
| 162 | u32 value = pmf_next32(cmd); |
| 163 | u32 mask = pmf_next32(cmd); |
| 164 | |
| 165 | LOG_PARSE("pmf: write_reg32(offset: %08x, value: %08x, mask: %08x)\n", |
| 166 | offset, value, mask); |
| 167 | |
| 168 | PMF_PARSE_CALL(write_reg32, cmd, h, offset, value, mask); |
| 169 | } |
| 170 | |
| 171 | static int pmf_parser_read_reg32(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 172 | { |
| 173 | u32 offset = pmf_next32(cmd); |
| 174 | |
| 175 | LOG_PARSE("pmf: read_reg32(offset: %08x)\n", offset); |
| 176 | |
| 177 | PMF_PARSE_CALL(read_reg32, cmd, h, offset); |
| 178 | } |
| 179 | |
| 180 | |
| 181 | static int pmf_parser_write_reg16(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 182 | { |
| 183 | u32 offset = pmf_next32(cmd); |
| 184 | u16 value = (u16)pmf_next32(cmd); |
| 185 | u16 mask = (u16)pmf_next32(cmd); |
| 186 | |
| 187 | LOG_PARSE("pmf: write_reg16(offset: %08x, value: %04x, mask: %04x)\n", |
| 188 | offset, value, mask); |
| 189 | |
| 190 | PMF_PARSE_CALL(write_reg16, cmd, h, offset, value, mask); |
| 191 | } |
| 192 | |
| 193 | static int pmf_parser_read_reg16(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 194 | { |
| 195 | u32 offset = pmf_next32(cmd); |
| 196 | |
| 197 | LOG_PARSE("pmf: read_reg16(offset: %08x)\n", offset); |
| 198 | |
| 199 | PMF_PARSE_CALL(read_reg16, cmd, h, offset); |
| 200 | } |
| 201 | |
| 202 | |
| 203 | static int pmf_parser_write_reg8(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 204 | { |
| 205 | u32 offset = pmf_next32(cmd); |
| 206 | u8 value = (u16)pmf_next32(cmd); |
| 207 | u8 mask = (u16)pmf_next32(cmd); |
| 208 | |
| 209 | LOG_PARSE("pmf: write_reg8(offset: %08x, value: %02x, mask: %02x)\n", |
| 210 | offset, value, mask); |
| 211 | |
| 212 | PMF_PARSE_CALL(write_reg8, cmd, h, offset, value, mask); |
| 213 | } |
| 214 | |
| 215 | static int pmf_parser_read_reg8(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 216 | { |
| 217 | u32 offset = pmf_next32(cmd); |
| 218 | |
| 219 | LOG_PARSE("pmf: read_reg8(offset: %08x)\n", offset); |
| 220 | |
| 221 | PMF_PARSE_CALL(read_reg8, cmd, h, offset); |
| 222 | } |
| 223 | |
| 224 | static int pmf_parser_delay(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 225 | { |
| 226 | u32 duration = pmf_next32(cmd); |
| 227 | |
| 228 | LOG_PARSE("pmf: delay(duration: %d us)\n", duration); |
| 229 | |
| 230 | PMF_PARSE_CALL(delay, cmd, h, duration); |
| 231 | } |
| 232 | |
| 233 | static int pmf_parser_wait_reg32(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 234 | { |
| 235 | u32 offset = pmf_next32(cmd); |
| 236 | u32 value = pmf_next32(cmd); |
| 237 | u32 mask = pmf_next32(cmd); |
| 238 | |
| 239 | LOG_PARSE("pmf: wait_reg32(offset: %08x, comp_value: %08x,mask: %08x)\n", |
| 240 | offset, value, mask); |
| 241 | |
| 242 | PMF_PARSE_CALL(wait_reg32, cmd, h, offset, value, mask); |
| 243 | } |
| 244 | |
| 245 | static int pmf_parser_wait_reg16(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 246 | { |
| 247 | u32 offset = pmf_next32(cmd); |
| 248 | u16 value = (u16)pmf_next32(cmd); |
| 249 | u16 mask = (u16)pmf_next32(cmd); |
| 250 | |
| 251 | LOG_PARSE("pmf: wait_reg16(offset: %08x, comp_value: %04x,mask: %04x)\n", |
| 252 | offset, value, mask); |
| 253 | |
| 254 | PMF_PARSE_CALL(wait_reg16, cmd, h, offset, value, mask); |
| 255 | } |
| 256 | |
| 257 | static int pmf_parser_wait_reg8(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 258 | { |
| 259 | u32 offset = pmf_next32(cmd); |
| 260 | u8 value = (u8)pmf_next32(cmd); |
| 261 | u8 mask = (u8)pmf_next32(cmd); |
| 262 | |
| 263 | LOG_PARSE("pmf: wait_reg8(offset: %08x, comp_value: %02x,mask: %02x)\n", |
| 264 | offset, value, mask); |
| 265 | |
| 266 | PMF_PARSE_CALL(wait_reg8, cmd, h, offset, value, mask); |
| 267 | } |
| 268 | |
| 269 | static int pmf_parser_read_i2c(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 270 | { |
| 271 | u32 bytes = pmf_next32(cmd); |
| 272 | |
| 273 | LOG_PARSE("pmf: read_i2c(bytes: %ud)\n", bytes); |
| 274 | |
| 275 | PMF_PARSE_CALL(read_i2c, cmd, h, bytes); |
| 276 | } |
| 277 | |
| 278 | static int pmf_parser_write_i2c(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 279 | { |
| 280 | u32 bytes = pmf_next32(cmd); |
| 281 | const void *blob = pmf_next_blob(cmd, bytes); |
| 282 | |
| 283 | LOG_PARSE("pmf: write_i2c(bytes: %ud) ...\n", bytes); |
| 284 | LOG_BLOB("pmf: data: \n", blob, bytes); |
| 285 | |
| 286 | PMF_PARSE_CALL(write_i2c, cmd, h, bytes, blob); |
| 287 | } |
| 288 | |
| 289 | |
| 290 | static int pmf_parser_rmw_i2c(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 291 | { |
| 292 | u32 maskbytes = pmf_next32(cmd); |
| 293 | u32 valuesbytes = pmf_next32(cmd); |
| 294 | u32 totalbytes = pmf_next32(cmd); |
| 295 | const void *maskblob = pmf_next_blob(cmd, maskbytes); |
| 296 | const void *valuesblob = pmf_next_blob(cmd, valuesbytes); |
| 297 | |
| 298 | LOG_PARSE("pmf: rmw_i2c(maskbytes: %ud, valuebytes: %ud, " |
| 299 | "totalbytes: %d) ...\n", |
| 300 | maskbytes, valuesbytes, totalbytes); |
| 301 | LOG_BLOB("pmf: mask data: \n", maskblob, maskbytes); |
| 302 | LOG_BLOB("pmf: values data: \n", valuesblob, valuesbytes); |
| 303 | |
| 304 | PMF_PARSE_CALL(rmw_i2c, cmd, h, maskbytes, valuesbytes, totalbytes, |
| 305 | maskblob, valuesblob); |
| 306 | } |
| 307 | |
| 308 | static int pmf_parser_read_cfg(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 309 | { |
| 310 | u32 offset = pmf_next32(cmd); |
| 311 | u32 bytes = pmf_next32(cmd); |
| 312 | |
| 313 | LOG_PARSE("pmf: read_cfg(offset: %x, bytes: %ud)\n", offset, bytes); |
| 314 | |
| 315 | PMF_PARSE_CALL(read_cfg, cmd, h, offset, bytes); |
| 316 | } |
| 317 | |
| 318 | |
| 319 | static int pmf_parser_write_cfg(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 320 | { |
| 321 | u32 offset = pmf_next32(cmd); |
| 322 | u32 bytes = pmf_next32(cmd); |
| 323 | const void *blob = pmf_next_blob(cmd, bytes); |
| 324 | |
| 325 | LOG_PARSE("pmf: write_cfg(offset: %x, bytes: %ud)\n", offset, bytes); |
| 326 | LOG_BLOB("pmf: data: \n", blob, bytes); |
| 327 | |
| 328 | PMF_PARSE_CALL(write_cfg, cmd, h, offset, bytes, blob); |
| 329 | } |
| 330 | |
| 331 | static int pmf_parser_rmw_cfg(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 332 | { |
| 333 | u32 offset = pmf_next32(cmd); |
| 334 | u32 maskbytes = pmf_next32(cmd); |
| 335 | u32 valuesbytes = pmf_next32(cmd); |
| 336 | u32 totalbytes = pmf_next32(cmd); |
| 337 | const void *maskblob = pmf_next_blob(cmd, maskbytes); |
| 338 | const void *valuesblob = pmf_next_blob(cmd, valuesbytes); |
| 339 | |
| 340 | LOG_PARSE("pmf: rmw_cfg(maskbytes: %ud, valuebytes: %ud," |
| 341 | " totalbytes: %d) ...\n", |
| 342 | maskbytes, valuesbytes, totalbytes); |
| 343 | LOG_BLOB("pmf: mask data: \n", maskblob, maskbytes); |
| 344 | LOG_BLOB("pmf: values data: \n", valuesblob, valuesbytes); |
| 345 | |
| 346 | PMF_PARSE_CALL(rmw_cfg, cmd, h, offset, maskbytes, valuesbytes, |
| 347 | totalbytes, maskblob, valuesblob); |
| 348 | } |
| 349 | |
| 350 | |
| 351 | static int pmf_parser_read_i2c_sub(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 352 | { |
| 353 | u8 subaddr = (u8)pmf_next32(cmd); |
| 354 | u32 bytes = pmf_next32(cmd); |
| 355 | |
| 356 | LOG_PARSE("pmf: read_i2c_sub(subaddr: %x, bytes: %ud)\n", |
| 357 | subaddr, bytes); |
| 358 | |
| 359 | PMF_PARSE_CALL(read_i2c_sub, cmd, h, subaddr, bytes); |
| 360 | } |
| 361 | |
| 362 | static int pmf_parser_write_i2c_sub(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 363 | { |
| 364 | u8 subaddr = (u8)pmf_next32(cmd); |
| 365 | u32 bytes = pmf_next32(cmd); |
| 366 | const void *blob = pmf_next_blob(cmd, bytes); |
| 367 | |
| 368 | LOG_PARSE("pmf: write_i2c_sub(subaddr: %x, bytes: %ud) ...\n", |
| 369 | subaddr, bytes); |
| 370 | LOG_BLOB("pmf: data: \n", blob, bytes); |
| 371 | |
| 372 | PMF_PARSE_CALL(write_i2c_sub, cmd, h, subaddr, bytes, blob); |
| 373 | } |
| 374 | |
| 375 | static int pmf_parser_set_i2c_mode(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 376 | { |
| 377 | u32 mode = pmf_next32(cmd); |
| 378 | |
| 379 | LOG_PARSE("pmf: set_i2c_mode(mode: %d)\n", mode); |
| 380 | |
| 381 | PMF_PARSE_CALL(set_i2c_mode, cmd, h, mode); |
| 382 | } |
| 383 | |
| 384 | |
| 385 | static int pmf_parser_rmw_i2c_sub(struct pmf_cmd *cmd, struct pmf_handlers *h) |
| 386 | { |
| 387 | u8 subaddr = (u8)pmf_next32(cmd); |
| 388 | u32 maskbytes = pmf_next32(cmd); |
| 389 | u32 valuesbytes = pmf_next32(cmd); |
| 390 | u32 totalbytes = pmf_next32(cmd); |
| 391 | const void *maskblob = pmf_next_blob(cmd, maskbytes); |
| 392 | const void *valuesblob = pmf_next_blob(cmd, valuesbytes); |
| 393 | |
| 394 | LOG_PARSE("pmf: rmw_i2c_sub(subaddr: %x, maskbytes: %ud, valuebytes: %ud" |
| 395 | ", totalbytes: %d) ...\n", |
| 396 | subaddr, maskbytes, valuesbytes, totalbytes); |
| 397 | LOG_BLOB("pmf: mask data: \n", maskblob, maskbytes); |
| 398 | LOG_BLOB("pmf: values data: \n", valuesblob, valuesbytes); |
| 399 | |
| 400 | PMF_PARSE_CALL(rmw_i2c_sub, cmd, h, subaddr, maskbytes, valuesbytes, |
| 401 | totalbytes, maskblob, valuesblob); |
| 402 | } |
| 403 | |
| 404 | static int pmf_parser_read_reg32_msrx(struct pmf_cmd *cmd, |
| 405 | struct pmf_handlers *h) |
| 406 | { |
| 407 | u32 offset = pmf_next32(cmd); |
| 408 | u32 mask = pmf_next32(cmd); |
| 409 | u32 shift = pmf_next32(cmd); |
| 410 | u32 xor = pmf_next32(cmd); |
| 411 | |
| 412 | LOG_PARSE("pmf: read_reg32_msrx(offset: %x, mask: %x, shift: %x," |
| 413 | " xor: %x\n", offset, mask, shift, xor); |
| 414 | |
| 415 | PMF_PARSE_CALL(read_reg32_msrx, cmd, h, offset, mask, shift, xor); |
| 416 | } |
| 417 | |
| 418 | static int pmf_parser_read_reg16_msrx(struct pmf_cmd *cmd, |
| 419 | struct pmf_handlers *h) |
| 420 | { |
| 421 | u32 offset = pmf_next32(cmd); |
| 422 | u32 mask = pmf_next32(cmd); |
| 423 | u32 shift = pmf_next32(cmd); |
| 424 | u32 xor = pmf_next32(cmd); |
| 425 | |
| 426 | LOG_PARSE("pmf: read_reg16_msrx(offset: %x, mask: %x, shift: %x," |
| 427 | " xor: %x\n", offset, mask, shift, xor); |
| 428 | |
| 429 | PMF_PARSE_CALL(read_reg16_msrx, cmd, h, offset, mask, shift, xor); |
| 430 | } |
| 431 | static int pmf_parser_read_reg8_msrx(struct pmf_cmd *cmd, |
| 432 | struct pmf_handlers *h) |
| 433 | { |
| 434 | u32 offset = pmf_next32(cmd); |
| 435 | u32 mask = pmf_next32(cmd); |
| 436 | u32 shift = pmf_next32(cmd); |
| 437 | u32 xor = pmf_next32(cmd); |
| 438 | |
| 439 | LOG_PARSE("pmf: read_reg8_msrx(offset: %x, mask: %x, shift: %x," |
| 440 | " xor: %x\n", offset, mask, shift, xor); |
| 441 | |
| 442 | PMF_PARSE_CALL(read_reg8_msrx, cmd, h, offset, mask, shift, xor); |
| 443 | } |
| 444 | |
| 445 | static int pmf_parser_write_reg32_slm(struct pmf_cmd *cmd, |
| 446 | struct pmf_handlers *h) |
| 447 | { |
| 448 | u32 offset = pmf_next32(cmd); |
| 449 | u32 shift = pmf_next32(cmd); |
| 450 | u32 mask = pmf_next32(cmd); |
| 451 | |
| 452 | LOG_PARSE("pmf: write_reg32_slm(offset: %x, shift: %x, mask: %x\n", |
| 453 | offset, shift, mask); |
| 454 | |
| 455 | PMF_PARSE_CALL(write_reg32_slm, cmd, h, offset, shift, mask); |
| 456 | } |
| 457 | |
| 458 | static int pmf_parser_write_reg16_slm(struct pmf_cmd *cmd, |
| 459 | struct pmf_handlers *h) |
| 460 | { |
| 461 | u32 offset = pmf_next32(cmd); |
| 462 | u32 shift = pmf_next32(cmd); |
| 463 | u32 mask = pmf_next32(cmd); |
| 464 | |
| 465 | LOG_PARSE("pmf: write_reg16_slm(offset: %x, shift: %x, mask: %x\n", |
| 466 | offset, shift, mask); |
| 467 | |
| 468 | PMF_PARSE_CALL(write_reg16_slm, cmd, h, offset, shift, mask); |
| 469 | } |
| 470 | |
| 471 | static int pmf_parser_write_reg8_slm(struct pmf_cmd *cmd, |
| 472 | struct pmf_handlers *h) |
| 473 | { |
| 474 | u32 offset = pmf_next32(cmd); |
| 475 | u32 shift = pmf_next32(cmd); |
| 476 | u32 mask = pmf_next32(cmd); |
| 477 | |
| 478 | LOG_PARSE("pmf: write_reg8_slm(offset: %x, shift: %x, mask: %x\n", |
| 479 | offset, shift, mask); |
| 480 | |
| 481 | PMF_PARSE_CALL(write_reg8_slm, cmd, h, offset, shift, mask); |
| 482 | } |
| 483 | |
| 484 | static int pmf_parser_mask_and_compare(struct pmf_cmd *cmd, |
| 485 | struct pmf_handlers *h) |
| 486 | { |
| 487 | u32 bytes = pmf_next32(cmd); |
| 488 | const void *maskblob = pmf_next_blob(cmd, bytes); |
| 489 | const void *valuesblob = pmf_next_blob(cmd, bytes); |
| 490 | |
| 491 | LOG_PARSE("pmf: mask_and_compare(length: %ud ...\n", bytes); |
| 492 | LOG_BLOB("pmf: mask data: \n", maskblob, bytes); |
| 493 | LOG_BLOB("pmf: values data: \n", valuesblob, bytes); |
| 494 | |
| 495 | PMF_PARSE_CALL(mask_and_compare, cmd, h, |
| 496 | bytes, maskblob, valuesblob); |
| 497 | } |
| 498 | |
| 499 | |
| 500 | typedef int (*pmf_cmd_parser_t)(struct pmf_cmd *cmd, struct pmf_handlers *h); |
| 501 | |
| 502 | static pmf_cmd_parser_t pmf_parsers[PMF_CMD_COUNT] = |
| 503 | { |
| 504 | NULL, |
| 505 | pmf_parser_write_gpio, |
| 506 | pmf_parser_read_gpio, |
| 507 | pmf_parser_write_reg32, |
| 508 | pmf_parser_read_reg32, |
| 509 | pmf_parser_write_reg16, |
| 510 | pmf_parser_read_reg16, |
| 511 | pmf_parser_write_reg8, |
| 512 | pmf_parser_read_reg8, |
| 513 | pmf_parser_delay, |
| 514 | pmf_parser_wait_reg32, |
| 515 | pmf_parser_wait_reg16, |
| 516 | pmf_parser_wait_reg8, |
| 517 | pmf_parser_read_i2c, |
| 518 | pmf_parser_write_i2c, |
| 519 | pmf_parser_rmw_i2c, |
| 520 | NULL, /* Bogus command */ |
| 521 | NULL, /* Shift bytes right: NYI */ |
| 522 | NULL, /* Shift bytes left: NYI */ |
| 523 | pmf_parser_read_cfg, |
| 524 | pmf_parser_write_cfg, |
| 525 | pmf_parser_rmw_cfg, |
| 526 | pmf_parser_read_i2c_sub, |
| 527 | pmf_parser_write_i2c_sub, |
| 528 | pmf_parser_set_i2c_mode, |
| 529 | pmf_parser_rmw_i2c_sub, |
| 530 | pmf_parser_read_reg32_msrx, |
| 531 | pmf_parser_read_reg16_msrx, |
| 532 | pmf_parser_read_reg8_msrx, |
| 533 | pmf_parser_write_reg32_slm, |
| 534 | pmf_parser_write_reg16_slm, |
| 535 | pmf_parser_write_reg8_slm, |
| 536 | pmf_parser_mask_and_compare, |
| 537 | }; |
| 538 | |
| 539 | struct pmf_device { |
| 540 | struct list_head link; |
| 541 | struct device_node *node; |
| 542 | struct pmf_handlers *handlers; |
| 543 | struct list_head functions; |
| 544 | struct kref ref; |
| 545 | }; |
| 546 | |
| 547 | static LIST_HEAD(pmf_devices); |
| 548 | static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED; |
| 549 | |
| 550 | static void pmf_release_device(struct kref *kref) |
| 551 | { |
| 552 | struct pmf_device *dev = container_of(kref, struct pmf_device, ref); |
| 553 | kfree(dev); |
| 554 | } |
| 555 | |
| 556 | static inline void pmf_put_device(struct pmf_device *dev) |
| 557 | { |
| 558 | kref_put(&dev->ref, pmf_release_device); |
| 559 | } |
| 560 | |
| 561 | static inline struct pmf_device *pmf_get_device(struct pmf_device *dev) |
| 562 | { |
| 563 | kref_get(&dev->ref); |
| 564 | return dev; |
| 565 | } |
| 566 | |
| 567 | static inline struct pmf_device *pmf_find_device(struct device_node *np) |
| 568 | { |
| 569 | struct pmf_device *dev; |
| 570 | |
| 571 | list_for_each_entry(dev, &pmf_devices, link) { |
| 572 | if (dev->node == np) |
| 573 | return pmf_get_device(dev); |
| 574 | } |
| 575 | return NULL; |
| 576 | } |
| 577 | |
| 578 | static int pmf_parse_one(struct pmf_function *func, |
| 579 | struct pmf_handlers *handlers, |
| 580 | void *instdata, struct pmf_args *args) |
| 581 | { |
| 582 | struct pmf_cmd cmd; |
| 583 | u32 ccode; |
| 584 | int count, rc; |
| 585 | |
| 586 | cmd.cmdptr = func->data; |
| 587 | cmd.cmdend = func->data + func->length; |
| 588 | cmd.func = func; |
| 589 | cmd.instdata = instdata; |
| 590 | cmd.args = args; |
| 591 | cmd.error = 0; |
| 592 | |
| 593 | LOG_PARSE("pmf: func %s, %d bytes, %s...\n", |
| 594 | func->name, func->length, |
| 595 | handlers ? "executing" : "parsing"); |
| 596 | |
| 597 | /* One subcommand to parse for now */ |
| 598 | count = 1; |
| 599 | |
| 600 | while(count-- && cmd.cmdptr < cmd.cmdend) { |
| 601 | /* Get opcode */ |
| 602 | ccode = pmf_next32(&cmd); |
| 603 | /* Check if we are hitting a command list, fetch new count */ |
| 604 | if (ccode == 0) { |
| 605 | count = pmf_next32(&cmd) - 1; |
| 606 | ccode = pmf_next32(&cmd); |
| 607 | } |
| 608 | if (cmd.error) { |
| 609 | LOG_ERROR("pmf: parse error, not enough data\n"); |
| 610 | return -ENXIO; |
| 611 | } |
| 612 | if (ccode >= PMF_CMD_COUNT) { |
| 613 | LOG_ERROR("pmf: command code %d unknown !\n", ccode); |
| 614 | return -ENXIO; |
| 615 | } |
| 616 | if (pmf_parsers[ccode] == NULL) { |
| 617 | LOG_ERROR("pmf: no parser for command %d !\n", ccode); |
| 618 | return -ENXIO; |
| 619 | } |
| 620 | rc = pmf_parsers[ccode](&cmd, handlers); |
| 621 | if (rc != 0) { |
| 622 | LOG_ERROR("pmf: parser for command %d returned" |
| 623 | " error %d\n", ccode, rc); |
| 624 | return rc; |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | /* We are doing an initial parse pass, we need to adjust the size */ |
| 629 | if (handlers == NULL) |
| 630 | func->length = cmd.cmdptr - func->data; |
| 631 | |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | static int pmf_add_function_prop(struct pmf_device *dev, void *driverdata, |
| 636 | const char *name, u32 *data, |
| 637 | unsigned int length) |
| 638 | { |
| 639 | int count = 0; |
| 640 | struct pmf_function *func = NULL; |
| 641 | |
| 642 | DBG("pmf: Adding functions for platform-do-%s\n", name); |
| 643 | |
| 644 | while (length >= 12) { |
| 645 | /* Allocate a structure */ |
| 646 | func = kzalloc(sizeof(struct pmf_function), GFP_KERNEL); |
| 647 | if (func == NULL) |
| 648 | goto bail; |
| 649 | kref_init(&func->ref); |
| 650 | INIT_LIST_HEAD(&func->irq_clients); |
| 651 | func->node = dev->node; |
| 652 | func->driver_data = driverdata; |
| 653 | func->name = name; |
| 654 | func->phandle = data[0]; |
| 655 | func->flags = data[1]; |
| 656 | data += 2; |
| 657 | length -= 8; |
| 658 | func->data = data; |
| 659 | func->length = length; |
| 660 | func->dev = dev; |
| 661 | DBG("pmf: idx %d: flags=%08x, phandle=%08x " |
| 662 | " %d bytes remaining, parsing...\n", |
| 663 | count+1, func->flags, func->phandle, length); |
| 664 | if (pmf_parse_one(func, NULL, NULL, NULL)) { |
| 665 | kfree(func); |
| 666 | goto bail; |
| 667 | } |
| 668 | length -= func->length; |
| 669 | data = (u32 *)(((u8 *)data) + func->length); |
| 670 | list_add(&func->link, &dev->functions); |
| 671 | pmf_get_device(dev); |
| 672 | count++; |
| 673 | } |
| 674 | bail: |
| 675 | DBG("pmf: Added %d functions\n", count); |
| 676 | |
| 677 | return count; |
| 678 | } |
| 679 | |
| 680 | static int pmf_add_functions(struct pmf_device *dev, void *driverdata) |
| 681 | { |
| 682 | struct property *pp; |
| 683 | #define PP_PREFIX "platform-do-" |
| 684 | const int plen = strlen(PP_PREFIX); |
| 685 | int count = 0; |
| 686 | |
| 687 | for (pp = dev->node->properties; pp != 0; pp = pp->next) { |
| 688 | char *name; |
| 689 | if (strncmp(pp->name, PP_PREFIX, plen) != 0) |
| 690 | continue; |
| 691 | name = pp->name + plen; |
| 692 | if (strlen(name) && pp->length >= 12) |
| 693 | count += pmf_add_function_prop(dev, driverdata, name, |
| 694 | (u32 *)pp->value, |
| 695 | pp->length); |
| 696 | } |
| 697 | return count; |
| 698 | } |
| 699 | |
| 700 | |
| 701 | int pmf_register_driver(struct device_node *np, |
| 702 | struct pmf_handlers *handlers, |
| 703 | void *driverdata) |
| 704 | { |
| 705 | struct pmf_device *dev; |
| 706 | unsigned long flags; |
| 707 | int rc = 0; |
| 708 | |
| 709 | if (handlers == NULL) |
| 710 | return -EINVAL; |
| 711 | |
| 712 | DBG("pmf: registering driver for node %s\n", np->full_name); |
| 713 | |
| 714 | spin_lock_irqsave(&pmf_lock, flags); |
| 715 | dev = pmf_find_device(np); |
| 716 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 717 | if (dev != NULL) { |
| 718 | DBG("pmf: already there !\n"); |
| 719 | pmf_put_device(dev); |
| 720 | return -EBUSY; |
| 721 | } |
| 722 | |
| 723 | dev = kzalloc(sizeof(struct pmf_device), GFP_KERNEL); |
| 724 | if (dev == NULL) { |
| 725 | DBG("pmf: no memory !\n"); |
| 726 | return -ENOMEM; |
| 727 | } |
| 728 | kref_init(&dev->ref); |
| 729 | dev->node = of_node_get(np); |
| 730 | dev->handlers = handlers; |
| 731 | INIT_LIST_HEAD(&dev->functions); |
| 732 | |
| 733 | rc = pmf_add_functions(dev, driverdata); |
| 734 | if (rc == 0) { |
| 735 | DBG("pmf: no functions, disposing.. \n"); |
| 736 | of_node_put(np); |
| 737 | kfree(dev); |
| 738 | return -ENODEV; |
| 739 | } |
| 740 | |
| 741 | spin_lock_irqsave(&pmf_lock, flags); |
| 742 | list_add(&dev->link, &pmf_devices); |
| 743 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 744 | |
| 745 | return 0; |
| 746 | } |
| 747 | EXPORT_SYMBOL_GPL(pmf_register_driver); |
| 748 | |
| 749 | struct pmf_function *pmf_get_function(struct pmf_function *func) |
| 750 | { |
| 751 | if (!try_module_get(func->dev->handlers->owner)) |
| 752 | return NULL; |
| 753 | kref_get(&func->ref); |
| 754 | return func; |
| 755 | } |
| 756 | EXPORT_SYMBOL_GPL(pmf_get_function); |
| 757 | |
| 758 | static void pmf_release_function(struct kref *kref) |
| 759 | { |
| 760 | struct pmf_function *func = |
| 761 | container_of(kref, struct pmf_function, ref); |
| 762 | pmf_put_device(func->dev); |
| 763 | kfree(func); |
| 764 | } |
| 765 | |
| 766 | static inline void __pmf_put_function(struct pmf_function *func) |
| 767 | { |
| 768 | kref_put(&func->ref, pmf_release_function); |
| 769 | } |
| 770 | |
| 771 | void pmf_put_function(struct pmf_function *func) |
| 772 | { |
| 773 | if (func == NULL) |
| 774 | return; |
| 775 | module_put(func->dev->handlers->owner); |
| 776 | __pmf_put_function(func); |
| 777 | } |
| 778 | EXPORT_SYMBOL_GPL(pmf_put_function); |
| 779 | |
| 780 | void pmf_unregister_driver(struct device_node *np) |
| 781 | { |
| 782 | struct pmf_device *dev; |
| 783 | unsigned long flags; |
| 784 | |
| 785 | DBG("pmf: unregistering driver for node %s\n", np->full_name); |
| 786 | |
| 787 | spin_lock_irqsave(&pmf_lock, flags); |
| 788 | dev = pmf_find_device(np); |
| 789 | if (dev == NULL) { |
| 790 | DBG("pmf: not such driver !\n"); |
| 791 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 792 | return; |
| 793 | } |
| 794 | list_del(&dev->link); |
| 795 | |
| 796 | while(!list_empty(&dev->functions)) { |
| 797 | struct pmf_function *func = |
| 798 | list_entry(dev->functions.next, typeof(*func), link); |
| 799 | list_del(&func->link); |
| 800 | __pmf_put_function(func); |
| 801 | } |
| 802 | |
| 803 | pmf_put_device(dev); |
| 804 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 805 | } |
| 806 | EXPORT_SYMBOL_GPL(pmf_unregister_driver); |
| 807 | |
| 808 | struct pmf_function *__pmf_find_function(struct device_node *target, |
| 809 | const char *name, u32 flags) |
| 810 | { |
| 811 | struct device_node *actor = of_node_get(target); |
| 812 | struct pmf_device *dev; |
| 813 | struct pmf_function *func, *result = NULL; |
| 814 | char fname[64]; |
| 815 | u32 *prop, ph; |
| 816 | |
| 817 | /* |
| 818 | * Look for a "platform-*" function reference. If we can't find |
| 819 | * one, then we fallback to a direct call attempt |
| 820 | */ |
| 821 | snprintf(fname, 63, "platform-%s", name); |
| 822 | prop = (u32 *)get_property(target, fname, NULL); |
| 823 | if (prop == NULL) |
| 824 | goto find_it; |
| 825 | ph = *prop; |
| 826 | if (ph == 0) |
| 827 | goto find_it; |
| 828 | |
| 829 | /* |
| 830 | * Ok, now try to find the actor. If we can't find it, we fail, |
| 831 | * there is no point in falling back there |
| 832 | */ |
| 833 | of_node_put(actor); |
| 834 | actor = of_find_node_by_phandle(ph); |
| 835 | if (actor == NULL) |
| 836 | return NULL; |
| 837 | find_it: |
| 838 | dev = pmf_find_device(actor); |
| 839 | if (dev == NULL) |
| 840 | return NULL; |
| 841 | |
| 842 | list_for_each_entry(func, &dev->functions, link) { |
| 843 | if (name && strcmp(name, func->name)) |
| 844 | continue; |
| 845 | if (func->phandle && target->node != func->phandle) |
| 846 | continue; |
| 847 | if ((func->flags & flags) == 0) |
| 848 | continue; |
| 849 | result = func; |
| 850 | break; |
| 851 | } |
| 852 | of_node_put(actor); |
| 853 | pmf_put_device(dev); |
| 854 | return result; |
| 855 | } |
| 856 | |
| 857 | |
| 858 | int pmf_register_irq_client(struct device_node *target, |
| 859 | const char *name, |
| 860 | struct pmf_irq_client *client) |
| 861 | { |
| 862 | struct pmf_function *func; |
| 863 | unsigned long flags; |
| 864 | |
| 865 | spin_lock_irqsave(&pmf_lock, flags); |
| 866 | func = __pmf_find_function(target, name, PMF_FLAGS_INT_GEN); |
| 867 | if (func == NULL) { |
| 868 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 869 | return -ENODEV; |
| 870 | } |
Ben Collins | cc0fa84 | 2006-02-01 03:04:47 -0800 | [diff] [blame] | 871 | if (list_empty(&func->irq_clients)) |
| 872 | func->dev->handlers->irq_enable(func); |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 873 | list_add(&client->link, &func->irq_clients); |
Ben Collins | cc0fa84 | 2006-02-01 03:04:47 -0800 | [diff] [blame] | 874 | client->func = func; |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 875 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 876 | |
| 877 | return 0; |
| 878 | } |
| 879 | EXPORT_SYMBOL_GPL(pmf_register_irq_client); |
| 880 | |
Ben Collins | cc0fa84 | 2006-02-01 03:04:47 -0800 | [diff] [blame] | 881 | void pmf_unregister_irq_client(struct pmf_irq_client *client) |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 882 | { |
Ben Collins | cc0fa84 | 2006-02-01 03:04:47 -0800 | [diff] [blame] | 883 | struct pmf_function *func = client->func; |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 884 | unsigned long flags; |
| 885 | |
Ben Collins | cc0fa84 | 2006-02-01 03:04:47 -0800 | [diff] [blame] | 886 | BUG_ON(func == NULL); |
| 887 | |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 888 | spin_lock_irqsave(&pmf_lock, flags); |
Ben Collins | cc0fa84 | 2006-02-01 03:04:47 -0800 | [diff] [blame] | 889 | client->func = NULL; |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 890 | list_del(&client->link); |
Ben Collins | cc0fa84 | 2006-02-01 03:04:47 -0800 | [diff] [blame] | 891 | if (list_empty(&func->irq_clients)) |
| 892 | func->dev->handlers->irq_disable(func); |
Benjamin Herrenschmidt | 5b9ca52 | 2006-01-07 11:41:02 +1100 | [diff] [blame] | 893 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 894 | } |
| 895 | EXPORT_SYMBOL_GPL(pmf_unregister_irq_client); |
| 896 | |
| 897 | |
| 898 | void pmf_do_irq(struct pmf_function *func) |
| 899 | { |
| 900 | unsigned long flags; |
| 901 | struct pmf_irq_client *client; |
| 902 | |
| 903 | /* For now, using a spinlock over the whole function. Can be made |
| 904 | * to drop the lock using 2 lists if necessary |
| 905 | */ |
| 906 | spin_lock_irqsave(&pmf_lock, flags); |
| 907 | list_for_each_entry(client, &func->irq_clients, link) { |
| 908 | if (!try_module_get(client->owner)) |
| 909 | continue; |
| 910 | client->handler(client->data); |
| 911 | module_put(client->owner); |
| 912 | } |
| 913 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 914 | } |
| 915 | EXPORT_SYMBOL_GPL(pmf_do_irq); |
| 916 | |
| 917 | |
| 918 | int pmf_call_one(struct pmf_function *func, struct pmf_args *args) |
| 919 | { |
| 920 | struct pmf_device *dev = func->dev; |
| 921 | void *instdata = NULL; |
| 922 | int rc = 0; |
| 923 | |
| 924 | DBG(" ** pmf_call_one(%s/%s) **\n", dev->node->full_name, func->name); |
| 925 | |
| 926 | if (dev->handlers->begin) |
| 927 | instdata = dev->handlers->begin(func, args); |
| 928 | rc = pmf_parse_one(func, dev->handlers, instdata, args); |
| 929 | if (dev->handlers->end) |
| 930 | dev->handlers->end(func, instdata); |
| 931 | |
| 932 | return rc; |
| 933 | } |
| 934 | EXPORT_SYMBOL_GPL(pmf_call_one); |
| 935 | |
| 936 | int pmf_do_functions(struct device_node *np, const char *name, |
| 937 | u32 phandle, u32 fflags, struct pmf_args *args) |
| 938 | { |
| 939 | struct pmf_device *dev; |
| 940 | struct pmf_function *func, *tmp; |
| 941 | unsigned long flags; |
| 942 | int rc = -ENODEV; |
| 943 | |
| 944 | spin_lock_irqsave(&pmf_lock, flags); |
| 945 | |
| 946 | dev = pmf_find_device(np); |
| 947 | if (dev == NULL) { |
| 948 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 949 | return -ENODEV; |
| 950 | } |
| 951 | list_for_each_entry_safe(func, tmp, &dev->functions, link) { |
| 952 | if (name && strcmp(name, func->name)) |
| 953 | continue; |
| 954 | if (phandle && func->phandle && phandle != func->phandle) |
| 955 | continue; |
| 956 | if ((func->flags & fflags) == 0) |
| 957 | continue; |
| 958 | if (pmf_get_function(func) == NULL) |
| 959 | continue; |
| 960 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 961 | rc = pmf_call_one(func, args); |
| 962 | pmf_put_function(func); |
| 963 | spin_lock_irqsave(&pmf_lock, flags); |
| 964 | } |
| 965 | pmf_put_device(dev); |
| 966 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 967 | |
| 968 | return rc; |
| 969 | } |
| 970 | EXPORT_SYMBOL_GPL(pmf_do_functions); |
| 971 | |
| 972 | |
| 973 | struct pmf_function *pmf_find_function(struct device_node *target, |
| 974 | const char *name) |
| 975 | { |
| 976 | struct pmf_function *func; |
| 977 | unsigned long flags; |
| 978 | |
| 979 | spin_lock_irqsave(&pmf_lock, flags); |
| 980 | func = __pmf_find_function(target, name, PMF_FLAGS_ON_DEMAND); |
| 981 | if (func) |
| 982 | func = pmf_get_function(func); |
| 983 | spin_unlock_irqrestore(&pmf_lock, flags); |
| 984 | return func; |
| 985 | } |
| 986 | EXPORT_SYMBOL_GPL(pmf_find_function); |
| 987 | |
| 988 | int pmf_call_function(struct device_node *target, const char *name, |
| 989 | struct pmf_args *args) |
| 990 | { |
| 991 | struct pmf_function *func = pmf_find_function(target, name); |
| 992 | int rc; |
| 993 | |
| 994 | if (func == NULL) |
| 995 | return -ENODEV; |
| 996 | |
| 997 | rc = pmf_call_one(func, args); |
| 998 | pmf_put_function(func); |
| 999 | return rc; |
| 1000 | } |
| 1001 | EXPORT_SYMBOL_GPL(pmf_call_function); |
| 1002 | |