20 Dec, 2014

2 commits

  • Also, print kernel version on oops.

    Signed-off-by: Jesper Nilsson

    Jesper Nilsson
     
  • strcmp was lost when all other string functions were removed,
    but we still have an optimized version for this on CRISv32,
    so any driver built as a module would not have access to this symbol.

    In a similar manner, we had optimized versions of
    csum_partial_copy_from_user and __do_clear_user
    but no exported symbols for them, breaking bunch of other drivers
    when built as a module.

    At the same time, move EXPORT_SYMBOL(__copy_user) and
    EXPORT_SYMBOL(__copy_user_zeroing) C-files so it's
    located together with the function definition.

    Signed-off-by: Jesper Nilsson

    Jesper Nilsson
     

08 Apr, 2014

1 commit

  • Fix breakage which will be exposed by the patch "kconfig: make allnoconfig
    disable options behind EMBEDDED and EXPERT".

    Now allnoconfig started disabling CONFIG_PROC_FS:

    arch/cris/kernel/built-in.o:(.rodata+0xc): undefined reference to `show_cpuinfo'
    make: *** [vmlinux] Error 1

    Signed-off-by: Geert Uytterhoeven
    Cc: Stephen Rothwell
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Geert Uytterhoeven
     

08 Jan, 2014

1 commit

  • This patch proposes to remove the IRQF_DISABLED flag from CRIS
    architecture code. It's a NOOP since 2.6.35 and it will be removed
    one day.

    Comments mentioning IRQF_DISABLED are also updated, knowing
    that all interrupts are now "fast interrupts", their handlers
    running with interrupts disabled.

    Don't hesitate to let me know if you have other ways of
    rephrasing the comments!

    This is an update for 3.11 of a patch already sent for 3.10

    Signed-off-by: Michael Opdenacker
    Signed-off-by: Jesper Nilsson

    Michael Opdenacker
     

08 May, 2013

1 commit

  • arch/arm/mach-msm/last_radio_log.c: In function 'msm_init_last_radio_log':
    arch/arm/mach-msm/last_radio_log.c:69:7: error: dereferencing pointer to incomplete type

    arch/cris/kernel/profile.c: In function 'init_cris_profile':
    arch/cris/kernel/profile.c:79:8: error: dereferencing pointer to incomplete type

    Use proc_set_size(), cfr. commit 271a15eabe094538d958dc68ccfc9c36b699247a
    ("proc: Supply PDE attribute setting accessor functions")

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Al Viro

    Geert Uytterhoeven
     

01 May, 2013

1 commit

  • Both dump_stack() and show_stack() are currently implemented by each
    architecture. show_stack(NULL, NULL) dumps the backtrace for the
    current task as does dump_stack(). On some archs, dump_stack() prints
    extra information - pid, utsname and so on - in addition to the
    backtrace while the two are identical on other archs.

    The usages in arch-independent code of the two functions indicate
    show_stack(NULL, NULL) should print out bare backtrace while
    dump_stack() is used for debugging purposes when something went wrong,
    so it does make sense to print additional information on the task which
    triggered dump_stack().

    There's no reason to require archs to implement two separate but mostly
    identical functions. It leads to unnecessary subtle information.

    This patch expands the dummy fallback dump_stack() implementation in
    lib/dump_stack.c such that it prints out debug information (taken from
    x86) and invokes show_stack(NULL, NULL) and drops arch-specific
    dump_stack() implementations in all archs except blackfin. Blackfin's
    dump_stack() does something wonky that I don't understand.

    Debug information can be printed separately by calling
    dump_stack_print_info() so that arch-specific dump_stack()
    implementation can still emit the same debug information. This is used
    in blackfin.

    This patch brings the following behavior changes.

    * On some archs, an extra level in backtrace for show_stack() could be
    printed. This is because the top frame was determined in
    dump_stack() on those archs while generic dump_stack() can't do that
    reliably. It can be compensated by inlining dump_stack() but not
    sure whether that'd be necessary.

    * Most archs didn't use to print debug info on dump_stack(). They do
    now.

    An example WARN dump follows.

    WARNING: at kernel/workqueue.c:4841 init_workqueues+0x35/0x505()
    Hardware name: empty
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #9
    0000000000000009 ffff88007c861e08 ffffffff81c614dc ffff88007c861e48
    ffffffff8108f50f ffffffff82228240 0000000000000040 ffffffff8234a03c
    0000000000000000 0000000000000000 0000000000000000 ffff88007c861e58
    Call Trace:
    [] dump_stack+0x19/0x1b
    [] warn_slowpath_common+0x7f/0xc0
    [] warn_slowpath_null+0x1a/0x20
    [] init_workqueues+0x35/0x505
    ...

    v2: CPU number added to the generic debug info as requested by s390
    folks and dropped the s390 specific dump_stack(). This loses %ksp
    from the debug message which the maintainers think isn't important
    enough to keep the s390-specific dump_stack() implementation.

    dump_stack_print_info() is moved to kernel/printk.c from
    lib/dump_stack.c. Because linkage is per objecct file,
    dump_stack_print_info() living in the same lib file as generic
    dump_stack() means that archs which implement custom dump_stack()
    - at this point, only blackfin - can't use dump_stack_print_info()
    as that will bring in the generic version of dump_stack() too. v1
    The v1 patch broke build on blackfin due to this issue. The build
    breakage was reported by Fengguang Wu.

    Signed-off-by: Tejun Heo
    Acked-by: David S. Miller
    Acked-by: Vineet Gupta
    Acked-by: Jesper Nilsson
    Acked-by: Vineet Gupta
    Acked-by: Martin Schwidefsky [s390 bits]
    Cc: Heiko Carstens
    Cc: Mike Frysinger
    Cc: Fengguang Wu
    Cc: Bjorn Helgaas
    Cc: Sam Ravnborg
    Acked-by: Richard Kuo [hexagon bits]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

08 Apr, 2013

2 commits

  • Signed-off-by: Thomas Gleixner
    Cc: Linus Torvalds
    Cc: Rusty Russell
    Cc: Paul McKenney
    Cc: Peter Zijlstra
    Reviewed-by: Cc: Srivatsa S. Bhat
    Cc: Magnus Damm
    Acked-by: Jesper Nilsson
    Link: http://lkml.kernel.org/r/20130321215234.148829489@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • enable/disable_hlt() does not need to be exported and can be killed on
    architectures which do not use it at all.

    Signed-off-by: Thomas Gleixner
    Cc: Linus Torvalds
    Cc: Rusty Russell
    Cc: Paul McKenney
    Cc: Peter Zijlstra
    Reviewed-by: Cc: Srivatsa S. Bhat
    Cc: Magnus Damm
    Link: http://lkml.kernel.org/r/20130321215233.377959540@linutronix.de
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

22 Feb, 2013

1 commit

  • Pull ARM SoC cleanups from Arnd Bergmann:
    "A large number of cleanups, all over the platforms. This is dominated
    largely by the Samsung platforms (s3c, s5p, exynos) and a few of the
    others moving code out of arch/arm into more appropriate subsystems.

    The clocksource and irqchip drivers are now abstracted to the point
    where platforms that are already cleaned up do not need to even
    specify the driver they use, it can all get configured from the device
    tree as we do for normal device drivers. The clocksource changes
    basically touch every single platform in the process.

    We further clean up the use of platform specific header files here,
    with the goal of turning more of the platforms over to being
    "multiplatform" enabled, which implies that they cannot expose their
    headers to architecture independent code any more.

    It is expected that no functional changes are part of the cleanup.
    The overall reduction in total code lines is mostly the result of
    removing broken and obsolete code."

    * tag 'cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (133 commits)
    ARM: mvebu: correct gated clock documentation
    ARM: kirkwood: add missing include for nsa310
    ARM: exynos: move exynos4210-combiner to drivers/irqchip
    mfd: db8500-prcmu: update resource passing
    drivers/db8500-cpufreq: delete dangling include
    ARM: at91: remove NEOCORE 926 board
    sunxi: Cleanup the reset code and add meaningful registers defines
    ARM: S3C24XX: header mach/regs-mem.h local
    ARM: S3C24XX: header mach/regs-power.h local
    ARM: S3C24XX: header mach/regs-s3c2412-mem.h local
    ARM: S3C24XX: Remove plat-s3c24xx directory in arch/arm/
    ARM: S3C24XX: transform s3c2443 subirqs into new structure
    ARM: S3C24XX: modify s3c2443 irq init to initialize all irqs
    ARM: S3C24XX: move s3c2443 irq code to irq.c
    ARM: S3C24XX: transform s3c2416 irqs into new structure
    ARM: S3C24XX: modify s3c2416 irq init to initialize all irqs
    ARM: S3C24XX: move s3c2416 irq init to common irq code
    ARM: S3C24XX: Modify s3c_irq_wake to use the hwirq property
    ARM: S3C24XX: Move irq syscore-ops to irq-pm
    clocksource: always define CLOCKSOURCE_OF_DECLARE
    ...

    Linus Torvalds
     

18 Feb, 2013

1 commit


25 Dec, 2012

2 commits

  • Currently, whenever CONFIG_ARCH_USES_GETTIMEOFFSET is enabled, each
    arch core provides a single implementation of arch_gettimeoffset(). In
    many cases, different sub-architectures, different machines, or
    different timer providers exist, and so the arch ends up implementing
    arch_gettimeoffset() as a call-through-pointer anyway. Examples are
    ARM, Cris, M68K, and it's arguable that the remaining architectures,
    M32R and Blackfin, should be doing this anyway.

    Modify arch_gettimeoffset so that it itself is a function pointer, which
    the arch initializes. This will allow later changes to move the
    initialization of this function into individual machine support or timer
    drivers. This is particularly useful for code in drivers/clocksource
    which should rely on an arch-independant mechanism to register their
    implementation of arch_gettimeoffset().

    This patch also converts the Cris architecture to set arch_gettimeoffset
    directly to the final implementation in time_init(), because Cris already
    had separate time_init() functions per sub-architecture. M68K and ARM
    are converted to set arch_gettimeoffset to the final implementation in
    later patches, because they already have function pointers in place for
    this purpose.

    Cc: Russell King
    Cc: Mike Frysinger
    Cc: Mikael Starvik
    Cc: Hirokazu Takata
    Cc: Thomas Gleixner
    Acked-by: Geert Uytterhoeven
    Acked-by: Jesper Nilsson
    Acked-by: John Stultz
    Signed-off-by: Stephen Warren

    Stephen Warren
     
  • Move usec to nsec conversion from arch_gettimeoffset() to
    do_slow_gettimeoffset(); in a future patch, do_slow_gettimeoffset()
    will be used directly as the implementation of arch_gettimeoffset(),
    so needs to perform all required calculations.

    Cc: Mikael Starvik
    Cc: linux-cris-kernel@axis.com
    Acked-by: Jesper Nilsson
    Signed-off-by: Stephen Warren

    Stephen Warren
     

20 Dec, 2012

1 commit


19 Dec, 2012

1 commit

  • Pull module update from Rusty Russell:
    "Nothing all that exciting; a new module-from-fd syscall for those who
    want to verify the source of the module (ChromeOS) and/or use standard
    IMA on it or other security hooks."

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    MODSIGN: Fix kbuild output when using default extra_certificates
    MODSIGN: Avoid using .incbin in C source
    modules: don't hand 0 to vmalloc.
    module: Remove a extra null character at the top of module->strtab.
    ASN.1: Use the ASN1_LONG_TAG and ASN1_INDEFINITE_LENGTH constants
    ASN.1: Define indefinite length marker constant
    moduleparam: use __UNIQUE_ID()
    __UNIQUE_ID()
    MODSIGN: Add modules_sign make target
    powerpc: add finit_module syscall.
    ima: support new kernel module syscall
    add finit_module syscall to asm-generic
    ARM: add finit_module syscall to ARM
    security: introduce kernel_module_from_file hook
    module: add flags arg to sys_finit_module()
    module: add syscall to load module from fd

    Linus Torvalds
     

14 Dec, 2012

1 commit

  • In commit d0a21265dfb5fa8a David Rientjes unified various archs'
    module_alloc implementation (including x86) and removed the graduitous
    shortcut for size == 0.

    Then, in commit de7d2b567d040e3b, Joe Perches added a warning for
    zero-length vmallocs, which can happen without kallsyms on modules
    with no init sections (eg. zlib_deflate).

    Fix this once and for all; the module code has to handle zero length
    anyway, so get it right at the caller and remove the now-gratuitous
    checks within the arch-specific module_alloc implementations.

    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=42608
    Reported-by: Conrad Kostecki
    Cc: David Rientjes
    Cc: Joe Perches
    Signed-off-by: Rusty Russell

    Rusty Russell
     

15 Oct, 2012

1 commit


23 Sep, 2012

1 commit

  • In the old times, the whole idle task was considered
    as an RCU quiescent state. But as RCU became more and
    more successful overtime, some RCU read side critical
    section have been added even in the code of some
    architectures idle tasks, for tracing for example.

    So nowadays, rcu_idle_enter() and rcu_idle_exit() must
    be called by the architecture to tell RCU about the part
    in the idle loop that doesn't make use of rcu read side
    critical sections, typically the part that puts the CPU
    in low power mode.

    This is necessary for RCU to find the quiescent states in
    idle in order to complete grace periods.

    Add this missing pair of calls in the Cris's idle loop.

    Reported-by: Paul E. McKenney
    Signed-off-by: Frederic Weisbecker
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: Cris
    Cc: # 3.3+
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Frederic Weisbecker
     

01 Jun, 2012

1 commit

  • Pull second pile of signal handling patches from Al Viro:
    "This one is just task_work_add() series + remaining prereqs for it.

    There probably will be another pull request from that tree this
    cycle - at least for helpers, to get them out of the way for per-arch
    fixes remaining in the tree."

    Fix trivial conflict in kernel/irq/manage.c: the merge of Andrew's pile
    had brought in commit 97fd75b7b8e0 ("kernel/irq/manage.c: use the
    pr_foo() infrastructure to prefix printks") which changed one of the
    pr_err() calls that this merge moves around.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal:
    keys: kill task_struct->replacement_session_keyring
    keys: kill the dummy key_replace_session_keyring()
    keys: change keyctl_session_to_parent() to use task_work_add()
    genirq: reimplement exit_irq_thread() hook via task_work_add()
    task_work_add: generic process-context callbacks
    avr32: missed _TIF_NOTIFY_RESUME on one of do_notify_resume callers
    parisc: need to check NOTIFY_RESUME when exiting from syscall
    move key_repace_session_keyring() into tracehook_notify_resume()
    TIF_NOTIFY_RESUME is defined on all targets now

    Linus Torvalds
     

25 May, 2012

1 commit

  • Pull CRIS changes from Jesper Nilsson:
    "No major changes here, but fixes some compile errors for CRIS, some
    small style issues, some documentation and as a bonus nukes a couple
    of obsolete rtc-files and related code."

    * tag 'cris-for-linus' of git://jni.nu/cris:
    cris: Remove old legacy "-traditional" flag from arch-v10/lib/Makefile
    CRIS: Remove legacy RTC drivers
    cris/mm/fault.c: Port OOM changes to do_page_fault
    cris:fix the wrong function declear
    CRIS: Add _sdata to vmlinux.lds.S
    cris: posix_types.h, include asm-generic/posix_types.h
    CRIS: Update documentation
    cris/arch-v32: cryptocop: Use kzalloc
    net:removed the unused variable
    cris:removed the unused variable
    CRISv32: Correct name of read_mostly section.

    Linus Torvalds
     

24 May, 2012

1 commit


05 May, 2012

1 commit


05 Apr, 2012

1 commit


03 Apr, 2012

1 commit


29 Mar, 2012

1 commit


01 Mar, 2012

1 commit


27 Jul, 2011

1 commit

  • This allows us to move duplicated code in
    (atomic_inc_not_zero() for now) to

    Signed-off-by: Arun Sharma
    Reviewed-by: Eric Dumazet
    Cc: Ingo Molnar
    Cc: David Miller
    Cc: Eric Dumazet
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun Sharma
     

24 Jul, 2011

1 commit

  • This patch removes all the module loader hook implementations in the
    architecture specific code where the functionality is the same as that
    now provided by the recently added default hooks.

    Signed-off-by: Jonas Bonn
    Acked-by: Mike Frysinger
    Acked-by: Geert Uytterhoeven
    Tested-by: Michal Simek
    Signed-off-by: Rusty Russell

    Jonas Bonn
     

25 May, 2011

1 commit


31 Mar, 2011

1 commit


25 Mar, 2011

1 commit

  • Percpu allocator honors alignment request upto PAGE_SIZE and both the
    percpu addresses in the percpu address space and the translated kernel
    addresses should be aligned accordingly. The calculation of the
    former depends on the alignment of percpu output section in the kernel
    image.

    The linker script macros PERCPU_VADDR() and PERCPU() are used to
    define this output section and the latter takes @align parameter.
    Several architectures are using @align smaller than PAGE_SIZE breaking
    percpu memory alignment.

    This patch removes @align parameter from PERCPU(), renames it to
    PERCPU_SECTION() and makes it always align to PAGE_SIZE. While at it,
    add PCPU_SETUP_BUG_ON() checks such that alignment problems are
    reliably detected and remove percpu alignment comment recently added
    in workqueue.c as the condition would trigger BUG way before reaching
    there.

    For um, this patch raises the alignment of percpu area. As the area
    is in .init, there shouldn't be any noticeable difference.

    This problem was discovered by David Howells while debugging boot
    failure on mn10300.

    Signed-off-by: Tejun Heo
    Acked-by: Mike Frysinger
    Cc: uclinux-dist-devel@blackfin.uclinux.org
    Cc: David Howells
    Cc: Jeff Dike
    Cc: user-mode-linux-devel@lists.sourceforge.net

    Tejun Heo
     

19 Mar, 2011

1 commit

  • …rnel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

    * 'irq-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    genirq: Fix incorrect unlock in __setup_irq()
    cris: Use generic show_interrupts()
    genirq: show_interrupts: Check desc->name before printing it blindly
    cris: Use accessor functions to set IRQ_PER_CPU flag
    cris: Fix irq conversion fallout

    * 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    sched, kernel-doc: Fix runqueue_is_locked() description

    Linus Torvalds
     

17 Mar, 2011

1 commit


16 Mar, 2011

1 commit

  • * 'for-2.6.39' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
    percpu, x86: Add arch-specific this_cpu_cmpxchg_double() support
    percpu: Generic support for this_cpu_cmpxchg_double()
    alpha: use L1_CACHE_BYTES for cacheline size in the linker script
    percpu: align percpu readmostly subsection to cacheline

    Fix up trivial conflict in arch/x86/kernel/vmlinux.lds.S due to the
    percpu alignment having changed ("x86: Reduce back the alignment of the
    per-CPU data section")

    Linus Torvalds
     

24 Feb, 2011

1 commit


25 Jan, 2011

1 commit

  • Currently percpu readmostly subsection may share cachelines with other
    percpu subsections which may result in unnecessary cacheline bounce
    and performance degradation.

    This patch adds @cacheline parameter to PERCPU() and PERCPU_VADDR()
    linker macros, makes each arch linker scripts specify its cacheline
    size and use it to align percpu subsections.

    This is based on Shaohua's x86 only patch.

    Signed-off-by: Tejun Heo
    Cc: Shaohua Li

    Tejun Heo
     

21 Jan, 2011

2 commits


14 Jan, 2011

1 commit

  • Occasionally the system gets into a state where the CMOS clock has gotten
    slightly ahead of current time and the periodic update of RTC fails. The
    message is a nuisance and repeats spamming the log.

    See: http://www.ntp.org/ntpfaq/NTP-s-trbl-spec.htm#Q-LINUX-SET-RTC-MMSS

    Rather than just removing the message, make it show only once and reduce
    severity since it indicates a normal and non urgent condition.

    Signed-off-by: Stephen Hemminger
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Ralf Baechle
    Cc: David Howells
    Cc: Paul Mundt
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Hemminger
     

15 Oct, 2010

1 commit

  • All file_operations should get a .llseek operation so we can make
    nonseekable_open the default for future file operations without a
    .llseek pointer.

    The three cases that we can automatically detect are no_llseek, seq_lseek
    and default_llseek. For cases where we can we can automatically prove that
    the file offset is always ignored, we use noop_llseek, which maintains
    the current behavior of not returning an error from a seek.

    New drivers should normally not use noop_llseek but instead use no_llseek
    and call nonseekable_open at open time. Existing drivers can be converted
    to do the same when the maintainer knows for certain that no user code
    relies on calling seek on the device file.

    The generated code is often incorrectly indented and right now contains
    comments that clarify for each added line why a specific variant was
    chosen. In the version that gets submitted upstream, the comments will
    be gone and I will manually fix the indentation, because there does not
    seem to be a way to do that using coccinelle.

    Some amount of new code is currently sitting in linux-next that should get
    the same modifications, which I will do at the end of the merge window.

    Many thanks to Julia Lawall for helping me learn to write a semantic
    patch that does all this.

    ===== begin semantic patch =====
    // This adds an llseek= method to all file operations,
    // as a preparation for making no_llseek the default.
    //
    // The rules are
    // - use no_llseek explicitly if we do nonseekable_open
    // - use seq_lseek for sequential files
    // - use default_llseek if we know we access f_pos
    // - use noop_llseek if we know we don't access f_pos,
    // but we still want to allow users to call lseek
    //
    @ open1 exists @
    identifier nested_open;
    @@
    nested_open(...)
    {

    }

    @ open exists@
    identifier open_f;
    identifier i, f;
    identifier open1.nested_open;
    @@
    int open_f(struct inode *i, struct file *f)
    {

    }

    @ read disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {

    }

    @ read_no_fpos disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ write @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {

    }

    @ write_no_fpos @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ fops0 @
    identifier fops;
    @@
    struct file_operations fops = {
    ...
    };

    @ has_llseek depends on fops0 @
    identifier fops0.fops;
    identifier llseek_f;
    @@
    struct file_operations fops = {
    ...
    .llseek = llseek_f,
    ...
    };

    @ has_read depends on fops0 @
    identifier fops0.fops;
    identifier read_f;
    @@
    struct file_operations fops = {
    ...
    .read = read_f,
    ...
    };

    @ has_write depends on fops0 @
    identifier fops0.fops;
    identifier write_f;
    @@
    struct file_operations fops = {
    ...
    .write = write_f,
    ...
    };

    @ has_open depends on fops0 @
    identifier fops0.fops;
    identifier open_f;
    @@
    struct file_operations fops = {
    ...
    .open = open_f,
    ...
    };

    // use no_llseek if we call nonseekable_open
    ////////////////////////////////////////////
    @ nonseekable1 depends on !has_llseek && has_open @
    identifier fops0.fops;
    identifier nso ~= "nonseekable_open";
    @@
    struct file_operations fops = {
    ... .open = nso, ...
    +.llseek = no_llseek, /* nonseekable */
    };

    @ nonseekable2 depends on !has_llseek @
    identifier fops0.fops;
    identifier open.open_f;
    @@
    struct file_operations fops = {
    ... .open = open_f, ...
    +.llseek = no_llseek, /* open uses nonseekable */
    };

    // use seq_lseek for sequential files
    /////////////////////////////////////
    @ seq depends on !has_llseek @
    identifier fops0.fops;
    identifier sr ~= "seq_read";
    @@
    struct file_operations fops = {
    ... .read = sr, ...
    +.llseek = seq_lseek, /* we have seq_read */
    };

    // use default_llseek if there is a readdir
    ///////////////////////////////////////////
    @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier readdir_e;
    @@
    // any other fop is used that changes pos
    struct file_operations fops = {
    ... .readdir = readdir_e, ...
    +.llseek = default_llseek, /* readdir is present */
    };

    // use default_llseek if at least one of read/write touches f_pos
    /////////////////////////////////////////////////////////////////
    @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read.read_f;
    @@
    // read fops use offset
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = default_llseek, /* read accesses f_pos */
    };

    @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ... .write = write_f, ...
    + .llseek = default_llseek, /* write accesses f_pos */
    };

    // Use noop_llseek if neither read nor write accesses f_pos
    ///////////////////////////////////////////////////////////

    @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    identifier write_no_fpos.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ...
    .write = write_f,
    .read = read_f,
    ...
    +.llseek = noop_llseek, /* read and write both use no f_pos */
    };

    @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write_no_fpos.write_f;
    @@
    struct file_operations fops = {
    ... .write = write_f, ...
    +.llseek = noop_llseek, /* write uses no f_pos */
    };

    @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    @@
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = noop_llseek, /* read uses no f_pos */
    };

    @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    @@
    struct file_operations fops = {
    ...
    +.llseek = noop_llseek, /* no read or write fn */
    };
    ===== End semantic patch =====

    Signed-off-by: Arnd Bergmann
    Cc: Julia Lawall
    Cc: Christoph Hellwig

    Arnd Bergmann
     

05 Aug, 2010

1 commit