178 Commits

Author SHA1 Message Date
Nathan Chancellor
52bdbb481c Merge 4.4.181 into android-msm-wahoo-4.4
Changes in 4.4.181: (244 commits)
        x86/speculation/mds: Revert CPU buffer clear on double fault exit
        x86/speculation/mds: Improve CPU buffer clear documentation
        ARM: exynos: Fix a leaked reference by adding missing of_node_put
        crypto: vmx - fix copy-paste error in CTR mode
        crypto: crct10dif-generic - fix use via crypto_shash_digest()
        crypto: x86/crct10dif-pcl - fix use via crypto_shash_digest()
        ALSA: usb-audio: Fix a memory leak bug
        ALSA: hda/hdmi - Consider eld_valid when reporting jack event
        ALSA: hda/realtek - EAPD turn on later
        ASoC: max98090: Fix restore of DAPM Muxes
        ASoC: RT5677-SPI: Disable 16Bit SPI Transfers
        mm/mincore.c: make mincore() more conservative
        ocfs2: fix ocfs2 read inode data panic in ocfs2_iget
        mfd: da9063: Fix OTP control register names to match datasheets for DA9063/63L
        tty/vt: fix write/write race in ioctl(KDSKBSENT) handler
        ext4: actually request zeroing of inode table after grow
        ext4: fix ext4_show_options for file systems w/o journal
        Btrfs: do not start a transaction at iterate_extent_inodes()
        bcache: fix a race between cache register and cacheset unregister
        bcache: never set KEY_PTRS of journal key to 0 in journal_reclaim()
        ipmi:ssif: compare block number correctly for multi-part return messages
        crypto: gcm - Fix error return code in crypto_gcm_create_common()
        crypto: gcm - fix incompatibility between "gcm" and "gcm_base"
        crypto: chacha20poly1305 - set cra_name correctly
        crypto: salsa20 - don't access already-freed walk.iv
        crypto: arm/aes-neonbs - don't access already-freed walk.iv
        writeback: synchronize sync(2) against cgroup writeback membership switches
        fs/writeback.c: use rcu_barrier() to wait for inflight wb switches going into workqueue when umount
        ext4: zero out the unused memory region in the extent tree block
        ALSA: hda/realtek - Fix for Lenovo B50-70 inverted internal microphone bug
        KVM: x86: Skip EFER vs. guest CPUID checks for host-initiated writes
        net: avoid weird emergency message
        net/mlx4_core: Change the error print to info print
        ppp: deflate: Fix possible crash in deflate_init
        tipc: switch order of device registration to fix a crash
        tipc: fix modprobe tipc failed after switch order of device registration
        stm class: Fix channel free in stm output free path
        md: add mddev->pers to avoid potential NULL pointer dereference
        intel_th: msu: Fix single mode with IOMMU
        of: fix clang -Wunsequenced for be32_to_cpu()
        cifs: fix strcat buffer overflow and reduce raciness in smb21_set_oplock_level()
        media: ov6650: Fix sensor possibly not detected on probe
        NFS4: Fix v4.0 client state corruption when mount
        clk: tegra: Fix PLLM programming on Tegra124+ when PMC overrides divider
        fuse: fix writepages on 32bit
        fuse: honor RLIMIT_FSIZE in fuse_file_fallocate
        iommu/tegra-smmu: Fix invalid ASID bits on Tegra30/114
        ceph: flush dirty inodes before proceeding with remount
        tracing: Fix partial reading of trace event's id file
        memory: tegra: Fix integer overflow on tick value calculation
        perf intel-pt: Fix instructions sampling rate
        perf intel-pt: Fix improved sample timestamp
        perf intel-pt: Fix sample timestamp wrt non-taken branches
        fbdev: sm712fb: fix brightness control on reboot, don't set SR30
        fbdev: sm712fb: fix VRAM detection, don't set SR70/71/74/75
        fbdev: sm712fb: fix white screen of death on reboot, don't set CR3B-CR3F
        fbdev: sm712fb: fix boot screen glitch when sm712fb replaces VGA
        fbdev: sm712fb: fix crashes during framebuffer writes by correctly mapping VRAM
        fbdev: sm712fb: fix support for 1024x768-16 mode
        fbdev: sm712fb: use 1024x768 by default on non-MIPS, fix garbled display
        fbdev: sm712fb: fix crashes and garbled display during DPMS modesetting
        PCI: Mark Atheros AR9462 to avoid bus reset
        dm delay: fix a crash when invalid device is specified
        xfrm: policy: Fix out-of-bound array accesses in __xfrm_policy_unlink
        xfrm6_tunnel: Fix potential panic when unloading xfrm6_tunnel module
        vti4: ipip tunnel deregistration fixes.
        xfrm4: Fix uninitialized memory read in _decode_session4
        KVM: arm/arm64: Ensure vcpu target is unset on reset failure
        power: supply: sysfs: prevent endless uevent loop with CONFIG_POWER_SUPPLY_DEBUG
        ufs: fix braino in ufs_get_inode_gid() for solaris UFS flavour
        perf bench numa: Add define for RUSAGE_THREAD if not present
        Revert "Don't jump to compute_result state from check_result state"
        md/raid: raid5 preserve the writeback action after the parity check
        btrfs: Honour FITRIM range constraints during free space trim
        fbdev: sm712fb: fix memory frequency by avoiding a switch/case fallthrough
        ext4: do not delete unlinked inode from orphan list on failed truncate
        KVM: x86: fix return value for reserved EFER
        bio: fix improper use of smp_mb__before_atomic()
        Revert "scsi: sd: Keep disk read-only when re-reading partition"
        crypto: vmx - CTR: always increment IV as quadword
        gfs2: Fix sign extension bug in gfs2_update_stats
        Btrfs: fix race between ranged fsync and writeback of adjacent ranges
        btrfs: sysfs: don't leak memory when failing add fsid
        fbdev: fix divide error in fb_var_to_videomode
        hugetlb: use same fault hash key for shared and private mappings
        fbdev: fix WARNING in __alloc_pages_nodemask bug
        media: cpia2: Fix use-after-free in cpia2_exit
        media: vivid: use vfree() instead of kfree() for dev->bitmap_cap
        ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit
        at76c50x-usb: Don't register led_trigger if usb_register_driver failed
        perf tools: No need to include bitops.h in util.h
        tools include: Adopt linux/bits.h
        gfs2: Fix lru_count going negative
        cxgb4: Fix error path in cxgb4_init_module
        mmc: core: Verify SD bus width
        powerpc/boot: Fix missing check of lseek() return value
        ASoC: imx: fix fiq dependencies
        spi: pxa2xx: fix SCR (divisor) calculation
        brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler()
        rtc: 88pm860x: prevent use-after-free on device remove
        w1: fix the resume command API
        dmaengine: pl330: _stop: clear interrupt status
        mac80211/cfg80211: update bss channel on channel switch
        ASoC: fsl_sai: Update is_slave_mode with correct value
        mwifiex: prevent an array overflow
        net: cw1200: fix a NULL pointer dereference
        bcache: return error immediately in bch_journal_replay()
        bcache: fix failure in journal relplay
        bcache: add failure check to run_cache_set() for journal replay
        bcache: avoid clang -Wunintialized warning
        x86/build: Move _etext to actual end of .text
        smpboot: Place the __percpu annotation correctly
        x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault()
        mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions
        HID: logitech-hidpp: use RAP instead of FAP to get the protocol version
        pinctrl: pistachio: fix leaked of_node references
        dmaengine: at_xdmac: remove BUG_ON macro in tasklet
        media: coda: clear error return value before picture run
        media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper
        media: au0828: stop video streaming only when last user stops
        media: ov2659: make S_FMT succeed even if requested format doesn't match
        audit: fix a memory leak bug
        media: au0828: Fix NULL pointer dereference in au0828_analog_stream_enable()
        media: pvrusb2: Prevent a buffer overflow
        powerpc/numa: improve control of topology updates
        sched/core: Check quota and period overflow at usec to nsec conversion
        sched/core: Handle overflow in cpu_shares_write_u64
        USB: core: Don't unbind interfaces following device reset failure
        x86/irq/64: Limit IST stack overflow check to #DB stack
        i40e: don't allow changes to HW VLAN stripping on active port VLANs
        RDMA/cxgb4: Fix null pointer dereference on alloc_skb failure
        hwmon: (vt1211) Use request_muxed_region for Super-IO accesses
        hwmon: (smsc47m1) Use request_muxed_region for Super-IO accesses
        hwmon: (smsc47b397) Use request_muxed_region for Super-IO accesses
        hwmon: (pc87427) Use request_muxed_region for Super-IO accesses
        hwmon: (f71805f) Use request_muxed_region for Super-IO accesses
        scsi: libsas: Do discovery on empty PHY to update PHY info
        mmc_spi: add a status check for spi_sync_locked
        mmc: sdhci-of-esdhc: add erratum eSDHC5 support
        mmc: sdhci-of-esdhc: add erratum eSDHC-A001 and A-008358 support
        PM / core: Propagate dev->power.wakeup_path when no callbacks
        extcon: arizona: Disable mic detect if running when driver is removed
        s390: cio: fix cio_irb declaration
        cpufreq: ppc_cbe: fix possible object reference leak
        cpufreq/pasemi: fix possible object reference leak
        cpufreq: pmac32: fix possible object reference leak
        x86/build: Keep local relocations with ld.lld
        iio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertion
        iio: hmc5843: fix potential NULL pointer dereferences
        iio: common: ssp_sensors: Initialize calculated_time in ssp_common_process_data
        rtlwifi: fix a potential NULL pointer dereference
        brcmfmac: fix missing checks for kmemdup
        b43: shut up clang -Wuninitialized variable warning
        brcmfmac: convert dev_init_lock mutex to completion
        brcmfmac: fix race during disconnect when USB completion is in progress
        scsi: ufs: Fix regulator load and icc-level configuration
        scsi: ufs: Avoid configuring regulator with undefined voltage range
        arm64: cpu_ops: fix a leaked reference by adding missing of_node_put
        x86/ia32: Fix ia32_restore_sigcontext() AC leak
        chardev: add additional check for minor range overlap
        HID: core: move Usage Page concatenation to Main item
        ASoC: eukrea-tlv320: fix a leaked reference by adding missing of_node_put
        ASoC: fsl_utils: fix a leaked reference by adding missing of_node_put
        cxgb3/l2t: Fix undefined behaviour
        spi: tegra114: reset controller on probe
        media: wl128x: prevent two potential buffer overflows
        virtio_console: initialize vtermno value for ports
        tty: ipwireless: fix missing checks for ioremap
        rcutorture: Fix cleanup path for invalid torture_type strings
        usb: core: Add PM runtime calls to usb_hcd_platform_shutdown
        scsi: qla4xxx: avoid freeing unallocated dma memory
        media: m88ds3103: serialize reset messages in m88ds3103_set_frontend
        media: go7007: avoid clang frame overflow warning with KASAN
        media: saa7146: avoid high stack usage with clang
        scsi: lpfc: Fix SLI3 commands being issued on SLI4 devices
        spi : spi-topcliff-pch: Fix to handle empty DMA buffers
        spi: rspi: Fix sequencer reset during initialization
        spi: Fix zero length xfer bug
        ASoC: davinci-mcasp: Fix clang warning without CONFIG_PM
        ipv6: Consider sk_bound_dev_if when binding a raw socket to an address
        llc: fix skb leak in llc_build_and_send_ui_pkt()
        net-gro: fix use-after-free read in napi_gro_frags()
        net: stmmac: fix reset gpio free missing
        usbnet: fix kernel crash after disconnect
        tipc: Avoid copying bytes beyond the supplied data
        bnxt_en: Fix aggregation buffer leak under OOM condition.
        net: mvpp2: fix bad MVPP2_TXQ_SCHED_TOKEN_CNTR_REG queue value
        crypto: vmx - ghash: do nosimd fallback manually
        xen/pciback: Don't disable PCI_COMMAND on PCI device reset.
        Revert "tipc: fix modprobe tipc failed after switch order of device registration"
        tipc: fix modprobe tipc failed after switch order of device registration -v2
        sparc64: Fix regression in non-hypervisor TLB flush xcall
        include/linux/bitops.h: sanitize rotate primitives
        xhci: Convert xhci_handshake() to use readl_poll_timeout_atomic()
        usb: xhci: avoid null pointer deref when bos field is NULL
        USB: Fix slab-out-of-bounds write in usb_get_bos_descriptor
        USB: sisusbvga: fix oops in error path of sisusb_probe
        USB: Add LPM quirk for Surface Dock GigE adapter
        USB: rio500: refuse more than one device at a time
        USB: rio500: fix memory leak in close after disconnect
        media: usb: siano: Fix general protection fault in smsusb
        media: usb: siano: Fix false-positive "uninitialized variable" warning
        media: smsusb: better handle optional alignment
        scsi: zfcp: fix missing zfcp_port reference put on -EBUSY from port_remove
        scsi: zfcp: fix to prevent port_remove with pure auto scan LUNs (only sdevs)
        Btrfs: fix race updating log root item during fsync
        ALSA: hda/realtek - Set default power save node to 0
        drm/nouveau/i2c: Disable i2c bus access after ->fini()
        tty: serial: msm_serial: Fix XON/XOFF
        tty: max310x: Fix external crystal register setup
        memcg: make it work on sparse non-0-node systems
        kernel/signal.c: trace_signal_deliver when signal_group_exit
        CIFS: cifs_read_allocate_pages: don't iterate through whole page array on ENOMEM
        binder: Replace "%p" with "%pK" for stable
        binder: replace "%p" with "%pK"
        net: create skb_gso_validate_mac_len()
        bnx2x: disable GSO where gso_size is too big for hardware
        brcmfmac: Add length checks on firmware events
        brcmfmac: screening firmware event packet
        brcmfmac: revise handling events in receive path
        brcmfmac: fix incorrect event channel deduction
        brcmfmac: add length checks in scheduled scan result handler
        brcmfmac: add subtype check for event handling in data path
        userfaultfd: don't pin the user memory in userfaultfd_file_create()
        Revert "x86/build: Move _etext to actual end of .text"
        net: cdc_ncm: GetNtbFormat endian fix
        usb: gadget: fix request length error for isoc transfer
        media: uvcvideo: Fix uvc_alloc_entity() allocation alignment
        ethtool: fix potential userspace buffer overflow
        neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
        net/mlx4_en: ethtool, Remove unsupported SFP EEPROM high pages query
        net: rds: fix memory leak in rds_ib_flush_mr_pool
        pktgen: do not sleep with the thread lock held.
        rcu: locking and unlocking need to always be at least barriers
        parisc: Use implicit space register selection for loading the coherence index of I/O pdirs
        fuse: fallocate: fix return with locked inode
        MIPS: pistachio: Build uImage.gz by default
        genwqe: Prevent an integer overflow in the ioctl
        drm/gma500/cdv: Check vbt config bits when detecting lvds panels
        fs: stream_open - opener for stream-like files so that read and write can run simultaneously without deadlock
        fuse: Add FOPEN_STREAM to use stream_open()
        ipv4: Define __ipv4_neigh_lookup_noref when CONFIG_INET is disabled
        ethtool: check the return value of get_regs_len
        Linux 4.4.181

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	drivers/android/binder.c
2019-06-11 08:37:51 -07:00
Lars-Peter Clausen
a86d061794 iio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertion
[ Upstream commit df1d80aee963480c5c2938c64ec0ac3e4a0df2e0 ]

For devices from the SigmaDelta family we need to keep CS low when doing a
conversion, since the device will use the MISO line as a interrupt to
indicate that the conversion is complete.

This is why the driver locks the SPI bus and when the SPI bus is locked
keeps as long as a conversion is going on. The current implementation gets
one small detail wrong though. CS is only de-asserted after the SPI bus is
unlocked. This means it is possible for a different SPI device on the same
bus to send a message which would be wrongfully be addressed to the
SigmaDelta device as well. Make sure that the last SPI transfer that is
done while holding the SPI bus lock de-asserts the CS signal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <Alexandru.Ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-06-11 12:24:02 +02:00
Nathan Chancellor
a0b63f6e73 Merge 4.4.139 into android-msm-wahoo-4.4
Changes in 4.4.139: (106 commits)
        xfrm6: avoid potential infinite loop in _decode_session6()
        netfilter: ebtables: handle string from userspace with care
        ipvs: fix buffer overflow with sync daemon and service
        atm: zatm: fix memcmp casting
        net: qmi_wwan: Add Netgear Aircard 779S
        net/sonic: Use dma_mapping_error()
        Revert "Btrfs: fix scrub to repair raid6 corruption"
        tcp: do not overshoot window_clamp in tcp_rcv_space_adjust()
        Btrfs: make raid6 rebuild retry more
        usb: musb: fix remote wakeup racing with suspend
        bonding: re-evaluate force_primary when the primary slave name changes
        tcp: verify the checksum of the first data segment in a new connection
        ext4: update mtime in ext4_punch_hole even if no blocks are released
        ext4: fix fencepost error in check for inode count overflow during resize
        driver core: Don't ignore class_dir_create_and_add() failure.
        btrfs: scrub: Don't use inode pages for device replace
        ALSA: hda - Handle kzalloc() failure in snd_hda_attach_pcm_stream()
        ALSA: hda: add dock and led support for HP EliteBook 830 G5
        ALSA: hda: add dock and led support for HP ProBook 640 G4
        cpufreq: Fix new policy initialization during limits updates via sysfs
        libata: zpodd: make arrays cdb static, reduces object code size
        libata: zpodd: small read overflow in eject_tray()
        libata: Drop SanDisk SD7UB3Q*G1001 NOLPM quirk
        w1: mxc_w1: Enable clock before calling clk_get_rate() on it
        fs/binfmt_misc.c: do not allow offset overflow
        x86/spectre_v1: Disable compiler optimizations over array_index_mask_nospec()
        m68k/mm: Adjust VM area to be unmapped by gap size for __iounmap()
        serial: sh-sci: Use spin_{try}lock_irqsave instead of open coding version
        signal/xtensa: Consistenly use SIGBUS in do_unaligned_user
        usb: do not reset if a low-speed or full-speed device timed out
        1wire: family module autoload fails because of upper/lower case mismatch.
        ASoC: dapm: delete dapm_kcontrol_data paths list before freeing it
        ASoC: cirrus: i2s: Fix LRCLK configuration
        ASoC: cirrus: i2s: Fix {TX|RX}LinCtrlData setup
        lib/vsprintf: Remove atomic-unsafe support for %pCr
        mips: ftrace: fix static function graph tracing
        branch-check: fix long->int truncation when profiling branches
        ipmi:bt: Set the timeout before doing a capabilities check
        Bluetooth: hci_qca: Avoid missing rampatch failure with userspace fw loader
        fuse: atomic_o_trunc should truncate pagecache
        fuse: don't keep dead fuse_conn at fuse_fill_super().
        fuse: fix control dir setup and teardown
        powerpc/mm/hash: Add missing isync prior to kernel stack SLB switch
        powerpc/ptrace: Fix setting 512B aligned breakpoints with PTRACE_SET_DEBUGREG
        powerpc/ptrace: Fix enforcement of DAWR constraints
        cpuidle: powernv: Fix promotion from snooze if next state disabled
        powerpc/fadump: Unregister fadump on kexec down path.
        ARM: 8764/1: kgdb: fix NUMREGBYTES so that gdb_regs[] is the correct size
        of: unittest: for strings, account for trailing \0 in property length field
        IB/qib: Fix DMA api warning with debug kernel
        RDMA/mlx4: Discard unknown SQP work requests
        mtd: cfi_cmdset_0002: Change write buffer to check correct value
        mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock()
        mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips
        mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary
        mtd: cfi_cmdset_0002: Avoid walking all chips when unlocking.
        MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum
        PCI: pciehp: Clear Presence Detect and Data Link Layer Status Changed on resume
        MIPS: io: Add barrier after register read in inX()
        time: Make sure jiffies_to_msecs() preserves non-zero time periods
        Btrfs: fix clone vs chattr NODATASUM race
        iio:buffer: make length types match kfifo types
        scsi: qla2xxx: Fix setting lower transfer speed if GPSC fails
        scsi: zfcp: fix missing SCSI trace for result of eh_host_reset_handler
        scsi: zfcp: fix missing SCSI trace for retry of abort / scsi_eh TMF
        scsi: zfcp: fix misleading REC trigger trace where erp_action setup failed
        scsi: zfcp: fix missing REC trigger trace on terminate_rport_io early return
        scsi: zfcp: fix missing REC trigger trace on terminate_rport_io for ERP_FAILED
        scsi: zfcp: fix missing REC trigger trace for all objects in ERP_FAILED
        scsi: zfcp: fix missing REC trigger trace on enqueue without ERP thread
        linvdimm, pmem: Preserve read-only setting for pmem devices
        md: fix two problems with setting the "re-add" device state.
        ubi: fastmap: Cancel work upon detach
        UBIFS: Fix potential integer overflow in allocation
        xfrm: Ignore socket policies when rebuilding hash tables
        xfrm: skip policies marked as dead while rehashing
        backlight: as3711_bl: Fix Device Tree node lookup
        backlight: max8925_bl: Fix Device Tree node lookup
        backlight: tps65217_bl: Fix Device Tree node lookup
        mfd: intel-lpss: Program REMAP register in PIO mode
        perf tools: Fix symbol and object code resolution for vdso32 and vdsox32
        perf intel-pt: Fix sync_switch INTEL_PT_SS_NOT_TRACING
        perf intel-pt: Fix decoding to accept CBR between FUP and corresponding TIP
        perf intel-pt: Fix MTC timing after overflow
        perf intel-pt: Fix "Unexpected indirect branch" error
        perf intel-pt: Fix packet decoding of CYC packets
        media: v4l2-compat-ioctl32: prevent go past max size
        media: cx231xx: Add support for AverMedia DVD EZMaker 7
        media: dvb_frontend: fix locking issues at dvb_frontend_get_event()
        nfsd: restrict rd_maxcount to svc_max_payload in nfsd_encode_readdir
        NFSv4: Fix possible 1-byte stack overflow in nfs_idmap_read_and_verify_message
        video: uvesafb: Fix integer overflow in allocation
        Input: elan_i2c - add ELAN0618 (Lenovo v330 15IKB) ACPI ID
        xen: Remove unnecessary BUG_ON from __unbind_from_irq()
        udf: Detect incorrect directory size
        Input: elan_i2c_smbus - fix more potential stack buffer overflows
        Input: elantech - enable middle button of touchpads on ThinkPad P52
        Input: elantech - fix V4 report decoding for module with middle key
        ALSA: hda/realtek - Add a quirk for FSC ESPRIMO U9210
        Btrfs: fix unexpected cow in run_delalloc_nocow
        spi: Fix scatterlist elements size in spi_map_buf
        block: Fix transfer when chunk sectors exceeds max
        dm thin: handle running out of data space vs concurrent discard
        cdc_ncm: avoid padding beyond end of skb
        Bluetooth: Fix connection if directed advertising and privacy is used
        Linux 4.4.139

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-07-03 04:36:58 -07:00
Martin Kelly
5c39f9f374 iio:buffer: make length types match kfifo types
commit c043ec1ca5baae63726aae32abbe003192bc6eec upstream.

Currently, we use int for buffer length and bytes_per_datum. However,
kfifo uses unsigned int for length and size_t for element size. We need
to make sure these matches or we will have bugs related to overflow (in
the range between INT_MAX and UINT_MAX for length, for example).

In addition, set_bytes_per_datum uses size_t while bytes_per_datum is an
int, which would cause bugs for large values of bytes_per_datum.

Change buffer length to use unsigned int and bytes_per_datum to use
size_t.

Signed-off-by: Martin Kelly <mkelly@xevo.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
[bwh: Backported to 4.4:
 - Drop change to iio_dma_buffer_set_length()
 - Adjust filename, context]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-03 11:21:30 +02:00
Nathan Chancellor
e4a2ad5046 Merge 4.4.105 into android-msm-wahoo-4.4-oreo-mr1
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Conflicts:
	drivers/gpu/drm/msm/msm_gem_submit.c
	drivers/media/v4l2-core/v4l2-compat-ioctl32.c
	drivers/mmc/core/bus.c
	drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
	drivers/scsi/ufs/ufshcd.h
	kernel/power/process.c
	net/wireless/nl80211.c
	sound/usb/card.c
2017-12-09 13:44:10 -07:00
Dragos Bogdan
4b9c62a00a iio: ad_sigma_delta: Implement a dedicated reset function
commit 7fc10de8d49a748c476532c9d8e8fe19e548dd67 upstream.

Since most of the SD ADCs have the option of reseting the serial
interface by sending a number of SCLKs with CS = 0 and DIN = 1,
a dedicated function that can do this is usefull.

Needed for the patch:  iio: ad7793: Fix the serial interface reset
Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-12 11:27:34 +02:00
Nicholas Troast
557ea9fd77 iio: support writing processed values to IIO channels
Add a new function to the IIO API which allows consumers to write
processed values to IIO channels.

This is particularly useful for supporting hardware which has
configurable ADC thresholds. A consumer would be able to change an ADC
threshold by providing a processed value instead of calculating a raw
value.

Change-Id: I7d3b22beddb6fd1fda0cc0aefbcb4cf5cb58bf82
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
2017-02-03 08:36:59 -08:00
Vladimir Barinov
735ad074ff iio: Support triggered events
Support triggered events.

This is useful for chips that don't have their own interrupt sources.
It allows to use generic/standalone iio triggers for those drivers.

Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-27 20:47:09 +01:00
Linus Walleij
a0175b9c76 iio: st_sensors: add debugfs register read hook
This adds a debugfs hook to read/write registers in the ST
sensors using debugfs. Proved to be awesome help when trying
to debug why IRQs do not arrive.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-16 10:51:25 +01:00
Lars-Peter Clausen
c689a923c8 iio: Add inverse unit conversion macros
Add inverse unit conversion macro to convert from standard IIO units to
units that might be used by some devices.

Those are useful in combination with scale factors that are specified as
IIO_VAL_FRACTIONAL. Typically the denominator for those specifications will
contain the maximum raw value the sensor will generate and the numerator
the value it maps to in a specific unit. Sometimes datasheets specify those
in different units than the standard IIO units (e.g. degree/s instead of
rad/s) and so we need to do a unit conversion.

From a mathematical point of view it does not make a difference whether we
apply the unit conversion to the numerator or the inverse unit conversion
to the denominator since (x / y) / z = x / (y * z). But as the denominator
is typically a larger value and we are rounding both the numerator and
denominator to integer values using the later method gives us a better
precision (E.g. the relative error is smaller if we round 8000.3 to 8000
rather than rounding 8.3 to 8).

This is where in inverse unit conversion macros will be used.

Marked for stable as used by some upcoming fixes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-08 12:50:40 +01:00
Pengyu Ma
ad30bad3a5 iio: declare struct to fix warning
When compile iio related driver the following warning shown:

include/linux/iio/trigger.h:35:34: warning: 'struct iio_trigger'
declared inside parameter list
  int (*set_trigger_state)(struct iio_trigger *trig, bool state);

include/linux/iio/trigger.h:38:18: warning: 'struct iio_dev'
declared inside parameter list
           struct iio_dev *indio_dev);

'struct iio_dev' and 'struct iio_trigger' was used before declaration,
forward declaration for these structs to fix warning.

Signed-off-by: Pengyu Ma <pengyu.ma@windriver.com>
Acked-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-08 12:28:46 +01:00
Cristina Opriceana
2854c098e2 include: linux: iio: Add missing kernel doc field
Fix kernel doc for the iio_dev_attr structure by adding its missing field.

Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-02 18:36:05 +01:00
Cristina Opriceana
e52e95199d include: linux: iio: Fix function parameter name in kernel doc
Fix buffer name from kernel doc according to the function parameter.

Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-02 18:34:18 +01:00
Giuseppe Barba
bc27381edb iio: st-sensors: add configuration for WhoAmI address
This patch permits to configure the WhoAmI register address
because some device could have not a standard address for
this register.

Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
Reviewed-by: Denis Ciocca <denis.ciocca@st.com>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-23 20:43:04 +01:00
Cristina Opriceana
fcc577dd55 iio: Fix parameters in iio_triggered_buffer_setup
This patch renames the top half handler and the bottom half handler
of iio_triggered_buffer_setup() in accordance with their usage.
The bottom half has been renamed to reflect the fact that it is a
thread based call, compliant with iio_alloc_pollfunc().
The names of the parameters were swapped, thus creating confusion.

Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-05 15:19:50 +01:00
Lars-Peter Clausen
225d59adf1 iio: Specify supported modes for buffers
For each buffer type specify the supported device modes for this buffer.
This allows us for devices which support multiple different operating modes
to pick the correct operating mode based on the modes supported by the
attached buffers.

It also prevents that buffers with conflicting modes are attached
to a device at the same time or that a buffer with a non-supported mode is
attached to a device (e.g. in-kernel callback buffer to a device only
supporting hardware mode).

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01 11:31:12 +01:00
Martin Fuzzey
3f7f642b9b iio: core: add high pass filter attributes
Add a high pass filter attribute for measurements
(like the existing low pass)

Also add both high and low pass attributes for events.

Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-17 10:32:35 +01:00
Irina Tirdea
faaa44955d iio: core: Introduce IIO_CHAN_INFO_OVERSAMPLING_RATIO
Some magnetometers can perform a number of repetitions in HW
for each measurement to increase accuracy. One example is
Bosch BMC150:
http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf.

Introduce an interface to set the oversampling ratio
for these devices.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-10 20:31:44 +01:00
Vianney le Clément de Saint-Marcq
c8a8585431 iio: core: Introduce IIO_CHAN_INFO_CALIBEMISSIVITY
Contact-less IR temperature sensors measure the temperature of an object
by using its thermal radiation.  Surfaces with different emissivity
ratios emit different amounts of energy at the same temperature.

IIO_CHAN_INFO_CALIBEMISSIVITY allows the user to inform the sensor of the
emissivity of the object in front of it, in order to effectively measure
its temperature.

A device providing such setting is Melexis's MLX90614:
http://melexis.com/Assets/IR-sensor-thermometer-MLX90614-Datasheet-5152.aspx.

Signed-off-by: Vianney le Clément de Saint-Marcq <vianney.leclement@essensium.com>
Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-09 15:03:05 +01:00
Octavian Purdila
f4f4673b75 iio: add support for hardware fifo
Some devices have hardware buffers that can store a number of samples
for later consumption. Hardware usually provides interrupts to notify
the processor when the FIFO is full or when it has reached a certain
watermark level. This helps with reducing the number of interrupts to
the host processor and thus it helps decreasing the power consumption.

This patch enables usage of hardware FIFOs for IIO devices in
conjunction with software device buffers. When the hardware FIFO is
enabled the samples are stored in the hardware FIFO. The samples are
later flushed to the device software buffer when the number of entries
in the hardware FIFO reaches the hardware watermark or when a flush
operation is triggered by the user when doing a non-blocking read
on an empty software device buffer.

In order to implement hardware FIFO support the device drivers must
implement the following new operations: setting and getting the
hardware FIFO watermark level, flushing the hardware FIFO to the
software device buffer. The device must also expose information about
the hardware FIFO such it's minimum and maximum watermark and if
necessary a list of supported watermark values. Finally, the device
driver must activate the hardware FIFO when the device buffer is
enabled, if the current device settings allows it.

The software device buffer watermark is passed by the IIO core to the
device driver as a hint for the hardware FIFO watermark. The device
driver can adjust this value to allow for hardware limitations (such
as capping it to the maximum hardware watermark or adjust it to a
value that is supported by the hardware). It can also disable the
hardware watermark (and implicitly the hardware FIFO) it this value is
below the minimum hardware watermark.

Since a driver may support hardware FIFO only when not in triggered
buffer mode (due to different semantics of hardware FIFO sampling and
triggered sampling) this patch changes the IIO core code to allow
falling back to non-triggered buffered mode if no trigger is enabled.

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-03-29 16:17:10 +01:00
Josselin Costanzi
37d3455672 iio: add watermark logic to iio read and poll
Currently the IIO buffer blocking read only wait until at least one
data element is available.
This patch makes the reader sleep until enough data is collected before
returning to userspace. This should limit the read() calls count when
trying to get data in batches.

Co-author: Yannick Bedhomme <yannick.bedhomme@mobile-devices.fr>
Signed-off-by: Josselin Costanzi <josselin.costanzi@mobile-devices.fr>
[rebased and remove buffer timeout]
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-03-29 16:17:09 +01:00
Antonio Fiol
a878a1a61a iio: max517: Add support for MAX520 and MAX521 chips.
MAX520 and MAX521 are protocol-compatible with the already supported
chips, just have more channels.

Signed-off-by: Antonio Fiol <antonio@fiol.es>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-03-28 10:57:34 +00:00
Daniel Baluta
293487c8ec iio: Export userspace IIO headers
After UAPI header file split [1] all user-kernel interfaces were
placed under include/uapi/.

This patch moves IIO user specific API from:
	* include/linux/iio/events.h => include/uapi/linux/iio/events.h
	* include/linux/types.h => include/uapi/linux/types.h

Now there is no need for nasty tricks to compile userspace programs
(e.g iio_event_monitor). Just installing the kernel headers with
make headers_install command does the job.

[1] http://lwn.net/Articles/507794/

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-02-14 17:05:03 +00:00
Irina Tirdea
2f0ecb7c65 iio: core: Introduce IIO_CHAN_INFO_DEBOUNCE_COUNT and _TIME
The pedometer needs to filter out false steps that might be generated by
tapping the foot, sitting, etc. To do that it computes the number of
steps that occur in a given time and decides the user is moving only
if this value is over a threshold. E.g.: the user starts moving only
if he takes 4 steps in 3 seconds. This filter is applied only when
the user starts moving.

A device that has such pedometer functionality is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf.

To export this feature, this patch introduces IIO_CHAN_INFO_DEBOUNCE_COUNT
and IIO_CHAN_INFO_DEBOUNCE_TIME. For the pedometer, in_steps_debounce_count
will specify the number of steps that need to occur in
in_steps_debounce_time seconds so that the pedometer decides the user is
moving.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-29 18:49:57 +00:00
Karol Wrona
50dd64d57e iio: common: ssp_sensors: Add sensorhub driver
Sensorhub  is MCU dedicated to collect data and manage several sensors.
Sensorhub is a spi device which provides a layer for IIO devices. It provides
some data parsing and common mechanism for sensorhub sensors.

Adds common sensorhub library for sensorhub driver and iio drivers
which uses sensorhub MCU to communicate with sensors.

Signed-off-by: Karol Wrona <k.wrona@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-29 18:49:05 +00:00
Irina Tirdea
17a2cbc279 iio: core: Remove IIO_EV_TYPE_INSTANCE
By introducing IIO_EV_TYPE_CHANGE, IIO_EV_TYPE_INSTANCE becomes redundant.
The effect of IIO_EV_TYPE_INSTANCE can be obtained by using IIO_EV_TYPE_CHANGE
with IIO_EV_INFO_VALUE set to 1.

Remove all instances of IIO_EV_TYPE_INSTANCE and replace them with
IIO_EV_TYPE_CHANGE where needed.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-27 18:49:55 +00:00
Irina Tirdea
27be84236d iio: core: Introduce CHANGE event type
A step detector will generate an interrupt each time N step are detected.
A device that has such pedometer functionality is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf.

Introduce IIO_EV_TYPE_CHANGE event type for events that are generated
when the channel passes a threshold on the absolute change in value.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-27 18:49:55 +00:00
Irina Tirdea
d37f6836fa iio: core: Introduce IIO_CHAN_INFO_CALIBWEIGHT
Some devices need the weight of the user to compute other
parameters. One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that needs the weight of the user to compute the number of calories burnt.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-27 18:49:54 +00:00
Irina Tirdea
5a1a932981 iio: core: Introduce IIO_VELOCITY and IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z
Some devices export the current speed value of the user.

One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that computes the speed of the user based on the number of steps and
stride length.

Introduce a new channel type VELOCITY and a modifier for the magniture or
norm of the velocity vector, IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-27 18:49:54 +00:00
Irina Tirdea
cc3c9eecae iio: core: Introduce DISTANCE channel type
Some devices export an estimation of the distance the user has covered
since the last reset.

One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that computes the distance based on the stride length and step rate.

Introduce a new channel type DISTANCE to export these values.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-27 18:49:53 +00:00
Irina Tirdea
72c6664467 iio: core: Introduce ENERGY channel type
Human activity sensors report the energy burnt by the user.
One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that computes the number of calories based on weight and step rate.

Introduce a new channel type ENERGY to export these values.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-27 18:49:52 +00:00
Karol Wrona
03af03ad7c iio: Add new operating mode for non triggered sw buffers
There was a need for non triggered software buffer type.  It can be used when
triggered model does not fit and INDIO_BUFFER_HARDWARE causes confusion because
the data stream can be obtained not directly form hardware backend.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Karol Wrona <k.wrona@samsung.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-25 22:53:38 +00:00
Greg Kroah-Hartman
6e49557b31 Merge tag 'iio-for-3.20a_take2' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-testing
Jonathan writes:

First round of IIO new drivers, cleanups and functionality for the 3.20 cycle take 2

Updated pull request with Daniel's fix on top for the power management
Kconfig changes that had snuck in since last update of the IIO tree
worked it's way through from mainline.

Original pull message

New device support
* jsa1212 proxmity / ambient light sensor
* SM08500 supported added to the kxcjk-1013 accelerometer driver
* KMX61 Accelerometer/Magnetometer.  This took a somewhat rocky path
  being first merged, then reverted for a rewrite after a discussion of
  how to support additional functionality and finally being merged prior
  to some last reviews coming in, with resultant follow up patches.
* Freescale mma9551l driver (minor follow up warning supression patch).
* Semtech SX9500 proximity device driver.
* ak8975 gains support for ak09911 and ak09912 and drop the standalone driver
  for the ak09911.

New functionality
 * Dummy driver gains some virtual registers making it more flexible.
 * IIO_ACTIVITY channel types, with modifiers running, walking etc.  This is
   to support on chip motion clasifiers.  As such it is in the form of a
   confidence percentage.  The only devices so far only do binary decisions
   but this gives us room when other devices give more nuanced clasification.
 * IIO_EV_DIR_NONE type for events where there is no obvious direction.
   First case is step detection.
 * IIO_STEPS channel type for pedometers.
 * ENABLE mask element used to control turning on counting types such as
   the pedometer that need a 'start point'.
 * INSTANCE event type to support things that happen once.
 * info element for height calibration (used in various motion estimation
   algorithms). Note heigh tof use
 * dummy driver demonstration of the use of all the new bits above.
 * event monitor support for the new events.
 * inv_mpu6050 gains an i2c mux to allow bypassing the device to access
   additional devices connected on the other side of it.  Note that in
   Windows these are handled by firmware on the device and not exposed
   directly.
 * inv_mpu6050 gains ACPI enumeration.
 * inkern interface gains iio_write_channel_raw to allow in kernel users
   of DAC functionality via a simple wrapper.
 * Document input current readings in the ABI docs.
 * Add an error message when we get an out of range error in device tree
   processing for the in kernel interfaces.  Basically a device tree debugging
   aid.
 * Add a sanity check that a scan index for a channel is unique during
   registration.  There to help catch bugs as this should never happen
   in a bug free driver.

Cleanups and fixlets

 A rework of buffer registration from Lars - a precursor to some other
 upcoming new stuff (a few patches from others rolled in here as well).
 * Ensure all drivers register the same channels for the device and buffer.
 * Move buffer registration into the core rather than using the old
   two step approach.  Now we have simple ways of using a unified set channels
   for both without requiring channels be exposed by both interface, this
   removes a fair bit of boilerplate.
 * Stop sca3000 and ad5933 (both in staging) enabling buffer channels by
   default. It has long be convention in IIO to startup with no channels
   enabled and leave it up to userspace to say what goes in the buffer.
   Getting rid of these allows us to drop export of iio_scan_mask_set.
 * Drop get_bytes_per_datum from iio_buffer_access_funcs as not been used
   for a while.
 * Allocate standard buffer attributes in the core rather than in every
   driver with a buffer.
 * Make the length attribute read only when a driver is not able to set
   the length.
 * Drop the get_length callback for buffers as it is already available in
   struct iio_buffer.
 * Drop an unused arguement form iio_kfifo_allocate and add devm allocator
   for it.
 * some kconfig entries gain anotation with the resulting module name.
 * Fix a resulting compile issue in dummy driver due to a stub taking
   wrong parameters as a result of the above rework.
 * Fix an off by 2 error in copying the core assigned buffer attributes.

Other cleanups,
 * Trivial space before comma fixups.
 * ak8975 fixlets - none critical.  Rework to allow more device support.
 * Drop unnecessary sizeof(u8) calls.
 * bmp280 - refactor the compensation code to reduce copy operations and
   code length.  A second patch futher optimized this and performed some
   other minor cleanups.
 * kxcjk-1013 - various power control cleanups to avoid unnecessary enable
   / disable of device.  Make sure it is only controlled at all if CONFIG_PM
   is enabled.  Also som cleanups of error paths.
 * Small cleanups in adf4530 driver - pointless message and unnecessary braces.
 * Clarifiy the proximity ABI docs to make it clear it should get bigger
   as we move futher away.
 * Drop a misleading comment form industrialio-core.c
 * Trivial white space cleanups.
 * sca3000 looses an unused debug function.
 * Fix char unsigned ordering in ad8366
 * Increase the sleep time in ad9523 to make it predictable (value didn't
   really matter so make it more than 20 msecs)
 * mxs-lradc touchscreen property cleanups in device tree are fixed to ensure
   the meet all the 'interesting' documentation.
 * A couple of cleanups for the staging ad5933 driver to avoid unnecessary
   conversion to a processed temperature vlaue in kernel and remove
   platform data form the state structure as not needed after probe.
 * Fix a wrong scale factor in the docs.

Misc
 * Add IIO include files to the maintainers entry.
2015-01-21 10:13:37 +08:00
Karol Wrona
780103fef5 iio: kfifo: Add resource management devm_iio_kfifo_allocate/free
iio kfifo allocate/free gained their devm_ wrappers.

Signed-off-by: Karol Wrona <k.wrona@samsung.com>
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-26 11:39:57 +00:00
Karol Wrona
7ab374a053 iio: kfifo: Remove unused argument in iio_kfifo_allocate
indio_dev was unused in function body plus some small style fix - add new
lines after "if(sth) return sth" and before the last return statement.

The argument was removed also in its client.

Signed-off-by: Karol Wrona <k.wrona@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-26 11:20:38 +00:00
Ivan T. Ivanov
09546a3063 iio: consumer.h: Fix scale factor in function comment
1 milivolt is equal to 1000000 nanovolts.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12 12:28:36 +00:00
Lars-Peter Clausen
374956600e iio: buffer: Drop get_length callback
We already do have the length field in the struct iio_buffer which is
expected to be in sync with the current size of the buffer. And currently
all implementations of the get_length callback either return this field or a
constant number.

This patch removes the get_length callback and replaces all occurrences in
the IIO core with directly accessing the length field of the buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12 12:28:34 +00:00
Lars-Peter Clausen
08e7e0adaa iio: buffer: Allocate standard attributes in the core
All buffers want at least the length and the enable attribute. Move the
creation of those attributes to the core instead of having to do this in
each individual buffer implementation. This allows us to get rid of some
boiler-plate code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12 12:28:33 +00:00
Lars-Peter Clausen
616dde2a1e iio: Remove get_bytes_per_datum() from iio_buffer_access_funcs
There haven't been any users of the get_bytes_per_datum() callback for a
while. The core assumes that the number of bytes per datum can be calculated
based on the enabled channels and the storage size of the channel and
iio_compute_scan_bytes() is used to compute this number. So remove the
callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12 12:28:32 +00:00
Lars-Peter Clausen
3e1b6c95b9 iio: Move buffer registration to the core
Originally device and buffer registration were kept as separate operations
in IIO to allow to register two distinct sets of channels for buffered and
non-buffered operations. This has since already been further restricted and
the channel set registered for the buffer needs to be a subset of the
channel set registered for the device. Additionally the possibility to not
have a raw (or processed) attribute for a channel which was registered for
the device was added a while ago. This means it is possible to not register
any device level attributes for a channel even if it is registered for the
device. Also if a channel's scan_index is set to -1 and the channel is
registered for the buffer it is ignored.

So in summary it means it is possible to register the same channel array for
both the device and the buffer yet still end up with distinctive sets of
channels for both of them. This makes the argument for having to have to
manually register the channels for both the device and the buffer invalid.
Considering that the vast majority of all drivers want to register the same
set of channels for both the buffer and the device it makes sense to move
the buffer registration into the core to avoid some boiler-plate code in the
device driver setup path.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12 12:28:31 +00:00
Lars-Peter Clausen
217a5cf0a1 iio: Unexport iio_scan_mask_set()
Individual drivers should not be messing with the scan mask that contains
the list of enabled channels. This is something that is supposed to be
managed by the core.

Now that the last few drivers that used it to configure a default scan mask
have been updated to not do this anymore we can unexport the function.

Note, this patch also requires moving a few functions around so they are all
declared before the first internal user.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12 12:28:29 +00:00
Dmitry Eremin-Solenikov
f9380e7123 iio: inkern: add iio_write_channel_raw
Introduce API for easy in-kernel setting of DAC values.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12 12:28:27 +00:00
Greg Kroah-Hartman
deef2a118a Merge 3.18-rc7 into staging-work.
We want those staging fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-12-02 16:20:59 -08:00
Irina Tirdea
bcdf28fb1b iio: core: Introduce IIO_CHAN_INFO_CALIBHEIGHT
Some devices need the height of the user to compute various
parameters. One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that needs the height of the user to compute the stride length which
is used further to determine distance, speed and activity type.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-22 11:05:56 +00:00
Irina Tirdea
a88bfe7858 iio: core: Introduce STEPS channel, ENABLE mask and INSTANCE event
These changes are needed to support the functionality of a pedometer.
A pedometer has two basic functionalities: step counter and step detector.

The step counter needs to be enabled and then it will count the steps
in its hardware register. Whenever the application needs to check
the step count, it will read the step counter register. To support the
step counter a new channel type STEPS is added. Since the pedometer needs
to be enabled first so that the hardware can count and store the steps,
we need a specific ENABLE channel info mask.

The step detector will generate an interrupt each time a step is detected.
To support this functionality we add a new event type INSTANCE.

For more information on the Android requirements for step counter and step
detector see:
http://source.android.com/devices/sensors/composite_sensors.html#counter
and http://source.android.com/devices/sensors/composite_sensors.html#detector.

A device that has the pedometer functionality this interface needs to
support is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-22 11:05:51 +00:00
Irina Tirdea
1843c2f3de iio: core: Introduce IIO_EV_DIR_NONE
For some events (e.g.: step detector) a direction does not make sense.

Add IIO_EV_DIR_NONE to be used with such events and generate sysfs event
attributes that do not contain direction.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-22 11:05:49 +00:00
Daniel Baluta
55aebeb926 iio: core: Introduce IIO_ACTIVITY channel
This channel will be used for exposing information about
activity composite sensors. Activities supported so far:
	* running
	* jogging
	* walking
	* still

THRESHOLD event is used to signal a change in the activity
state.

We associate a confidence interval for each activity expressed
as a percentage from 0 to 100.
  * 0, means the sensor IS NOT reporting that activity.
  * 100, means the sensor IS reporting that activity.

Users of this interface have two possible means to gather
information about the ongoing activities.

1. Event based, via event file descriptor
  * sensor may report an event when ENTERING an activity or LEAVING
    an activity based on a threshold value.
  * drivers will wake up applications waiting data on the event fd

2. Polling, by reading the sysfs associated attribute files:
  * /sys/bus/iio/devices/iio:device0/in_activity_running_input
expressed as percentage confidence value from 0 to 100.

This will offer an interface for Android significant motion
composite sensor defined here:
http://source.android.com/devices/sensors/composite_sensors.html

Activities listed above are supported by Freescale's MMA9553 sensor:
http://freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-22 11:05:47 +00:00
Cristina Ciocan
ccf54555da iio: Fix IIO_EVENT_CODE_EXTRACT_DIR bit mask
The direction field is set on 7 bits, thus we need to AND it with 0111 111 mask
in order to retrieve it, that is 0x7F, not 0xCF as it is now.

Fixes: ade7ef7ba (staging:iio: Differential channel handling)
Signed-off-by: Cristina Ciocan <cristina.ciocan@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-15 16:04:56 +00:00
Greg Kroah-Hartman
be61a0d784 Merge tag 'iio-for-3.19a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:

First round of new drivers, features and cleanups for IIO in the 3.19 cycle.

New drivers / supported parts
* rockchip - rk3066-tsadc variant
* si7020 humidity and temperature sensor
* mcp320x - add mcp3001, mcp3002, mcp3004, mcp3008, mcp3201, mcp3202
* bmp280 pressure and temperature sensor
* Qualcomm SPMI PMIC current ADC driver
* Exynos_adc - support exynos7

New features
* vf610-adc - add temperature sensor support
* Documentation of current attributes, scaled pressure, offset and
  scaled humidity, RGBC intensity gain factor and scale applied to
  differential voltage channels.
* Bring iio_event_monitor up to date with newer modifiers.
* Add of_xlate function to allow for complex channel mappings from the
  device tree.
* Add -g parameter to generic_buffer example to allow for devices with
  directly fed (no trigger) buffers.
* Move exynos driver over to syscon for PMU register access.

Cleanups, fixes for new drivers
* lis3l02dq drop an unneeded else.
* st sensors - renam st_sensors to st_sensor_settings (for clarity)
* st sensors - drop an unused parameter from all the probe utility
  functions.
* vf610 better error handling and tidy up.
* si7020 - cleanups following merge
* as3935 - drop some unnecessary semicolons.
* bmp280 - fix the pressure calculation.
2014-11-05 11:42:48 -08:00
Ivan T. Ivanov
acd8256723 iio: inkern: Add of_xlate function to struct iio_info
When #iio-cells is greater than '0', the driver could provide
a custom of_xlate function that reads the *args* and returns
the appropriate index in registered IIO channels array.

Add simple translation function, suitable for the most 1:1
mapped channels in IIO chips, and use it when driver did not
provide custom implementation.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-10-25 11:03:40 +01:00