netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com
Subject: [PATCH 17/33] sfc: Clean up board identification
Date: Fri, 12 Dec 2008 12:54:19 +0000	[thread overview]
Message-ID: <20081212125418.GQ10372@solarflare.com> (raw)
In-Reply-To: <20081212124622.GK32518@solarflare.com>

Remove kluge for development boards with unspecified board type.

Remove assumption of contiguous board type code assignments.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/boards.c |   68 ++++++++++++---------------------------------
 drivers/net/sfc/boards.h |    7 +---
 2 files changed, 20 insertions(+), 55 deletions(-)

diff --git a/drivers/net/sfc/boards.c b/drivers/net/sfc/boards.c
index edf0262..08fa4e3 100644
--- a/drivers/net/sfc/boards.c
+++ b/drivers/net/sfc/boards.c
@@ -1,6 +1,6 @@
 /****************************************************************************
  * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2007 Solarflare Communications Inc.
+ * Copyright 2007-2008 Solarflare Communications Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
@@ -231,70 +231,38 @@ static int sfe4002_init(struct efx_nic *efx)
 /* This will get expanded as board-specific details get moved out of the
  * PHY drivers. */
 struct efx_board_data {
+	enum efx_board_type type;
 	const char *ref_model;
 	const char *gen_type;
 	int (*init) (struct efx_nic *nic);
 };
 
-static int dummy_init(struct efx_nic *nic)
-{
-	return 0;
-}
 
 static struct efx_board_data board_data[] = {
-	[EFX_BOARD_INVALID] =
-	{NULL,	    NULL,                  dummy_init},
-	[EFX_BOARD_SFE4001] =
-	{"SFE4001", "10GBASE-T adapter",   sfe4001_init},
-	[EFX_BOARD_SFE4002] =
-	{"SFE4002", "XFP adapter",         sfe4002_init},
+	{ EFX_BOARD_SFE4001, "SFE4001", "10GBASE-T adapter", sfe4001_init },
+	{ EFX_BOARD_SFE4002, "SFE4002", "XFP adapter", sfe4002_init },
 };
 
-int efx_set_board_info(struct efx_nic *efx, u16 revision_info)
+void efx_set_board_info(struct efx_nic *efx, u16 revision_info)
 {
-	int rc = 0;
-	struct efx_board_data *data;
+	struct efx_board_data *data = NULL;
+	int i;
 
-	if (BOARD_TYPE(revision_info) >= EFX_BOARD_MAX) {
-		EFX_ERR(efx, "squashing unknown board type %d\n",
-			BOARD_TYPE(revision_info));
-		revision_info = 0;
-	}
-
-	if (BOARD_TYPE(revision_info) == 0) {
-		efx->board_info.major = 0;
-		efx->board_info.minor = 0;
-		/* For early boards that don't have revision info. there is
-		 * only 1 board for each PHY type, so we can work it out, with
-		 * the exception of the PHY-less boards. */
-		switch (efx->phy_type) {
-		case PHY_TYPE_10XPRESS:
-			efx->board_info.type = EFX_BOARD_SFE4001;
-			break;
-		case PHY_TYPE_XFP:
-			efx->board_info.type = EFX_BOARD_SFE4002;
-			break;
-		default:
-			efx->board_info.type = 0;
-			break;
-		}
-	} else {
-		efx->board_info.type = BOARD_TYPE(revision_info);
-		efx->board_info.major = BOARD_MAJOR(revision_info);
-		efx->board_info.minor = BOARD_MINOR(revision_info);
-	}
+	efx->board_info.type = BOARD_TYPE(revision_info);
+	efx->board_info.major = BOARD_MAJOR(revision_info);
+	efx->board_info.minor = BOARD_MINOR(revision_info);
 
-	data = &board_data[efx->board_info.type];
+	for (i = 0; i < ARRAY_SIZE(board_data); i++)
+		if (board_data[i].type == efx->board_info.type)
+			data = &board_data[i];
 
-	/* Report the board model number or generic type for recognisable
-	 * boards. */
-	if (efx->board_info.type != 0)
+	if (data) {
 		EFX_INFO(efx, "board is %s rev %c%d\n",
 			 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC)
 			 ? data->ref_model : data->gen_type,
 			 'A' + efx->board_info.major, efx->board_info.minor);
-
-	efx->board_info.init = data->init;
-
-	return rc;
+		efx->board_info.init = data->init;
+	} else {
+		EFX_ERR(efx, "unknown board type %d\n", efx->board_info.type);
+	}
 }
diff --git a/drivers/net/sfc/boards.h b/drivers/net/sfc/boards.h
index c6e01b6..5e0dde5 100644
--- a/drivers/net/sfc/boards.h
+++ b/drivers/net/sfc/boards.h
@@ -1,6 +1,6 @@
 /****************************************************************************
  * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2007 Solarflare Communications Inc.
+ * Copyright 2007-2008 Solarflare Communications Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
@@ -12,14 +12,11 @@
 
 /* Board IDs (must fit in 8 bits) */
 enum efx_board_type {
-	EFX_BOARD_INVALID = 0,
 	EFX_BOARD_SFE4001 = 1,   /* SFE4001 (10GBASE-T) */
 	EFX_BOARD_SFE4002 = 2,
-	/* Insert new types before here */
-	EFX_BOARD_MAX
 };
 
-extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info);
+extern void efx_set_board_info(struct efx_nic *efx, u16 revision_info);
 extern int sfe4001_init(struct efx_nic *efx);
 
 #endif
-- 
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.

  parent reply	other threads:[~2008-12-12 12:54 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1229085672.git.bhutchings@solarflare.com>
2008-12-12 12:46 ` [PATCH 00/33] sfc version 2.3 Ben Hutchings
2008-12-12 12:48   ` [PATCH 01/33] sfc: Board support fixes Ben Hutchings
2008-12-13  5:29     ` David Miller
2008-12-12 12:48   ` [PATCH 02/33] sfc: Change SPI lengths to type size_t Ben Hutchings
2008-12-13  5:30     ` David Miller
2008-12-13  5:53     ` David Miller
2008-12-13  6:30       ` Ben Hutchings
2008-12-12 12:49   ` [PATCH 03/33] sfc: Do not use pci_disable_device() to disable bus mastering Ben Hutchings
2008-12-13  5:31     ` David Miller
2008-12-13  6:27       ` Ben Hutchings
2008-12-12 12:49   ` [PATCH 04/33] sfc: Remove unneeded register write Ben Hutchings
2008-12-13  5:31     ` David Miller
2008-12-12 12:49   ` [PATCH 05/33] sfc: Correct interpretation of second param to ethtool phys_id() Ben Hutchings
2008-12-13  5:32     ` David Miller
2008-12-12 12:50   ` [PATCH 06/33] sfc: Make reset_workqueue driver-global rather than per-NIC Ben Hutchings
2008-12-13  5:33     ` David Miller
2008-12-12 12:51   ` [PATCH 07/33] sfc: Clean up waits for flash/EEPROM operations Ben Hutchings
2008-12-13  5:33     ` David Miller
2008-12-12 12:51   ` [PATCH 08/33] sfc: Work around unreliable strap pins Ben Hutchings
2008-12-13  5:34     ` David Miller
2008-12-12 12:51   ` [PATCH 09/33] sfc: Restore phy_flash_cfg module parameter Ben Hutchings
2008-12-13  5:35     ` David Miller
2008-12-12 12:53   ` [PATCH 13/33] sfc: Don't count RX checksum errors during loopback self-test Ben Hutchings
2008-12-13  5:42     ` David Miller
2008-12-12 12:53   ` [PATCH 14/33] sfc: Remove MII extension cruft Ben Hutchings
2008-12-13  5:43     ` David Miller
2008-12-12 12:53   ` [PATCH 15/33] sfc: Add support for MMDs numbered >15 Ben Hutchings
2008-12-13  5:44     ` David Miller
2008-12-12 12:54   ` [PATCH 16/33] sfc: Add phy_type device attribute Ben Hutchings
2008-12-13  5:47     ` David Miller
2008-12-12 12:54   ` Ben Hutchings [this message]
2008-12-13  5:48     ` [PATCH 17/33] sfc: Clean up board identification David Miller
2008-12-12 12:54   ` [PATCH 18/33] sfc: Clean up MDIO flag setting Ben Hutchings
2008-12-13  5:49     ` David Miller
2008-12-12 12:54   ` [PATCH 19/33] sfc: Add support for sub-10G speeds Ben Hutchings
2008-12-13  5:50     ` David Miller
2008-12-12 12:55   ` [PATCH 20/33] sfc: Implement auto-negotiation Ben Hutchings
2008-12-13  5:50     ` David Miller
2008-12-12 12:55   ` [PATCH 21/33] sfc: Rework MAC, PHY and board event handling Ben Hutchings
2008-12-13  5:59     ` David Miller
2008-12-12 12:56   ` [PATCH 22/33] sfc: Add support for Solarflare 10Xpress SFT9001 Ben Hutchings
2008-12-13  6:00     ` David Miller
2008-12-12 12:56   ` [PATCH 23/33] sfc: Add support for SFN4111T Ben Hutchings
2008-12-13  6:01     ` David Miller
2008-12-12 12:56   ` [PATCH 25/33] sfc: Generate unique names for per-NIC workqueues Ben Hutchings
2008-12-13  6:04     ` David Miller
2008-12-13  6:23       ` Ben Hutchings
2008-12-13  6:29         ` David Miller
2008-12-13 14:01           ` Ben Hutchings
2008-12-12 12:57   ` [PATCH 26/33] sfc: Remove leading spaces Ben Hutchings
2008-12-13  6:05     ` David Miller
2008-12-12 12:57   ` [PATCH 27/33] sfc: Specify a meaningful component for loopback RX-side and PHY tests Ben Hutchings
2008-12-13  6:05     ` David Miller
2008-12-12 12:59   ` [PATCH 28/33] sfc: Use mutex_lock_interruptible() for ethtool EEPROM access Ben Hutchings
2008-12-13  6:06     ` David Miller
2008-12-12 12:59   ` [PATCH 29/33] sfc: Use model numbers for PHY type names Ben Hutchings
2008-12-13  6:07     ` David Miller
2008-12-12 13:00   ` [PATCH 30/33] sfc: Treat probe as unsuccessful if it scheduled a reset Ben Hutchings
2008-12-13  6:08     ` David Miller
2008-12-12 13:00   ` [PATCH 31/33] sfc: Use kzalloc() to ensure struct efx_spi_device is fully initialised Ben Hutchings
2008-12-13  6:09     ` David Miller
2008-12-12 12:52 ` [PATCH 10/33] sfc: Add option to use a separate channel for TX completions Ben Hutchings
2008-12-13  5:36   ` David Miller
2008-12-12 12:52 ` [PATCH 11/33] sfc: Provide hints to irqbalance daemon Ben Hutchings
2008-12-13  5:37   ` David Miller
2008-12-12 12:52 ` [PATCH 12/33] sfc: Abbreviate self-test names so they are not truncated Ben Hutchings
2008-12-13  5:42   ` David Miller
2008-12-12 12:56 ` [PATCH 24/33] sfc: Fix format arguments for warning about MSI-X allocation Ben Hutchings
2008-12-12 20:34   ` Ben Hutchings
2008-12-13  5:25     ` David Miller
2008-12-12 13:00 ` [PATCH 32/33] sfc: Fix synchronisation of efx_mtd_{probe,rename,remove} Ben Hutchings
2008-12-13  6:09   ` David Miller
2008-12-12 13:01 ` [PATCH 33/33] sfc: Version 2.3 Ben Hutchings
2008-12-13  6:10   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081212125418.GQ10372@solarflare.com \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).