diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-11-04 12:34:53 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-06 16:48:53 -0500 |
commit | 7a345d3d2512769ca693d4844b215ae2cc267dce (patch) | |
tree | e5479eec7a1d8f9e5eaf06beb4b97f16dcc1ceab /drivers | |
parent | ee134fcc552e17e708346a183076db21b8c49188 (diff) |
rt2800usb: convert to use struct rt2800_ops methods
Add chipset registers access abstraction layer and prepare for later
code unification.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.c | 13 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.h | 44 |
2 files changed, 51 insertions, 6 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 3783fdc4251f..a3ec97a4c744 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -2627,10 +2627,23 @@ static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2627 | return 0; | 2627 | return 0; |
2628 | } | 2628 | } |
2629 | 2629 | ||
2630 | static const struct rt2800_ops rt2800usb_rt2800_ops = { | ||
2631 | .register_read = rt2x00usb_register_read, | ||
2632 | .register_write = rt2x00usb_register_write, | ||
2633 | .register_write_lock = rt2x00usb_register_write_lock, | ||
2634 | |||
2635 | .register_multiread = rt2x00usb_register_multiread, | ||
2636 | .register_multiwrite = rt2x00usb_register_multiwrite, | ||
2637 | |||
2638 | .regbusy_read = rt2x00usb_regbusy_read, | ||
2639 | }; | ||
2640 | |||
2630 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) | 2641 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) |
2631 | { | 2642 | { |
2632 | int retval; | 2643 | int retval; |
2633 | 2644 | ||
2645 | rt2x00dev->priv = (void *)&rt2800usb_rt2800_ops; | ||
2646 | |||
2634 | /* | 2647 | /* |
2635 | * Allocate eeprom data. | 2648 | * Allocate eeprom data. |
2636 | */ | 2649 | */ |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.h b/drivers/net/wireless/rt2x00/rt2800usb.h index 180dfce41b20..6524d72631cd 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.h +++ b/drivers/net/wireless/rt2x00/rt2800usb.h | |||
@@ -27,39 +27,69 @@ | |||
27 | #ifndef RT2800USB_H | 27 | #ifndef RT2800USB_H |
28 | #define RT2800USB_H | 28 | #define RT2800USB_H |
29 | 29 | ||
30 | struct rt2800_ops { | ||
31 | void (*register_read)(struct rt2x00_dev *rt2x00dev, | ||
32 | const unsigned int offset, u32 *value); | ||
33 | void (*register_write)(struct rt2x00_dev *rt2x00dev, | ||
34 | const unsigned int offset, u32 value); | ||
35 | void (*register_write_lock)(struct rt2x00_dev *rt2x00dev, | ||
36 | const unsigned int offset, u32 value); | ||
37 | |||
38 | void (*register_multiread)(struct rt2x00_dev *rt2x00dev, | ||
39 | const unsigned int offset, | ||
40 | void *value, const u32 length); | ||
41 | void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev, | ||
42 | const unsigned int offset, | ||
43 | void *value, const u32 length); | ||
44 | |||
45 | int (*regbusy_read)(struct rt2x00_dev *rt2x00dev, | ||
46 | const unsigned int offset, | ||
47 | struct rt2x00_field32 field, u32 *reg); | ||
48 | }; | ||
49 | |||
30 | static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev, | 50 | static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev, |
31 | const unsigned int offset, | 51 | const unsigned int offset, |
32 | u32 *value) | 52 | u32 *value) |
33 | { | 53 | { |
34 | rt2x00usb_register_read(rt2x00dev, offset, value); | 54 | const struct rt2800_ops *rt2800ops = rt2x00dev->priv; |
55 | |||
56 | rt2800ops->register_read(rt2x00dev, offset, value); | ||
35 | } | 57 | } |
36 | 58 | ||
37 | static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev, | 59 | static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev, |
38 | const unsigned int offset, | 60 | const unsigned int offset, |
39 | u32 value) | 61 | u32 value) |
40 | { | 62 | { |
41 | rt2x00usb_register_write(rt2x00dev, offset, value); | 63 | const struct rt2800_ops *rt2800ops = rt2x00dev->priv; |
64 | |||
65 | rt2800ops->register_write(rt2x00dev, offset, value); | ||
42 | } | 66 | } |
43 | 67 | ||
44 | static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev, | 68 | static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev, |
45 | const unsigned int offset, | 69 | const unsigned int offset, |
46 | u32 value) | 70 | u32 value) |
47 | { | 71 | { |
48 | rt2x00usb_register_write_lock(rt2x00dev, offset, value); | 72 | const struct rt2800_ops *rt2800ops = rt2x00dev->priv; |
73 | |||
74 | rt2800ops->register_write_lock(rt2x00dev, offset, value); | ||
49 | } | 75 | } |
50 | 76 | ||
51 | static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev, | 77 | static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev, |
52 | const unsigned int offset, | 78 | const unsigned int offset, |
53 | void *value, const u32 length) | 79 | void *value, const u32 length) |
54 | { | 80 | { |
55 | rt2x00usb_register_multiread(rt2x00dev, offset, value, length); | 81 | const struct rt2800_ops *rt2800ops = rt2x00dev->priv; |
82 | |||
83 | rt2800ops->register_multiread(rt2x00dev, offset, value, length); | ||
56 | } | 84 | } |
57 | 85 | ||
58 | static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev, | 86 | static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev, |
59 | const unsigned int offset, | 87 | const unsigned int offset, |
60 | void *value, const u32 length) | 88 | void *value, const u32 length) |
61 | { | 89 | { |
62 | rt2x00usb_register_multiwrite(rt2x00dev, offset, value, length); | 90 | const struct rt2800_ops *rt2800ops = rt2x00dev->priv; |
91 | |||
92 | rt2800ops->register_multiwrite(rt2x00dev, offset, value, length); | ||
63 | } | 93 | } |
64 | 94 | ||
65 | static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, | 95 | static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, |
@@ -67,7 +97,9 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, | |||
67 | struct rt2x00_field32 field, | 97 | struct rt2x00_field32 field, |
68 | u32 *reg) | 98 | u32 *reg) |
69 | { | 99 | { |
70 | return rt2x00usb_regbusy_read(rt2x00dev, offset, field, reg); | 100 | const struct rt2800_ops *rt2800ops = rt2x00dev->priv; |
101 | |||
102 | return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg); | ||
71 | } | 103 | } |
72 | 104 | ||
73 | /* | 105 | /* |