From: Sujith Manoharan Date: Tue, 24 Jul 2012 06:42:15 +0530 Subject: [ath9k-devel] [PATCH] qca-swiss-army-knife: Add a tool to dump EEPROM In-Reply-To: <20120723210854.28601.qmail@stuge.se> References: <20492.53272.943747.11705@gargle.gargle.HOWL> <20120723210854.28601.qmail@stuge.se> Message-ID: <20493.63087.260070.398504@gargle.gargle.HOWL> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org Peter Stuge wrote: > What is the define+undef about in each of these fill functions? I > guess there could be a better solution for these sizes? > > Even writing out sizeof(struct ar5416_eeprom_4k) / sizeof(uint16_t) > in the loop condition would be an improvement IMO. How would that make the code more readable ? > Several lovely two-letter macros which get undefined again. Not super > awesome for code readability, which is really a shame, since the rest > of the code looks rather good. > > > > + PR("Ant Chain 0", "0x", "X", pModal->antCtrlChain[0]); > > + PR("Antenna Common", "0x", "X", pModal->antCtrlCommon); > > + PR("Antenna Gain Chain 0", "", "d", pModal->antennaGainCh[0]); > ..followed by 44 more lines with second and third parameter > identical. What do you think about having two macros instead? Care to show how ? > I don't see why these size defines aren't at least next to the > structs. Sure, they can be moved. > > +static void modal_eeprom_def(struct edump *edump) > > +{ > > +#define PR(_token, _p, _val_fmt, _val) \ > > + do { \ > > + printf("%-23s %-8s", (_token), ":"); \ > > + if (pBase->opCapFlags & AR5416_OPFLAGS_11G) { \ > > + pModal = &(ar5416Eep->modalHeader[1]); \ > > + printf("%s%-6"_val_fmt, _p, (_val)); \ > > + } \ > > + if (pBase->opCapFlags & AR5416_OPFLAGS_11A) { \ > > + pModal = &(ar5416Eep->modalHeader[0]); \ > > + printf("%8s%"_val_fmt"\n", _p, (_val)); \ > > + } else { \ > > + printf("\n"); \ > > + } \ > > + } while(0) > > Yeah baby. Got another one! Um, I am not sure what you are getting at ?. Some values need to be printed in HEX, some in decimal. We have dual-band cards, 2G only cards, 5G only cards. This is just a macro to handle all that.. But, patches are always welcome to improve things. Sujith