mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yani Ioannou <yani.ioannou@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org
Subject: Re: [PATCH 2.6.12-rc4-mm2] drivers: (dynamic sysfs callbacks) update device attribute callbacks
Date: Thu, 19 May 2005 07:53:06 -0400	[thread overview]
Message-ID: <2538186705051904531382021a@mail.gmail.com> (raw)
In-Reply-To: <253818670505190445647685ed@mail.gmail.com>

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";
}

      reply	other threads:[~2005-05-19 11:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-19 11:35 Yani Ioannou
2005-05-19 11:45 ` Yani Ioannou
2005-05-19 11:53   ` Yani Ioannou [this message]

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=2538186705051904531382021a@mail.gmail.com \
    --to=yani.ioannou@gmail.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    /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

all inboxes | Powered by JetHome®