Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp799182imm; Fri, 12 Oct 2018 06:58:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV60PeDp3wHbhrDVjBfZ9eDA11uRNoMFwa/Q2MO7Lr7smVmqJSy+T1JV9xLWXMOYvgUCXl5bm X-Received: by 2002:a62:cc0e:: with SMTP id a14-v6mr6149624pfg.131.1539352693261; Fri, 12 Oct 2018 06:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539352693; cv=none; d=google.com; s=arc-20160816; b=IJLBcAdxJPhAI/7pFLJZMadx9z6hRvOKlf49uWnFZsoIavIYSfFXaYT/RdjgQhw7tx fScBTkzXvl6ptg69F4qxYlZCD8Svi/yocYZPRFga87CAic+0GQplAgk8ow7aoIJFqjpJ +ErdbQfKdqN7SlJpJmUrTbwZiv+th63Bw/cyAI1ljHri0+EMCQbXZZafoeNbqHg5/mca 4AMzzoWPqTbi3vuN4griTRLxYn5OEPETK1h4yXyy1lTowq4R99CRd+U165xZIdMQ0eZ0 iqMCJCQlyyyayzv4zf7rBEKDSycobRBHcwlTuvst8Cg6PpPJ//hNODF1PpXBwizKtpnQ zpCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=VDR8cBCAux9gPq7pPMigmtKG5j3yetuE5TZg3+cnUa8=; b=EE7mzbKU9/rmF4q+y0oCvv/ACYAGO0THxuUnnWnEC1iwW4ohd0ytpKapKzihcteu4z zmcm9DoxEOJKtaqVpxl/yqVXnEtyDGJp2N2mZrzHyyRH/Zp8VinT8rIlcKecGmJCcIt7 z94Q6OB4KIMFL19Dp+uM2YCgtUHH0Zk5mhif7oT/+eDLdV2M0IRHN8tCo9C+sazz9R6L 8rKesbI5SSUxEryzKILRiNRT/5uQ0J0p+20A8Yr2vVCrRd/LcuzKZqFcR1dTSHidaCiU ub0vTjgYNnNHzuA8Y7AW+3YCK5/3r70ph4/1N9Ium+IeQmb3zxdpxrr4CWWzWFI6hx6P P9FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaUTNaz7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r134-v6si1335238pgr.252.2018.10.12.06.57.56; Fri, 12 Oct 2018 06:58:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaUTNaz7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728635AbeJLVaI (ORCPT + 99 others); Fri, 12 Oct 2018 17:30:08 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:34521 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728527AbeJLVaI (ORCPT ); Fri, 12 Oct 2018 17:30:08 -0400 Received: by mail-yw1-f66.google.com with SMTP id m129-v6so4986197ywc.1 for ; Fri, 12 Oct 2018 06:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VDR8cBCAux9gPq7pPMigmtKG5j3yetuE5TZg3+cnUa8=; b=WaUTNaz76TPZi6zwzw4ZK1X/B2IrHxyaC1DEfGT7vq3+Fy0iJmdF6sbrLa9ifdO/KK dBeJc/wVz/9TZFbSCF9qRUG+CWIZZraK+UYiDVDRbA1FhmQ7WYf0x9PhZGpi0ZBbolmC WGYn8k/g7naKtjNpggkpm0Je3sb37y4lC5jM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VDR8cBCAux9gPq7pPMigmtKG5j3yetuE5TZg3+cnUa8=; b=gsy5QZep/Sn+Pzzl48j2EIkrHGjsL4GgU+Ub1Pp7yN1EP5Ki8Xjw/XApBcPuApffWg R0faNMOgu9FkvvKnqxfdQWOBXADOnKvh4zYqsPLvEUpUcQRwd5tpKTeMpCEBi5BPtkrM eQ8eS67XbCJN1DnXJn7WkBT2EOf6edP7cXIXpNc2Q9oCTJgMvjoO3yvAy79Cab0WCdfW ByTB9fxOCuOq2wegJoZMo0kcD7j5bY037E3QDHiqQgn22wwKUfxVK6SY89dSwGhLgysC 4ME2g20w8o9RgKPtqNlTR+pR9dVh/CvjRi2maLapwISbVnNNE7J3VkodLGr8558cxH2C 4zQg== X-Gm-Message-State: ABuFfoj3n8IE8sCwCIjyI4z1yiGh36KENXStyz9X6SJUUdEglrOo3UTQ r5m0O/XSlcIz7Mr7x5vZTGiPEgo4427CsBUe48+BOg== X-Received: by 2002:a81:1b85:: with SMTP id b127-v6mr3517264ywb.381.1539352653412; Fri, 12 Oct 2018 06:57:33 -0700 (PDT) MIME-Version: 1.0 References: <1539337442-3676-1-git-send-email-firoz.khan@linaro.org> <1539337442-3676-4-git-send-email-firoz.khan@linaro.org> In-Reply-To: From: Firoz Khan Date: Fri, 12 Oct 2018 19:27:22 +0530 Message-ID: Subject: Re: [PATCH v4 3/6] parisc: add system call table generation support To: eike-kernel@sf-tec.de Cc: linux-parisc@vger.kernel.org, "James E . J . Bottomley" , Helge Deller , Thomas Gleixner , Greg Kroah-Hartman , Philippe Ombredanne , Kate Stewart , y2038 Mailman List , Linux Kernel Mailing List , Linux-Arch , Arnd Bergmann , Deepa Dinamani , Marcin Juszkiewicz , linux-parisc-owner@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, Rolf, Thanks for the comments. It will help me to fine tune my scripts! On Fri, 12 Oct 2018 at 17:37, Rolf Eike Beer wrote: > > Firoz Khan wrote: > > > diff --git a/arch/parisc/kernel/syscalls/syscallhdr.sh > > b/arch/parisc/kernel/syscalls/syscallhdr.sh > > new file mode 100644 > > index 0000000..607d4ca > > --- /dev/null > > +++ b/arch/parisc/kernel/syscalls/syscallhdr.sh > > @@ -0,0 +1,35 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0 > > + > > +in="$1" > > +out="$2" > > +my_abis=`echo "($3)" | tr ',' '|'` > > Any reason not to use $() instead of backticks? > > > +prefix="$4" > > +offset="$5" > > + > > +fileguard=_UAPI_ASM_PARISC_`basename "$out" | sed \ > > + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ > > + -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` > > +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( > > + echo "#ifndef ${fileguard}" > > + echo "#define ${fileguard}" > > + echo "" > > + > > + nxt=0 > > + while read nr abi name entry compat ; do > > + if [ -z "$offset" ]; then > > + echo -e "#define __NR_${prefix}${name}\t$nr" > > This mixed indentation with both tabs and spaces is a bit messy. > > > + else > > + echo -e "#define __NR_${prefix}${name}\t($offset + $nr)" > > + fi > > + nxt=$nr > > + let nxt=nxt+1 > > Why do you use let here when you do $(()) calculations at other places? > > > + done > > + > > + echo "" > > + echo "#ifdef __KERNEL__" > > + echo -e "#define __NR_syscalls\t$nxt" > > + echo "#endif" > > + echo "" > > + echo "#endif /* ${fileguard} */" > > +) > "$out" > > diff --git a/arch/parisc/kernel/syscalls/syscalltbl.sh > > b/arch/parisc/kernel/syscalls/syscalltbl.sh > > new file mode 100644 > > index 0000000..04abde7 > > --- /dev/null > > +++ b/arch/parisc/kernel/syscalls/syscalltbl.sh > > @@ -0,0 +1,46 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0 > > + > > +in="$1" > > +out="$2" > > +my_abis=`echo "($3)" | tr ',' '|'` > > +offset="$4" > > + > > +emit() { > > + nxt="$1" > > + if [ -z "$offset" ]; then > > + nr="$2" > > + else > > + nr="$2" > > + nr=$((nr+offset)) > > This could be one line, no? Or just set offset to 0 if it is empty and > avoid that if alltogether. > > > + fi > > + entry="$3" > > + > > + while [ $nxt -lt $nr ]; do > > + echo "__SYSCALL($nxt, sys_ni_syscall, )" > > + let nxt=nxt+1 > > + done > > + echo "__SYSCALL($nxt, $entry, )" > > +} > > + > > +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( > > + if [ -z "$offset" ]; then > > + nxt=0 > > + else > > + nxt=$offset > > + fi > > Another argument for offset=0 as default. > > > + > > + my_abi="$(cut -d'|' -f2 <<< $my_abis)" Here is the logic of identifying the generated script is for compat interface or not. So systbl_abi_syscall_table_c32 := common,compat,32 in Makefile will parse the script and check the second string whether this is "compat" or not. Other ways are: 1. add an extra flag, that will again add the complexity 2. check if [ ${out: -5} = "c32.h" ], this looks weird Is there any better way to do the same? > > "<<<" is a bash extension and will not work with /bin/sh. > > > + while read nr abi name entry compat ; do > > + if [ $my_abi = "compat" ]; then > > + if [ -z "$compat" ]; then > > + emit $nxt $nr $entry > > + else > > + emit $nxt $nr $compat > > + fi > > + else > > + emit $nxt $nr $entry > > + fi > > I would go for a local variable being set to $compat or $entry and > calling emit at only one place. And there should be only one if with 2 > expressions, no need for 3 branches. > > > + let nxt=nxt+1 > > Inconsistent indentation. > > > + done > > +) > "$out" I'll address rest of the comment soon. Helge, I can update this patches asap with their comments and we can perform the boot test with next version. And thanks for your great support! Firoz > > Eike