Commit b0a1edab authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by John W. Linville

rt2800pci: convert to use struct rt2800_ops methods

Add chipset registers access abstraction layer and prepare for later
code unification.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Acked-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7a345d3d
...@@ -2988,10 +2988,23 @@ static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) ...@@ -2988,10 +2988,23 @@ static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
return 0; return 0;
} }
static const struct rt2800_ops rt2800pci_rt2800_ops = {
.register_read = rt2x00pci_register_read,
.register_write = rt2x00pci_register_write,
.register_write_lock = rt2x00pci_register_write, /* same for PCI */
.register_multiread = rt2x00pci_register_multiread,
.register_multiwrite = rt2x00pci_register_multiwrite,
.regbusy_read = rt2x00pci_regbusy_read,
};
static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev) static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
{ {
int retval; int retval;
rt2x00dev->priv = (void *)&rt2800pci_rt2800_ops;
/* /*
* Allocate eeprom data. * Allocate eeprom data.
*/ */
......
...@@ -27,32 +27,60 @@ ...@@ -27,32 +27,60 @@
#ifndef RT2800PCI_H #ifndef RT2800PCI_H
#define RT2800PCI_H #define RT2800PCI_H
struct rt2800_ops {
void (*register_read)(struct rt2x00_dev *rt2x00dev,
const unsigned int offset, u32 *value);
void (*register_write)(struct rt2x00_dev *rt2x00dev,
const unsigned int offset, u32 value);
void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
const unsigned int offset, u32 value);
void (*register_multiread)(struct rt2x00_dev *rt2x00dev,
const unsigned int offset,
void *value, const u16 length);
void (*register_multiwrite)(struct rt2x00_dev *rt2x00dev,
const unsigned int offset,
const void *value, const u16 length);
int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
const unsigned int offset,
const struct rt2x00_field32 field, u32 *reg);
};
static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev, static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
const unsigned int offset, const unsigned int offset,
u32 *value) u32 *value)
{ {
rt2x00pci_register_read(rt2x00dev, offset, value); const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
rt2800ops->register_read(rt2x00dev, offset, value);
} }
static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev, static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
const unsigned int offset, const unsigned int offset,
u32 value) u32 value)
{ {
rt2x00pci_register_write(rt2x00dev, offset, value); const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
rt2800ops->register_write(rt2x00dev, offset, value);
} }
static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev, static inline void rt2800_register_write_lock(struct rt2x00_dev *rt2x00dev,
const unsigned int offset, const unsigned int offset,
u32 value) u32 value)
{ {
rt2x00pci_register_write(rt2x00dev, offset, value); const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
rt2800ops->register_write_lock(rt2x00dev, offset, value);
} }
static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev, static inline void rt2800_register_multiread(struct rt2x00_dev *rt2x00dev,
const unsigned int offset, const unsigned int offset,
void *value, const u16 length) void *value, const u16 length)
{ {
rt2x00pci_register_multiread(rt2x00dev, offset, value, length); const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
rt2800ops->register_multiread(rt2x00dev, offset, value, length);
} }
static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev, static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
...@@ -60,7 +88,9 @@ static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev, ...@@ -60,7 +88,9 @@ static inline void rt2800_register_multiwrite(struct rt2x00_dev *rt2x00dev,
const void *value, const void *value,
const u16 length) const u16 length)
{ {
rt2x00pci_register_multiwrite(rt2x00dev, offset, value, length); const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
rt2800ops->register_multiwrite(rt2x00dev, offset, value, length);
} }
static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
...@@ -68,7 +98,9 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, ...@@ -68,7 +98,9 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
const struct rt2x00_field32 field, const struct rt2x00_field32 field,
u32 *reg) u32 *reg)
{ {
return rt2x00pci_regbusy_read(rt2x00dev, offset, field, reg); const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment