From: Paul Menzel Subject: Re: [PATCH 1/3] intel_reg_read: add support for getopt Date: Tue, 28 Feb 2012 23:02:54 +0100 Message-ID: <1330466574.14757.8.camel@mattotaupa> References: <1330462541-1375-1-git-send-email-eugeni.dodonov@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0488419790==" Return-path: Received: from mail.gw90.de (mail.gw90.de [188.40.100.199]) by gabe.freedesktop.org (Postfix) with ESMTP id 45F22A0A54 for ; Tue, 28 Feb 2012 14:03:01 -0800 (PST) In-Reply-To: <1330462541-1375-1-git-send-email-eugeni.dodonov@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org Cc: Eugeni Dodonov List-Id: intel-gfx@lists.freedesktop.org --===============0488419790== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-3SJnCr7AxwhQHSnglAzv" --=-3SJnCr7AxwhQHSnglAzv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear Eugeni, Am Dienstag, den 28.02.2012, 17:55 -0300 schrieb Eugeni Dodonov: > This will allow us to pass more options to it in the future. >=20 > Signed-off-by: Eugeni Dodonov > --- > tools/intel_reg_read.c | 44 +++++++++++++++++++++++++++++++++++-------= -- > 1 file changed, 35 insertions(+), 9 deletions(-) >=20 > diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c > index cad30ff..c3e559b 100644 > --- a/tools/intel_reg_read.c > +++ b/tools/intel_reg_read.c > @@ -41,21 +41,45 @@ static void dump_range(uint32_t start, uint32_t end) > *(volatile uint32_t *)((volatile char*)mmio + i)); > } > =20 > +static void usage(char *cmdname) > +{ > + printf("Usage: %s [-f | addr]\n", cmdname); > + printf("\t -f : read back full range of registers.\n"); > + printf("\t WARNING! This could be danger to hang the machine!\n"); I know you just copied this sentence, but could a native English speaker proof read it? It sounds strange to me. > + printf("\t addr : in 0xXXXX format\n"); > +} > + > int main(int argc, char** argv) > { > + int ret=3D0; Coding style seems to differ, does not it? There are some occurrences where `=3D` does have spaces around. Care to send a patch cleaning that up beforehand? > uint32_t reg; > + int ch; > + char *cmdname =3D strdup(argv[0]); > + int full_dump=3D0; > + > + while ((ch =3D getopt(argc, argv, "fh")) !=3D -1) { I did not check further. But I guess no headers need to be included for `getopt`. > + switch(ch) { > + case 'f': > + full_dump=3D1; > + break; Indentation seems to differ in the line `full_dump =3D 1`. > + case 'h': > + usage(cmdname); > + ret=3D1; > + goto out; > + } > + } > + argc -=3D optind; > + argv +=3D optind; > =20 > - if (argc !=3D 2) { > - printf("Usage: %s [-f | addr]\n", argv[0]); > - printf("\t -f : read back full range of registers.\n"); > - printf("\t WARNING! This could be danger to hang the machine!\n")= ; > - printf("\t addr : in 0xXXXX format\n"); > - exit(1); > + if (argc !=3D 1) { > + usage(cmdname); > + ret=3D1; > + goto out; > } > =20 > intel_register_access_init(intel_get_pci_device(), 0); > =20 > - if (!strcmp(argv[1], "-f")) { > + if (full_dump) { > dump_range(0x00000, 0x00fff); /* VGA registers */ > dump_range(0x02000, 0x02fff); /* instruction, memory, interrupt cont= rol registers */ > dump_range(0x03000, 0x031ff); /* FENCE and PPGTT control registers *= / > @@ -71,12 +95,14 @@ int main(int argc, char** argv) > dump_range(0x70000, 0x72fff); /* display and cursor registers */ > dump_range(0x73000, 0x73fff); /* performance counters */ > } else { > - sscanf(argv[1], "0x%x", ®); > + sscanf(argv[0], "0x%x", ®); > dump_range(reg, reg + 4); > } > =20 > intel_register_access_fini(); > =20 > - return 0; > +out: > + free(cmdname); > + return ret; > } Otherwise you can add Reviewed-by: Paul Menzel Thanks, Paul --=-3SJnCr7AxwhQHSnglAzv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEABECAAYFAk9NTw8ACgkQPX1aK2wOHVhZpwCfSn+dS7+NWgK3djrr6FYqwge5 sioAniS55WkpY4srdcYshtH82u2yKhMm =FaeF -----END PGP SIGNATURE----- --=-3SJnCr7AxwhQHSnglAzv-- --===============0488419790== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============0488419790==--