10 Sep, 2015

1 commit

  • /sys/class/watchdog/watchdogn/device/modalias can help to identify the
    driver/module for a given watchdog node. However, many wdt devices do not
    set their parent and so, we do not see an entry for device in sysfs for
    such devices.

    This patch fixes parent of watchdog_device so that
    /sys/class/watchdog/watchdogn/device is populated.

    Exceptions: booke, diag288, octeon, softdog and w83627hf -- They do not
    have any parent. Not sure, how we can identify driver for these devices.

    Signed-off-by: Pratyush Anand
    Reviewed-by: Johannes Thumshirn
    Acked-by: Guenter Roeck
    Acked-by: H Hartley Sweeten
    Acked-by: Lee Jones
    Acked-by: Lubomir Rintel
    Acked-by: Maxime Coquelin
    Acked-by: Thierry Reding
    Acked-by: Viresh Kumar
    Acked-by: Linus Walleij
    Signed-off-by: Wim Van Sebroeck

    Pratyush Anand
     

01 Jul, 2015

1 commit

  • Add a early_enable module parameter to the omap_wdt that starts the
    watchdog on module insertion. The default value is 0 which does not
    start the watchdog - which also does not change the behavior if the
    parameter is not given.

    Signed-off-by: Lars Poeschel
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Lars Poeschel
     

22 Jun, 2015

5 commits

  • The omap watchdog hardware is able to read the watchdog timer counter
    register. This implements this functionality in the omap_wdt driver, so
    one is can read the time until the watchdog will trigger the reset in
    seconds using WDIOC_GETTIMELEFT.

    Signed-off-by: Lars Poeschel
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Lars Poeschel
     
  • The omap watchdog has the annoying behaviour that writes to most
    registers don't have any effect when the watchdog is already running.
    Quoting the AM335x reference manual:

    To modify the timer counter value (the WDT_WCRR register),
    prescaler ratio (the WDT_WCLR[4:2] PTV bit field), delay
    configuration value (the WDT_WDLY[31:0] DLY_VALUE bit field), or
    the load value (the WDT_WLDR[31:0] TIMER_LOAD bit field), the
    watchdog timer must be disabled by using the start/stop sequence
    (the WDT_WSPR register).

    Currently the timer is stopped in the .probe callback but still there
    are possibilities that yield to a situation where omap_wdt_start is
    entered with the timer running (e.g. when /dev/watchdog is closed
    without stopping and then reopened). In such a case programming the
    timeout silently fails!

    To circumvent this stop the timer before reprogramming.

    Assuming one of the first things the watchdog user does is setting the
    timeout explicitly nothing too bad should happen because this explicit
    setting works fine.

    Fixes: 7768a13c252a ("[PATCH] OMAP: Add Watchdog driver support")
    Signed-off-by: Uwe Kleine-König
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Uwe Kleine-König
     
  • Instead of using an over-long expression involving the ?: operator use
    an if and instead of an else branch rely on the fact that the data
    structure was allocated using devm_kzalloc. This also allows to put the
    used helper variable into a more local scope.

    There is no functional change.

    Signed-off-by: Uwe Kleine-König
    Reviewed-by: Felipe Balbi
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Uwe Kleine-König
     
  • This way only a single allocation is needed (per device). Also this
    simplifies the data structure used by the driver because there is no
    need anymore to link from one struct to the other (by means of
    watchdog_{set,get}_drvdata).

    Signed-off-by: Uwe Kleine-König
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Uwe Kleine-König
     
  • Instead of (partly) open coding watchdog_init_timeout to determine the
    inital timeout use the core function that exists for exactly this
    purpose.

    As a side effect the "timeout-sec" device-tree property is recognized now
    (though currently unused in the omap device trees).

    Signed-off-by: Uwe Kleine-König
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Uwe Kleine-König
     

18 Feb, 2015

1 commit


20 Oct, 2014

1 commit


31 Mar, 2014

2 commits

  • Use devm_ioremap_resource() in order to make the code simpler,
    and remove 'struct resource *mem' from 'struct omap_wdt_dev'
    and omap_wdt_probe(), resplectively. because the 'mem' variables
    are not used anymore. Also the redundant return value check of
    platform_get_resource() is removed, because the value is checked
    by devm_ioremap_resource().

    Signed-off-by: Jingoo Han
    Acked-by: Aaro Koskinen
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Jingoo Han
     
  • None of these files are actually using any __init type directives
    and hence don't need to include . Most are just a
    left over from __devinit and __cpuinit removal, or simply due to
    code getting copied from one driver to the next.

    Signed-off-by: Paul Gortmaker
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck
    Cc: linux-watchdog@vger.kernel.org

    Paul Gortmaker
     

18 Nov, 2013

2 commits

  • All OMAP IP blocks expect LE data, but CPU may operate in BE mode.
    Need to use endian neutral functions to read/write h/w registers.
    I.e instead of __raw_read[lw] and __raw_write[lw] functions code
    need to use read[lw]_relaxed and write[lw]_relaxed functions.
    If the first simply reads/writes register, the second will byteswap
    it if host operates in BE mode.

    Changes are trivial sed like replacement of __raw_xxx functions
    with xxx_relaxed variant.

    Signed-off-by: Victor Kamensky
    Signed-off-by: Taras Kondratiuk
    Acked-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Victor Kamensky
     
  • Use the wrapper function for retrieving the platform data instead of
    accessing dev->platform_data directly.

    Signed-off-by: Jingoo Han
    Reviewed-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Jingoo Han
     

01 Mar, 2013

1 commit


02 Jan, 2013

1 commit

  • We forgot to delete this in the commit 4f4753d9 (watchdog: omap_wdt:
    convert to devm_ functions), and as a result the following compilation
    warning was introduced:

    drivers/watchdog/omap_wdt.c: In function 'omap_wdt_remove':
    drivers/watchdog/omap_wdt.c:299:19: warning: unused variable 'res' [-Wunused-variable]

    Signed-off-by: Aaro Koskinen
    Reviewed-by: Paul Walmsley
    Signed-off-by: Wim Van Sebroeck

    Aaro Koskinen
     

20 Dec, 2012

4 commits


14 Dec, 2012

1 commit

  • Pull ARM SoC power management and clock changes from Olof Johansson:
    "This branch contains a largeish set of updates of power management and
    clock setup. The bulk of it is for OMAP/AM33xx platforms, but also a
    few around hotplug/suspend/resume on Exynos.

    It includes a split-up of some of the OMAP clock data into separate
    files which adds to the diffstat, but gross delta is fairly reasonable."

    * tag 'pm-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (60 commits)
    ARM: OMAP: Move plat-omap/dma-omap.h to include/linux/omap-dma.h
    ASoC: OMAP: mcbsp fixes for enabling ARM multiplatform support
    watchdog: OMAP: fixup for ARM multiplatform support
    ARM: EXYNOS: Add flush_cache_all in suspend finisher
    ARM: EXYNOS: Remove scu_enable from cpuidle
    ARM: EXYNOS: Fix soft reboot hang after suspend/resume
    ARM: EXYNOS: Add support for rtc wakeup
    ARM: EXYNOS: fix the hotplug for Cortex-A15
    ARM: OMAP2+: omap_device: Correct resource handling for DT boot
    ARM: OMAP2+: hwmod: Add possibility to count hwmod resources based on type
    ARM: OMAP2+: hwmod: Add support for per hwmod/module context lost count
    ARM: OMAP2+: PRM: initialize some PRM functions early
    ARM: OMAP2+: voltage: fixup oscillator handling when CONFIG_PM=n
    ARM: OMAP4: USB: power down MUSB PHY during boot
    ARM: OMAP2+: clock: Cleanup !CONFIG_COMMON_CLK parts
    ARM: OMAP2xxx: clock: drop obsolete clock data
    ARM: OMAP2: clock: Cleanup !CONFIG_COMMON_CLK parts
    ARM: OMAP3+: DPLL: drop !CONFIG_COMMON_CLK sections
    ARM: AM33xx: clock: drop obsolete clock data
    ARM: OMAP3xxx: clk: drop obsolete clock data
    ...

    Linus Torvalds
     

13 Dec, 2012

1 commit

  • Pull ARM SoC cleanups on various subarchitectures from Olof Johansson:
    "Cleanup patches for various ARM platforms and some of their associated
    drivers. There's also a branch in here that enables Freescale i.MX to
    be part of the multiplatform support -- the first "big" SoC that is
    moved over (more multiplatform work comes in a separate branch later
    during the merge window)."

    Conflicts fixed as per Olof, including a silent semantic one in
    arch/arm/mach-omap2/board-generic.c (omap_prcm_restart() was renamed to
    omap3xxx_restart(), and a new user of the old name was added).

    * tag 'cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (189 commits)
    ARM: omap: fix typo on timer cleanup
    ARM: EXYNOS: Remove unused regs-mem.h file
    ARM: EXYNOS: Remove unused non-dt support for dwmci controller
    ARM: Kirkwood: Use hw_pci.ops instead of hw_pci.scan
    ARM: OMAP3: cm-t3517: use GPTIMER for system clock
    ARM: OMAP2+: timer: remove CONFIG_OMAP_32K_TIMER
    ARM: SAMSUNG: use devm_ functions for ADC driver
    ARM: EXYNOS: no duplicate mask/unmask in eint0_15
    ARM: S3C24XX: SPI clock channel setup is fixed for S3C2443
    ARM: EXYNOS: Remove i2c0 resource information and setting of device names
    ARM: Kirkwood: checkpatch cleanups
    ARM: Kirkwood: Fix sparse warnings.
    ARM: Kirkwood: Remove unused includes
    ARM: kirkwood: cleanup lsxl board includes
    ARM: integrator: use BUG_ON where possible
    ARM: integrator: push down SC dependencies
    ARM: integrator: delete static UART1 mapping
    ARM: integrator: delete SC mapping on the CP
    ARM: integrator: remove static CP syscon mapping
    ARM: integrator: remove static AP syscon mapping
    ...

    Linus Torvalds
     

01 Dec, 2012

1 commit


29 Nov, 2012

3 commits

  • CONFIG_HOTPLUG is going away as an option so __devexit is no
    longer needed.

    Signed-off-by: Bill Pemberton
    Cc: Wim Van Sebroeck
    Cc: Wan ZongShun
    Cc: Ben Dooks
    Cc: Kukjin Kim
    Acked-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Bill Pemberton
     
  • CONFIG_HOTPLUG is going away as an option so __devinit is no longer
    needed.

    Signed-off-by: Bill Pemberton
    Cc: Wim Van Sebroeck
    Cc: Wan ZongShun
    Cc: Ben Dooks
    Cc: Kukjin Kim
    Acked-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Bill Pemberton
     
  • CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
    needed.

    Signed-off-by: Bill Pemberton
    Cc: Wim Van Sebroeck
    Cc: Wan ZongShun
    Cc: Ben Dooks
    Cc: Kukjin Kim
    Acked-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Bill Pemberton
     

09 Nov, 2012

1 commit

  • Previously the OMAP watchdog driver used a non-standard way to report
    the chip reset source via the GETBOOTSTATUS ioctl. This patch
    converts the driver to use the standard WDIOF_* flags for this
    purpose.

    This patch may break existing userspace code that uses the existing
    non-standard data format returned by the OMAP watchdog driver's
    GETBOOTSTATUS ioctl. To fetch detailed reset source information,
    userspace code will need to retrieve it directly from the CGRM or PRM
    drivers when those are completed.

    Previously, to fetch the reset source, the driver either read a
    register outside the watchdog IP block (OMAP1), or called a function
    exported directly from arch/arm/mach-omap2. Both approaches are
    broken. This patch also converts the driver to use a platform_data
    function pointer. This approach is temporary, and is due to the lack
    of drivers for the OMAP16xx+ Clock Generation and Reset Management IP
    block and the OMAP2+ Power and Reset Management IP block. Once
    drivers are available for those IP blocks, the watchdog driver can be
    converted to call exported functions from those drivers directly.
    At that point, the platform_data function pointer can be removed.

    In the short term, this patch is needed to allow the PRM code to be
    removed from arch/arm/mach-omap2 (it is being moved to a driver).

    This version integrates a fix from Jon Hunter
    that avoids a NULL pointer dereference in a DT-only boot, and integrates
    a patch commit message fix from Felipe Balbi .

    Signed-off-by: Paul Walmsley
    Cc: Wim Van Sebroeck
    Acked-by: Wim Van Sebroeck
    [paul@pwsan.com: integrated pdata fix from Jon Hunter]
    Cc: Jon Hunter
    [paul@pwsan.com: integrated changelog fix from Felipe Balbi]
    Cc: Felipe Balbi

    Paul Walmsley
     

13 Sep, 2012

1 commit

  • As the plat and mach includes need to disappear for single zImage work,
    we need to remove plat/hardware.h.

    Do this by splitting plat/hardware.h into omap1 and omap2+ specific files.

    The old plat/hardware.h already has omap1 only defines, so it gets moved
    to mach/hardware.h for omap1. For omap2+, we use the local soc.h
    that for now just includes the related SoC headers to keep this patch more
    readable.

    Note that the local soc.h still includes plat/cpu.h that can be dealt
    with in later patches. Let's also include plat/serial.h from common.h for
    all the board-*.c files. This allows making the include files local later
    on without patching these files again.

    Note that only minimal changes are done in this patch for the
    drivers/watchdog/omap_wdt.c driver to keep things compiling. Further
    patches are needed to eventually remove cpu_is_omap usage in the drivers.

    Also only minimal changes are done to sound/soc/omap/* to remove the
    unneeded includes and to define OMAP44XX_MCPDM_L3_BASE locally so there's
    no need to include omap44xx.h.

    While at it, also sort some of the includes in the standard way.

    Cc: linux-watchdog@vger.kernel.org
    Cc: alsa-devel@alsa-project.org
    Cc: Peter Ujfalusi
    Cc: Jarkko Nikula
    Cc: Liam Girdwood
    Acked-by: Wim Van Sebroeck
    Acked-by: Mark Brown
    Signed-off-by: Tony Lindgren

    Tony Lindgren
     

25 Jul, 2012

1 commit

  • Pull watchdog changes from Wim Van Sebroeck:
    - conversion of iTCO_wdt and orion_wdt to the generic watchdog API
    - uses module_platform_driver() for s3c2410_wdt
    - Adds support for Jetway JNF99 Motherboard
    - various fixes

    * git://www.linux-watchdog.org/linux-watchdog:
    watchdog: orion_wdt: Convert driver to watchdog core
    watchdog: s3c2410_wdt: Use module_platform_driver()
    watchdog: sch311x_wdt: Fix Polarity when starting watchdog
    Watchdog: OMAP: Fix the runtime pm code to avoid module getting stuck intransition state.
    watchdog: ie6xx_wdt: section mismatch in ie6xx_wdt_probe()
    watchdog: bcm63xx_wdt: fix driver section mismatch
    watchdog: iTCO_wdt.c: convert to watchdog core
    char/ipmi: remove local ioctl defines replaced by generic ones
    watchdog: xilinx: Read clock frequency directly from DT node
    watchdog: coh901327_wdt: use clk_prepare/unprepare
    watchdog: f71808e_wdt: Add support for Jetway JNF99 motherboard

    Linus Torvalds
     

23 Jul, 2012

1 commit

  • OMAP watchdog driver is adapted to runtime PM like a general device
    driver but it is not appropriate. It is causing couple of functional
    issues.

    1. On OMAP4 SYSCLK can't be gated, because of issue with WDTIMER2 module,
    which constantly stays in "in transition" state. Value of register
    CM_WKUP_WDTIMER2_CLKCTRL is always 0x00010000 in this case.
    Issue occurs immediately after first idle, when hwmod framework tries
    to disable WDTIMER2 functional clock - "wd_timer2_fck". After this
    module falls to "in transition" state, and SYSCLK gating is blocked.

    2. Due to runtime PM, watchdog timer may be completely disabled.
    In current code base watchdog timer is not disabled only because of
    issue 1. Otherwise state of WDTIMER2 module will be "Disabled", and there
    will be no interrupts from omap_wdt. In other words watchdog will not
    work at all.

    Watchdong is a special IP and it should not be disabled otherwise
    purpose of it itself is defeated. Watchdog functional clock should
    never be disabled. This patch updates the runtime PM handling in
    driver so that runtime PM is limited only during probe/shutdown
    and suspend/resume.

    The patch fixes issue 1 and 2

    Signed-off-by: Lokesh Vutla
    Acked-by: Santosh Shilimkar
    Signed-off-by: Wim Van Sebroeck

    Lokesh Vutla
     

09 Jul, 2012

1 commit


28 Mar, 2012

1 commit

  • Use the current logging styles.

    Make sure all output has a prefix.
    Add missing newlines.
    Remove now unnecessary PFX, NAME, and miscellaneous other #defines.
    Coalesce formats.

    Signed-off-by: Joe Perches
    Signed-off-by: Wim Van Sebroeck

    Joe Perches
     

27 Jan, 2012

1 commit

  • Currently the watchdog driver calls the pm_runtime_enable and never
    the disable. This may cause a warning when pm_runtime_enable
    checks for the count match.

    Also fixes the error

    /build/watchdog # insmod omap_wdt.ko
    [ 44.999389] omap_wdt omap_wdt: Unbalanced pm_runtime_enable!
    [ 45.011047] OMAP Watchdog Timer Rev 0x00: initial timeout 60 sec
    /build/watchdog #

    Attempting to fix the same by calling pm_runtime_disable.

    Signed-off-by: Shubhrajyoti D
    Signed-off-by: Wim Van Sebroeck

    Shubhrajyoti D
     

06 Jan, 2012

3 commits

  • WDIOC_GETBOOTSTATUS ioctl is imlemented for cpu_is_omap16xx and cpu_is_omap24xx
    cpus only. For other cpus it falls through to WDIOC_KEEPALIVE.
    This patch prevents the fall through.

    Cc: sricharan
    Signed-off-by: Shubhrajyoti D
    Signed-off-by: Wim Van Sebroeck

    Shubhrajyoti D
     
  • This patch converts the drivers in drivers/watchdog/* to use the
    module_platform_driver() macro which makes the code smaller and a bit
    simpler.

    Signed-off-by: Axel Lin
    Cc: Nicolas Thill
    Cc: Florian Fainelli
    Cc: "David S. Miller"
    Cc: Paul Cercueil
    Cc: Marc Zyngier
    Cc: Wan ZongShun
    Cc: Alejandro Cabrera
    Cc: "George G. Davis"
    Cc: Sylver Bruneau
    Cc: Vitaly Wool
    Cc: Mika Westerberg
    Cc: Timo Kokkonen
    Signed-off-by: Wim Van Sebroeck

    Axel Lin
     
  • Rather than just defining static spinlock_t variables and then
    initializing them later in init functions, simply define them with
    DEFINE_SPINLOCK() and remove the calls to spin_lock_init().

    Signed-off-by: Axel Lin
    Cc: Nicolas Thill
    Cc: Heiko Ronsdorf
    Cc: Rodolfo Giometti
    Cc: Andrey Panin
    Cc: Guido Guenther
    Cc: Curt E Bruns
    Cc: Deepak Saxena
    Cc: Andrew Victor
    Cc: George G. Davis
    Cc: Sylver Bruneau
    Signed-off-by: Wim Van Sebroeck

    Axel Lin
     

11 Mar, 2011

1 commit

  • The omap_wdt should only be in full active state when the
    registers are being accessed. Otherwise the device can be
    on lower power mode.

    This patch is based on a patch created by Kalle Jokiniemi:
    https://patchwork.kernel.org/patch/618231/
    which is itself based on a patch created by Atal
    Shargorodsky: http://lkml.org/lkml/2009/3/10/266.

    Signed-off-by: Paul Walmsley
    Signed-off-by: Kalle Jokiniemi
    Tested-by: Kalle Jokiniemi
    Cc: Wim Van Sebroeck
    Acked-by: Wim Van Sebroeck
    Acked-by: Kevin Hilman

    Paul Walmsley
     

26 Oct, 2010

1 commit

  • * 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6: (163 commits)
    omap: complete removal of machine_desc.io_pg_offst and .phys_io
    omap: UART: fix wakeup registers for OMAP24xx UART2
    omap: Fix spotty MMC voltages
    ASoC: OMAP4: MCPDM: Remove unnecessary include of plat/control.h
    serial: omap-serial: fix signess error
    OMAP3: DMA: Errata i541: sDMA FIFO draining does not finish
    omap: dma: Fix buffering disable bit setting for omap24xx
    omap: serial: Fix the boot-up crash/reboot without CONFIG_PM
    OMAP3: PM: fix scratchpad memory accesses for off-mode
    omap4: pandaboard: enable the ehci port on pandaboard
    omap4: pandaboard: Fix the init if CONFIG_MMC_OMAP_HS is not set
    omap4: pandaboard: remove unused hsmmc definition
    OMAP: McBSP: Remove null omap44xx ops comment
    OMAP: McBSP: Swap CLKS source definition
    OMAP: McBSP: Fix CLKR and FSR signal muxing
    OMAP2+: clock: reduce the amount of standard debugging while disabling unused clocks
    OMAP: control: move plat-omap/control.h to mach-omap2/control.h
    OMAP: split plat-omap/common.c
    OMAP: McBSP: implement functional clock switching via clock framework
    OMAP: McBSP: implement McBSP CLKR and FSR signal muxing via mach-omap2/mcbsp.c
    ...

    Fixed up trivial conflicts in arch/arm/mach-omap2/
    {board-zoom-peripherals.c,devices.c} as per Tony

    Linus Torvalds
     

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
     

30 Sep, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo