Skip to contentSkip to conversation

sfc: Clean up struct falcon_board and struct falcon_board_data

PATCH In review Ben Hutchings 1 participant 1 message Nov 26, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/16 sfc: Clean up struct falcon_board and struct falcon_board_data

Put all static information in struct falcon_board_type and replace it with a pointer in struct falcon_board. Simplify probing aocordingly.

---
 drivers/net/sfc/efx.c           |    2 +-
 drivers/net/sfc/ethtool.c       |    6 +-
 drivers/net/sfc/falcon.c        |    4 +-
 drivers/net/sfc/falcon.h        |   34 ++++++++----
 drivers/net/sfc/falcon_boards.c |  115 ++++++++++++++++++---------------------
 drivers/net/sfc/qt202x_phy.c    |    2 +-
 drivers/net/sfc/tenxpress.c     |    2 +-
 7 files changed, 85 insertions(+), 80 deletions(-)
drivers/net/sfc/efx.c +1 -1
index 9f3ef38..dc85efa 100644
@@ -1309,7 +1309,7 @@ static void efx_monitor(struct work_struct *data)
 		goto out_requeue;
 	if (!efx->port_enabled)
 		goto out_unlock;
-	rc = falcon_board(efx)->monitor(efx);
+	rc = falcon_board(efx)->type->monitor(efx);
 	if (rc) {
 		EFX_ERR(efx, "Board sensor %s; shutting down PHY\n",
 			(rc == -ERANGE) ? "reported fault" : "failed");
drivers/net/sfc/ethtool.c +3 -3
index d8915b9..bb9abf2 100644
@@ -174,14 +174,14 @@ static int efx_ethtool_phys_id(struct net_device *net_dev, u32 count)
 	struct efx_nic *efx = netdev_priv(net_dev);
 
 	do {
-		falcon_board(efx)->set_id_led(efx, EFX_LED_ON);
+		falcon_board(efx)->type->set_id_led(efx, EFX_LED_ON);
 		schedule_timeout_interruptible(HZ / 2);
 
-		falcon_board(efx)->set_id_led(efx, EFX_LED_OFF);
+		falcon_board(efx)->type->set_id_led(efx, EFX_LED_OFF);
 		schedule_timeout_interruptible(HZ / 2);
 	} while (!signal_pending(current) && --count != 0);
 
-	falcon_board(efx)->set_id_led(efx, EFX_LED_DEFAULT);
+	falcon_board(efx)->type->set_id_led(efx, EFX_LED_DEFAULT);
 	return 0;
 }
 
drivers/net/sfc/falcon.c +2 -2
index 2c0be6c..2f1f1fc 100644
@@ -2864,7 +2864,7 @@ int falcon_probe_nic(struct efx_nic *efx)
 	if (rc)
 		goto fail5;
 
-	rc = falcon_board(efx)->init(efx);
+	rc = falcon_board(efx)->type->init(efx);
 	if (rc) {
 		EFX_ERR(efx, "failed to initialise board\n");
 		goto fail6;
@@ -3067,7 +3067,7 @@ void falcon_remove_nic(struct efx_nic *efx)
 	struct falcon_board *board = falcon_board(efx);
 	int rc;
 
-	falcon_board(efx)->fini(efx);
+	board->type->fini(efx);
 
 	/* Remove I2C adapter and clear it in preparation for a retry */
 	rc = i2c_del_adapter(&board->i2c_adap);
drivers/net/sfc/falcon.h +23 -11
index ea6ac06..b331889 100644
@@ -31,29 +31,41 @@ static inline int falcon_rev(struct efx_nic *efx)
 }
 
 /**
- * struct falcon_board - board information
- * @type: Board model type
- * @major: Major rev. ('A', 'B' ...)
- * @minor: Minor rev. (0, 1, ...)
+ * struct falcon_board_type - board operations and type information
+ * @id: Board type id, as found in NVRAM
+ * @ref_model: Model number of Solarflare reference design
+ * @gen_type: Generic board type description
  * @init: Allocate resources and initialise peripheral hardware
  * @init_phy: Do board-specific PHY initialisation
+ * @fini: Shut down hardware and free resources
  * @set_id_led: Set state of identifying LED or revert to automatic function
  * @monitor: Board-specific health check function
- * @fini: Shut down hardware and free resources
+ */
+struct falcon_board_type {
+	u8 id;
+	const char *ref_model;
+	const char *gen_type;
+	int (*init) (struct efx_nic *nic);
+	void (*init_phy) (struct efx_nic *efx);
+	void (*fini) (struct efx_nic *nic);
+	void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
+	int (*monitor) (struct efx_nic *nic);
+};
+
+/**
+ * struct falcon_board - board information
+ * @type: Type of board
+ * @major: Major rev. ('A', 'B' ...)
+ * @minor: Minor rev. (0, 1, ...)
  * @i2c_adap: I2C adapter for on-board peripherals
  * @i2c_data: Data for bit-banging algorithm
  * @hwmon_client: I2C client for hardware monitor
  * @ioexp_client: I2C client for power/port control
  */
 struct falcon_board {
-	int type;
+	const struct falcon_board_type *type;
 	int major;
 	int minor;
-	int (*init) (struct efx_nic *nic);
-	void (*init_phy) (struct efx_nic *efx);
-	void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
-	int (*monitor) (struct efx_nic *nic);
-	void (*fini) (struct efx_nic *nic);
 	struct i2c_adapter i2c_adap;
 	struct i2c_algo_bit_data i2c_data;
 	struct i2c_client *hwmon_client, *ioexp_client;
drivers/net/sfc/falcon_boards.c +54 -61

167 lines not on this page · raw message

drivers/net/sfc/qt202x_phy.c +1 -1
index 8208ac0..f9c354e 100644
@@ -126,7 +126,7 @@ static int qt202x_reset_phy(struct efx_nic *efx)
 	if (rc < 0)
 		goto fail;
 
-	falcon_board(efx)->init_phy(efx);
+	falcon_board(efx)->type->init_phy(efx);
 
 	return rc;
 
drivers/net/sfc/tenxpress.c +1 -1
index b001f38..a95402d 100644
@@ -303,7 +303,7 @@ static int tenxpress_phy_init(struct efx_nic *efx)
 	u16 old_adv, adv;
 	int rc = 0;
 
-	falcon_board(efx)->init_phy(efx);
+	falcon_board(efx)->type->init_phy(efx);
 
 	phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
 	if (!phy_data)
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.