28 May, 2016

1 commit

  • Most users of IS_ERR_VALUE() in the kernel are wrong, as they
    pass an 'int' into a function that takes an 'unsigned long'
    argument. This happens to work because the type is sign-extended
    on 64-bit architectures before it gets converted into an
    unsigned type.

    However, anything that passes an 'unsigned short' or 'unsigned int'
    argument into IS_ERR_VALUE() is guaranteed to be broken, as are
    8-bit integers and types that are wider than 'unsigned long'.

    Andrzej Hajda has already fixed a lot of the worst abusers that
    were causing actual bugs, but it would be nice to prevent any
    users that are not passing 'unsigned long' arguments.

    This patch changes all users of IS_ERR_VALUE() that I could find
    on 32-bit ARM randconfig builds and x86 allmodconfig. For the
    moment, this doesn't change the definition of IS_ERR_VALUE()
    because there are probably still architecture specific users
    elsewhere.

    Almost all the warnings I got are for files that are better off
    using 'if (err)' or 'if (err < 0)'.
    The only legitimate user I could find that we get a warning for
    is the (32-bit only) freescale fman driver, so I did not remove
    the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
    For 9pfs, I just worked around one user whose calling conventions
    are so obscure that I did not dare change the behavior.

    I was using this definition for testing:

    #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
    unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))

    which ends up making all 16-bit or wider types work correctly with
    the most plausible interpretation of what IS_ERR_VALUE() was supposed
    to return according to its users, but also causes a compile-time
    warning for any users that do not pass an 'unsigned long' argument.

    I suggested this approach earlier this year, but back then we ended
    up deciding to just fix the users that are obviously broken. After
    the initial warning that caused me to get involved in the discussion
    (fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
    asked me to send the whole thing again.

    [ Updated the 9p parts as per Al Viro - Linus ]

    Signed-off-by: Arnd Bergmann
    Cc: Andrzej Hajda
    Cc: Andrew Morton
    Link: https://lkml.org/lkml/2016/1/7/363
    Link: https://lkml.org/lkml/2016/5/27/486
    Acked-by: Srinivas Kandagatla # For nvmem part
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

11 Aug, 2015

1 commit

  • set_irq_flags is ARM specific with custom flags which have genirq
    equivalents. Convert drivers to use the genirq interfaces directly, so we
    can kill off set_irq_flags. The translation of flags is as follows:

    IRQF_VALID -> !IRQ_NOREQUEST
    IRQF_PROBE -> !IRQ_NOPROBE
    IRQF_NOAUTOEN -> IRQ_NOAUTOEN

    For IRQs managed by an irqdomain, the irqdomain core code handles clearing
    and setting IRQ_NOREQUEST already, so there is no need to do this in
    .map() functions and we can simply remove the set_irq_flags calls. Some
    users also modify IRQ_NOPROBE and this has been maintained although it
    is not clear that is really needed. There appears to be a great deal of
    blind copy and paste of this code.

    Signed-off-by: Rob Herring
    Acked-by: Linus Walleij
    Signed-off-by: Lee Jones

    Rob Herring
     

22 Jun, 2015

1 commit

  • Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject
    bogus threaded irq requests") threaded IRQs without a primary handler
    need to be requested with IRQF_ONESHOT, otherwise the request will fail.

    So pass the IRQF_ONESHOT flag in this case.

    The semantic patch that makes this change is available
    in scripts/coccinelle/misc/irqf_oneshot.cocci.

    Signed-off-by: Fabio Estevam
    Signed-off-by: Lee Jones

    Fabio Estevam
     

26 Sep, 2014

1 commit


25 Jul, 2014

1 commit

  • This is part of an effort to clean-up the MFD subsystem.

    WARNING: Prefer pr_warn(... to pr_warning(...
    + pr_warning("twl4030: I2C error %d reading PIH ISR\n", ret);

    WARNING: sizeof buf should be sizeof(buf)
    + memset(buf, 0xff, sizeof buf);

    WARNING: sizeof *agent should be sizeof(*agent)
    + agent = kzalloc(sizeof *agent, GFP_KERNEL);

    Signed-off-by: Lee Jones

    Lee Jones
     

19 Mar, 2014

1 commit


11 Jul, 2013

1 commit

  • Pull MFD update from Samuel Ortiz:
    "For the 3.11 merge we only have one new MFD driver for the Kontron
    PLD.

    But we also have:
    - Support for the TPS659038 PMIC from the palmas driver.
    - Intel's Coleto Creek and Avoton SoCs support from the lpc_ich
    driver.
    - RTL8411B support from the rtsx driver.
    - More DT support for the Arizona, max8998, twl4030-power and the
    ti_am335x_tsadc drivers.
    - The SSBI driver move under MFD.
    - A conversion to the devm_* API for most of the MFD drivers.
    - The twl4030-power got split from twl-core into its own module.
    - A major ti_am335x_adc cleanup, leading to a proper DT support.
    - Our regular arizona and wm* updates and cleanups from the Wolfson
    folks.
    - A better error handling and initialization, and a regulator
    subdevice addition for the 88pm80x driver.
    - A bulk platform_set_drvdata() call removal that's no longer need
    since commit 0998d0631001 ("device-core: Ensure drvdata = NULL when
    no driver is bound")

    * tag 'mfd-3.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next: (102 commits)
    mfd: sec: Provide max_register to regmap
    mfd: wm8994: Remove duplicate check for active JACKDET
    MAINTAINERS: Add include directory to MFD file patterns
    mfd: sec: Remove fields not used since regmap conversion
    watchdog: Kontron PLD watchdog timer driver
    mfd: max8998: Add support for Device Tree
    regulator: max8998: Use arrays for specifying voltages in platform data
    mfd: max8998: Add irq domain support
    regulator: palmas: Add TPS659038 support
    mfd: Kontron PLD mfd driver
    mfd: palmas: Add TPS659038 PMIC support
    mfd: palmas: Add SMPS10_BOOST feature
    mfd: palmas: Check if irq is valid
    mfd: lpc_ich: iTCO_wdt patch for Intel Coleto Creek DeviceIDs
    mfd: twl-core: Change TWL6025 references to TWL6032
    mfd: davinci_voicecodec: Fix build breakage
    mfd: vexpress: Make the driver optional for arm and arm64
    mfd: htc-egpio: Use devm_ioremap_nocache() instead of ioremap_nocache()
    mfd: davinci_voicecodec: Convert to use devm_* APIs
    mfd: twl4030-power: Fix relocking on error
    ...

    Linus Torvalds
     

25 Jun, 2013

1 commit

  • Use irq_get_trigger_type() to get the IRQ trigger type flags
    instead calling irqd_get_trigger_type(irq_get_irq_data(irq))

    Signed-off-by: Javier Martinez Canillas
    Acked-by: Grant Likely
    Cc: Linus Walleij
    Acked-by: Samuel Ortiz
    Cc: Jason Cooper
    Cc: Andrew Lunn
    Cc: Russell King
    Cc: Ralf Baechle
    Cc: Benjamin Herrenschmidt
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-mips@linux-mips.org
    Link: http://lkml.kernel.org/r/1371228049-27080-4-git-send-email-javier.martinez@collabora.co.uk
    Signed-off-by: Thomas Gleixner

    Javier Martinez Canillas
     

18 Jun, 2013

1 commit

  • The genirq IRQ wake method will default to failure if the irq_chip
    does not provide a set_wake method. However, for TWL4030 sub-chip
    IRQs, we want the wake enable to succeed even though we don't provide
    a set_wake method. This allows sub-chip IRQs to still be flagged as
    wakeup capable, and allow them to wakeup from suspend (or abort
    suspend if they fire during suspend.)

    To fix, use the IRQCHIP_SKIP_SET_WAKE flag in the irq_chip.

    Signed-off-by: Kevin Hilman
    Signed-off-by: Samuel Ortiz

    Kevin Hilman
     

17 Dec, 2012

1 commit

  • Pull MFS update from Samuel Ortiz:
    "This is the MFD patch set for the 3.8 merge window.

    We have several new drivers, most of the time coming with their sub
    devices drivers:

    - Austria Microsystem's AS3711
    - Nano River's viperboard
    - TI's TPS80031, AM335x TS/ADC,
    - Realtek's MMC/memstick card reader
    - Nokia's retu

    We also got some notable cleanups and improvements:

    - tps6586x got converted to IRQ domains.
    - tps65910 and tps65090 moved to the regmap IRQ API.
    - STMPE is now Device Tree aware.
    - A general twl6040 and twl-core cleanup, with moves to the regmap
    I/O and IRQ APIs and a conversion to the recently added PWM
    framework.
    - sta2x11 gained regmap support.

    Then the rest is mostly tiny cleanups and fixes, among which we have
    Mark's wm5xxx and wm8xxx patchset."

    Far amount of annoying but largely trivial conflicts. Many due to
    __devinit/exit removal, others due to one or two of the new drivers also
    having come in through another tree.

    * tag 'mfd-3.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (119 commits)
    mfd: tps6507x: Convert to devm_kzalloc
    mfd: stmpe: Update DT support for stmpe driver
    mfd: wm5102: Add readback of DSP status 3 register
    mfd: arizona: Log if we fail to create the primary IRQ domain
    mfd: tps80031: MFD_TPS80031 needs to select REGMAP_IRQ
    mfd: tps80031: Add terminating entry for tps80031_id_table
    mfd: sta2x11: Fix potential NULL pointer dereference in __sta2x11_mfd_mask()
    mfd: wm5102: Add tuning for revision B
    mfd: arizona: Defer patch initialistation until after first device boot
    mfd: tps65910: Fix wrong ack_base register
    mfd: tps65910: Remove unused data
    mfd: stmpe: Get rid of irq_invert_polarity
    mfd: ab8500-core: Fix invalid free of devm_ allocated data
    mfd: wm5102: Mark DSP memory regions as volatile
    mfd: wm5102: Correct default for LDO1_CONTROL_2
    mfd: arizona: Register haptics devices
    mfd: wm8994: Make current device behaviour the default
    mfd: tps65090: MFD_TPS65090 needs to select REGMAP_IRQ
    mfd: Fix stmpe.c build when OF is not enabled
    mfd: jz4740-adc: Use devm_kzalloc
    ...

    Linus Torvalds
     

22 Nov, 2012

1 commit

  • The irqs are enabled one-by-one in pm core resume_noirq phase.
    This leads to situation where the twl4030 primary interrupt
    handler (PIH) is enabled before the chained secondary handlers
    (SIH). As the PIH cannot clear the pending interrupt, and
    SIHs have not been enabled yet, a flood of interrupts hangs
    the device.

    Fixed the issue by setting the SIH irqs with IRQF_EARLY_RESUME
    flags, so they get enabled before the PIH.

    Signed-off-by: Kalle Jokiniemi
    Acked-by: Kevin Hilman
    Signed-off-by: Samuel Ortiz

    Kalle Jokiniemi
     

21 Nov, 2012

2 commits


10 May, 2012

1 commit

  • Most of the interrupts that come through this line should trigger
    wakeups:
    power button
    RTC alarm
    power available
    usb plug/unplug

    so mark the interrupt as a wakeup interrupt.
    This is particularly important for when the interrupt arrives during
    the late suspend phase. Without this setting it will be ignored.

    Signed-off-by: NeilBrown
    Acked-by: Kevin Hilman
    Signed-off-by: Samuel Ortiz

    NeilBrown
     

22 Mar, 2012

4 commits

  • Since a structure device is available now, use the dev_ macros instead
    of the pr_ ones.

    Clean some badly formatted comments.
    Remove some unused variables.
    Move some variable to the place they belong.
    Clean some badly wrapped lines.
    Align variable definition
    Add missing braces in if-then-else block.
    Add blank line for better readability.
    Move stuff here and there...

    Conflicts:

    drivers/mfd/twl-core.c

    Signed-off-by: Benoit Cousson
    Cc: Felipe Balbi
    Signed-off-by: Samuel Ortiz

    Benoit Cousson
     
  • __ffs() will be far faster than the for loop used.

    Signed-off-by: Felipe Balbi
    Signed-off-by: Samuel Ortiz

    Felipe Balbi
     
  • twl4030 is using a two level irq controllers infrastruture.
    So far, only the first level was using dynamic irq_desc allocation
    to be able to have irq_domain support for device tree.
    There is a need to allocate separate irq_descs for the SIH too to
    avoid hacking the first level with interrupts from the second level.

    Add an irq_base parameter to allow the caller to provide the base from
    pdata or from dynamic allocation.

    Affect TWL4030_NR_IRQS to the twl-core IRQs only.

    Moreover that will allow the extraction of the of_node pointer for further
    Device Tree conversion.

    Signed-off-by: Felipe Balbi
    Signed-off-by: Benoit Cousson
    Signed-off-by: Samuel Ortiz

    Benoit Cousson
     
  • During DT adaptation, the irq_alloc_desc was added into twl-core, but
    due to the rather different and weird IRQ management required by the twl4030,
    it is much better to have a different approach for it.
    The issue is that twl4030 uses a two level IRQ mechanism but handles all the
    PWR interrupts as part of the twl-core interrupt range. It ends up with a
    range of 16 interrupts total for CORE and PWR.

    The other twl4030 functionalities already have a dedicated driver and thus
    their IRQs and irqdomain can and should be defined localy.

    twl6030 is using a single level IRQ controller and thus does not require any
    trick.

    Move the irq_alloc_desc and irq_domain_add_legacy in twl4030-irq and
    twl6030-irq.

    Allocate together CORE and PWR IRQs for twl4030-irq.

    Conflicts:

    drivers/mfd/twl-core.c

    Signed-off-by: Benoit Cousson
    Acked-by: Felipe Balbi
    Signed-off-by: Samuel Ortiz

    Benoit Cousson
     

07 Mar, 2012

1 commit


09 Jan, 2012

2 commits


21 Dec, 2011

2 commits

  • irq_set_chained_handler sets 'desc->handle_irq'.
    However this irq is called by handle_nested_irq from handle_twl4030_pih,
    and that uses action->thread_fn.

    So the handled set with irq_set_chained_handler is never called.

    So change to use request_threaded_irq instead - that sets the correct field.

    Tested on GTA04 Phoenux.

    Signed-off-by: NeilBrown
    Tested-by: Felipe Contreras
    Signed-off-by: Samuel Ortiz

    NeilBrown
     
  • As the interrupt source is only cleared by the threaded interrupt
    service routine, we need to make the base interrupt IRQF_ONESHOT.
    Without this, the first interrupt from the TWL4030 cause the CPU to
    enter an infinite loop trying to handle to interrupt but never
    clearing it.

    Signed-off-by: NeilBrown
    Tested-by: Felipe Contreras
    Signed-off-by: Samuel Ortiz

    NeilBrown
     

24 Oct, 2011

7 commits


27 Mar, 2011

2 commits

  • Converted with coccinelle.

    Signed-off-by: Thomas Gleixner
    Acked-by: Mark Brown
    Signed-off-by: Samuel Ortiz

    Thomas Gleixner
     
  • irq_desc checking in a function which is called with that irq
    descriptor locked, is pointless. Equally pointless as the irq desc
    check in the interrupt service routine. The driver sets those lines
    up, so that cant go away magically.

    Remove the open coded handler magic and use the proper accessor.

    No need to fiddle with irq_desc in the type setting function. The
    original value is in irq_data and the core code stores the new setting
    when the return value is 0.

    This driver needs to be converted to threaded interrupts and buslock.

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Samuel Ortiz

    Thomas Gleixner
     

14 Jan, 2011

1 commit


29 Oct, 2010

2 commits

  • Fixes following sparse warnings for twl4030 and twl6030 irq files.

    drivers/mfd/twl4030-irq.c:783:5: warning: symbol 'twl4030_init_irq' was not
    declared. Should it be static?
    drivers/mfd/twl4030-irq.c:863:5: warning: symbol 'twl4030_exit_irq' was not
    declared. Should it be static?
    drivers/mfd/twl4030-irq.c:873:5: warning: symbol 'twl4030_init_chip_irq' was
    not declared. Should it be static?

    drivers/mfd/twl6030-irq.c:226:5: warning: symbol 'twl6030_init_irq' was not
    declared. Should it be static?
    drivers/mfd/twl6030-irq.c:290:5: warning: symbol 'twl6030_exit_irq' was not
    declared. Should it be static?

    Signed-off-by: G, Manjunath Kondaiah
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: Tony Lindgren
    Cc: Nishanth Menon
    Signed-off-by: Samuel Ortiz

    G, Manjunath Kondaiah
     
  • The chip TRM documentation contradicts itself about this bit, page 174
    of swcu050e says bit should be 0 for clear-on-read behavior, while
    page 487 says it should be 1. Testing shows it should be 1, so set
    the .set_cor flag accordingly. This is needed for upcoming BCI
    charging driver to function.

    Signed-off-by: Grazvydas Ignotas
    Acked-by: Tony Lindgren
    Signed-off-by: Samuel Ortiz

    Grazvydas Ignotas
     

08 Oct, 2010

1 commit


04 Oct, 2010

1 commit


28 May, 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
     

01 Jan, 2010

1 commit