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

Commit 141518c9 authored by Matt Carlson's avatar Matt Carlson Committed by David S. Miller
Browse files

tg3: Add some VPD preprocessor constants



This patch cleans up the VPD code by creating preprocessor definitions
and using them in the place of hardcoded constants.

Signed-off-by: default avatarMatt Carlson <mcarlson@broadcom.com>
Reviewed-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b703df6f
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -12433,7 +12433,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)

static void __devinit tg3_read_partno(struct tg3 *tp)
{
	unsigned char vpd_data[256];   /* in little-endian format */
	unsigned char vpd_data[TG3_NVM_VPD_LEN];   /* in little-endian format */
	unsigned int i;
	u32 magic;

@@ -12442,14 +12442,14 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
		goto out_not_found;

	if (magic == TG3_EEPROM_MAGIC) {
		for (i = 0; i < 256; i += 4) {
		for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) {
			u32 tmp;

			/* The data is in little-endian format in NVRAM.
			 * Use the big-endian read routines to preserve
			 * the byte order as it exists in NVRAM.
			 */
			if (tg3_nvram_read_be32(tp, 0x100 + i, &tmp))
			if (tg3_nvram_read_be32(tp, TG3_NVM_VPD_OFF + i, &tmp))
				goto out_not_found;

			memcpy(&vpd_data[i], &tmp, sizeof(tmp));
@@ -12458,7 +12458,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
		int vpd_cap;

		vpd_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_VPD);
		for (i = 0; i < 256; i += 4) {
		for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) {
			u32 tmp, j = 0;
			__le32 v;
			u16 tmp16;
@@ -12483,7 +12483,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
	}

	/* Now parse and find the part number. */
	for (i = 0; i < 254; ) {
	for (i = 0; i < TG3_NVM_VPD_LEN - 2; ) {
		unsigned char val = vpd_data[i];
		unsigned int block_end;

@@ -12502,7 +12502,7 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
			      (vpd_data[i + 2] << 8)));
		i += 3;

		if (block_end > 256)
		if (block_end > TG3_NVM_VPD_LEN)
			goto out_not_found;

		while (i < (block_end - 2)) {
@@ -12511,7 +12511,8 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
				int partno_len = vpd_data[i + 2];

				i += 3;
				if (partno_len > 24 || (partno_len + i) > 256)
				if (partno_len > TG3_BPN_SIZE ||
				    (partno_len + i) > TG3_NVM_VPD_LEN)
					goto out_not_found;

				memcpy(tp->board_part_number,
+8 −2
Original line number Diff line number Diff line
@@ -1821,6 +1821,11 @@

#define TG3_OTP_DEFAULT			0x286c1640


/* Hardware Legacy NVRAM layout */
#define TG3_NVM_VPD_OFF			0x100
#define TG3_NVM_VPD_LEN			256

/* Hardware Selfboot NVRAM layout */
#define TG3_NVM_HWSB_CFG1		0x00000004
#define  TG3_NVM_HWSB_CFG1_MAJMSK	0xf8000000
@@ -2893,8 +2898,9 @@ struct tg3 {
	u32				led_ctrl;
	u32				phy_otp;

	char				board_part_number[24];
#define TG3_VER_SIZE 32
#define TG3_BPN_SIZE			24
	char				board_part_number[TG3_BPN_SIZE];
#define TG3_VER_SIZE			ETHTOOL_FWVERS_LEN
	char				fw_ver[TG3_VER_SIZE];
	u32				nic_sram_data_cfg;
	u32				pci_clock_ctrl;
+2 −1
Original line number Diff line number Diff line
@@ -49,13 +49,14 @@ static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
	return (ep->speed_hi << 16) | ep->speed;
}

#define ETHTOOL_FWVERS_LEN	32
#define ETHTOOL_BUSINFO_LEN	32
/* these strings are set to whatever the driver author decides... */
struct ethtool_drvinfo {
	__u32	cmd;
	char	driver[32];	/* driver short name, "tulip", "eepro100" */
	char	version[32];	/* driver version string */
	char	fw_version[32];	/* firmware version string, if applicable */
	char	fw_version[ETHTOOL_FWVERS_LEN];	/* firmware version string */
	char	bus_info[ETHTOOL_BUSINFO_LEN];	/* Bus info for this IF. */
				/* For PCI devices, use pci_name(pci_dev). */
	char	reserved1[32];