diff options
author | David Kilroy <kilroyd@googlemail.com> | 2010-05-01 09:05:38 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-05-03 14:53:06 -0400 |
commit | b42f2074dedef559ecf72dce61a6501f9f9b273a (patch) | |
tree | d75bfd6c7e6db6fd5e81310b3326d2aad5829041 /drivers/net/wireless/orinoco/hermes.h | |
parent | f7c65594f7148b778f41d591a701e94bb22428e4 (diff) |
orinoco: add hermes_ops
Pave the way for introducing USB alternative functions.
Force callers to dereference ops instead of providing wrappers.
Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco/hermes.h')
-rw-r--r-- | drivers/net/wireless/orinoco/hermes.h | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/drivers/net/wireless/orinoco/hermes.h b/drivers/net/wireless/orinoco/hermes.h index 2dddbb597c4d..18b268c54dfe 100644 --- a/drivers/net/wireless/orinoco/hermes.h +++ b/drivers/net/wireless/orinoco/hermes.h | |||
@@ -374,6 +374,27 @@ struct hermes_multicast { | |||
374 | /* Timeouts */ | 374 | /* Timeouts */ |
375 | #define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us */ | 375 | #define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us */ |
376 | 376 | ||
377 | struct hermes; | ||
378 | |||
379 | /* Functions to access hardware */ | ||
380 | struct hermes_ops { | ||
381 | int (*init)(struct hermes *hw); | ||
382 | int (*cmd_wait)(struct hermes *hw, u16 cmd, u16 parm0, | ||
383 | struct hermes_response *resp); | ||
384 | int (*init_cmd_wait)(struct hermes *hw, u16 cmd, | ||
385 | u16 parm0, u16 parm1, u16 parm2, | ||
386 | struct hermes_response *resp); | ||
387 | int (*allocate)(struct hermes *hw, u16 size, u16 *fid); | ||
388 | int (*read_ltv)(struct hermes *hw, int bap, u16 rid, unsigned buflen, | ||
389 | u16 *length, void *buf); | ||
390 | int (*write_ltv)(struct hermes *hw, int bap, u16 rid, | ||
391 | u16 length, const void *value); | ||
392 | int (*bap_pread)(struct hermes *hw, int bap, void *buf, int len, | ||
393 | u16 id, u16 offset); | ||
394 | int (*bap_pwrite)(struct hermes *hw, int bap, const void *buf, | ||
395 | int len, u16 id, u16 offset); | ||
396 | }; | ||
397 | |||
377 | /* Basic control structure */ | 398 | /* Basic control structure */ |
378 | typedef struct hermes { | 399 | typedef struct hermes { |
379 | void __iomem *iobase; | 400 | void __iomem *iobase; |
@@ -381,6 +402,7 @@ typedef struct hermes { | |||
381 | #define HERMES_16BIT_REGSPACING 0 | 402 | #define HERMES_16BIT_REGSPACING 0 |
382 | #define HERMES_32BIT_REGSPACING 1 | 403 | #define HERMES_32BIT_REGSPACING 1 |
383 | u16 inten; /* Which interrupts should be enabled? */ | 404 | u16 inten; /* Which interrupts should be enabled? */ |
405 | const struct hermes_ops *ops; | ||
384 | } hermes_t; | 406 | } hermes_t; |
385 | 407 | ||
386 | /* Register access convenience macros */ | 408 | /* Register access convenience macros */ |
@@ -394,22 +416,6 @@ typedef struct hermes { | |||
394 | 416 | ||
395 | /* Function prototypes */ | 417 | /* Function prototypes */ |
396 | void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing); | 418 | void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing); |
397 | int hermes_init(hermes_t *hw); | ||
398 | int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0, | ||
399 | struct hermes_response *resp); | ||
400 | int hermes_doicmd_wait(hermes_t *hw, u16 cmd, | ||
401 | u16 parm0, u16 parm1, u16 parm2, | ||
402 | struct hermes_response *resp); | ||
403 | int hermes_allocate(hermes_t *hw, u16 size, u16 *fid); | ||
404 | |||
405 | int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len, | ||
406 | u16 id, u16 offset); | ||
407 | int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, | ||
408 | u16 id, u16 offset); | ||
409 | int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen, | ||
410 | u16 *length, void *buf); | ||
411 | int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, | ||
412 | u16 length, const void *value); | ||
413 | 419 | ||
414 | /* Inline functions */ | 420 | /* Inline functions */ |
415 | 421 | ||
@@ -426,13 +432,13 @@ static inline void hermes_set_irqmask(hermes_t *hw, u16 events) | |||
426 | 432 | ||
427 | static inline int hermes_enable_port(hermes_t *hw, int port) | 433 | static inline int hermes_enable_port(hermes_t *hw, int port) |
428 | { | 434 | { |
429 | return hermes_docmd_wait(hw, HERMES_CMD_ENABLE | (port << 8), | 435 | return hw->ops->cmd_wait(hw, HERMES_CMD_ENABLE | (port << 8), |
430 | 0, NULL); | 436 | 0, NULL); |
431 | } | 437 | } |
432 | 438 | ||
433 | static inline int hermes_disable_port(hermes_t *hw, int port) | 439 | static inline int hermes_disable_port(hermes_t *hw, int port) |
434 | { | 440 | { |
435 | return hermes_docmd_wait(hw, HERMES_CMD_DISABLE | (port << 8), | 441 | return hw->ops->cmd_wait(hw, HERMES_CMD_DISABLE | (port << 8), |
436 | 0, NULL); | 442 | 0, NULL); |
437 | } | 443 | } |
438 | 444 | ||
@@ -440,7 +446,7 @@ static inline int hermes_disable_port(hermes_t *hw, int port) | |||
440 | * information frame in __orinoco_ev_info() */ | 446 | * information frame in __orinoco_ev_info() */ |
441 | static inline int hermes_inquire(hermes_t *hw, u16 rid) | 447 | static inline int hermes_inquire(hermes_t *hw, u16 rid) |
442 | { | 448 | { |
443 | return hermes_docmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL); | 449 | return hw->ops->cmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL); |
444 | } | 450 | } |
445 | 451 | ||
446 | #define HERMES_BYTES_TO_RECLEN(n) ((((n)+1)/2) + 1) | 452 | #define HERMES_BYTES_TO_RECLEN(n) ((((n)+1)/2) + 1) |
@@ -475,10 +481,10 @@ static inline void hermes_clear_words(struct hermes *hw, int off, | |||
475 | } | 481 | } |
476 | 482 | ||
477 | #define HERMES_READ_RECORD(hw, bap, rid, buf) \ | 483 | #define HERMES_READ_RECORD(hw, bap, rid, buf) \ |
478 | (hermes_read_ltv((hw), (bap), (rid), sizeof(*buf), NULL, (buf))) | 484 | (hw->ops->read_ltv((hw), (bap), (rid), sizeof(*buf), NULL, (buf))) |
479 | #define HERMES_WRITE_RECORD(hw, bap, rid, buf) \ | 485 | #define HERMES_WRITE_RECORD(hw, bap, rid, buf) \ |
480 | (hermes_write_ltv((hw), (bap), (rid), \ | 486 | (hw->ops->write_ltv((hw), (bap), (rid), \ |
481 | HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf))) | 487 | HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf))) |
482 | 488 | ||
483 | static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word) | 489 | static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word) |
484 | { | 490 | { |