30 Dec, 2020

2 commits

  • [ Upstream commit db29d3d1c2451e673e29c7257471e3ce9d50383a ]

    Fix to return a error code from the error handling case instead of 0.

    Fixes: 926341250102 ("memstick: add driver for Ricoh R5C592 card reader")
    Signed-off-by: Jing Xiangfeng
    Link: https://lore.kernel.org/r/20201125014718.153563-1-jingxiangfeng@huawei.com
    Signed-off-by: Ulf Hansson
    Signed-off-by: Sasha Levin

    Jing Xiangfeng
     
  • [ Upstream commit e3e9ced5c93803d5b2ea1942c4bf0192622531d6 ]

    kfree(host->card) has been called in put_device so that
    another kfree would raise cause a double-free bug.

    Fixes: 0193383a5833 ("memstick: core: fix device_register() error handling")
    Reported-by: Hulk Robot
    Signed-off-by: Qinglang Miao
    Link: https://lore.kernel.org/r/20201120074846.31322-1-miaoqinglang@huawei.com
    Signed-off-by: Ulf Hansson
    Signed-off-by: Sasha Levin

    Qinglang Miao
     

28 Sep, 2020

2 commits

  • Ulf Hansson
     
  • After commit 6827ca573c03 ("memstick: rtsx_usb_ms: Support runtime power
    management"), removing module rtsx_usb_ms will be stuck.

    The deadlock is caused by powering on and powering off at the same time,
    the former one is when memstick_check() is flushed, and the later is called
    by memstick_remove_host().

    Soe let's skip allocating card to prevent this issue.

    Fixes: 6827ca573c03 ("memstick: rtsx_usb_ms: Support runtime power management")
    Signed-off-by: Kai-Heng Feng
    Link: https://lore.kernel.org/r/20200925084952.13220-1-kai.heng.feng@canonical.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Ulf Hansson

    Kai-Heng Feng
     

07 Sep, 2020

1 commit


24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

06 Aug, 2020

1 commit

  • Pull MMC updates from Ulf Hansson:
    "MMC core:

    - Add a new host cap bit and a corresponding DT property, to support
    power cycling of the card by FW at system suspend/resume.

    - Fix clock rate setting for SDIO in SDR12/SDR25 speed-mode

    - Fix switch to 1/4-bit mode at system suspend/resume for SD-combo
    cards

    - Convert the mmc-pwrseq DT bindings to the json-schema

    - Always allow the card detect uevent to be consumed by userspace

    MMC host controllers:

    - Convert a few DT bindings to the json-schema

    - mtk-sd:
    - Add support for command queue through cqhci
    - Add support for the MT6779 variant

    - renesas_sdhi_internal_dmac:
    - Fix dma unmapping in the error path

    - sdhci_am654:
    - Add support for the AM65x PG2.0 variant
    - Extend support for phys/clocks

    - sdhci-cadence:
    - Drop incorrect HW tuning for SD mode

    - sdhci-msm:
    - Add support for interconnect bandwidth scaling
    - Enable internal voltage control
    - Enable low power state for pinctrls

    - sdhci-of-at91:
    - Ludovic Desroches handovers maintenance to Eugen Hristev

    - sdhci-pci-gli:
    - Improve clock handling for GL975x

    - sdhci-pci-o2micro:
    - Add HW tuning for SDR104 mode
    - Fix support for O2 host controller Seabird1"

    * tag 'mmc-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (66 commits)
    mmc: mediatek: make function msdc_cqe_disable() static
    MAINTAINERS: mmc: sdhci-of-at91: handover maintenance to Eugen Hristev
    dt-bindings: mmc: mediatek: Add document for mt6779
    mmc: mediatek: command queue support
    mmc: mediatek: refine msdc timeout api
    mmc: mediatek: add MT6779 MMC driver support
    mmc: sdhci-pci-o2micro: Add HW tuning for SDR104 mode
    mmc: sdhci-pci-o2micro: Bug fix for O2 host controller Seabird1
    mmc: via-sdmmc: use generic power management
    memstick: jmb38x_ms: use generic power management
    mmc: sdhci-cadence: do not use hardware tuning for SD mode
    mmc: sdhci-pci-gli: Set SDR104's clock to 205MHz and enable SSC for GL975x
    mmc: cqhci: Fix a print format for the task descriptor
    mmc: sdhci-of-arasan: fix timings allocation code
    mmc: sdhci: Fix a potential uninitialized variable
    dt-bindings: mmc: renesas,sdhi: convert to YAML
    dt-bindings: mmc: convert arasan sdhci bindings to yaml
    mmc: sdhci: Fix potential null pointer access while accessing vqmmc
    mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND
    dt-bindings: mmc: Add full-pwr-cycle-in-suspend property
    ...

    Linus Torvalds
     

24 Jul, 2020

1 commit

  • Drivers using legacy PM have to manage PCI states and device's PM states
    themselves. They also need to take care of configuration registers.

    With improved and powerful support of generic PM, PCI Core takes care of
    above mentioned, device-independent, jobs.

    This driver makes use of PCI helper functions like
    pci_save/restore_state(), pci_enable/disable_device(),
    pci_set_power_state() and pci_set_master() to do required operations. In
    generic mode, they are no longer needed.

    Change function parameter in both .suspend() and .resume() to
    "struct device*" type. Use to_pci_dev() and dev_get_drvdata() to get
    "struct pci_dev*" variable and drv data.

    Compile-tested only.

    Signed-off-by: Vaibhav Gupta
    Link: https://lore.kernel.org/r/20200720111625.306681-1-vaibhavgupta40@gmail.com
    Signed-off-by: Ulf Hansson

    Vaibhav Gupta
     

17 Jul, 2020

1 commit

  • Using uninitialized_var() is dangerous as it papers over real bugs[1]
    (or can in the future), and suppresses unrelated compiler warnings
    (e.g. "unused variable"). If the compiler thinks it is uninitialized,
    either simply initialize the variable or make compiler changes.

    In preparation for removing[2] the[3] macro[4], remove all remaining
    needless uses with the following script:

    git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \
    xargs perl -pi -e \
    's/\buninitialized_var\(([^\)]+)\)/\1/g;
    s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;'

    drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid
    pathological white-space.

    No outstanding warnings were found building allmodconfig with GCC 9.3.0
    for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64,
    alpha, and m68k.

    [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/
    [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/
    [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/
    [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/

    Reviewed-by: Leon Romanovsky # drivers/infiniband and mlx4/mlx5
    Acked-by: Jason Gunthorpe # IB
    Acked-by: Kalle Valo # wireless drivers
    Reviewed-by: Chao Yu # erofs
    Signed-off-by: Kees Cook

    Kees Cook
     

04 Dec, 2019

1 commit

  • Pull PCI updates from Bjorn Helgaas:
    "Enumeration:

    - Warn if a host bridge has no NUMA info (Yunsheng Lin)

    - Add PCI_STD_NUM_BARS for the number of standard BARs (Denis
    Efremov)

    Resource management:

    - Fix boot-time Embedded Controller GPE storm caused by incorrect
    resource assignment after ACPI Bus Check Notification (Mika
    Westerberg)

    - Protect pci_reassign_bridge_resources() against concurrent
    addition/removal (Benjamin Herrenschmidt)

    - Fix bridge dma_ranges resource list cleanup (Rob Herring)

    - Add "pci=hpmmiosize" and "pci=hpmmioprefsize" parameters to control
    the MMIO and prefetchable MMIO window sizes of hotplug bridges
    independently (Nicholas Johnson)

    - Fix MMIO/MMIO_PREF window assignment that assigned more space than
    desired (Nicholas Johnson)

    - Only enforce bus numbers from bridge EA if the bridge has EA
    devices downstream (Subbaraya Sundeep)

    - Consolidate DT "dma-ranges" parsing and convert all host drivers to
    use shared parsing (Rob Herring)

    Error reporting:

    - Restore AER capability after resume (Mayurkumar Patel)

    - Add PoisonTLPBlocked AER counter (Rajat Jain)

    - Use for_each_set_bit() to simplify AER code (Andy Shevchenko)

    - Fix AER kernel-doc (Andy Shevchenko)

    - Add "pcie_ports=dpc-native" parameter to allow native use of DPC
    even if platform didn't grant control over AER (Olof Johansson)

    Hotplug:

    - Avoid returning prematurely from sysfs requests to enable or
    disable a PCIe hotplug slot (Lukas Wunner)

    - Don't disable interrupts twice when suspending hotplug ports (Mika
    Westerberg)

    - Fix deadlocks when PCIe ports are hot-removed while suspended (Mika
    Westerberg)

    Power management:

    - Remove unnecessary ASPM locking (Bjorn Helgaas)

    - Add support for disabling L1 PM Substates (Heiner Kallweit)

    - Allow re-enabling Clock PM after it has been disabled (Heiner
    Kallweit)

    - Add sysfs attributes for controlling ASPM link states (Heiner
    Kallweit)

    - Remove CONFIG_PCIEASPM_DEBUG, including "link_state" and "clk_ctl"
    sysfs files (Heiner Kallweit)

    - Avoid AMD FCH XHCI USB PME# from D0 defect that prevents wakeup on
    USB 2.0 or 1.1 connect events (Kai-Heng Feng)

    - Move power state check out of pci_msi_supported() (Bjorn Helgaas)

    - Fix incorrect MSI-X masking on resume and revert related nvme quirk
    for Kingston NVME SSD running FW E8FK11.T (Jian-Hong Pan)

    - Always return devices to D0 when thawing to fix hibernation with
    drivers like mlx4 that used legacy power management (previously we
    only did it for drivers with new power management ops) (Dexuan Cui)

    - Clear PCIe PME Status even for legacy power management (Bjorn
    Helgaas)

    - Fix PCI PM documentation errors (Bjorn Helgaas)

    - Use dev_printk() for more power management messages (Bjorn Helgaas)

    - Apply D2 delay as milliseconds, not microseconds (Bjorn Helgaas)

    - Convert xen-platform from legacy to generic power management (Bjorn
    Helgaas)

    - Removed unused .resume_early() and .suspend_late() legacy power
    management hooks (Bjorn Helgaas)

    - Rearrange power management code for clarity (Rafael J. Wysocki)

    - Decode power states more clearly ("4" or "D4" really refers to
    "D3cold") (Bjorn Helgaas)

    - Notice when reading PM Control register returns an error (~0)
    instead of interpreting it as being in D3hot (Bjorn Helgaas)

    - Add missing link delays required by the PCIe spec (Mika Westerberg)

    Virtualization:

    - Move pci_prg_resp_pasid_required() to CONFIG_PCI_PRI (Bjorn
    Helgaas)

    - Allow VFs to use PRI (the PF PRI is shared by the VFs, but the code
    previously didn't recognize that) (Kuppuswamy Sathyanarayanan)

    - Allow VFs to use PASID (the PF PASID capability is shared by the
    VFs, but the code previously didn't recognize that) (Kuppuswamy
    Sathyanarayanan)

    - Disconnect PF and VF ATS enablement, since ATS in PFs and
    associated VFs can be enabled independently (Kuppuswamy
    Sathyanarayanan)

    - Cache PRI and PASID capability offsets (Kuppuswamy Sathyanarayanan)

    - Cache the PRI PRG Response PASID Required bit (Bjorn Helgaas)

    - Consolidate ATS declarations in linux/pci-ats.h (Krzysztof
    Wilczynski)

    - Remove unused PRI and PASID stubs (Bjorn Helgaas)

    - Removed unnecessary EXPORT_SYMBOL_GPL() from ATS, PRI, and PASID
    interfaces that are only used by built-in IOMMU drivers (Bjorn
    Helgaas)

    - Hide PRI and PASID state restoration functions used only inside the
    PCI core (Bjorn Helgaas)

    - Add a DMA alias quirk for the Intel VCA NTB (Slawomir Pawlowski)

    - Serialize sysfs sriov_numvfs reads vs writes (Pierre Crégut)

    - Update Cavium ACS quirk for ThunderX2 and ThunderX3 (George
    Cherian)

    - Fix the UPDCR register address in the Intel ACS quirk (Steffen
    Liebergeld)

    - Unify ACS quirk implementations (Bjorn Helgaas)

    Amlogic Meson host bridge driver:

    - Fix meson PERST# GPIO polarity problem (Remi Pommarel)

    - Add DT bindings for Amlogic Meson G12A (Neil Armstrong)

    - Fix meson clock names to match DT bindings (Neil Armstrong)

    - Add meson support for Amlogic G12A SoC with separate shared PHY
    (Neil Armstrong)

    - Add meson extended PCIe PHY functions for Amlogic G12A USB3+PCIe
    combo PHY (Neil Armstrong)

    - Add arm64 DT for Amlogic G12A PCIe controller node (Neil Armstrong)

    - Add commented-out description of VIM3 USB3/PCIe mux in arm64 DT
    (Neil Armstrong)

    Broadcom iProc host bridge driver:

    - Invalidate iProc PAXB address mapping before programming it
    (Abhishek Shah)

    - Fix iproc-msi and mvebu __iomem annotations (Ben Dooks)

    Cadence host bridge driver:

    - Refactor Cadence PCIe host controller to use as a library for both
    host and endpoint (Tom Joseph)

    Freescale Layerscape host bridge driver:

    - Add layerscape LS1028a support (Xiaowei Bao)

    Intel VMD host bridge driver:

    - Add VMD bus 224-255 restriction decode (Jon Derrick)

    - Add VMD 8086:9A0B device ID (Jon Derrick)

    - Remove Keith from VMD maintainer list (Keith Busch)

    Marvell ARMADA 3700 / Aardvark host bridge driver:

    - Use LTSSM state to build link training flag since Aardvark doesn't
    implement the Link Training bit (Remi Pommarel)

    - Delay before training Aardvark link in case PERST# was asserted
    before the driver probe (Remi Pommarel)

    - Fix Aardvark issues with Root Control reads and writes (Remi
    Pommarel)

    - Don't rely on jiffies in Aardvark config access path since
    interrupts may be disabled (Remi Pommarel)

    - Fix Aardvark big-endian support (Grzegorz Jaszczyk)

    Marvell ARMADA 370 / XP host bridge driver:

    - Make mvebu_pci_bridge_emul_ops static (Ben Dooks)

    Microsoft Hyper-V host bridge driver:

    - Add hibernation support for Hyper-V virtual PCI devices (Dexuan
    Cui)

    - Track Hyper-V pci_protocol_version per-hbus, not globally (Dexuan
    Cui)

    - Avoid kmemleak false positive on hv hbus buffer (Dexuan Cui)

    Mobiveil host bridge driver:

    - Change mobiveil csr_read()/write() function names that conflict
    with riscv arch functions (Kefeng Wang)

    NVIDIA Tegra host bridge driver:

    - Fix Tegra CLKREQ dependency programming (Vidya Sagar)

    Renesas R-Car host bridge driver:

    - Remove unnecessary header include from rcar (Andrew Murray)

    - Tighten register index checking for rcar inbound range programming
    (Marek Vasut)

    - Fix rcar inbound range alignment calculation to improve packing of
    multiple entries (Marek Vasut)

    - Update rcar MACCTLR setting to match documentation (Yoshihiro
    Shimoda)

    - Clear bit 0 of MACCTLR before PCIETCTLR.CFINIT per manual
    (Yoshihiro Shimoda)

    - Add Marek Vasut and Yoshihiro Shimoda as R-Car maintainers (Simon
    Horman)

    Rockchip host bridge driver:

    - Make rockchip 0V9 and 1V8 power regulators non-optional (Robin
    Murphy)

    Socionext UniPhier host bridge driver:

    - Set uniphier to host (RC) mode always (Kunihiko Hayashi)

    Endpoint drivers:

    - Fix endpoint driver sign extension problem when shifting page
    number to phys_addr_t (Alan Mikhak)

    Misc:

    - Add NumaChip SPDX header (Krzysztof Wilczynski)

    - Replace EXTRA_CFLAGS with ccflags-y (Krzysztof Wilczynski)

    - Remove unused includes (Krzysztof Wilczynski)

    - Removed unused sysfs attribute groups (Ben Dooks)

    - Remove PTM and ASPM dependencies on PCIEPORTBUS (Bjorn Helgaas)

    - Add PCIe Link Control 2 register field definitions to replace magic
    numbers in AMDGPU and Radeon CIK/SI (Bjorn Helgaas)

    - Fix incorrect Link Control 2 Transmit Margin usage in AMDGPU and
    Radeon CIK/SI PCIe Gen3 link training (Bjorn Helgaas)

    - Use pcie_capability_read_word() instead of pci_read_config_word()
    in AMDGPU and Radeon CIK/SI (Frederick Lawler)

    - Remove unused pci_irq_get_node() Greg Kroah-Hartman)

    - Make asm/msi.h mandatory and simplify PCI_MSI_IRQ_DOMAIN Kconfig
    (Palmer Dabbelt, Michal Simek)

    - Read all 64 bits of Switchtec part_event_bitmap (Logan Gunthorpe)

    - Fix erroneous intel-iommu dependency on CONFIG_AMD_IOMMU (Bjorn
    Helgaas)

    - Fix bridge emulation big-endian support (Grzegorz Jaszczyk)

    - Fix dwc find_next_bit() usage (Niklas Cassel)

    - Fix pcitest.c fd leak (Hewenliang)

    - Fix typos and comments (Bjorn Helgaas)

    - Fix Kconfig whitespace errors (Krzysztof Kozlowski)"

    * tag 'pci-v5.5-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (160 commits)
    PCI: Remove PCI_MSI_IRQ_DOMAIN architecture whitelist
    asm-generic: Make msi.h a mandatory include/asm header
    Revert "nvme: Add quirk for Kingston NVME SSD running FW E8FK11.T"
    PCI/MSI: Fix incorrect MSI-X masking on resume
    PCI/MSI: Move power state check out of pci_msi_supported()
    PCI/MSI: Remove unused pci_irq_get_node()
    PCI: hv: Avoid a kmemleak false positive caused by the hbus buffer
    PCI: hv: Change pci_protocol_version to per-hbus
    PCI: hv: Add hibernation support
    PCI: hv: Reorganize the code in preparation of hibernation
    MAINTAINERS: Remove Keith from VMD maintainer
    PCI/ASPM: Remove PCIEASPM_DEBUG Kconfig option and related code
    PCI/ASPM: Add sysfs attributes for controlling ASPM link states
    PCI: Fix indentation
    drm/radeon: Prefer pcie_capability_read_word()
    drm/radeon: Replace numbers with PCI_EXP_LNKCTL2 definitions
    drm/radeon: Correct Transmit Margin masks
    drm/amdgpu: Prefer pcie_capability_read_word()
    PCI: uniphier: Set mode register to host mode
    drm/amdgpu: Replace numbers with PCI_EXP_LNKCTL2 definitions
    ...

    Linus Torvalds
     

28 Nov, 2019

1 commit

  • - Protect pci_reassign_bridge_resources() against concurrent
    addition/removal (Benjamin Herrenschmidt)

    - Fix bridge dma_ranges resource list cleanup (Rob Herring)

    - Add PCI_STD_NUM_BARS for the number of standard BARs (Denis Efremov)

    - Add "pci=hpmmiosize" and "pci=hpmmioprefsize" parameters to control the
    MMIO and prefetchable MMIO window sizes of hotplug bridges
    independently (Nicholas Johnson)

    - Fix MMIO/MMIO_PREF window assignment that assigned more space than
    desired (Nicholas Johnson)

    - Only enforce bus numbers from bridge EA if the bridge has EA devices
    downstream (Subbaraya Sundeep)

    * pci/resource:
    PCI: Do not use bus number zero from EA capability
    PCI: Avoid double hpmemsize MMIO window assignment
    PCI: Add "pci=hpmmiosize" and "pci=hpmmioprefsize" parameters
    PCI: Add PCI_STD_NUM_BARS for the number of standard BARs
    PCI: Fix missing bridge dma_ranges resource list cleanup
    PCI: Protect pci_reassign_bridge_resources() against concurrent addition/removal

    Bjorn Helgaas
     

21 Nov, 2019

1 commit


13 Nov, 2019

1 commit


14 Oct, 2019

1 commit

  • Code that iterates over all standard PCI BARs typically uses
    PCI_STD_RESOURCE_END. However, that requires the unusual test
    "i < PCI_STD_NUM_BARS".

    Add a definition for PCI_STD_NUM_BARS and change loops to use the more
    idiomatic C style to help avoid fencepost errors.

    Link: https://lore.kernel.org/r/20190927234026.23342-1-efremov@linux.com
    Link: https://lore.kernel.org/r/20190927234308.23935-1-efremov@linux.com
    Link: https://lore.kernel.org/r/20190916204158.6889-3-efremov@linux.com
    Signed-off-by: Denis Efremov
    Signed-off-by: Bjorn Helgaas
    Acked-by: Sebastian Ott # arch/s390/
    Acked-by: Bartlomiej Zolnierkiewicz # video/fbdev/
    Acked-by: Gustavo Pimentel # pci/controller/dwc/
    Acked-by: Jack Wang # scsi/pm8001/
    Acked-by: Martin K. Petersen # scsi/pm8001/
    Acked-by: Ulf Hansson # memstick/

    Denis Efremov
     

09 Oct, 2019

1 commit


11 Sep, 2019

2 commits


12 Jul, 2019

1 commit

  • Pull MMC updates from Ulf Hansson:
    "MMC core:
    - Let the dma map ops deal with bouncing and drop dma_max_pfn() from
    the dma-mapping interface for ARM
    - Convert the generic MMC DT doc to YAML schemas
    - Drop questionable support for powered-on re-init of SDIO cards at
    runtime resume and for SDIO HW reset
    - Prevent questionable re-init of powered-on removable SDIO cards at
    system resume
    - Cleanup and clarify some SDIO core code

    MMC host:
    - tmio: Make runtime PM enablement more flexible for variants
    - tmio/renesas_sdhi: Rename DT doc tmio_mmc.txt to renesas,sdhi.txt
    to clarify
    - sdhci-pci: Add support for Intel EHL
    - sdhci-pci-o2micro: Enable support for 8-bit bus
    - sdhci-msm: Prevent acquiring a mutex while holding a spin_lock
    - sdhci-of-esdhc: Improve clock management and tuning
    - sdhci_am654: Enable support for 4 and 8-bit bus on J721E
    - sdhci-sprd: Use pinctrl for a proper signal voltage switch
    - sdhci-sprd: Add support for HS400 enhanced strobe mode
    - sdhci-sprd: Enable PHY DLL and allow delay config to stabilize the
    clock
    - sdhci-sprd: Add support for optional gate clock
    - sunxi-mmc: Convert DT doc to YAML schemas
    - meson-gx: Add support for broken DRAM access for DMA

    MEMSTICK core:
    - Fixup error path of memstick_init()"

    * tag 'mmc-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (52 commits)
    mmc: sdhci_am654: Add dependency on MMC_SDHCI_AM654
    mmc: alcor: remove a redundant greater or equal to zero comparison
    mmc: sdhci-msm: fix mutex while in spinlock
    mmc: sdhci_am654: Make some symbols static
    dma-mapping: remove dma_max_pfn
    mmc: core: let the dma map ops handle bouncing
    dt-binding: mmc: rename tmio_mmc.txt to renesas,sdhi.txt
    mmc: sdhci-sprd: Add pin control support for voltage switch
    dt-bindings: mmc: sprd: Add pinctrl support
    mmc: sdhci-sprd: Add start_signal_voltage_switch ops
    mmc: sdhci-pci: Add support for Intel EHL
    mmc: tmio: Use dma_max_mapping_size() instead of a workaround
    mmc: sdio: Drop unused in-parameter from mmc_sdio_init_card()
    mmc: sdio: Drop unused in-parameter to mmc_sdio_reinit_card()
    mmc: sdio: Don't re-initialize powered-on removable SDIO cards at resume
    mmc: sdio: Drop powered-on re-init at runtime resume and HW reset
    mmc: sdio: Move comment about re-initialization to mmc_sdio_reinit_card()
    mmc: sdio: Drop mmc_claim|release_host() in mmc_sdio_power_restore()
    mmc: sdio: Turn sdio_run_irqs() into static
    mmc: sdhci: Fix indenting on SDHCI_CTRL_8BITBUS
    ...

    Linus Torvalds
     

19 Jun, 2019

2 commits

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation #

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 4122 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Enrico Weigelt
    Reviewed-by: Kate Stewart
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not see http www gnu org
    licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 503 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Reviewed-by: Enrico Weigelt
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190602204653.811534538@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

10 Jun, 2019

1 commit

  • If bus_register fails. On its error handling path, it has cleaned up
    what it has done. There is no need to call bus_unregister again.
    Otherwise, if bus_unregister is called, issues such as null-ptr-deref
    will arise.

    Syzkaller report this:

    kobject_add_internal failed for memstick (error: -12 parent: bus)
    BUG: KASAN: null-ptr-deref in sysfs_remove_file_ns+0x1b/0x40 fs/sysfs/file.c:467
    Read of size 8 at addr 0000000000000078 by task syz-executor.0/4460

    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0xa9/0x10e lib/dump_stack.c:113
    __kasan_report+0x171/0x18d mm/kasan/report.c:321
    kasan_report+0xe/0x20 mm/kasan/common.c:614
    sysfs_remove_file_ns+0x1b/0x40 fs/sysfs/file.c:467
    sysfs_remove_file include/linux/sysfs.h:519 [inline]
    bus_remove_file+0x6c/0x90 drivers/base/bus.c:145
    remove_probe_files drivers/base/bus.c:599 [inline]
    bus_unregister+0x6e/0x100 drivers/base/bus.c:916 ? 0xffffffffc1590000
    memstick_init+0x7a/0x1000 [memstick]
    do_one_initcall+0xb9/0x3b5 init/main.c:914
    do_init_module+0xe0/0x330 kernel/module.c:3468
    load_module+0x38eb/0x4270 kernel/module.c:3819
    __do_sys_finit_module+0x162/0x190 kernel/module.c:3909
    do_syscall_64+0x72/0x2a0 arch/x86/entry/common.c:298
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    Fixes: baf8532a147d ("memstick: initial commit for Sony MemoryStick support")
    Reported-by: Hulk Robot
    Signed-off-by: Wang Hai
    Signed-off-by: Ulf Hansson

    Wang Hai
     

28 May, 2019

1 commit

  • We accidentally changed the error code from -EAGAIN to 1 when we did the
    blk-mq conversion.

    Maybe a contributing factor to this mistake is that it wasn't obvious
    that the "while (chunk) {" condition is always true. I have cleaned
    that up as well.

    Fixes: d0be12274dad ("mspro_block: convert to blk-mq")
    Cc: stable@vger.kernel.org
    Signed-off-by: Dan Carpenter
    Signed-off-by: Ulf Hansson

    Dan Carpenter
     

21 May, 2019

2 commits

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 or at your option any
    later version this program is distributed in the hope that it will
    be useful but without any warranty without even the implied warranty
    of merchantability or fitness for a particular purpose see the gnu
    general public license for more details you should have received a
    copy of the gnu general public license along with this program if
    not see http www gnu org licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 13 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Steve Winslow
    Reviewed-by: Jilayne Lovejoy
    Reviewed-by: Kate Stewart
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190519154042.236620792@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • Add SPDX license identifiers to all Make/Kconfig files which:

    - Have no license information of any form

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 May, 2019

2 commits

  • Pull MMC updates from Ulf Hansson:
    "MMC core:
    - Fix a few memoryleaks
    - Minor improvements to the card initialization sequence
    - Partially support sleepy GPIO controllers for pwrseq eMMC

    MMC host:
    - alcor: Work with multiple-entry sglists
    - alcor: Enable DMA for writes
    - meson-gx: Improve tuning support
    - meson-gx: Avoid clock glitch when switching to DDR modes
    - meson-gx: Disable unreliable HS400 mode
    - mmci: Minor updates for support of HW busy detection
    - mmci: Support data transfers for the stm32_sdmmc variant
    - mmci: Restructure code to better support different variants
    - mtk-sd: Add support for version found on MT7620 family SOCs
    - mtk-sd: Add support for the MT8516 version
    - mtk-sd: Add Chaotian Jing as the maintainer
    - sdhci: Reorganize request-code to convert from tasklet to workqueue
    - sdhci_am654: Stabilize support for lower speed modes
    - sdhci-esdhc-imx: Add HS400 support for iMX7ULP
    - sdhci-esdhc-imx: Add support for iMX7ULP version
    - sdhci-of-arasan: Allow to disable DCMDs via DT for CQE
    - sdhci-of-esdhc: Add support for the ls1028a version
    - sdhci-of-esdhc: Several fixups for errata
    - sdhci-pci: Fix BYT OCP setting
    - sdhci-pci: Add support for Intel CML
    - sdhci-tegra: Add support for system suspend/resume
    - sdhci-tegra: Add CQE support for Tegra186 WAR
    - sdhci-tegra: Add support for Tegra194
    - sdhci-tegra: Update HW tuning process

    MEMSTICK:
    - I volunteered to help as a maintainer for the memstick subsystem,
    which is reflected by an update to the MAINTAINERS file. Changes
    are funneled through my MMC git and we will use the linux-mmc
    mailing list.

    MEMSTICK host:
    - A few minor cleanups"

    * tag 'mmc-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (87 commits)
    mmc: sdhci-pci: Fix BYT OCP setting
    dt-bindings: mmc: add DT bindings for ls1028a eSDHC host controller
    mmc: alcor: Drop pointer to mmc_host from alcor_sdmmc_host
    mmc: mtk-sd: select REGULATOR
    mmc: mtk-sd: enable internal card-detect logic.
    mmc: mtk-sd: add support for config found in mt7620 family SOCs.
    mmc: mtk-sd: don't hard-code interrupt trigger type
    mmc: core: Fix tag set memory leak
    dt-bindings: mmc: Add support for MT8516 to mtk-sd
    mmc: mmci: Prevent polling for busy detection in IRQ context
    mmc: mmci: Cleanup mmci_cmd_irq() for busy detect
    mmc: usdhi6rol0: mark expected switch fall-throughs
    mmc: core: Verify SD bus width
    mmc: sdhci-esdhc-imx: Add HS400 support for iMX7ULP
    mmc: sdhci-esdhc-imx: add pm_qos to interact with cpuidle
    dt-bindings: mmc: fsl-imx-esdhc: add imx7ulp compatible string
    mmc: meson-gx: add signal resampling tuning
    mmc: meson-gx: remove Rx phase tuning
    mmc: meson-gx: avoid clock glitch when switching to DDR modes
    mmc: meson-gx: disable HS400
    ...

    Linus Torvalds
     
  • …kernel/git/gustavoars/linux

    Pull Wimplicit-fallthrough updates from Gustavo A. R. Silva:
    "Mark switch cases where we are expecting to fall through.

    This is part of the ongoing efforts to enable -Wimplicit-fallthrough.

    Most of them have been baking in linux-next for a whole development
    cycle. And with Stephen Rothwell's help, we've had linux-next
    nag-emails going out for newly introduced code that triggers
    -Wimplicit-fallthrough to avoid gaining more of these cases while we
    work to remove the ones that are already present.

    We are getting close to completing this work. Currently, there are
    only 32 of 2311 of these cases left to be addressed in linux-next. I'm
    auditing every case; I take a look into the code and analyze it in
    order to determine if I'm dealing with an actual bug or a false
    positive, as explained here:

    https://lore.kernel.org/lkml/c2fad584-1705-a5f2-d63c-824e9b96cf50@embeddedor.com/

    While working on this, I've found and fixed the several missing
    break/return bugs, some of them introduced more than 5 years ago.

    Once this work is finished, we'll be able to universally enable
    "-Wimplicit-fallthrough" to avoid any of these kinds of bugs from
    entering the kernel again"

    * tag 'Wimplicit-fallthrough-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux: (27 commits)
    memstick: mark expected switch fall-throughs
    drm/nouveau/nvkm: mark expected switch fall-throughs
    NFC: st21nfca: Fix fall-through warnings
    NFC: pn533: mark expected switch fall-throughs
    block: Mark expected switch fall-throughs
    ASN.1: mark expected switch fall-through
    lib/cmdline.c: mark expected switch fall-throughs
    lib: zstd: Mark expected switch fall-throughs
    scsi: sym53c8xx_2: sym_nvram: Mark expected switch fall-through
    scsi: sym53c8xx_2: sym_hipd: mark expected switch fall-throughs
    scsi: ppa: mark expected switch fall-through
    scsi: osst: mark expected switch fall-throughs
    scsi: lpfc: lpfc_scsi: Mark expected switch fall-throughs
    scsi: lpfc: lpfc_nvme: Mark expected switch fall-through
    scsi: lpfc: lpfc_nportdisc: Mark expected switch fall-through
    scsi: lpfc: lpfc_hbadisc: Mark expected switch fall-throughs
    scsi: lpfc: lpfc_els: Mark expected switch fall-throughs
    scsi: lpfc: lpfc_ct: Mark expected switch fall-throughs
    scsi: imm: mark expected switch fall-throughs
    scsi: csiostor: csio_wr: mark expected switch fall-through
    ...

    Linus Torvalds
     

06 May, 2019

1 commit

  • Fixes gcc '-Wunused-but-set-variable' warning:

    drivers/memstick/host/tifm_ms.c: In function 'tifm_ms_issue_cmd':
    drivers/memstick/host/tifm_ms.c:259:17: warning:
    variable 'data' set but not used [-Wunused-but-set-variable]

    It's not used any more since commit 92b22d935fed ("tifm: fix the
    MemoryStick host fifo handling code")

    Signed-off-by: YueHaibing
    Signed-off-by: Ulf Hansson

    YueHaibing
     

23 Apr, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch
    cases where we are expecting to fall through.

    This patch fixes the following warnings:

    drivers/memstick/host/jmb38x_ms.c: In function ‘jmb38x_ms_write_data’:
    drivers/memstick/host/jmb38x_ms.c:261:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    host->io_pos++;
    ~~~~~~~~~~~~^~
    drivers/memstick/host/jmb38x_ms.c:262:2: note: here
    case 2:
    ^~~~
    drivers/memstick/host/jmb38x_ms.c:264:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    host->io_pos++;
    ~~~~~~~~~~~~^~
    drivers/memstick/host/jmb38x_ms.c:265:2: note: here
    case 1:
    ^~~~
    drivers/memstick/host/tifm_ms.c: In function ‘tifm_ms_write_data’:
    drivers/memstick/host/tifm_ms.c:168:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    host->io_pos++;
    ~~~~~~~~~~~~^~
    drivers/memstick/host/tifm_ms.c:169:2: note: here
    case 2:
    ^~~~
    drivers/memstick/host/tifm_ms.c:171:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    host->io_pos++;
    ~~~~~~~~~~~~^~
    drivers/memstick/host/tifm_ms.c:172:2: note: here
    case 1:
    ^~~~

    Warning level 3 was used: -Wimplicit-fallthrough=3

    This patch is part of the ongoing efforts to enable
    -Wimplicit-fallthrough.

    Reviewed-by: Kees Cook
    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

15 Apr, 2019

1 commit

  • Fixes gcc '-Wunused-but-set-variable' warning:

    drivers/memstick/host/jmb38x_ms.c: In function 'jmb38x_ms_issue_cmd':
    drivers/memstick/host/jmb38x_ms.c:371:17: warning:
    variable 'data' set but not used [-Wunused-but-set-variable]

    It's never used since introduction and can be removed.
    Signed-off-by: YueHaibing
    Signed-off-by: Ulf Hansson

    YueHaibing
     

08 Apr, 2019

1 commit

  • mmiowb() is now implied by spin_unlock() on architectures that require
    it, so there is no reason to call it from driver code. This patch was
    generated using coccinelle:

    @mmiowb@
    @@
    - mmiowb();

    and invoked as:

    $ for d in drivers include/linux/qed sound; do \
    spatch --include-headers --sp-file mmiowb.cocci --dir $d --in-place; done

    NOTE: mmiowb() has only ever guaranteed ordering in conjunction with
    spin_unlock(). However, pairing each mmiowb() removal in this patch with
    the corresponding call to spin_unlock() is not at all trivial, so there
    is a small chance that this change may regress any drivers incorrectly
    relying on mmiowb() to order MMIO writes between CPUs using lock-free
    synchronisation. If you've ended up bisecting to this commit, you can
    reintroduce the mmiowb() calls using wmb() instead, which should restore
    the old behaviour on all architectures other than some esoteric ia64
    systems.

    Acked-by: Linus Torvalds
    Signed-off-by: Will Deacon

    Will Deacon
     

29 Dec, 2018

1 commit

  • Pull MMC updates from Ulf Hansson:
    "This time, this pull request contains changes crossing subsystems and
    archs/platforms, which is mainly because of a bigger modernization of
    moving from legacy GPIO to GPIO descriptors for MMC (by Linus
    Walleij).

    Additionally, once again, I am funneling changes to
    drivers/misc/cardreader/* and drivers/memstick/* through my MMC tree,
    mostly due to that we lack a maintainer for these.

    Summary:

    MMC core:
    - Cleanup BKOPS support
    - Introduce MMC_CAP_SYNC_RUNTIME_PM
    - slot-gpio: Delete legacy slot GPIO handling

    MMC host:
    - alcor: Add new mmc host driver for Alcor Micro PCI based cardreader
    - bcm2835: Several improvements to better recover from errors
    - jz4740: Rework and fixup pre|post_req support
    - mediatek: Add support for SDIO IRQs
    - meson-gx: Improve clock phase management
    - meson-gx: Stop descriptor on errors
    - mmci: Complete the sbc error path by sending a stop command
    - renesas_sdhi/tmio: Fixup reset/resume operations
    - renesas_sdhi: Add support for r8a774c0 and R7S9210
    - renesas_sdhi: Whitelist R8A77990 SDHI
    - renesas_sdhi: Fixup eMMC HS400 compatibility issues for H3 and M3-W
    - rtsx_usb_sdmmc: Re-work card detection/removal support
    - rtsx_usb_sdmmc: Re-work runtime PM support
    - sdhci: Fix timeout loops for some variant drivers
    - sdhci: Improve support for error handling due to failing commands
    - sdhci-acpi/pci: Disable LED control for Intel BYT-based controllers
    - sdhci_am654: Add new SDHCI variant driver to support TI's AM654 SOCs
    - sdhci-of-esdhc: Add support for eMMC HS400 mode
    - sdhci-omap: Fixup reset support
    - sdhci-omap: Workaround errata regarding SDR104/HS200 tuning failures
    - sdhci-msm: Fixup sporadic write transfers issues for SDR104/HS200
    - sdhci-msm: Fixup dynamical clock gating issues
    - various: Complete converting all hosts into using slot GPIO descriptors

    Other:
    - Move GPIO mmc platform data for mips/sh/arm to GPIO descriptors
    - Add new Alcor Micro cardreader PCI driver
    - Support runtime power management for memstick rtsx_usb_ms driver
    - Use USB remote wakeups for card detection for rtsx_usb misc driver"

    * tag 'mmc-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (99 commits)
    mmc: mediatek: Add MMC_CAP_SDIO_IRQ support
    mmc: renesas_sdhi_internal_dmac: Whitelist r8a774c0
    dt-bindings: mmc: renesas_sdhi: Add r8a774c0 support
    mmc: core: Cleanup BKOPS support
    mmc: core: Drop redundant check in mmc_send_hpi_cmd()
    mmc: sdhci-omap: Workaround errata regarding SDR104/HS200 tuning failures (i929)
    dt-bindings: sdhci-omap: Add note for cpu_thermal
    mmc: sdhci-acpi: Disable LED control for Intel BYT-based controllers
    mmc: sdhci-pci: Disable LED control for Intel BYT-based controllers
    mmc: sdhci: Add quirk to disable LED control
    mmc: mmci: add variant property to set command stop bit
    misc: alcor_pci: fix spelling mistake "invailid" -> "invalid"
    mmc: meson-gx: add signal resampling
    mmc: meson-gx: align default phase on soc vendor tree
    mmc: meson-gx: remove useless lock
    mmc: meson-gx: make sure the descriptor is stopped on errors
    mmc: sdhci_am654: Add Initial Support for AM654 SDHCI driver
    dt-bindings: mmc: sdhci-of-arasan: Add deprecated message for AM65
    dt-bindings: mmc: sdhci-am654: Document bindings for the host controllers on TI's AM654 SOCs
    mmc: sdhci-msm: avoid unused function warning
    ...

    Linus Torvalds
     

17 Dec, 2018

4 commits

  • In order to let host's parent device, rtsx_usb, to use USB remote wake
    up signaling to do card detection, it needs to be suspended. Hence it's
    necessary to add runtime PM support for the memstick host.

    To keep memstick host stays suspended when it's not in use, convert the
    card detection function from kthread to delayed_work, which can be
    scheduled when the host is resumed and can be canceled when the host is
    suspended.

    Put the device to suspend when there's no card and the power mode is
    MEMSTICK_POWER_OFF.

    Signed-off-by: Kai-Heng Feng
    Tested-by: Oleksandr Natalenko
    Signed-off-by: Ulf Hansson

    Kai-Heng Feng
     
  • Use ms_dev() helper for consistency.

    Signed-off-by: Kai-Heng Feng
    Tested-by: Oleksandr Natalenko
    Signed-off-by: Ulf Hansson

    Kai-Heng Feng
     
  • We can use MEMSTICK_POWER_{ON,OFF} along with pm_runtime_{get,put}
    helpers to let memstick host support runtime pm.

    The rpm count may go down to zero before the memstick host powers on, so
    the host can be runtime suspended.

    So before doing card detection, increment the rpm count to avoid the
    host gets runtime suspended. Balance the rpm count after card detection
    is done.

    Signed-off-by: Kai-Heng Feng
    Tested-by: Oleksandr Natalenko
    Signed-off-by: Ulf Hansson

    Kai-Heng Feng
     
  • If the probe fails, we should use pm_runtime_disable() to balance
    pm_runtime_enable().

    Add missing pm_runtime_disable() for rtsx_usb_ms.

    Signed-off-by: Kai-Heng Feng
    Tested-by: Oleksandr Natalenko
    Signed-off-by: Ulf Hansson

    Kai-Heng Feng
     

08 Nov, 2018

3 commits

  • Pointer 'set' is declared but not used, remove it. Cleans up warning:

    warning: unused variable ‘set’ [-Wunused-variable]

    Signed-off-by: Colin Ian King
    Signed-off-by: Jens Axboe

    Colin Ian King
     
  • Straight forward conversion, there's room for improvement.

    Reviewed-by: Hannes Reinecke
    Tested-by: Ming Lei
    Reviewed-by: Omar Sandoval
    Signed-off-by: Jens Axboe

    Jens Axboe
     
  • Straight forward conversion, room for optimization in how everything
    is punted to a work queue. Also looks plenty racy all over the map,
    with the state changes. I fixed a bunch of them up while doing the
    conversion, but there are surely more.

    Cc: Maxim Levitsky
    Reviewed-by: Hannes Reinecke
    Tested-by: Ming Lei
    Reviewed-by: Omar Sandoval
    Signed-off-by: Jens Axboe

    Jens Axboe
     

28 Sep, 2018

1 commit

  • Update device_add_disk() to take an 'groups' argument so that
    individual drivers can register a device with additional sysfs
    attributes.
    This avoids race condition the driver would otherwise have if these
    groups were to be created with sysfs_add_groups().

    Signed-off-by: Martin Wilck
    Signed-off-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Bart Van Assche
    Signed-off-by: Jens Axboe

    Hannes Reinecke
     

13 Jun, 2018

1 commit

  • The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:

    kmalloc(a * b, gfp)

    with:
    kmalloc_array(a * b, gfp)

    as well as handling cases of:

    kmalloc(a * b * c, gfp)

    with:

    kmalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kmalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kmalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kmalloc
    + kmalloc_array
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kmalloc(sizeof(THING) * C2, ...)
    |
    kmalloc(sizeof(TYPE) * C2, ...)
    |
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(C1 * C2, ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook