From: Dan Carpenter <dan.carpenter@oracle.com>
To: Marek Vasut <marex@denx.de>
Cc: "Jürgen Beisert" <jbe@pengutronix.de>,
linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org,
"Fabio Estevam" <fabio.estevam@freescale.com>,
linux-iio@vger.kernel.org, "Jonathan Cameron" <jic23@cam.ac.uk>
Subject: Re: [PATCH 3/5] Staging/iio/adc/touchscreen/MXS: add i.MX23 support to the LRADC driver
Date: Thu, 5 Sep 2013 21:15:56 +0300 [thread overview]
Message-ID: <20130905181556.GU19256@mwanda> (raw)
In-Reply-To: <201309051251.39877.marex@denx.de>
[-- Attachment #1: Type: text/plain, Size: 711 bytes --]
Since I work in staging I review hundreds of churn patches per cycle.
One thing which helps me is my rename_rev.pl script (attached).
So if I get a patch like the one I'm about to send which introduces
lradc_reg_set/clear() functions, then I can do this:
cat diff | rename_rev.pl -ea 's/,\n/,/' | \
rename_rev.pl -e 's/writel\((.*?),\s+lradc->base \+ (.*?) .*SET\)/lradc_reg_set(lradc, $1, $2)/' \
-e 's/writel\((.*?),\s+lradc->base \+ (.*?) .*CLR\)/lradc_reg_clear(lradc, $1, $2)/'
It simplifies the patch down to its most minimal form.
I should probably automate the first part which strips out some
line breaks... I'll post a new version of rename_rev.pl to LKML soon.
regards,
dan carpenter
[-- Attachment #2: rename_rev.pl --]
[-- Type: text/x-perl, Size: 4221 bytes --]
#!/usr/bin/perl
# This is a tool to help review variable rename patches. The goal is
# to strip out the automatic sed renames and the white space changes
# and leaves the interesting code changes.
#
# Example 1: A patch renames openInfo to open_info:
# cat diff | rename_review.pl openInfo open_info
#
# Example 2: A patch swaps the first two arguments to some_func():
# cat diff | rename_review.pl \
# -e 's/some_func\((.*?),(.*?),/some_func\($2, $1,/'
#
# Example 3: A patch removes the xkcd_ prefix from some but not all the
# variables. Instead of trying to figure out which variables were renamed
# just remove the prefix from them all:
# cat diff | rename_review.pl -ea 's/xkcd_//g'
#
# Example 4: A patch renames 20 CamelCase variables. To review this let's
# just ignore all case changes and all '_' chars.
# cat diff | rename_review -ea 'tr/[A-Z]/[a-z]/' -ea 's/_//g'
#
# The other arguments are:
# -nc removes comments
# -ns removes '\' chars if they are at the end of the line.
use strict;
use File::Temp qw/ :mktemp /;
sub usage() {
print "usage: cat diff | $0 old new old new old new...\n";
print " or: cat diff | $0 -e 's/old/new/g'\n";
print " -e : execute on old lines\n";
print " -ea: execute on all lines\n";
print " -nc: no comments\n";
print " -nb: no unneeded braces\n";
print " -ns: no slashes at the end of a line\n";
exit(1);
}
my @subs;
my @cmds;
my $strip_comments;
my $strip_braces;
my $strip_slashes;
sub filter($) {
my $_ = shift();
my $old = 0;
if ($_ =~ /^-/) {
$old = 1;
}
# remove the first char
s/^[ +-]//;
if ($strip_comments) {
s/\/\*.*?\*\///g;
s/\/\/.*//;
}
foreach my $cmd (@cmds) {
if ($old || $cmd->[0] =~ /^-ea$/) {
eval $cmd->[1];
}
}
foreach my $sub (@subs) {
if ($old) {
s/$sub->[0]/$sub->[1]/g;
}
}
return $_;
}
while (my $param1 = shift()) {
if ($param1 =~ /^-nc$/) {
$strip_comments = 1;
next;
}
if ($param1 =~ /^-nb$/) {
$strip_braces = 1;
next;
}
if ($param1 =~ /^-ns$/) {
$strip_slashes = 1;
next;
}
my $param2 = shift();
if ($param2 =~ /^$/) {
usage();
}
if ($param1 =~ /^-e(a|)$/) {
push @cmds, [$param1, $param2];
next;
}
push @subs, [$param1, $param2];
}
my ($oldfh, $oldfile) = mkstemp("/tmp/oldXXXXX");
my ($newfh, $newfile) = mkstemp("/tmp/newXXXXX");
while (<>) {
if ($_ =~ /^(---|\+\+\+)/) {
next;
}
my $output = filter($_);
if ($_ =~ /^-/) {
print $oldfh $output;
next;
}
if ($_ =~ /^\+/) {
print $newfh $output;
next;
}
print $oldfh $output;
print $newfh $output;
}
my $hunk;
my $old_txt;
my $new_txt;
open diff, "diff -uw $oldfile $newfile |";
while (<diff>) {
if ($_ =~ /^(---|\+\+\+)/) {
next;
}
if ($_ =~ /^@/) {
if ($strip_comments) {
$old_txt =~ s/\/\*.*?\*\///g;
$new_txt =~ s/\/\*.*?\*\///g;
}
if ($strip_braces) {
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
# this is a hack because i don't know how to replace nested
# unneeded curly braces.
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
}
if ($old_txt ne $new_txt) {
print $hunk;
print $_;
}
$hunk = "";
$old_txt = "";
$new_txt = "";
next;
}
$hunk = $hunk . $_;
if ($strip_slashes) {
s/\\$//;
}
if ($_ =~ /^-/) {
s/-//;
s/[ \t\n]//g;
$old_txt = $old_txt . $_;
next;
}
if ($_ =~ /^\+/) {
s/\+//;
s/[ \t\n]//g;
$new_txt = $new_txt . $_;
next;
}
if ($_ =~ /^ /) {
s/^ //;
s/[ \t\n]//g;
$old_txt = $old_txt . $_;
$new_txt = $new_txt . $_;
}
}
if ($old_txt ne $new_txt) {
if ($strip_comments) {
$old_txt =~ s/\/\*.*?\*\///g;
$new_txt =~ s/\/\*.*?\*\///g;
}
if ($strip_braces) {
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
$old_txt =~ s/{([^;{]*?);}/$1;/g;
$new_txt =~ s/{([^;{]*?);}/$1;/g;
}
print $hunk;
}
unlink($oldfile);
unlink($newfile);
next prev parent reply other threads:[~2013-09-05 18:15 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-04 13:01 [RFC] staging/iio/adc: change the MXS touchscreen driver implementation Juergen Beisert
2013-09-04 13:01 ` [PATCH 1/5] Staging/iio/adc/touchscreen/MXS: distinguish i.MX23's and i.MX28's LRADC Juergen Beisert
2013-09-04 13:01 ` [PATCH 2/5] Staging/iio/adc/touchscreen/MXS: separate i.MX28 specific register bits Juergen Beisert
2013-09-04 14:06 ` Marek Vasut
2013-09-05 7:12 ` Jürgen Beisert
2013-09-04 14:36 ` Dan Carpenter
2013-09-05 7:13 ` Jürgen Beisert
2013-09-04 13:01 ` [PATCH 3/5] Staging/iio/adc/touchscreen/MXS: add i.MX23 support to the LRADC driver Juergen Beisert
2013-09-04 14:27 ` Dan Carpenter
2013-09-05 10:16 ` Jürgen Beisert
2013-09-05 10:42 ` Dan Carpenter
2013-09-05 10:51 ` Marek Vasut
2013-09-05 18:15 ` Dan Carpenter [this message]
2013-09-05 18:16 ` [patch] iio: mxs-lradc: use helper functions to simplify the code Dan Carpenter
2013-09-05 20:15 ` Fabio Estevam
2013-09-05 20:29 ` Marek Vasut
2013-09-06 8:39 ` Russell King - ARM Linux
2013-09-06 7:01 ` Jürgen Beisert
2013-09-06 7:29 ` Dan Carpenter
2013-09-04 13:01 ` [PATCH 4/5] Staging/iio/adc/touchscreen/MXS: add interrupt driven touch detection Juergen Beisert
2013-09-04 13:01 ` [PATCH 5/5] Staging/iio/adc/touchscreen/MXS: Remove old touchscreen detection implementation Juergen Beisert
2013-09-04 14:37 ` Dan Carpenter
2013-09-05 7:10 ` Jürgen Beisert
-- strict thread matches above, loose matches on Subject: below --
2013-09-06 10:08 [RFCv2] staging/iio/adc: change the MXS touchscreen driver implementation Juergen Beisert
2013-09-06 10:08 ` [PATCH 3/5] Staging/iio/adc/touchscreen/MXS: add i.MX23 support to the LRADC driver Juergen Beisert
2013-09-09 8:03 [RFCv3] staging/iio/adc: change the MXS touchscreen driver implementation Juergen Beisert
2013-09-09 8:03 ` [PATCH 3/5] Staging/iio/adc/touchscreen/MXS: add i.MX23 support to the LRADC driver Juergen Beisert
2013-09-09 16:04 ` Marek Vasut
2013-09-10 7:36 ` Jürgen Beisert
2013-09-10 8:22 ` Marek Vasut
2013-09-10 12:58 ` Jürgen Beisert
2013-09-10 13:43 ` Marek Vasut
2013-09-10 20:54 ` Dan Carpenter
2013-09-10 21:21 ` Marek Vasut
2013-09-11 7:07 ` Jürgen Beisert
2013-09-11 7:06 ` Jürgen Beisert
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=20130905181556.GU19256@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=fabio.estevam@freescale.com \
--cc=jbe@pengutronix.de \
--cc=jic23@cam.ac.uk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=marex@denx.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