Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ebbc485 authored by Gertjan van Wingerde's avatar Gertjan van Wingerde Committed by John W. Linville
Browse files

rt2x00: Introduce concept of driver data in struct rt2x00_dev.



We are getting more and more fields in struct rt2x00_dev that are
specific to one or two of the low-level drivers. Instead of putting
these fields inside the main structure and thus clobbering all low-level
drivers with these fields, introduce the concept of driver data inside
struct rt2x00_dev, whose size is indicated by the low-level driver and
which can be populated by the low-level driver.

Signed-off-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Acked-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 234f6e5c
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -647,6 +647,7 @@ struct rt2x00lib_ops {
 */
 */
struct rt2x00_ops {
struct rt2x00_ops {
	const char *name;
	const char *name;
	const unsigned int drv_data_size;
	const unsigned int max_sta_intf;
	const unsigned int max_sta_intf;
	const unsigned int max_ap_intf;
	const unsigned int max_ap_intf;
	const unsigned int eeprom_size;
	const unsigned int eeprom_size;
@@ -741,6 +742,11 @@ struct rt2x00_dev {
	 */
	 */
	const struct rt2x00_ops *ops;
	const struct rt2x00_ops *ops;


	/*
	 * Driver data.
	 */
	void *drv_data;

	/*
	/*
	 * IEEE80211 control structure.
	 * IEEE80211 control structure.
	 */
	 */
+18 −0
Original line number Original line Diff line number Diff line
@@ -1121,6 +1121,18 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
{
{
	int retval = -ENOMEM;
	int retval = -ENOMEM;


	/*
	 * Allocate the driver data memory, if necessary.
	 */
	if (rt2x00dev->ops->drv_data_size > 0) {
		rt2x00dev->drv_data = kzalloc(rt2x00dev->ops->drv_data_size,
			                      GFP_KERNEL);
		if (!rt2x00dev->drv_data) {
			retval = -ENOMEM;
			goto exit;
		}
	}

	spin_lock_init(&rt2x00dev->irqmask_lock);
	spin_lock_init(&rt2x00dev->irqmask_lock);
	mutex_init(&rt2x00dev->csr_mutex);
	mutex_init(&rt2x00dev->csr_mutex);


@@ -1261,6 +1273,12 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
	 * Free queue structures.
	 * Free queue structures.
	 */
	 */
	rt2x00queue_free(rt2x00dev);
	rt2x00queue_free(rt2x00dev);

	/*
	 * Free the driver data.
	 */
	if (rt2x00dev->drv_data)
		kfree(rt2x00dev->drv_data);
}
}
EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);