Commit 6b81745e authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Kalle Valo
Browse files

rt2x00: change function pointers for register accessors



This prepares the driver for changing all the 'read' register accessors
to return the value instead of passing it by reference. Since a lot
of them are used in callbacks, this takes care of the callbacks first,
adding a couple of helpers that will be removed again one at a time.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4bc606af
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -164,10 +164,20 @@ static void rt2400pci_eepromregister_write(struct eeprom_93cx6 *eeprom)
}

#ifdef CONFIG_RT2X00_LIB_DEBUGFS
static u8 _rt2400pci_bbp_read(struct rt2x00_dev *rt2x00dev,
			      const unsigned int word)
{
	u8 value;

	rt2400pci_bbp_read(rt2x00dev, word, &value);

	return value;
}

static const struct rt2x00debug rt2400pci_rt2x00debug = {
	.owner	= THIS_MODULE,
	.csr	= {
		.read		= rt2x00mmio_register_read,
		.read		= _rt2x00mmio_register_read,
		.write		= rt2x00mmio_register_write,
		.flags		= RT2X00DEBUGFS_OFFSET,
		.word_base	= CSR_REG_BASE,
@@ -175,21 +185,21 @@ static const struct rt2x00debug rt2400pci_rt2x00debug = {
		.word_count	= CSR_REG_SIZE / sizeof(u32),
	},
	.eeprom	= {
		.read		= rt2x00_eeprom_read,
		.read		= _rt2x00_eeprom_read,
		.write		= rt2x00_eeprom_write,
		.word_base	= EEPROM_BASE,
		.word_size	= sizeof(u16),
		.word_count	= EEPROM_SIZE / sizeof(u16),
	},
	.bbp	= {
		.read		= rt2400pci_bbp_read,
		.read		= _rt2400pci_bbp_read,
		.write		= rt2400pci_bbp_write,
		.word_base	= BBP_BASE,
		.word_size	= sizeof(u8),
		.word_count	= BBP_SIZE / sizeof(u8),
	},
	.rf	= {
		.read		= rt2x00_rf_read,
		.read		= _rt2x00_rf_read,
		.write		= rt2400pci_rf_write,
		.word_base	= RF_BASE,
		.word_size	= sizeof(u32),
+14 −4
Original line number Diff line number Diff line
@@ -164,10 +164,20 @@ static void rt2500pci_eepromregister_write(struct eeprom_93cx6 *eeprom)
}

#ifdef CONFIG_RT2X00_LIB_DEBUGFS
static u8 _rt2500pci_bbp_read(struct rt2x00_dev *rt2x00dev,
			      const unsigned int word)
{
	u8 value;

	rt2500pci_bbp_read(rt2x00dev, word, &value);

	return value;
}

static const struct rt2x00debug rt2500pci_rt2x00debug = {
	.owner	= THIS_MODULE,
	.csr	= {
		.read		= rt2x00mmio_register_read,
		.read		= _rt2x00mmio_register_read,
		.write		= rt2x00mmio_register_write,
		.flags		= RT2X00DEBUGFS_OFFSET,
		.word_base	= CSR_REG_BASE,
@@ -175,21 +185,21 @@ static const struct rt2x00debug rt2500pci_rt2x00debug = {
		.word_count	= CSR_REG_SIZE / sizeof(u32),
	},
	.eeprom	= {
		.read		= rt2x00_eeprom_read,
		.read		= _rt2x00_eeprom_read,
		.write		= rt2x00_eeprom_write,
		.word_base	= EEPROM_BASE,
		.word_size	= sizeof(u16),
		.word_count	= EEPROM_SIZE / sizeof(u16),
	},
	.bbp	= {
		.read		= rt2500pci_bbp_read,
		.read		= _rt2500pci_bbp_read,
		.write		= rt2500pci_bbp_write,
		.word_base	= BBP_BASE,
		.word_size	= sizeof(u8),
		.word_count	= BBP_SIZE / sizeof(u8),
	},
	.rf	= {
		.read		= rt2x00_rf_read,
		.read		= _rt2x00_rf_read,
		.write		= rt2500pci_rf_write,
		.word_base	= RF_BASE,
		.word_size	= sizeof(u32),
+17 −7
Original line number Diff line number Diff line
@@ -216,14 +216,14 @@ static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev,
}

#ifdef CONFIG_RT2X00_LIB_DEBUGFS
static void _rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
				     const unsigned int offset,
				     u32 *value)
static u32 _rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
				     const unsigned int offset)
{
	u16 tmp;

	rt2500usb_register_read(rt2x00dev, offset, &tmp);
	*value = tmp;

	return tmp;
}

static void _rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
@@ -233,6 +233,16 @@ static void _rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
	rt2500usb_register_write(rt2x00dev, offset, value);
}

static u8 _rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev,
			      const unsigned int word)
{
	u8 value;

	rt2500usb_bbp_read(rt2x00dev, word, &value);

	return value;
}

static const struct rt2x00debug rt2500usb_rt2x00debug = {
	.owner	= THIS_MODULE,
	.csr	= {
@@ -244,21 +254,21 @@ static const struct rt2x00debug rt2500usb_rt2x00debug = {
		.word_count	= CSR_REG_SIZE / sizeof(u16),
	},
	.eeprom	= {
		.read		= rt2x00_eeprom_read,
		.read		= _rt2x00_eeprom_read,
		.write		= rt2x00_eeprom_write,
		.word_base	= EEPROM_BASE,
		.word_size	= sizeof(u16),
		.word_count	= EEPROM_SIZE / sizeof(u16),
	},
	.bbp	= {
		.read		= rt2500usb_bbp_read,
		.read		= _rt2500usb_bbp_read,
		.write		= rt2500usb_bbp_write,
		.word_base	= BBP_BASE,
		.word_size	= sizeof(u8),
		.word_count	= BBP_SIZE / sizeof(u8),
	},
	.rf	= {
		.read		= rt2x00_rf_read,
		.read		= _rt2x00_rf_read,
		.write		= rt2500usb_rf_write,
		.word_base	= RF_BASE,
		.word_size	= sizeof(u32),
+23 −5
Original line number Diff line number Diff line
@@ -1225,10 +1225,28 @@ void rt2800_clear_beacon(struct queue_entry *entry)
EXPORT_SYMBOL_GPL(rt2800_clear_beacon);

#ifdef CONFIG_RT2X00_LIB_DEBUGFS
static u8 _rt2800_bbp_read(struct rt2x00_dev *rt2x00dev, const unsigned int word)
{
	u8 value;

	rt2800_bbp_read(rt2x00dev, word, &value);

	return value;
}

static u8 _rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev, const unsigned int word)
{
	u8 value;

	rt2800_rfcsr_read(rt2x00dev, word, &value);

	return value;
}

const struct rt2x00debug rt2800_rt2x00debug = {
	.owner	= THIS_MODULE,
	.csr	= {
		.read		= rt2800_register_read,
		.read		= _rt2800_register_read,
		.write		= rt2800_register_write,
		.flags		= RT2X00DEBUGFS_OFFSET,
		.word_base	= CSR_REG_BASE,
@@ -1239,28 +1257,28 @@ const struct rt2x00debug rt2800_rt2x00debug = {
		/* NOTE: The local EEPROM access functions can't
		 * be used here, use the generic versions instead.
		 */
		.read		= rt2x00_eeprom_read,
		.read		= _rt2x00_eeprom_read,
		.write		= rt2x00_eeprom_write,
		.word_base	= EEPROM_BASE,
		.word_size	= sizeof(u16),
		.word_count	= EEPROM_SIZE / sizeof(u16),
	},
	.bbp	= {
		.read		= rt2800_bbp_read,
		.read		= _rt2800_bbp_read,
		.write		= rt2800_bbp_write,
		.word_base	= BBP_BASE,
		.word_size	= sizeof(u8),
		.word_count	= BBP_SIZE / sizeof(u8),
	},
	.rf	= {
		.read		= rt2x00_rf_read,
		.read		= _rt2x00_rf_read,
		.write		= rt2800_rf_write,
		.word_base	= RF_BASE,
		.word_size	= sizeof(u32),
		.word_count	= RF_SIZE / sizeof(u32),
	},
	.rfcsr	= {
		.read		= rt2800_rfcsr_read,
		.read		= _rt2800_rfcsr_read,
		.write		= rt2800_rfcsr_write,
		.word_base	= RFCSR_BASE,
		.word_size	= sizeof(u8),
+14 −6
Original line number Diff line number Diff line
@@ -49,10 +49,10 @@ struct rt2800_drv_data {
};

struct rt2800_ops {
	void (*register_read)(struct rt2x00_dev *rt2x00dev,
			      const unsigned int offset, u32 *value);
	void (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
				   const unsigned int offset, u32 *value);
	u32 (*register_read)(struct rt2x00_dev *rt2x00dev,
			      const unsigned int offset);
	u32 (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
				   const unsigned int offset);
	void (*register_write)(struct rt2x00_dev *rt2x00dev,
			       const unsigned int offset, u32 value);
	void (*register_write_lock)(struct rt2x00_dev *rt2x00dev,
@@ -84,7 +84,7 @@ static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
{
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;

	rt2800ops->register_read(rt2x00dev, offset, value);
	*value = rt2800ops->register_read(rt2x00dev, offset);
}

static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
@@ -93,7 +93,15 @@ static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
{
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;

	rt2800ops->register_read_lock(rt2x00dev, offset, value);
	*value = rt2800ops->register_read_lock(rt2x00dev, offset);
}

static inline u32 _rt2800_register_read(struct rt2x00_dev *rt2x00dev,
					const unsigned int offset)
{
	const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;

	return rt2800ops->register_read(rt2x00dev, offset);
}

static inline void rt2800_register_write(struct rt2x00_dev *rt2x00dev,
Loading