Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: Clean up board identification

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ben Hutchings and committed by
David S. Miller
04300d24 06d5e193

+20 -55
+18 -50
drivers/net/sfc/boards.c
··· 1 1 /**************************************************************************** 2 2 * Driver for Solarflare Solarstorm network controllers and boards 3 - * Copyright 2007 Solarflare Communications Inc. 3 + * Copyright 2007-2008 Solarflare Communications Inc. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it 6 6 * under the terms of the GNU General Public License version 2 as published ··· 231 231 /* This will get expanded as board-specific details get moved out of the 232 232 * PHY drivers. */ 233 233 struct efx_board_data { 234 + enum efx_board_type type; 234 235 const char *ref_model; 235 236 const char *gen_type; 236 237 int (*init) (struct efx_nic *nic); 237 238 }; 238 239 239 - static int dummy_init(struct efx_nic *nic) 240 - { 241 - return 0; 242 - } 243 240 244 241 static struct efx_board_data board_data[] = { 245 - [EFX_BOARD_INVALID] = 246 - {NULL, NULL, dummy_init}, 247 - [EFX_BOARD_SFE4001] = 248 - {"SFE4001", "10GBASE-T adapter", sfe4001_init}, 249 - [EFX_BOARD_SFE4002] = 250 - {"SFE4002", "XFP adapter", sfe4002_init}, 242 + { EFX_BOARD_SFE4001, "SFE4001", "10GBASE-T adapter", sfe4001_init }, 243 + { EFX_BOARD_SFE4002, "SFE4002", "XFP adapter", sfe4002_init }, 251 244 }; 252 245 253 - int efx_set_board_info(struct efx_nic *efx, u16 revision_info) 246 + void efx_set_board_info(struct efx_nic *efx, u16 revision_info) 254 247 { 255 - int rc = 0; 256 - struct efx_board_data *data; 248 + struct efx_board_data *data = NULL; 249 + int i; 257 250 258 - if (BOARD_TYPE(revision_info) >= EFX_BOARD_MAX) { 259 - EFX_ERR(efx, "squashing unknown board type %d\n", 260 - BOARD_TYPE(revision_info)); 261 - revision_info = 0; 262 - } 251 + efx->board_info.type = BOARD_TYPE(revision_info); 252 + efx->board_info.major = BOARD_MAJOR(revision_info); 253 + efx->board_info.minor = BOARD_MINOR(revision_info); 263 254 264 - if (BOARD_TYPE(revision_info) == 0) { 265 - efx->board_info.major = 0; 266 - efx->board_info.minor = 0; 267 - /* For early boards that don't have revision info. there is 268 - * only 1 board for each PHY type, so we can work it out, with 269 - * the exception of the PHY-less boards. */ 270 - switch (efx->phy_type) { 271 - case PHY_TYPE_10XPRESS: 272 - efx->board_info.type = EFX_BOARD_SFE4001; 273 - break; 274 - case PHY_TYPE_XFP: 275 - efx->board_info.type = EFX_BOARD_SFE4002; 276 - break; 277 - default: 278 - efx->board_info.type = 0; 279 - break; 280 - } 281 - } else { 282 - efx->board_info.type = BOARD_TYPE(revision_info); 283 - efx->board_info.major = BOARD_MAJOR(revision_info); 284 - efx->board_info.minor = BOARD_MINOR(revision_info); 285 - } 255 + for (i = 0; i < ARRAY_SIZE(board_data); i++) 256 + if (board_data[i].type == efx->board_info.type) 257 + data = &board_data[i]; 286 258 287 - data = &board_data[efx->board_info.type]; 288 - 289 - /* Report the board model number or generic type for recognisable 290 - * boards. */ 291 - if (efx->board_info.type != 0) 259 + if (data) { 292 260 EFX_INFO(efx, "board is %s rev %c%d\n", 293 261 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) 294 262 ? data->ref_model : data->gen_type, 295 263 'A' + efx->board_info.major, efx->board_info.minor); 296 - 297 - efx->board_info.init = data->init; 298 - 299 - return rc; 264 + efx->board_info.init = data->init; 265 + } else { 266 + EFX_ERR(efx, "unknown board type %d\n", efx->board_info.type); 267 + } 300 268 }
+2 -5
drivers/net/sfc/boards.h
··· 1 1 /**************************************************************************** 2 2 * Driver for Solarflare Solarstorm network controllers and boards 3 - * Copyright 2007 Solarflare Communications Inc. 3 + * Copyright 2007-2008 Solarflare Communications Inc. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it 6 6 * under the terms of the GNU General Public License version 2 as published ··· 12 12 13 13 /* Board IDs (must fit in 8 bits) */ 14 14 enum efx_board_type { 15 - EFX_BOARD_INVALID = 0, 16 15 EFX_BOARD_SFE4001 = 1, /* SFE4001 (10GBASE-T) */ 17 16 EFX_BOARD_SFE4002 = 2, 18 - /* Insert new types before here */ 19 - EFX_BOARD_MAX 20 17 }; 21 18 22 - extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info); 19 + extern void efx_set_board_info(struct efx_nic *efx, u16 revision_info); 23 20 extern int sfe4001_init(struct efx_nic *efx); 24 21 25 22 #endif