cmd_mii: localize & constify local funcs/data

No need for these structures to be writable or global.

While we're here, also drop local versions of the ARRAY_SIZE macro.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
master
Mike Frysinger 14 years ago committed by Wolfgang Denk
parent d0d2271f8c
commit 3a5ee0b1d6
  1. 68
      common/cmd_mii.c

@ -34,7 +34,7 @@ typedef struct _MII_reg_desc_t {
char * name; char * name;
} MII_reg_desc_t; } MII_reg_desc_t;
MII_reg_desc_t reg_0_5_desc_tbl[] = { static const MII_reg_desc_t reg_0_5_desc_tbl[] = {
{ 0, "PHY control register" }, { 0, "PHY control register" },
{ 1, "PHY status register" }, { 1, "PHY status register" },
{ 2, "PHY ID 1 register" }, { 2, "PHY ID 1 register" },
@ -50,7 +50,7 @@ typedef struct _MII_field_desc_t {
char * name; char * name;
} MII_field_desc_t; } MII_field_desc_t;
MII_field_desc_t reg_0_desc_tbl[] = { static const MII_field_desc_t reg_0_desc_tbl[] = {
{ 15, 15, 0x01, "reset" }, { 15, 15, 0x01, "reset" },
{ 14, 14, 0x01, "loopback" }, { 14, 14, 0x01, "loopback" },
{ 13, 6, 0x81, "speed selection" }, /* special */ { 13, 6, 0x81, "speed selection" }, /* special */
@ -63,7 +63,7 @@ MII_field_desc_t reg_0_desc_tbl[] = {
{ 5, 0, 0x3f, "(reserved)" } { 5, 0, 0x3f, "(reserved)" }
}; };
MII_field_desc_t reg_1_desc_tbl[] = { static const MII_field_desc_t reg_1_desc_tbl[] = {
{ 15, 15, 0x01, "100BASE-T4 able" }, { 15, 15, 0x01, "100BASE-T4 able" },
{ 14, 14, 0x01, "100BASE-X full duplex able" }, { 14, 14, 0x01, "100BASE-X full duplex able" },
{ 13, 13, 0x01, "100BASE-X half duplex able" }, { 13, 13, 0x01, "100BASE-X half duplex able" },
@ -82,17 +82,17 @@ MII_field_desc_t reg_1_desc_tbl[] = {
{ 0, 0, 0x01, "extended capabilities" }, { 0, 0, 0x01, "extended capabilities" },
}; };
MII_field_desc_t reg_2_desc_tbl[] = { static const MII_field_desc_t reg_2_desc_tbl[] = {
{ 15, 0, 0xffff, "OUI portion" }, { 15, 0, 0xffff, "OUI portion" },
}; };
MII_field_desc_t reg_3_desc_tbl[] = { static const MII_field_desc_t reg_3_desc_tbl[] = {
{ 15, 10, 0x3f, "OUI portion" }, { 15, 10, 0x3f, "OUI portion" },
{ 9, 4, 0x3f, "manufacturer part number" }, { 9, 4, 0x3f, "manufacturer part number" },
{ 3, 0, 0x0f, "manufacturer rev. number" }, { 3, 0, 0x0f, "manufacturer rev. number" },
}; };
MII_field_desc_t reg_4_desc_tbl[] = { static const MII_field_desc_t reg_4_desc_tbl[] = {
{ 15, 15, 0x01, "next page able" }, { 15, 15, 0x01, "next page able" },
{ 14, 14, 0x01, "reserved" }, { 14, 14, 0x01, "reserved" },
{ 13, 13, 0x01, "remote fault" }, { 13, 13, 0x01, "remote fault" },
@ -107,7 +107,7 @@ MII_field_desc_t reg_4_desc_tbl[] = {
{ 4, 0, 0x1f, "xxx to do" }, { 4, 0, 0x1f, "xxx to do" },
}; };
MII_field_desc_t reg_5_desc_tbl[] = { static const MII_field_desc_t reg_5_desc_tbl[] = {
{ 15, 15, 0x01, "next page able" }, { 15, 15, 0x01, "next page able" },
{ 14, 14, 0x01, "acknowledge" }, { 14, 14, 0x01, "acknowledge" },
{ 13, 13, 0x01, "remote fault" }, { 13, 13, 0x01, "remote fault" },
@ -121,39 +121,31 @@ MII_field_desc_t reg_5_desc_tbl[] = {
{ 5, 5, 0x01, "10BASE-T able" }, { 5, 5, 0x01, "10BASE-T able" },
{ 4, 0, 0x1f, "xxx to do" }, { 4, 0, 0x1f, "xxx to do" },
}; };
#define DESC0LEN (sizeof(reg_0_desc_tbl)/sizeof(reg_0_desc_tbl[0]))
#define DESC1LEN (sizeof(reg_1_desc_tbl)/sizeof(reg_1_desc_tbl[0]))
#define DESC2LEN (sizeof(reg_2_desc_tbl)/sizeof(reg_2_desc_tbl[0]))
#define DESC3LEN (sizeof(reg_3_desc_tbl)/sizeof(reg_3_desc_tbl[0]))
#define DESC4LEN (sizeof(reg_4_desc_tbl)/sizeof(reg_4_desc_tbl[0]))
#define DESC5LEN (sizeof(reg_5_desc_tbl)/sizeof(reg_5_desc_tbl[0]))
typedef struct _MII_field_desc_and_len_t { typedef struct _MII_field_desc_and_len_t {
MII_field_desc_t * pdesc; const MII_field_desc_t *pdesc;
ushort len; ushort len;
} MII_field_desc_and_len_t; } MII_field_desc_and_len_t;
MII_field_desc_and_len_t desc_and_len_tbl[] = { static const MII_field_desc_and_len_t desc_and_len_tbl[] = {
{ reg_0_desc_tbl, DESC0LEN }, { reg_0_desc_tbl, ARRAY_SIZE(reg_0_desc_tbl) },
{ reg_1_desc_tbl, DESC1LEN }, { reg_1_desc_tbl, ARRAY_SIZE(reg_1_desc_tbl) },
{ reg_2_desc_tbl, DESC2LEN }, { reg_2_desc_tbl, ARRAY_SIZE(reg_2_desc_tbl) },
{ reg_3_desc_tbl, DESC3LEN }, { reg_3_desc_tbl, ARRAY_SIZE(reg_3_desc_tbl) },
{ reg_4_desc_tbl, DESC4LEN }, { reg_4_desc_tbl, ARRAY_SIZE(reg_4_desc_tbl) },
{ reg_5_desc_tbl, DESC5LEN }, { reg_5_desc_tbl, ARRAY_SIZE(reg_5_desc_tbl) },
}; };
static void dump_reg( static void dump_reg(
ushort regval, ushort regval,
MII_reg_desc_t * prd, const MII_reg_desc_t *prd,
MII_field_desc_and_len_t * pdl); const MII_field_desc_and_len_t *pdl);
static int special_field( static int special_field(
ushort regno, ushort regno,
MII_field_desc_t * pdesc, const MII_field_desc_t *pdesc,
ushort regval); ushort regval);
void MII_dump_0_to_5( static void MII_dump_0_to_5(
ushort regvals[6], ushort regvals[6],
uchar reglo, uchar reglo,
uchar reghi) uchar reghi)
@ -169,12 +161,12 @@ void MII_dump_0_to_5(
static void dump_reg( static void dump_reg(
ushort regval, ushort regval,
MII_reg_desc_t * prd, const MII_reg_desc_t *prd,
MII_field_desc_and_len_t * pdl) const MII_field_desc_and_len_t *pdl)
{ {
ulong i; ulong i;
ushort mask_in_place; ushort mask_in_place;
MII_field_desc_t * pdesc; const MII_field_desc_t *pdesc;
printf("%u. (%04hx) -- %s --\n", printf("%u. (%04hx) -- %s --\n",
prd->regno, regval, prd->name); prd->regno, regval, prd->name);
@ -217,7 +209,7 @@ static void dump_reg(
static int special_field( static int special_field(
ushort regno, ushort regno,
MII_field_desc_t * pdesc, const MII_field_desc_t *pdesc,
ushort regval) ushort regval)
{ {
if ((regno == 0) && (pdesc->lo == 6)) { if ((regno == 0) && (pdesc->lo == 6)) {
@ -268,12 +260,12 @@ static int special_field(
return 0; return 0;
} }
char last_op[2]; static char last_op[2];
uint last_data; static uint last_data;
uint last_addr_lo; static uint last_addr_lo;
uint last_addr_hi; static uint last_addr_hi;
uint last_reg_lo; static uint last_reg_lo;
uint last_reg_hi; static uint last_reg_hi;
static void extract_range( static void extract_range(
char * input, char * input,
@ -292,7 +284,7 @@ static void extract_range(
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{ {
char op[2]; char op[2];
unsigned char addrlo, addrhi, reglo, reghi; unsigned char addrlo, addrhi, reglo, reghi;

Loading…
Cancel
Save