linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linux-serial <linux-serial@vger.kernel.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	alpha <linux-alpha@vger.kernel.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Helge Deller <deller@gmx.de>,
	Parisc List <linux-parisc@vger.kernel.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] termbits: Convert octal defines to hex
Date: Wed, 4 May 2022 11:33:32 +0300 (EEST)	[thread overview]
Message-ID: <ca39c741-8d15-33c0-7bd6-635778cc436@linux.intel.com> (raw)
In-Reply-To: <CAK8P3a0hy8Ras7pwF9rJADtCAfeV49K7GWkftJnzqeGiQ6j-zA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4370 bytes --]

On Wed, 4 May 2022, Arnd Bergmann wrote:

> On Wed, May 4, 2022 at 9:20 AM Ilpo Järvinen
> <ilpo.jarvinen@linux.intel.com> wrote:
> >
> > Many archs have termbits.h as octal numbers. It makes hard for humans
> > to parse the magnitude of large numbers correctly and to compare with
> > hex ones of the same define.
> >
> > Convert octal values to hex.
> >
> > First step is an automated conversion with:
> >
> > for i in $(git ls-files | grep 'termbits\.h'); do
> >         awk --non-decimal-data '/^#define\s+[A-Z][A-Z0-9]*\s+0[0-9]/ {
> >                 l=int(((length($3) - 1) * 3 + 3) / 4);
> >                 repl = sprintf("0x%0" l "x", $3);
> >                 print gensub(/[^[:blank:]]+/, repl, 3);
> >                 next} {print}' $i > $i~;
> >         mv $i~ $i;
> > done
> >
> > On top of that, some manual processing on alignment and number of zeros.
> > In addition, small tweaks to formatting of a few comments on the same
> > lines.
> >
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> 
> Good idea!
> 
> I assume you already checked if additional file contents can be shared across
> architectures? I think I've tried in the past but didn't really get
> anywhere with
> that.
> 
> After applying the patch locally, I still see a bunch of whitespace
> differences in the
> changed lines if I run
> 
> vimdiff arch/*/include/uapi/asm/termbits.h include/uapi/asm-generic/termbits.h
> 
> I think this mostly because you left the sparc version alone (it already
> uses hex constants), but it may be nice to edit this a little more to
> make the actual differences stick out more.

I took a look on further harmonizing, however, it turned out to be not 
that simple. This is basically the pipeline I use to further cleanup the 
differences and remove comments if you want to play yourself, just remove 
stages from the tail to get the intermediate datas (gawk is required for 
--non-decimal-data):

$ git ls-files | grep 'termbits\.h' | xargs grep -h -e '#define' | awk --non-decimal-data '{if (NF < 3) {next}; printf("#define %s\t0x%08x\n", $2, $3)}' | sort | uniq -c | sort | awk '{print $1}' | uniq -c
     82 1
     74 2
     14 3
     58 4
     11 5
     54 6

So only 54 are the same for all archs (non-numeric defines such as EXT[AB] 
will appear as 0x0 but at least those two seem the same across archs 
anyway):
      6 #define B0      0x00000000
      6 #define B110    0x00000003
      6 #define B1200   0x00000009
      6 #define B134    0x00000004
      6 #define B150    0x00000005
      6 #define B1800   0x0000000a
      6 #define B19200  0x0000000e
      6 #define B200    0x00000006
      6 #define B2400   0x0000000b
      6 #define B300    0x00000007
      6 #define B38400  0x0000000f
      6 #define B4800   0x0000000c
      6 #define B50     0x00000001
      6 #define B600    0x00000008
      6 #define B75     0x00000002
      6 #define B9600   0x0000000d
      6 #define BRKINT  0x00000002
      6 #define BS0     0x00000000
      6 #define CMSPAR  0x40000000
      6 #define CR0     0x00000000
      6 #define CRTSCTS 0x80000000
      6 #define CS5     0x00000000
      6 #define ECHO    0x00000008
      6 #define EXTA    0x00000000
      6 #define EXTB    0x00000000
      6 #define FF0     0x00000000
      6 #define IBSHIFT 0x00000010
      6 #define ICRNL   0x00000100
      6 #define IGNBRK  0x00000001
      6 #define IGNCR   0x00000080
      6 #define IGNPAR  0x00000004
      6 #define INLCR   0x00000040
      6 #define INPCK   0x00000010
      6 #define ISTRIP  0x00000020
      6 #define IXANY   0x00000800
      6 #define NL0     0x00000000
      6 #define NL1     0x00000100
      6 #define OCRNL   0x00000008
      6 #define OFDEL   0x00000080
      6 #define OFILL   0x00000040
      6 #define ONLRET  0x00000020
      6 #define ONOCR   0x00000010
      6 #define OPOST   0x00000001
      6 #define PARMRK  0x00000008
      6 #define TAB0    0x00000000
      6 #define TCIFLUSH        0x00000000
      6 #define TCIOFF  0x00000002
      6 #define TCIOFLUSH       0x00000002
      6 #define TCION   0x00000003
      6 #define TCOFLUSH        0x00000001
      6 #define TCOOFF  0x00000000
      6 #define TCOON   0x00000001
      6 #define TCSANOW 0x00000000
      6 #define VT0     0x00000000

Sadly for the others, it just tends to be that one or two are different 
from the rest.



-- 
 i.

  reply	other threads:[~2022-05-04  8:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  7:20 [PATCH 1/1] termbits: Convert octal defines to hex Ilpo Järvinen
2022-05-04  7:42 ` Arnd Bergmann
2022-05-04  8:33   ` Ilpo Järvinen [this message]
2022-05-04 11:59     ` Arnd Bergmann
2022-05-05  8:56       ` Ilpo Järvinen
2022-05-05 10:46         ` Arnd Bergmann
2022-05-04 11:03 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca39c741-8d15-33c0-7bd6-635778cc436@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=deller@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=ink@jurassic.park.msu.ru \
    --cc=jirislaby@kernel.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mattst88@gmail.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).