Re: [PATCH 2.6.12-rc4-mm2] drivers: (dynamic sysfs callbacks) update device attribute callbacks

From: Yani Ioannou
Date: Thu May 19 2005 - 06:54:36 EST


Here is the previously mentioned perl script. Its quite simplistic,
and accepts the filename of a source file to update as a parameter, or
uses stdin/stdout if no parameters are given. To update a whole tree
using the below just use something like:

find linux-2.6.12-rc4 -type f -exec ./updatedyncallbackdevattr.pl {} \;

This script should catch every device_attribute callback, including
multiline function signatures and embedded in macros. If it fails to
catch something please let me know.

Thanks,
Yani

---
#!/usr/bin/perl

use strict;

my $infile=shift;

if(!defined $infile){
open(IN,"<&STDIN") or die "Could not open an input stream";
}else{
open(IN,"<$infile") or die "Could not open an input stream";
}

my $subs = 0;
my $code = "";

while(<IN>){$code.=$_};
close(IN);

$code =~ s/(ssize_t[\s\\]+?[^(;]+?\(\s*?struct[\s\\]+?(?:device)[\s\\]*?\*[^,);]*?,)([\s\\]*?char[\s\\]*?\*[^,);]*?[\s\\]*?\))/$1
struct device_attribute *attr,$2/gs && $subs++;
$code =~ s/(ssize_t[\s\\]+?[^(;]+?\(\s*?struct[\s\\]+?(?:device)[\s\\]*?\*[^,);]*?,)([\s\\]*?const[\s\\]+?char[\s\\]*?\*[^,);]*?[\s\\]*?,[\s\\]*size_t[^,);]*?[\s\\]*\))/$1
struct device_attribute *attr,$2/gs && $subs++;

if($subs){
if(!defined $infile){
open(OUT,">&STDOUT") or die "Could not open an output stream";
}else{
open(OUT,">$infile") or die "Could not open an output stream";
}
$|;
print OUT $code;
close(OUT);
$infile && print STDOUT "$infile updated.\n";
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/