From patchwork Tue Jul 28 15:12:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4477B913 for ; Tue, 28 Jul 2020 15:13:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BE06204EA for ; Tue, 28 Jul 2020 15:13:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Nxhgyc2o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730707AbgG1PNO (ORCPT ); Tue, 28 Jul 2020 11:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730705AbgG1PNN (ORCPT ); Tue, 28 Jul 2020 11:13:13 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC0DC0619D2 for ; Tue, 28 Jul 2020 08:13:13 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id y18so8041111ilp.10 for ; Tue, 28 Jul 2020 08:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jHxD6udjM+BmNfhqgaIfVpk0lOiGcwdA5o4lB9ADOmg=; b=Nxhgyc2o90wGCC4mr9sfow37Cv8CwXysAIFqU5XftS8rVLH/R0j6zi4OUP+0feVtHc 2aQrmr4IZpXxZXEk5WU8glZ3RpNmTVQgrtkZ7t2nHytXPgPRxQ5Jn7oNJRmf4U5+GCw0 rbQ+jK6iC+QaaegD5ga8biXsQl1XuUdSjDycA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jHxD6udjM+BmNfhqgaIfVpk0lOiGcwdA5o4lB9ADOmg=; b=PtIgBwtmsKGjMl0GfCichhDDi8JsYuMQpADKM4WwsUDfImN0qsGpxuBAkVRF9NNin4 rZoD9k2VIM0TG7hSiZdSz4TywvWbktedOEP6zpTR5Fdh1vuhcmh6xNmxzyxDy8Hc8g4c cIDKTmqYyjxxEgkAPpPLCq1oUts21DvNAblofDj2GEoVdztQsy3bS0q6PyH5+CpwtuFJ IbMQYVDtyXvKGC4Uo87c4srRjnk6e/9KL5vffhog8AmIBLiKdcG5CCWYUoyCIaOIIz2D qKt8iVFdArAVCIOVV25UZHH9tTtn1ZX/5MKVDrV4qXeJZZkKpH8QTDnc6TXLTK7G5CB0 bxxQ== X-Gm-Message-State: AOAM532yWuRcQmD+QsOfaWBrRVjAXLsGPSLZJSfyuKIP8fZHW6L2IvoC roaUaKWze0Q8jXZEg8o+m5LA2Q== X-Google-Smtp-Source: ABdhPJyY0Au2KBM6mUQMhG/TED004pcY9xvoRI9jRFk1FoUdWituv1aslVKg5ArjQJN0Jf9d+hx9og== X-Received: by 2002:a92:de42:: with SMTP id e2mr28066004ilr.189.1595949193089; Tue, 28 Jul 2020 08:13:13 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:12 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Douglas Anderson , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 01/15] dt-bindings: iio: Add bindings for sx9310 sensor Date: Tue, 28 Jul 2020 09:12:44 -0600 Message-Id: <20200728091057.1.I3bf8ece8c303bd9ecfc1573464cdacc47d73784b@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Adds device tree bandings for sx9310 sensor. Signed-off-by: Daniel Campello Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Rob Herring Reviewed-by: Douglas Anderson [swboyd@chromium.org: Add both regulators and make them optional] Signed-off-by: Stephen Boyd --- .../iio/proximity/semtech,sx9310.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml new file mode 100644 index 00000000000000..ba734ee868c77f --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/proximity/semtech,sx9310.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Semtech's SX9310 capacitive proximity sensor + +maintainers: + - Daniel Campello + +description: | + Semtech's SX9310/SX9311 capacitive proximity/button solution. + + Specifications about the devices can be found at: + https://www.semtech.com/products/smart-sensing/sar-sensors/sx9310 + +properties: + compatible: + enum: + - semtech,sx9310 + - semtech,sx9311 + + reg: + maxItems: 1 + + interrupts: + description: + The sole interrupt generated by the device used to announce the + preceding reading request has finished and that data is + available or that a close/far proximity event has happened. + maxItems: 1 + + vdd-supply: + description: Main power supply + + svdd-supply: + description: Host interface power supply + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + proximity@28 { + compatible = "semtech,sx9310"; + reg = <0x28>; + interrupt-parent = <&pio>; + interrupts = <5 IRQ_TYPE_LEVEL_LOW 5>; + vdd-supply = <&pp3300_a>; + svdd-supply = <&pp1800_prox>; + }; + }; From patchwork Tue Jul 28 15:12:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76E84913 for ; Tue, 28 Jul 2020 15:14:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EF36204EA for ; Tue, 28 Jul 2020 15:14:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PSOkcR2p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730890AbgG1POa (ORCPT ); Tue, 28 Jul 2020 11:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730706AbgG1PNO (ORCPT ); Tue, 28 Jul 2020 11:13:14 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8A9FC061794 for ; Tue, 28 Jul 2020 08:13:14 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id j8so8744065ioe.9 for ; Tue, 28 Jul 2020 08:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d6BHT2FTcQy59tF7DgmAkO1M5ULGb7av5syAm7cNjQU=; b=PSOkcR2p5oqgBcOfvdul6pbFR88U8JR/gnsEOyKsMKkiVO7n1jt1UAtSr81f8nfYTr psQrFYsEGxBmC4xa18AvOfEJ1U9cE4S+m8uoVVoksPK/AAI/qoI0lLgIp5yIv2LcI9EC SBdovSJ7hLZljcukntUrKL6uUTNXHVq77kOpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d6BHT2FTcQy59tF7DgmAkO1M5ULGb7av5syAm7cNjQU=; b=k4NZeVd8Smzp6CxATl/K5zp0eWLv929EbV84TvazqGKZL3Z4ltxeTut/Hai9vip12g WcVVq/NIqi0Ef3t0vhwl2DDZBimTEN0++tPcGUEYpi3Hl/pv4t/6CV8zhkEXZZJNd6Rj 9j+zo04Cfmyh4/35la/kSSIWPw2g2D952hQh/Cd5co8JfdZJhhlitzLDzPDs2OoSuST5 wbpCOGoXDD/tkSnUTnWv63zGHwDD7ueoYlQrEK9jQpii9h4hXExL22vbtFUINca3bk2C QWkaUbkq6M/XABXPene4ofyv4Pcm6Ycopl3L0WrUzMMSbk2kjJEaoA1ZbSqAVaPM375W mvpA== X-Gm-Message-State: AOAM5300/j7Ad8kb4cZuSgp2FRYjTN1IIIHJ1wCy4J8YQU5wTSf8O7WW u1OhwZvfEQKd31tiXXiImvmnZw== X-Google-Smtp-Source: ABdhPJwPyPbILqy+8eOgOCRvLTXkXHSb/ZBPtN1y+mn8ws1JRW9Q2pKkKa5Sh5k8XJoY1imIKntRHw== X-Received: by 2002:a05:6602:2549:: with SMTP id j9mr28413147ioe.89.1595949194047; Tue, 28 Jul 2020 08:13:14 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:13 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 02/15] iio: sx9310: Update macros declarations Date: Tue, 28 Jul 2020 09:12:45 -0600 Message-Id: <20200728091057.2.Idb6af9292f18f54be0b62cede52b481063738707@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Follows spec sheet for macro declarations. Signed-off-by: Daniel Campello Reviewed-by: Stephen Boyd --- drivers/iio/proximity/sx9310.c | 143 +++++++++++++++------------------ 1 file changed, 67 insertions(+), 76 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index d161f3061e353d..07895d4b935d12 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -33,45 +33,45 @@ #define SX9310_REG_IRQ_SRC 0x00 #define SX9310_REG_STAT0 0x01 #define SX9310_REG_STAT1 0x02 +#define SX9310_REG_STAT1_COMPSTAT_MASK GENMASK(3, 0) #define SX9310_REG_IRQ_MSK 0x03 #define SX9310_CONVDONE_IRQ BIT(3) #define SX9310_FAR_IRQ BIT(5) #define SX9310_CLOSE_IRQ BIT(6) -#define SX9310_EVENT_IRQ (SX9310_FAR_IRQ | \ - SX9310_CLOSE_IRQ) #define SX9310_REG_IRQ_FUNC 0x04 #define SX9310_REG_PROX_CTRL0 0x10 -#define SX9310_REG_PROX_CTRL0_PROXSTAT2 0x10 -#define SX9310_REG_PROX_CTRL0_EN_MASK 0x0F +#define SX9310_REG_PROX_CTRL0_SENSOREN_MASK GENMASK(3, 0) +#define SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK GENMASK(7, 4) +#define SX9310_REG_PROX_CTRL0_SCANPERIOD_SHIFT 4 +#define SX9310_REG_PROX_CTRL0_SCANPERIOD_15MS 0x01 #define SX9310_REG_PROX_CTRL1 0x11 #define SX9310_REG_PROX_CTRL2 0x12 -#define SX9310_REG_PROX_CTRL2_COMBMODE_ALL 0x80 -#define SX9310_REG_PROX_CTRL2_SHIELDEN_DYNAMIC 0x04 +#define SX9310_REG_PROX_CTRL2_COMBMODE_CS1_CS2 (0x02 << 6) +#define SX9310_REG_PROX_CTRL2_SHIELDEN_DYNAMIC (0x01 << 2) #define SX9310_REG_PROX_CTRL3 0x13 -#define SX9310_REG_PROX_CTRL3_GAIN0_X8 0x0c +#define SX9310_REG_PROX_CTRL3_GAIN0_X8 (0x03 << 2) #define SX9310_REG_PROX_CTRL3_GAIN12_X4 0x02 #define SX9310_REG_PROX_CTRL4 0x14 #define SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST 0x07 #define SX9310_REG_PROX_CTRL5 0x15 -#define SX9310_REG_PROX_CTRL5_RANGE_SMALL 0xc0 -#define SX9310_REG_PROX_CTRL5_STARTUPSENS_CS1 0x04 +#define SX9310_REG_PROX_CTRL5_RANGE_SMALL (0x03 << 6) +#define SX9310_REG_PROX_CTRL5_STARTUPSENS_CS1 (0x01 << 2) #define SX9310_REG_PROX_CTRL5_RAWFILT_1P25 0x02 #define SX9310_REG_PROX_CTRL6 0x16 -#define SX9310_REG_PROX_CTRL6_COMP_COMMON 0x20 +#define SX9310_REG_PROX_CTRL6_AVGTHRESH_DEFAULT 0x20 #define SX9310_REG_PROX_CTRL7 0x17 -#define SX9310_REG_PROX_CTRL7_AVGNEGFILT_2 0x08 +#define SX9310_REG_PROX_CTRL7_AVGNEGFILT_2 (0x01 << 3) #define SX9310_REG_PROX_CTRL7_AVGPOSFILT_512 0x05 #define SX9310_REG_PROX_CTRL8 0x18 #define SX9310_REG_PROX_CTRL9 0x19 -#define SX9310_REG_PROX_CTRL8_9_PTHRESH12_28 0x40 -#define SX9310_REG_PROX_CTRL8_9_PTHRESH_96 0x88 +#define SX9310_REG_PROX_CTRL8_9_PTHRESH_28 (0x08 << 3) +#define SX9310_REG_PROX_CTRL8_9_PTHRESH_96 (0x11 << 3) #define SX9310_REG_PROX_CTRL8_9_BODYTHRESH_900 0x03 #define SX9310_REG_PROX_CTRL8_9_BODYTHRESH_1500 0x05 #define SX9310_REG_PROX_CTRL10 0x1a -#define SX9310_REG_PROX_CTRL10_HYST_6PCT 0x10 -#define SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_8 0x12 -#define SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_8 0x03 +#define SX9310_REG_PROX_CTRL10_HYST_6PCT (0x01 << 4) +#define SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_2 0x01 #define SX9310_REG_PROX_CTRL11 0x1b #define SX9310_REG_PROX_CTRL12 0x1c #define SX9310_REG_PROX_CTRL13 0x1d @@ -82,8 +82,8 @@ #define SX9310_REG_PROX_CTRL18 0x22 #define SX9310_REG_PROX_CTRL19 0x23 #define SX9310_REG_SAR_CTRL0 0x2a -#define SX9310_REG_SAR_CTRL0_SARDEB_4_SAMPLES 0x40 -#define SX9310_REG_SAR_CTRL0_SARHYST_8 0x10 +#define SX9310_REG_SAR_CTRL0_SARDEB_4_SAMPLES (0x02 << 5) +#define SX9310_REG_SAR_CTRL0_SARHYST_8 (0x02 << 3) #define SX9310_REG_SAR_CTRL1 0x2b /* Each increment of the slope register is 0.0078125. */ #define SX9310_REG_SAR_CTRL1_SLOPE(_hnslope) (_hnslope / 78125) @@ -107,7 +107,7 @@ #define SX9310_REG_SAR_MSB 0x39 #define SX9310_REG_SAR_LSB 0x3a -#define SX9310_REG_I2CADDR 0x40 +#define SX9310_REG_I2C_ADDR 0x40 #define SX9310_REG_PAUSE 0x41 #define SX9310_REG_WHOAMI 0x42 #define SX9310_WHOAMI_VALUE 0x01 @@ -116,14 +116,9 @@ #define SX9310_REG_RESET 0x7f #define SX9310_SOFT_RESET 0xde -#define SX9310_SCAN_PERIOD_MASK GENMASK(7, 4) -#define SX9310_SCAN_PERIOD_SHIFT 4 - -#define SX9310_COMPSTAT_MASK GENMASK(3, 0) /* 4 hardware channels, as defined in STAT0: COMB, CS2, CS1 and CS0. */ #define SX9310_NUM_CHANNELS 4 -#define SX9310_CHAN_ENABLED_MASK GENMASK(3, 0) struct sx9310_data { /* Serialize access to registers and channel configuration */ @@ -251,7 +246,7 @@ static const struct regmap_range sx9310_readable_reg_ranges[] = { regmap_reg_range(SX9310_REG_PROX_CTRL0, SX9310_REG_PROX_CTRL19), regmap_reg_range(SX9310_REG_SAR_CTRL0, SX9310_REG_SAR_CTRL2), regmap_reg_range(SX9310_REG_SENSOR_SEL, SX9310_REG_SAR_LSB), - regmap_reg_range(SX9310_REG_I2CADDR, SX9310_REG_WHOAMI), + regmap_reg_range(SX9310_REG_I2C_ADDR, SX9310_REG_WHOAMI), regmap_reg_range(SX9310_REG_RESET, SX9310_REG_RESET), }; @@ -292,7 +287,7 @@ static int sx9310_update_chan_en(struct sx9310_data *data, if ((data->chan_read | data->chan_event) != (chan_read | chan_event)) { ret = regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL0, - SX9310_CHAN_ENABLED_MASK, + SX9310_REG_PROX_CTRL0_SENSOREN_MASK, chan_read | chan_event); if (ret) return ret; @@ -361,7 +356,8 @@ static int sx9310_wait_for_sample(struct sx9310_data *data) if (ret < 0) return ret; - val = (val & SX9310_SCAN_PERIOD_MASK) >> SX9310_SCAN_PERIOD_SHIFT; + val = (val & SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK) >> + SX9310_REG_PROX_CTRL0_SCANPERIOD_SHIFT; msleep(sx9310_scan_period_table[val]); @@ -435,7 +431,8 @@ static int sx9310_read_samp_freq(struct sx9310_data *data, int *val, int *val2) if (ret < 0) return ret; - regval = (regval & SX9310_SCAN_PERIOD_MASK) >> SX9310_SCAN_PERIOD_SHIFT; + regval = (regval & SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK) >> + SX9310_REG_PROX_CTRL0_SCANPERIOD_SHIFT; *val = sx9310_samp_freq_table[regval].val; *val2 = sx9310_samp_freq_table[regval].val2; @@ -483,8 +480,8 @@ static int sx9310_set_samp_freq(struct sx9310_data *data, int val, int val2) mutex_lock(&data->mutex); ret = regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL0, - SX9310_SCAN_PERIOD_MASK, - i << SX9310_SCAN_PERIOD_SHIFT); + SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK, + i << SX9310_REG_PROX_CTRL0_SCANPERIOD_SHIFT); mutex_unlock(&data->mutex); @@ -572,7 +569,7 @@ static irqreturn_t sx9310_irq_thread_handler(int irq, void *private) goto out; } - if (val & SX9310_EVENT_IRQ) + if (val & (SX9310_FAR_IRQ | SX9310_CLOSE_IRQ)) sx9310_push_events(indio_dev); if (val & SX9310_CONVDONE_IRQ) @@ -600,6 +597,7 @@ static int sx9310_write_event_config(struct iio_dev *indio_dev, enum iio_event_direction dir, int state) { struct sx9310_data *data = iio_priv(indio_dev); + unsigned int eventirq = SX9310_FAR_IRQ | SX9310_CLOSE_IRQ; int ret; /* If the state hasn't changed, there's nothing to do. */ @@ -612,7 +610,7 @@ static int sx9310_write_event_config(struct iio_dev *indio_dev, if (ret < 0) goto out_unlock; if (!(data->chan_event & ~BIT(chan->channel))) { - ret = sx9310_enable_irq(data, SX9310_EVENT_IRQ); + ret = sx9310_enable_irq(data, eventirq); if (ret < 0) sx9310_put_event_channel(data, chan->channel); } @@ -621,7 +619,7 @@ static int sx9310_write_event_config(struct iio_dev *indio_dev, if (ret < 0) goto out_unlock; if (!data->chan_event) { - ret = sx9310_disable_irq(data, SX9310_EVENT_IRQ); + ret = sx9310_disable_irq(data, eventirq); if (ret < 0) sx9310_get_event_channel(data, chan->channel); } @@ -746,53 +744,46 @@ struct sx9310_reg_default { u8 def; }; -#define SX_INIT(_reg, _def) \ - { \ - .reg = SX9310_REG_##_reg, \ - .def = _def, \ - } - static const struct sx9310_reg_default sx9310_default_regs[] = { - SX_INIT(IRQ_MSK, 0x00), - SX_INIT(IRQ_FUNC, 0x00), + { SX9310_REG_IRQ_MSK, 0x00 }, + { SX9310_REG_IRQ_FUNC, 0x00 }, /* * The lower 4 bits should not be set as it enable sensors measurements. * Turning the detection on before the configuration values are set to * good values can cause the device to return erroneous readings. */ - SX_INIT(PROX_CTRL0, SX9310_REG_PROX_CTRL0_PROXSTAT2), - SX_INIT(PROX_CTRL1, 0x00), - SX_INIT(PROX_CTRL2, SX9310_REG_PROX_CTRL2_COMBMODE_ALL | - SX9310_REG_PROX_CTRL2_SHIELDEN_DYNAMIC), - SX_INIT(PROX_CTRL3, SX9310_REG_PROX_CTRL3_GAIN0_X8 | - SX9310_REG_PROX_CTRL3_GAIN12_X4), - SX_INIT(PROX_CTRL4, SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST), - SX_INIT(PROX_CTRL5, SX9310_REG_PROX_CTRL5_RANGE_SMALL | - SX9310_REG_PROX_CTRL5_STARTUPSENS_CS1 | - SX9310_REG_PROX_CTRL5_RAWFILT_1P25), - SX_INIT(PROX_CTRL6, SX9310_REG_PROX_CTRL6_COMP_COMMON), - SX_INIT(PROX_CTRL7, SX9310_REG_PROX_CTRL7_AVGNEGFILT_2 | - SX9310_REG_PROX_CTRL7_AVGPOSFILT_512), - SX_INIT(PROX_CTRL8, SX9310_REG_PROX_CTRL8_9_PTHRESH_96 | - SX9310_REG_PROX_CTRL8_9_BODYTHRESH_1500), - SX_INIT(PROX_CTRL9, SX9310_REG_PROX_CTRL8_9_PTHRESH12_28 | - SX9310_REG_PROX_CTRL8_9_BODYTHRESH_900), - SX_INIT(PROX_CTRL10, SX9310_REG_PROX_CTRL10_HYST_6PCT | - SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_8 | - SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_8), - SX_INIT(PROX_CTRL11, 0x00), - SX_INIT(PROX_CTRL12, 0x00), - SX_INIT(PROX_CTRL13, 0x00), - SX_INIT(PROX_CTRL14, 0x00), - SX_INIT(PROX_CTRL15, 0x00), - SX_INIT(PROX_CTRL16, 0x00), - SX_INIT(PROX_CTRL17, 0x00), - SX_INIT(PROX_CTRL18, 0x00), - SX_INIT(PROX_CTRL19, 0x00), - SX_INIT(SAR_CTRL0, SX9310_REG_SAR_CTRL0_SARDEB_4_SAMPLES | - SX9310_REG_SAR_CTRL0_SARHYST_8), - SX_INIT(SAR_CTRL1, SX9310_REG_SAR_CTRL1_SLOPE(10781250)), - SX_INIT(SAR_CTRL2, SX9310_REG_SAR_CTRL2_SAROFFSET_DEFAULT), + { SX9310_REG_PROX_CTRL0, SX9310_REG_PROX_CTRL0_SCANPERIOD_15MS }, + { SX9310_REG_PROX_CTRL1, 0x00 }, + { SX9310_REG_PROX_CTRL2, SX9310_REG_PROX_CTRL2_COMBMODE_CS1_CS2 | + SX9310_REG_PROX_CTRL2_SHIELDEN_DYNAMIC }, + { SX9310_REG_PROX_CTRL3, SX9310_REG_PROX_CTRL3_GAIN0_X8 | + SX9310_REG_PROX_CTRL3_GAIN12_X4 }, + { SX9310_REG_PROX_CTRL4, SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST }, + { SX9310_REG_PROX_CTRL5, SX9310_REG_PROX_CTRL5_RANGE_SMALL | + SX9310_REG_PROX_CTRL5_STARTUPSENS_CS1 | + SX9310_REG_PROX_CTRL5_RAWFILT_1P25 }, + { SX9310_REG_PROX_CTRL6, SX9310_REG_PROX_CTRL6_AVGTHRESH_DEFAULT }, + { SX9310_REG_PROX_CTRL7, SX9310_REG_PROX_CTRL7_AVGNEGFILT_2 | + SX9310_REG_PROX_CTRL7_AVGPOSFILT_512 }, + { SX9310_REG_PROX_CTRL8, SX9310_REG_PROX_CTRL8_9_PTHRESH_96 | + SX9310_REG_PROX_CTRL8_9_BODYTHRESH_1500 }, + { SX9310_REG_PROX_CTRL9, SX9310_REG_PROX_CTRL8_9_PTHRESH_28 | + SX9310_REG_PROX_CTRL8_9_BODYTHRESH_900 }, + { SX9310_REG_PROX_CTRL10, SX9310_REG_PROX_CTRL10_HYST_6PCT | + SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_2 }, + { SX9310_REG_PROX_CTRL11, 0x00 }, + { SX9310_REG_PROX_CTRL12, 0x00 }, + { SX9310_REG_PROX_CTRL13, 0x00 }, + { SX9310_REG_PROX_CTRL14, 0x00 }, + { SX9310_REG_PROX_CTRL15, 0x00 }, + { SX9310_REG_PROX_CTRL16, 0x00 }, + { SX9310_REG_PROX_CTRL17, 0x00 }, + { SX9310_REG_PROX_CTRL18, 0x00 }, + { SX9310_REG_PROX_CTRL19, 0x00 }, + { SX9310_REG_SAR_CTRL0, SX9310_REG_SAR_CTRL0_SARDEB_4_SAMPLES | + SX9310_REG_SAR_CTRL0_SARHYST_8 }, + { SX9310_REG_SAR_CTRL1, SX9310_REG_SAR_CTRL1_SLOPE(10781250) }, + { SX9310_REG_SAR_CTRL2, SX9310_REG_SAR_CTRL2_SAROFFSET_DEFAULT }, }; /* Activate all channels and perform an initial compensation. */ @@ -809,7 +800,7 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev) /* run the compensation phase on all channels */ ret = regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, - ctrl0 | SX9310_REG_PROX_CTRL0_EN_MASK); + ctrl0 | SX9310_REG_PROX_CTRL0_SENSOREN_MASK); if (ret < 0) return ret; @@ -992,7 +983,7 @@ static int __maybe_unused sx9310_suspend(struct device *dev) if (ret) goto out; - ctrl0 = data->suspend_ctrl0 & ~SX9310_REG_PROX_CTRL0_EN_MASK; + ctrl0 = data->suspend_ctrl0 & ~SX9310_REG_PROX_CTRL0_SENSOREN_MASK; ret = regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, ctrl0); if (ret) goto out; From patchwork Tue Jul 28 15:12:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A09EC14E3 for ; Tue, 28 Jul 2020 15:13:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88A8E206D8 for ; Tue, 28 Jul 2020 15:13:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CW0fy1nz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730737AbgG1PNT (ORCPT ); Tue, 28 Jul 2020 11:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730723AbgG1PNQ (ORCPT ); Tue, 28 Jul 2020 11:13:16 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3397AC061794 for ; Tue, 28 Jul 2020 08:13:16 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id e64so21074111iof.12 for ; Tue, 28 Jul 2020 08:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UXu1LI4EreJiPCGpDoc5eFU1VLFE8sDpcfNeo5EdH5U=; b=CW0fy1nzyEScVEgQupl6l+tgIFLDYcNerhH8YNh0B+COR1awhJw+rrOEbSChQ0DpQt 1hZVOZqOjV+v0xPI4msvxw+MX2ArFCL+INIAfGxudPO2aybWdIFdKHWMBnbcqolrofOt fIx9moaF3r0nGihk2ldFJ3ATQMOfkm24LsQss= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UXu1LI4EreJiPCGpDoc5eFU1VLFE8sDpcfNeo5EdH5U=; b=gryhIrkdcfV5vl7x2FzD2hfZZpRPjtrIczNnwkV+0ZxAF/vQRCvzqxr2oF3xW0sBVJ fo9sggM0COsuge8WjKQRZBQ2rvmAcdi+nnQ6HVGuN/JPA1mZVrcAzTQHhcIitzD1Pfgn dvQeTgGZe+YFOtwCiuRt/JvZlMIy6SBGCdSIKI5URvNH8/RxlWOHX9zrSmtBfvP7nj2F /jfNK0hh5q5IQWa8R3m6IzLodSr81iICv9yZj0WdRZx90SMWtpG/nswZ7jj0NQ0XQF9A rs7xUUKhn5Vv9qACCzZAaSj3cxCPsRp96Tt6m84JZCS2CLJJlenTh8K+l+i3F0xpz16M YAGQ== X-Gm-Message-State: AOAM533i+lcWmi6cKm+pAOqO5QVk/f8SK9hRj4Emnptr96UxFPpTTWPh mQUGGhY1B5UuTEZhbnfs1SXbDg== X-Google-Smtp-Source: ABdhPJxM7VC9nu3erFc2LP9bXhgfPe5tRGvIPgx/QAwT2vEhHFHgM7cY+paS40z4V1Vt7rEyI8sPvA== X-Received: by 2002:a6b:bc82:: with SMTP id m124mr7069591iof.172.1595949195633; Tue, 28 Jul 2020 08:13:15 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:15 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 03/15] iio: sx9310: Fix irq handling Date: Tue, 28 Jul 2020 09:12:46 -0600 Message-Id: <20200728091057.3.I2a1314232ace4323af96f9981c1e1a4f31f78049@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Fixes enable/disable irq handling at various points. The driver needs to only enable/disable irqs if there is an actual irq handler installed. Signed-off-by: Daniel Campello --- drivers/iio/proximity/sx9310.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 07895d4b935d12..76b8bedebeef50 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -376,13 +376,15 @@ static int sx9310_read_proximity(struct sx9310_data *data, if (ret < 0) goto out; - ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) - goto out_put_channel; + if (data->client->irq) { + ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); + if (ret) + goto out_put_channel; + } mutex_unlock(&data->mutex); - if (data->client->irq > 0) { + if (data->client->irq) { ret = wait_for_completion_interruptible(&data->completion); reinit_completion(&data->completion); } else { @@ -401,9 +403,11 @@ static int sx9310_read_proximity(struct sx9310_data *data, *val = sign_extend32(be16_to_cpu(rawval), (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); - ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) - goto out_put_channel; + if (data->client->irq) { + ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); + if (ret) + goto out_put_channel; + } ret = sx9310_put_read_channel(data, chan->channel); if (ret < 0) @@ -414,7 +418,8 @@ static int sx9310_read_proximity(struct sx9310_data *data, return IIO_VAL_INT; out_disable_irq: - sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); + if (data->client->irq) + sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); out_put_channel: sx9310_put_read_channel(data, chan->channel); out: @@ -1012,7 +1017,8 @@ static int __maybe_unused sx9310_resume(struct device *dev) out: mutex_unlock(&data->mutex); - enable_irq(data->client->irq); + if (!ret) + enable_irq(data->client->irq); return ret; } From patchwork Tue Jul 28 15:12:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AA4D14E3 for ; Tue, 28 Jul 2020 15:14:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32BFA206D8 for ; Tue, 28 Jul 2020 15:14:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XHy3Hkgo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730715AbgG1POY (ORCPT ); Tue, 28 Jul 2020 11:14:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730729AbgG1PNS (ORCPT ); Tue, 28 Jul 2020 11:13:18 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A1BFC0619D6 for ; Tue, 28 Jul 2020 08:13:17 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id y18so8041307ilp.10 for ; Tue, 28 Jul 2020 08:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X77SPgqeRzIi7EPS0EuqxV7/IKv3AykZrtE724jPXxg=; b=XHy3HkgoBzyU7B0kjB5UebEtF+vf06VHhx0/jKsJcL5bugXvMSbqZpMi8LdXQsiAhs pA9Q4Mvy6EMrzMQqeo179qzEolOlL2P210L6mZPhKXNPHkK3jYFB+kyEovPurqDOskHe ruyA7I6IGIUfSEYtFOk+INJ51lS916hhvF6MI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X77SPgqeRzIi7EPS0EuqxV7/IKv3AykZrtE724jPXxg=; b=HAB3O4gGs9T6xtAJX5ABAf8gXNpI0QhhKMNMfmU+/mhwMwUNW/lshMsstMudMXTy2e VKII0FARsbz9bBiyC28UamTRPuhPwzyw7V9CsQPjmUkSfSy0iQfZiERlb3ctgQj8WUc/ 67TnG9o6ZV+t77o71RXFkFoW+DBXfhkcSIHY7qaexgRZvTaMYMShd3KkqHBRs9welpOR 5GUq0bcFifvaDFr85zSC8rEDmWuxrpeQHWxxnpyRoYk5yvv3V5LtCKxDXaGX9mTMOvgy W4q5h8xsyTbVlM9eLxuypcsfThR+C5ops5ZA0vwZ42tDD8IHbrOGTMCibm9fouvQpe8b 7/hQ== X-Gm-Message-State: AOAM532wIwHBMFCDyxj7OROzP/8dHOpsOyE3doN0gTuZDWv2Flu2qYy7 YSFIULMb0Y4+Eb/xMZrTAvNfOA== X-Google-Smtp-Source: ABdhPJySXXN72bxVJJIeBDgnmesD5K+vdd8uvbwtfSploVLqeodEPgHI3v5z+I/kvRvKqA3xmgBA3Q== X-Received: by 2002:a92:1b5b:: with SMTP id b88mr22688298ilb.104.1595949196575; Tue, 28 Jul 2020 08:13:16 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:16 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , kbuild test robot , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 04/15] iio: sx9310: Remove acpi and of table macros Date: Tue, 28 Jul 2020 09:12:47 -0600 Message-Id: <20200728091057.4.I33c50453845a8167969130d514af86e573b6ef31@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Avoids unused warnings due to acpi/of table macros. Signed-off-by: Daniel Campello Reported-by: kbuild test robot --- drivers/iio/proximity/sx9310.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 76b8bedebeef50..0fb88ad66f7342 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -1051,8 +1050,8 @@ MODULE_DEVICE_TABLE(i2c, sx9310_id); static struct i2c_driver sx9310_driver = { .driver = { .name = "sx9310", - .acpi_match_table = ACPI_PTR(sx9310_acpi_match), - .of_match_table = of_match_ptr(sx9310_of_match), + .acpi_match_table = sx9310_acpi_match, + .of_match_table = sx9310_of_match, .pm = &sx9310_pm_ops, }, .probe = sx9310_probe, From patchwork Tue Jul 28 15:12:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E447913 for ; Tue, 28 Jul 2020 15:14:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07DEC206D8 for ; Tue, 28 Jul 2020 15:14:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kNwnsSnj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730721AbgG1POL (ORCPT ); Tue, 28 Jul 2020 11:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730734AbgG1PNT (ORCPT ); Tue, 28 Jul 2020 11:13:19 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 300ACC0619D9 for ; Tue, 28 Jul 2020 08:13:18 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id s21so16459792ilk.5 for ; Tue, 28 Jul 2020 08:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B8BLZMzA+ROESYBLDJPQNqdkwcaC9Aplp9oQfc1AvvU=; b=kNwnsSnjzw3GS/T34EFdhzO/5dv9m35wRnd4ukW+2NNL2zPTwIs+axO3N7H9ePHoc4 xR/QkOG5nIsWmTlfnCmKRwE266q7wtJsvZyXOPX5W4jgL8qAJM7/Te6Cr0SJfR+KRtX5 40M6FL0kNyriRzsn0IMGNC2zQbl8PbnAk+mOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B8BLZMzA+ROESYBLDJPQNqdkwcaC9Aplp9oQfc1AvvU=; b=oRIJ+1hsitljeYottjDbkm8EFytAcTv7GsYDfcnBW7LXYtrnWBihnxAvB4HQ02WnXk 2+744zb/DHpkuq3OOR7fdGfcbFSfPSekjDD6EkNci5XN5JBWmHNVt6wEc25m88ovduLM Rkrn/DLcYSSTbk3aIJbhJPAQHybbhvPDtmRPWfSDdkVDDPOERYuGe9GHdwCKtD6GkmLG LtHr67wxlqgpgv6hhGSb25+GVgzAKiPSVSD9ZWekCg5oCBvQakv+yFY1sZ4uTvHkaOoJ Fe6r89S69WXki+R11FGMZZfKwG2grqfNi4KDS5CPXMCRVBKrdIjRyIMwvwRh/olcjhAo Metw== X-Gm-Message-State: AOAM530nANADC7OT9Vay2hmwjnuEMv9RSUzMIcGBS27ElT7lohs5vPBg V2BAF3DHpTHp1x0TlNqvyvHgRA== X-Google-Smtp-Source: ABdhPJwCeImWtRTvcIL1MrXSvzfCaWV+TydneoD9Ux6DY8eVfPmskXiyrnxLJPbrlik2TpFYrQhBgA== X-Received: by 2002:a92:d444:: with SMTP id r4mr7018829ilm.63.1595949197603; Tue, 28 Jul 2020 08:13:17 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:17 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 05/15] iio: sx9310: Change from .probe to .probe_new Date: Tue, 28 Jul 2020 09:12:48 -0600 Message-Id: <20200728091057.5.I0ea31fe183b99838b28213df05b0e7912db3ba29@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Uses .probe_new in place of .probe. Also uses device_get_match_data() for whoami matching. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko Reviewed-by: Stephen Boyd --- drivers/iio/proximity/sx9310.c | 37 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 0fb88ad66f7342..de52afd7c13333 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -138,7 +138,7 @@ struct sx9310_data { struct completion completion; unsigned int chan_read, chan_event; int channel_users[SX9310_NUM_CHANNELS]; - int whoami; + unsigned int whoami; }; static const struct iio_event_spec sx9310_events[] = { @@ -859,24 +859,15 @@ static int sx9310_init_device(struct iio_dev *indio_dev) static int sx9310_set_indio_dev_name(struct device *dev, struct iio_dev *indio_dev, - const struct i2c_device_id *id, int whoami) + unsigned int whoami) { - const struct acpi_device_id *acpi_id; - - /* id will be NULL when enumerated via ACPI */ - if (id) { - if (id->driver_data != whoami) - dev_err(dev, "WHOAMI does not match i2c_device_id: %s", - id->name); - } else if (ACPI_HANDLE(dev)) { - acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); - if (!acpi_id) - return -ENODEV; - if (acpi_id->driver_data != whoami) - dev_err(dev, "WHOAMI does not match acpi_device_id: %s", - acpi_id->id); - } else + unsigned int long ddata; + + ddata = (uintptr_t)device_get_match_data(dev); + if (ddata != whoami) { + dev_err(dev, "WHOAMI does not match device data: %u", whoami); return -ENODEV; + } switch (whoami) { case SX9310_WHOAMI_VALUE: @@ -893,8 +884,7 @@ static int sx9310_set_indio_dev_name(struct device *dev, return 0; } -static int sx9310_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int sx9310_probe(struct i2c_client *client) { int ret; struct iio_dev *indio_dev; @@ -920,8 +910,7 @@ static int sx9310_probe(struct i2c_client *client, return ret; } - ret = sx9310_set_indio_dev_name(&client->dev, indio_dev, id, - data->whoami); + ret = sx9310_set_indio_dev_name(&client->dev, indio_dev, data->whoami); if (ret < 0) return ret; @@ -1034,8 +1023,8 @@ static const struct acpi_device_id sx9310_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, sx9310_acpi_match); static const struct of_device_id sx9310_of_match[] = { - { .compatible = "semtech,sx9310" }, - { .compatible = "semtech,sx9311" }, + { .compatible = "semtech,sx9310", (void *)SX9310_WHOAMI_VALUE }, + { .compatible = "semtech,sx9311", (void *)SX9311_WHOAMI_VALUE }, {}, }; MODULE_DEVICE_TABLE(of, sx9310_of_match); @@ -1054,7 +1043,7 @@ static struct i2c_driver sx9310_driver = { .of_match_table = sx9310_of_match, .pm = &sx9310_pm_ops, }, - .probe = sx9310_probe, + .probe_new = sx9310_probe, .id_table = sx9310_id, }; module_i2c_driver(sx9310_driver); From patchwork Tue Jul 28 15:12:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62F8114E3 for ; Tue, 28 Jul 2020 15:14:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A07120786 for ; Tue, 28 Jul 2020 15:14:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ed/5En/h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730718AbgG1POL (ORCPT ); Tue, 28 Jul 2020 11:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730736AbgG1PNT (ORCPT ); Tue, 28 Jul 2020 11:13:19 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 268ADC061794 for ; Tue, 28 Jul 2020 08:13:19 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id s21so16459854ilk.5 for ; Tue, 28 Jul 2020 08:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Arxg0V8+xHLDJQOE3XC6XEI2D610eTDQSgAgiHWic2E=; b=ed/5En/huJmkV7H3sr4JUDjl4+6DT7yd+2en/sv+vhamRLo2GMIG/zccn5VTenFrLp VDrRuPQQ8+Bd7hE7AUGPlnxQZUKbA9Smb+Qj/5k56WU4GxeioqOPgqxYoN9CxcaxIr2b 4HYQATKa8y0w1jXw8qa8Hh/1P2XA7VjDwEDx8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Arxg0V8+xHLDJQOE3XC6XEI2D610eTDQSgAgiHWic2E=; b=EsvZufiDqW2XBn7RWzJSCVQx+oP1qpPs6FCh1iI1hubGFBKjbc8eFimr6HExk9MoXG TxZatX2pb/v1AAFtkQ0D7vCurUBwaPJ/Y3Msw2vVzmCrH02TQnRPuGHu+8LnftMtFNG8 TLs5mMva2M+4Ew+zSuOaMTWGDgSsTQTnGcyNAKoTMUIOVm2yDhS9lOo4X2JW4s+fpK/q SFY2FX1Y0F+rkJAiSRfS3aEcBJZ2Uu7LaNaPdGZG00E3xTJjThM7fnWACupJ7pt8GrpF tqQEdop6QPnSb/yrodszbHGrreE/2uzrzD1tRVdQusfN7nJtWGuaT7w/9oYeYX2TWksO 8wjA== X-Gm-Message-State: AOAM5321uZL8aHa/zMcRsFxWhEPPviLImiRg63Mzt0mzliJyB87pXLJF A+dweQMEDnQPy/XBL5ESx6sLIg== X-Google-Smtp-Source: ABdhPJzItrrOk/abLny4EURhjo3V8tqNGWdD2HMPltz32026rUJgZvwpqAZHJ4OpQQ3cbVuaKiK+tg== X-Received: by 2002:a92:ce42:: with SMTP id a2mr26094617ilr.37.1595949198545; Tue, 28 Jul 2020 08:13:18 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:18 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 06/15] iio: sx9310: Align memory Date: Tue, 28 Jul 2020 09:12:49 -0600 Message-Id: <20200728091057.6.I27a5605d9cb3ff643ef040c4ef932a30df9a8fac@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use __aligned(8) to ensure that the timestamp is correctly aligned when we call push_to_buffers Signed-off-by: Daniel Campello --- drivers/iio/proximity/sx9310.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index de52afd7c13333..fb5c16f2aa6b1a 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -131,8 +131,8 @@ struct sx9310_data { */ bool prox_stat[SX9310_NUM_CHANNELS]; bool trigger_enabled; - __be16 buffer[SX9310_NUM_CHANNELS + - 4]; /* 64-bit data + 64-bit timestamp */ + /* 64-bit data + 64-bit timestamp buffer */ + __be16 buffer[SX9310_NUM_CHANNELS + 4] __aligned(8); /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; struct completion completion; @@ -339,7 +339,7 @@ static int sx9310_read_prox_data(struct sx9310_data *data, if (ret < 0) return ret; - return regmap_bulk_read(data->regmap, chan->address, val, 2); + return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val)); } /* From patchwork Tue Jul 28 15:12:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689315 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18837913 for ; Tue, 28 Jul 2020 15:13:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00A1A20786 for ; Tue, 28 Jul 2020 15:13:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ldt1Qqla" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730756AbgG1PNX (ORCPT ); Tue, 28 Jul 2020 11:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730618AbgG1PNV (ORCPT ); Tue, 28 Jul 2020 11:13:21 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ABB5C0619DD for ; Tue, 28 Jul 2020 08:13:20 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id l17so6259365ilq.13 for ; Tue, 28 Jul 2020 08:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FBxxg43y21daaJb2slakYjo79C/jv3+HeW/qSD1nJIA=; b=ldt1QqlamitrLWI3C0KvuawslYN21v+uhA2FJ/Ee/zjJWKQ4HDJTD6eZmey75yN5fU eAbNY9fgaAKGZLz3a5aU2QLJABQ4lbUEbxTk/7srnTul4aytLgIYLtPs1M593fo28h/T r31SMK+n0vMqx/JcPyqVf14U5o5MTmm97A1IY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FBxxg43y21daaJb2slakYjo79C/jv3+HeW/qSD1nJIA=; b=GBeHaJn9Kj6B1Xw0AtUIBYE/DpKv6JIMaxG0EGGZp0TwLyGMIwNPkHdXD7SQznF7/g 8uDJgngMHzVcYn/6XLoq3cR1jJQT9StwSGJcbOEZLLf3jfzJmpR8wPucSjHpBEKILir9 P3DxuOyYHTjGAigMeJsPAYaRBte660qWOp46RkrY2d3mhhQTCNczEMNyCm9ha7rtVFwB ISnEyyvPHuyxPr1X0oM3bwaZapDzjTTXtgXMjjKnD9bZkk/W6qfJ5SgWFr9D/Jwa08z5 Bqsg4NydIwJYXMpRL+m7yLTfZ3PmTlUbXWXqJQnrVqIN2aDsxtgrQR/O/lhUF3LXRM/d fwpQ== X-Gm-Message-State: AOAM530nKr7MhqzcEYRpwuBUaKI28gF4zgzUZnwBuhBSktmFHwxN7/Am OCbchov6iuRkvEN1Y2TEf96Glw== X-Google-Smtp-Source: ABdhPJzHpqfHpVdzOgmWOQKFPQtZC44Y/MezvpPV2geBeMXx3gyAKAuxjipi7EN2sVPUZB1xsrQMCg== X-Received: by 2002:a05:6e02:c21:: with SMTP id q1mr22581160ilg.28.1595949199470; Tue, 28 Jul 2020 08:13:19 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:19 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 07/15] iio: sx9310: Use long instead of int for channel bitmaps Date: Tue, 28 Jul 2020 09:12:50 -0600 Message-Id: <20200728091057.7.I3a5582a3e1589e351f6335b39f52e5ccc5f46b61@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Uses for_each_set_bit() macro to loop over channel bitmaps. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- drivers/iio/proximity/sx9310.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index fb5c16f2aa6b1a..2465064971d0a7 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -136,7 +136,8 @@ struct sx9310_data { /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; struct completion completion; - unsigned int chan_read, chan_event; + unsigned long chan_read; + unsigned long chan_event; int channel_users[SX9310_NUM_CHANNELS]; unsigned int whoami; }; @@ -279,15 +280,16 @@ static const struct regmap_config sx9310_regmap_config = { }; static int sx9310_update_chan_en(struct sx9310_data *data, - unsigned int chan_read, - unsigned int chan_event) + unsigned long chan_read, + unsigned long chan_event) { int ret; + unsigned long channels = chan_read | chan_event; - if ((data->chan_read | data->chan_event) != (chan_read | chan_event)) { + if ((data->chan_read | data->chan_event) != channels) { ret = regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL0, SX9310_REG_PROX_CTRL0_SENSOREN_MASK, - chan_read | chan_event); + channels); if (ret) return ret; } @@ -538,13 +540,13 @@ static void sx9310_push_events(struct iio_dev *indio_dev) return; } - for (chan = 0; chan < SX9310_NUM_CHANNELS; chan++) { + for_each_set_bit(chan, &data->chan_event, SX9310_NUM_CHANNELS) { int dir; u64 ev; - bool new_prox = val & BIT(chan); + bool new_prox; + + new_prox = val & BIT(chan); - if (!(data->chan_event & BIT(chan))) - continue; if (new_prox == data->prox_stat[chan]) /* No change on this channel. */ continue; @@ -712,13 +714,13 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) static int sx9310_buffer_preenable(struct iio_dev *indio_dev) { struct sx9310_data *data = iio_priv(indio_dev); - unsigned int channels = 0; + unsigned long channels = 0; int bit, ret; mutex_lock(&data->mutex); for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) - channels |= BIT(indio_dev->channels[bit].channel); + __set_bit(indio_dev->channels[bit].channel, &channels); ret = sx9310_update_chan_en(data, channels, data->chan_event); mutex_unlock(&data->mutex); From patchwork Tue Jul 28 15:12:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AC5A913 for ; Tue, 28 Jul 2020 15:14:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 130CA20786 for ; Tue, 28 Jul 2020 15:14:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="eLzRLoUF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730842AbgG1POC (ORCPT ); Tue, 28 Jul 2020 11:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730748AbgG1PNV (ORCPT ); Tue, 28 Jul 2020 11:13:21 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22FB2C0619DF for ; Tue, 28 Jul 2020 08:13:21 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id y18so8041516ilp.10 for ; Tue, 28 Jul 2020 08:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iO8S6+VQF9v4JirDDLBlt0iKshG9f1w+n4ePBu/++FQ=; b=eLzRLoUFGK18UYfdm52AoqO40ycbCnhYQdhe0EofC0D/oRtbA/cldr7JC/SaVxm4ty pi69iCv2p75oSPVmEDR9S9Bep1V4ApEfVQ1s+qsKd7KNJGLlvKLCTAbJmfS3kyNW7isG 1yc40mtfm2+XVQxtIoGqwOHfnABARdmug36Ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iO8S6+VQF9v4JirDDLBlt0iKshG9f1w+n4ePBu/++FQ=; b=lUSvCadLlbiZQATP6cNhI43oKBTlwLoLz1vJFrjiSQ4gguE+GfUqg28pAz0fXbTnh2 y4CQNR8DVP+JsXcVV3QYGuiOSOFV7zdYGMwdENSFEvSsbp4DjMohYNLUJUA77i+x84el U73wZEtexeEwVitoK7jqzGmigOhn8W9nh+VZXj7KnDpD1V0j9pAudD5ckd7nY8ihmxTe j0o74lsS296aA32dWvaPvWZQ9KEHeZL/8VmrWsiIMSLSU704sfYWhDmmbTLBrPh9RXL2 o14wBsppcyl5Pprrq7jjLilq7qRiGoZYH0bZzAcfG1YxDauvXGCcB5xI0c9vXznNDujK DGCg== X-Gm-Message-State: AOAM533PDHkpf3knd2LhsjOfB6oscxlrqgVsEFn44kVLoxPrb/GutQbA bL5ayFHdPWda8Qp5Y3f7do/o/Q== X-Google-Smtp-Source: ABdhPJxVhHK+GaWEAAtctrpps1GfIJkqfuGUZRlqOyOg5X1KbB+82HDKyZut8Xuv9logZSiQjYK/HQ== X-Received: by 2002:a92:c0c9:: with SMTP id t9mr23988549ilf.82.1595949200455; Tue, 28 Jul 2020 08:13:20 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:20 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 08/15] iio: sx9310: Use regmap_read_poll_timeout() for compensation Date: Tue, 28 Jul 2020 09:12:51 -0600 Message-Id: <20200728091057.8.I34c7a1bfca7fe3d607f8876ef9f10c22153556d2@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Simplify compensation stage by using regmap_read_poll_timeout(). Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- drivers/iio/proximity/sx9310.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 2465064971d0a7..3956fd679c6db9 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -796,7 +796,7 @@ static const struct sx9310_reg_default sx9310_default_regs[] = { static int sx9310_init_compensation(struct iio_dev *indio_dev) { struct sx9310_data *data = iio_priv(indio_dev); - int i, ret; + int ret; unsigned int val; unsigned int ctrl0; @@ -810,22 +810,17 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev) if (ret < 0) return ret; - for (i = 100; i >= 0; i--) { - msleep(20); - ret = regmap_read(data->regmap, SX9310_REG_STAT1, &val); - if (ret < 0) - goto out; - if (!(val & SX9310_COMPSTAT_MASK)) - break; - } - - if (i < 0) { - dev_err(&data->client->dev, - "initial compensation timed out: 0x%02x", val); - ret = -ETIMEDOUT; + ret = regmap_read_poll_timeout(data->regmap, SX9310_REG_STAT1, val, + !(val & SX9310_REG_STAT1_COMPSTAT_MASK), + 20000, 2000000); + if (ret) { + if (ret == -ETIMEDOUT) + dev_err(&data->client->dev, + "0x02 << 3l compensation timed out: 0x%02x", + val); + return ret; } -out: regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, ctrl0); return ret; } From patchwork Tue Jul 28 15:12:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 626DF159A for ; Tue, 28 Jul 2020 15:13:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4630120786 for ; Tue, 28 Jul 2020 15:13:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="k8Iz73x9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730618AbgG1PNX (ORCPT ); Tue, 28 Jul 2020 11:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730750AbgG1PNW (ORCPT ); Tue, 28 Jul 2020 11:13:22 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0325AC0619D8 for ; Tue, 28 Jul 2020 08:13:22 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id t15so12176739iob.3 for ; Tue, 28 Jul 2020 08:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FDqTksQ36evV6y3c+mmwks3K6Lhx7dvyjiJBLqUyvDg=; b=k8Iz73x9o5wh2wBk4SqmFDSosu25UGC4vA/PCOWk/qgNtUamQLHAJvXnBScg8d/Sbg BJic5xDK6f9/0KLBBrFu0YppuWQ//oq83P0kWACgrequ3lAGaSzkAmWLaVXQxevn0kfa qZUR6686Vsdxjpb6LajhgItklVeGH6lvWKaDk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FDqTksQ36evV6y3c+mmwks3K6Lhx7dvyjiJBLqUyvDg=; b=rh+sPnnIk+CD9by6m35yV1OA8CLGMiK0H3fKXht7ALNeERSIdbGF/qrcqNz/hMUrxt mXY9P/MFEnrPvS07fSak7fCWvreRh6ih8cBrc84LWJ0KFWKTRpjzphyPRxN1F7JHNNfV TcRrv0PgfebShM0bilU2fStINqJeeO7z4bp1x1Ugd/lLFDB/LxTdYwKOGkqm648/9JJn V85qX2QOu+r8WUHILK8mDRMcGxtCLJ73W+E3UBmAnNl87BKNBIXFJAgOtXrIM2p4NIjL T1PkbLalTHZOWZMJfKQSyMnKDOkRPNQnmWtL6RiW+Ql49pFYQRr1mwZ6TTOVPVqpV/P/ 7KCA== X-Gm-Message-State: AOAM533krOlJxLmlE5dN0oS79Y9DVwkWmhxdGstqSy0bj/NPyq34Xqoj cqZuXXhrPLQZao6KW9ZNyeE32Q== X-Google-Smtp-Source: ABdhPJy15gMJ7gQGSdMcz49FoSB23iVg0C4f7La2orWJtBBVztmxfQZeOsfkrvzTws1vzuKZP48UPA== X-Received: by 2002:a02:a584:: with SMTP id b4mr22046511jam.68.1595949201432; Tue, 28 Jul 2020 08:13:21 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:21 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 09/15] iio: sx9310: Update copyright Date: Tue, 28 Jul 2020 09:12:52 -0600 Message-Id: <20200728091057.9.I3bc9c85e4b0dec9a67b4af91cd6fd451a238ec42@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Fixes wrong copyright year. Signed-off-by: Daniel Campello --- drivers/iio/proximity/sx9310.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 3956fd679c6db9..31234691a31abf 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright 2018 Google LLC. + * Copyright 2020 Google LLC. * * Driver for Semtech's SX9310/SX9311 capacitive proximity/button solution. * Based on SX9500 driver and Semtech driver using the input framework * . - * Reworked April 2019 by Evan Green - * and January 2020 by Daniel Campello + * Reworked in April 2019 by Evan Green + * and in January 2020 by Daniel Campello . */ #include From patchwork Tue Jul 28 15:12:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F6E6159A for ; Tue, 28 Jul 2020 15:13:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5694E20825 for ; Tue, 28 Jul 2020 15:13:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gpnA78Ke" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730640AbgG1PNq (ORCPT ); Tue, 28 Jul 2020 11:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730766AbgG1PNY (ORCPT ); Tue, 28 Jul 2020 11:13:24 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 064F2C0619D5 for ; Tue, 28 Jul 2020 08:13:23 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id k23so21064078iom.10 for ; Tue, 28 Jul 2020 08:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6EMdfDK2JVnoPakwKVYfubyIjeUj/QwNofE9r5/lvRA=; b=gpnA78KeLCg1HWWE2SvnWAO1QGdTqdVOXjeL6/UlSOSJOaoyPjm5Xn7ro6PFHlXxyc eqhQVMsGn+j82T19pdrk7En9d+KVSCUxEjXlYjI4RijSotEFaaumJngPn0NVwYyfS5aH WVlvYS8EDwoIjfWCJYkGalPkajqsKkK0gICn8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6EMdfDK2JVnoPakwKVYfubyIjeUj/QwNofE9r5/lvRA=; b=qxMrz0J8LHyMkEQCMrIusdZYl2A51oyylX4n7NZSR8RojftxdG7MxoDx3v37vNmY9g gTUL43y+jT+rHMUWJpnjVXvz7A/IBJTUQRE3mvFCOeS5YcoDGXTng47J7QcKkxVbs24d 11JRGOoeWrMaX4KpfxHMIe0+7iz0JuLOlSX0g0LPPwzWueSnZ5dlSsMxuFG0sm/cQVEJ deFlSZCuubYM8EJoM3PiqrhvwtRre296H3Fh9RsfNIP85B9fsj+pE5TfQnxeUWNAkmm9 ZsXyiOMgYyr3MmC9UJm0iPLHXqiRwqtZ/kDbA39Qi+MRFmNcfPub5q+zvSFZp9YLdCrI xJ1Q== X-Gm-Message-State: AOAM531kkGFnqzaqeuL7HGcrm5Iu0ZiB+wcACl18v0/yoyezHDEHAwDy oRq74e2NNzzpKL0qeDrSl6IB4w== X-Google-Smtp-Source: ABdhPJzja/aWKs3RfmosX6sws9TVFdrU6C8foQOQMR8RPCCw5JbZTBSLsJbclHdwhbki/NQMP2H9qA== X-Received: by 2002:a02:b689:: with SMTP id i9mr14283022jam.59.1595949202371; Tue, 28 Jul 2020 08:13:22 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:22 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 10/15] iio: sx9310: Simplify error return handling Date: Tue, 28 Jul 2020 09:12:53 -0600 Message-Id: <20200728091057.10.Ibe84fae61cd914c116e6d59ffeb644f1cbecd601@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Checks for non-zero return values to signal error conditions. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- drivers/iio/proximity/sx9310.c | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 31234691a31abf..051c6515e62c18 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -338,7 +338,7 @@ static int sx9310_read_prox_data(struct sx9310_data *data, int ret; ret = regmap_write(data->regmap, SX9310_REG_SENSOR_SEL, chan->channel); - if (ret < 0) + if (ret) return ret; return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val)); @@ -354,7 +354,7 @@ static int sx9310_wait_for_sample(struct sx9310_data *data) unsigned int val; ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, &val); - if (ret < 0) + if (ret) return ret; val = (val & SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK) >> @@ -368,13 +368,13 @@ static int sx9310_wait_for_sample(struct sx9310_data *data) static int sx9310_read_proximity(struct sx9310_data *data, const struct iio_chan_spec *chan, int *val) { - int ret = 0; + int ret; __be16 rawval; mutex_lock(&data->mutex); ret = sx9310_get_read_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out; if (data->client->irq) { @@ -394,11 +394,11 @@ static int sx9310_read_proximity(struct sx9310_data *data, mutex_lock(&data->mutex); - if (ret < 0) + if (ret) goto out_disable_irq; ret = sx9310_read_prox_data(data, chan, &rawval); - if (ret < 0) + if (ret) goto out_disable_irq; *val = sign_extend32(be16_to_cpu(rawval), @@ -411,7 +411,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, } ret = sx9310_put_read_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out; mutex_unlock(&data->mutex); @@ -434,7 +434,7 @@ static int sx9310_read_samp_freq(struct sx9310_data *data, int *val, int *val2) unsigned int regval; int ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, ®val); - if (ret < 0) + if (ret) return ret; regval = (regval & SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK) >> @@ -535,7 +535,7 @@ static void sx9310_push_events(struct iio_dev *indio_dev) /* Read proximity state on all channels */ ret = regmap_read(data->regmap, SX9310_REG_STAT0, &val); - if (ret < 0) { + if (ret) { dev_err(&data->client->dev, "i2c transfer error in irq\n"); return; } @@ -570,7 +570,7 @@ static irqreturn_t sx9310_irq_thread_handler(int irq, void *private) mutex_lock(&data->mutex); ret = regmap_read(data->regmap, SX9310_REG_IRQ_SRC, &val); - if (ret < 0) { + if (ret) { dev_err(&data->client->dev, "i2c transfer error in irq\n"); goto out; } @@ -613,20 +613,20 @@ static int sx9310_write_event_config(struct iio_dev *indio_dev, mutex_lock(&data->mutex); if (state) { ret = sx9310_get_event_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out_unlock; if (!(data->chan_event & ~BIT(chan->channel))) { ret = sx9310_enable_irq(data, eventirq); - if (ret < 0) + if (ret) sx9310_put_event_channel(data, chan->channel); } } else { ret = sx9310_put_event_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out_unlock; if (!data->chan_event) { ret = sx9310_disable_irq(data, eventirq); - if (ret < 0) + if (ret) sx9310_get_event_channel(data, chan->channel); } } @@ -665,7 +665,7 @@ static int sx9310_set_trigger_state(struct iio_trigger *trig, bool state) ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); else if (!data->chan_read) ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) + if (ret) goto out; data->trigger_enabled = state; @@ -694,7 +694,7 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) indio_dev->masklength) { ret = sx9310_read_prox_data(data, &indio_dev->channels[bit], &val); - if (ret < 0) + if (ret) goto out; data->buffer[i++] = val; @@ -801,13 +801,13 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev) unsigned int ctrl0; ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, &ctrl0); - if (ret < 0) + if (ret) return ret; /* run the compensation phase on all channels */ ret = regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, ctrl0 | SX9310_REG_PROX_CTRL0_SENSOREN_MASK); - if (ret < 0) + if (ret) return ret; ret = regmap_read_poll_timeout(data->regmap, SX9310_REG_STAT1, val, @@ -833,21 +833,21 @@ static int sx9310_init_device(struct iio_dev *indio_dev) unsigned int i, val; ret = regmap_write(data->regmap, SX9310_REG_RESET, SX9310_SOFT_RESET); - if (ret < 0) + if (ret) return ret; usleep_range(1000, 2000); /* power-up time is ~1ms. */ /* Clear reset interrupt state by reading SX9310_REG_IRQ_SRC. */ ret = regmap_read(data->regmap, SX9310_REG_IRQ_SRC, &val); - if (ret < 0) + if (ret) return ret; /* Program some sane defaults. */ for (i = 0; i < ARRAY_SIZE(sx9310_default_regs); i++) { initval = &sx9310_default_regs[i]; ret = regmap_write(data->regmap, initval->reg, initval->def); - if (ret < 0) + if (ret) return ret; } @@ -901,14 +901,14 @@ static int sx9310_probe(struct i2c_client *client) return PTR_ERR(data->regmap); ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &data->whoami); - if (ret < 0) { + if (ret) { dev_err(&client->dev, "error in reading WHOAMI register: %d", ret); return ret; } ret = sx9310_set_indio_dev_name(&client->dev, indio_dev, data->whoami); - if (ret < 0) + if (ret) return ret; ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(&client->dev)); @@ -920,7 +920,7 @@ static int sx9310_probe(struct i2c_client *client) i2c_set_clientdata(client, indio_dev); ret = sx9310_init_device(indio_dev); - if (ret < 0) + if (ret) return ret; if (client->irq) { @@ -929,7 +929,7 @@ static int sx9310_probe(struct i2c_client *client) sx9310_irq_thread_handler, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "sx9310_event", indio_dev); - if (ret < 0) + if (ret) return ret; data->trig = @@ -951,7 +951,7 @@ static int sx9310_probe(struct i2c_client *client) iio_pollfunc_store_time, sx9310_trigger_handler, &sx9310_buffer_setup_ops); - if (ret < 0) + if (ret) return ret; return devm_iio_device_register(&client->dev, indio_dev); From patchwork Tue Jul 28 15:12:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F3FC14E3 for ; Tue, 28 Jul 2020 15:13:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08C1D20786 for ; Tue, 28 Jul 2020 15:13:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="U7+6MXXJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730766AbgG1PNq (ORCPT ); Tue, 28 Jul 2020 11:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730761AbgG1PNY (ORCPT ); Tue, 28 Jul 2020 11:13:24 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3D96C0619D4 for ; Tue, 28 Jul 2020 08:13:23 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id z17so1365836ill.6 for ; Tue, 28 Jul 2020 08:13:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5QD2zMnkde3qFVDG/0jVGmkVeNpBgY28HlienvJxu1M=; b=U7+6MXXJbfJhJboNeaOQcjn/6u4Z0sOQn4YYtsAU5jeIIHHLmIBWWjhfEptqNyIunS lQok0lgKmNtFpnjYFHQihk5T5K7DBgJGj1Q4bRmDXZg5W23G2Vqz9TE6hlZbaDmC7GD6 nG2wiYdxg6klUZrFlGHPBnqjcoaSXKRx9szvE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5QD2zMnkde3qFVDG/0jVGmkVeNpBgY28HlienvJxu1M=; b=nVM1UcMI4EbRWDzpP8THYVe0k3QTDC9MkEZFDwQVa7d0EQ+o0z6viaeQKzoSpvQYQh MXENbt3T0oSBnlFfu+4tTol/lLWDU0v5dbIZF/7sL9UBkBhPfT+MEq02qxNfuysqfJlQ tFGUDYXAwx7od/gql2r9PhrMoOJynsVi8wHI4nT+YU0qa7x5F/hxYq33zvVomLv/R1AJ clAb/PrVnMIm6ItC5+5U2HVtoQKNfgVCE1DonBwhTHvO6kloau1+bop552Ffo4bo5MzK wGDQFcAHbmQYWJgcDIQtDTBTw3Sd7MSmoPbA5AnYx8hQYrRFIqF4xMO6lXB4z5Pj5df/ kP4A== X-Gm-Message-State: AOAM532x6t5qeB3A58BoLl7gXxUu6c58dEW/e5JfNQHNgeQI8bx1+VbL xvpINRL5jfvL23UVIwHUK1waXQ== X-Google-Smtp-Source: ABdhPJyXVY5GbwA+/x0E3BUwZmX7S5nD9TvLV4rfdjrILbG+w5vt7+4jxBQT0a0zZbjdnOp8qBvR/A== X-Received: by 2002:a92:ad01:: with SMTP id w1mr23769254ilh.301.1595949203284; Tue, 28 Jul 2020 08:13:23 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:22 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 11/15] iio: sx9310: Use variable to hold &client->dev Date: Tue, 28 Jul 2020 09:12:54 -0600 Message-Id: <20200728091057.11.I126c3f697e0b7ee951ea24ac60ce79d368790de9@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Improves readability by storing &client->dev in a local variable. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko Reviewed-by: Stephen Boyd --- drivers/iio/proximity/sx9310.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 051c6515e62c18..ba383710ef0dcf 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -884,11 +884,12 @@ static int sx9310_set_indio_dev_name(struct device *dev, static int sx9310_probe(struct i2c_client *client) { int ret; + struct device *dev = &client->dev; struct iio_dev *indio_dev; struct sx9310_data *data; - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); - if (indio_dev == NULL) + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) return -ENOMEM; data = iio_priv(indio_dev); @@ -902,17 +903,16 @@ static int sx9310_probe(struct i2c_client *client) ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &data->whoami); if (ret) { - dev_err(&client->dev, "error in reading WHOAMI register: %d", - ret); + dev_err(dev, "error in reading WHOAMI register: %d", ret); return ret; } - ret = sx9310_set_indio_dev_name(&client->dev, indio_dev, data->whoami); + ret = sx9310_set_indio_dev_name(dev, indio_dev, data->whoami); if (ret) return ret; - ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(&client->dev)); - indio_dev->dev.parent = &client->dev; + ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(dev)); + indio_dev->dev.parent = dev; indio_dev->channels = sx9310_channels; indio_dev->num_channels = ARRAY_SIZE(sx9310_channels); indio_dev->info = &sx9310_info; @@ -924,7 +924,7 @@ static int sx9310_probe(struct i2c_client *client) return ret; if (client->irq) { - ret = devm_request_threaded_irq(&client->dev, client->irq, + ret = devm_request_threaded_irq(dev, client->irq, sx9310_irq_handler, sx9310_irq_thread_handler, IRQF_TRIGGER_LOW | IRQF_ONESHOT, @@ -932,29 +932,29 @@ static int sx9310_probe(struct i2c_client *client) if (ret) return ret; - data->trig = - devm_iio_trigger_alloc(&client->dev, "%s-dev%d", - indio_dev->name, indio_dev->id); + data->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", + indio_dev->name, + indio_dev->id); if (!data->trig) return -ENOMEM; - data->trig->dev.parent = &client->dev; + data->trig->dev.parent = dev; data->trig->ops = &sx9310_trigger_ops; iio_trigger_set_drvdata(data->trig, indio_dev); - ret = devm_iio_trigger_register(&client->dev, data->trig); + ret = devm_iio_trigger_register(dev, data->trig); if (ret) return ret; } - ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, iio_pollfunc_store_time, sx9310_trigger_handler, &sx9310_buffer_setup_ops); if (ret) return ret; - return devm_iio_device_register(&client->dev, indio_dev); + return devm_iio_device_register(dev, indio_dev); } static int __maybe_unused sx9310_suspend(struct device *dev) From patchwork Tue Jul 28 15:12:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689319 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9748B159A for ; Tue, 28 Jul 2020 15:13:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AD7120786 for ; Tue, 28 Jul 2020 15:13:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iP7KyadU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730786AbgG1PN2 (ORCPT ); Tue, 28 Jul 2020 11:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730758AbgG1PN0 (ORCPT ); Tue, 28 Jul 2020 11:13:26 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA15FC0619DD for ; Tue, 28 Jul 2020 08:13:24 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id z6so21147914iow.6 for ; Tue, 28 Jul 2020 08:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p2EPkQyeRIURdgFyo/f9Dyfw352T0LaZ3N6QIzNpCZs=; b=iP7KyadUIXxYmoNuooKYjo+SoVnssM4rOi59DcS1slyy3GG9oYkwYcxTgd9PI5yseb TdLPTF8xJGxo9usrHSQLQ1dhArIkFuLraWhDhUBGLA198aAOSbZzoIhKHJ+WgF5YK74M RD2gD/UWn/+GEKEsaUJGqJ9H+Qj1GBkWE9g4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p2EPkQyeRIURdgFyo/f9Dyfw352T0LaZ3N6QIzNpCZs=; b=H5yPFPZHG1rnk9kHdbc4MKBoeHps8QKw15IY/osZExVUvNycSLWHk0HWNMrnXCheC9 49mhyQBYZ5bhqdUBvqv+GdK7O05zLelWB1x+Vt5M69w4t44gPjaskkuked4DprKnRIfm 7qKBfdlgigHFJVadJOcOnSG6GpEMD3cBV5Ml9VwH3TFeVdN/g8jKlE+Qn9+hxUOhdiHB b0rrJwCMgMYGrdr46/Qiu4DBQRgdsglwuw8T2UZ69j063DdJPxC3XWN+ko833DV08fId LcnY6PLXqbtHz/f6g/NWZf7FTY9l59HFaFCEtRBaBg/gO3ETk/HJbJoPEOWHP0/hn64+ 5o/A== X-Gm-Message-State: AOAM533HmM18q1fxIacq0hxA7F3n6LZxt+wYJCjpZ1VLptvxICTd3+Tc r3I+61/jZUrSkEvFNSDhZ+kHrDrYBaNfRQ== X-Google-Smtp-Source: ABdhPJxzZ7Hth+BmekoFZFUxXcp70VDLjpmGKdXidtvR/JmHNpe/hZNpt3veoSJcmHkF19zBP0Eo1g== X-Received: by 2002:a05:6638:771:: with SMTP id y17mr32809735jad.96.1595949204155; Tue, 28 Jul 2020 08:13:24 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:23 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH 12/15] iio: sx9310: Miscellaneous format fixes Date: Tue, 28 Jul 2020 09:12:55 -0600 Message-Id: <20200728091057.12.Iacab204f4164af12fa47206b98505bfbf8770cf3@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Miscellaneous format fixes throughout the whole file. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko Reviewed-by: Stephen Boyd --- drivers/iio/proximity/sx9310.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index ba383710ef0dcf..3f981d28ee4056 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -90,28 +90,21 @@ #define SX9310_REG_SAR_CTRL2_SAROFFSET_DEFAULT 0x3c #define SX9310_REG_SENSOR_SEL 0x30 - #define SX9310_REG_USE_MSB 0x31 #define SX9310_REG_USE_LSB 0x32 - #define SX9310_REG_AVG_MSB 0x33 #define SX9310_REG_AVG_LSB 0x34 - #define SX9310_REG_DIFF_MSB 0x35 #define SX9310_REG_DIFF_LSB 0x36 - #define SX9310_REG_OFFSET_MSB 0x37 #define SX9310_REG_OFFSET_LSB 0x38 - #define SX9310_REG_SAR_MSB 0x39 #define SX9310_REG_SAR_LSB 0x3a - #define SX9310_REG_I2C_ADDR 0x40 #define SX9310_REG_PAUSE 0x41 #define SX9310_REG_WHOAMI 0x42 #define SX9310_WHOAMI_VALUE 0x01 #define SX9311_WHOAMI_VALUE 0x02 - #define SX9310_REG_RESET 0x7f #define SX9310_SOFT_RESET 0xde @@ -402,7 +395,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, goto out_disable_irq; *val = sign_extend32(be16_to_cpu(rawval), - (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); + chan->address == SX9310_REG_DIFF_MSB ? 11 : 15); if (data->client->irq) { ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); @@ -432,8 +425,9 @@ static int sx9310_read_proximity(struct sx9310_data *data, static int sx9310_read_samp_freq(struct sx9310_data *data, int *val, int *val2) { unsigned int regval; - int ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, ®val); + int ret; + ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, ®val); if (ret) return ret; @@ -518,10 +512,9 @@ static irqreturn_t sx9310_irq_handler(int irq, void *private) iio_trigger_poll(data->trig); /* - * Even if no event is enabled, we need to wake the thread to - * clear the interrupt state by reading SX9310_REG_IRQ_SRC. It - * is not possible to do that here because regmap_read takes a - * mutex. + * Even if no event is enabled, we need to wake the thread to clear the + * interrupt state by reading SX9310_REG_IRQ_SRC. + * It is not possible to do that here because regmap_read takes a mutex. */ return IRQ_WAKE_THREAD; } @@ -638,7 +631,7 @@ static int sx9310_write_event_config(struct iio_dev *indio_dev, static struct attribute *sx9310_attributes[] = { &iio_dev_attr_sampling_frequency_available.dev_attr.attr, - NULL, + NULL }; static const struct attribute_group sx9310_attribute_group = { @@ -969,7 +962,6 @@ static int __maybe_unused sx9310_suspend(struct device *dev) mutex_lock(&data->mutex); ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL0, &data->suspend_ctrl0); - if (ret) goto out; @@ -1015,21 +1007,21 @@ static const struct dev_pm_ops sx9310_pm_ops = { static const struct acpi_device_id sx9310_acpi_match[] = { { "STH9310", SX9310_WHOAMI_VALUE }, { "STH9311", SX9311_WHOAMI_VALUE }, - {}, + {} }; MODULE_DEVICE_TABLE(acpi, sx9310_acpi_match); static const struct of_device_id sx9310_of_match[] = { { .compatible = "semtech,sx9310", (void *)SX9310_WHOAMI_VALUE }, { .compatible = "semtech,sx9311", (void *)SX9311_WHOAMI_VALUE }, - {}, + {} }; MODULE_DEVICE_TABLE(of, sx9310_of_match); static const struct i2c_device_id sx9310_id[] = { { "sx9310", SX9310_WHOAMI_VALUE }, { "sx9311", SX9311_WHOAMI_VALUE }, - {}, + {} }; MODULE_DEVICE_TABLE(i2c, sx9310_id); From patchwork Tue Jul 28 15:12:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4016714E3 for ; Tue, 28 Jul 2020 15:13:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AB4E20829 for ; Tue, 28 Jul 2020 15:13:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ZDN3H2FX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730691AbgG1PNh (ORCPT ); Tue, 28 Jul 2020 11:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730776AbgG1PNZ (ORCPT ); Tue, 28 Jul 2020 11:13:25 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B042FC0619D4 for ; Tue, 28 Jul 2020 08:13:25 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id q75so12953658iod.1 for ; Tue, 28 Jul 2020 08:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dBdydSoMKXmEdaffi7O9O0wgF/TEt9JKgR6178mXM9M=; b=ZDN3H2FXLdJTJyyOyKwo1UsyPtVLwiflwAGYLEHP/VTYvYZwDPVoAND8SEDKbuMOBe /+ROVE9tP8bVAdijZ/I0/wUIi9zI2+N0ZbjYuY60iGCnPjy9A1P2eEJpF3yPtjtnP+dX nktogQjb/VN6LlP4kfLf64RXYmfmo4J5gjieo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dBdydSoMKXmEdaffi7O9O0wgF/TEt9JKgR6178mXM9M=; b=Bl5kQwfmDu/g5Qfn2mzdh7ss4b3EOEr3CLDU+gaUG/BqT1fvNuVHrzHCHStFAylBl4 Kom0fKWh6761IOITYxGlQ+xvJq5Vs7wHESQ/BQAqf35HzB6KVXLskRFsIJWn8LmbvcBh qvi9Bivmt3v9hWfxhSK9469aFp3uDnMKoOalCjZw9C2Bd+sJRIqYZn0ubfg/PwC6Qy0k IHshINsugONjtsCtfoXx7ZI93RfRrb3jB7yrS0HcvNLGZU8V8j2849ST9b0zhs4Bbv1s Y/u8rgEz1GxP0VUhLjFV7uI60foVOIxgyCfYxPJrLDo6V3G/ZPWnweV2ThgVe4Z1tfcD 5pXw== X-Gm-Message-State: AOAM533kpl3nKtWKBtCSUlU6Zx2ERgOy++rqY9Qfuvq5JY0hKo3zrXLV Nh0jU3I3DkDbhYqhN+3DiBtS4A== X-Google-Smtp-Source: ABdhPJxheG4noLBhnCh3S2+F/84pEFZ4uw6a7eN1qHSiQ8i19vDcXpxohLRyRyn6LT+vAZgHpbzNBg== X-Received: by 2002:a02:6d07:: with SMTP id m7mr2381002jac.140.1595949205135; Tue, 28 Jul 2020 08:13:25 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:24 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Daniel Campello , Douglas Anderson , Enrico Granata , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH 13/15] iio: sx9310: Add newlines to printks Date: Tue, 28 Jul 2020 09:12:56 -0600 Message-Id: <20200728091057.13.I14600506d0f725bf800c8da4ef89fdb3c3fb45cd@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Stephen Boyd Printks in the kernel have newlines at the end. Add them to the few printks in this driver. Reviewed-by: Daniel Campello Reviewed-by: Douglas Anderson Fixes: 72ad02b15d63 ("iio: Add SEMTECH SX9310/9311 sensor driver") Signed-off-by: Stephen Boyd Signed-off-by: Daniel Campello --- drivers/iio/proximity/sx9310.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 3f981d28ee4056..4553ee83a016a3 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -809,7 +809,7 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev) if (ret) { if (ret == -ETIMEDOUT) dev_err(&data->client->dev, - "0x02 << 3l compensation timed out: 0x%02x", + "0x02 << 3l compensation timed out: 0x%02x\n", val); return ret; } @@ -855,7 +855,7 @@ static int sx9310_set_indio_dev_name(struct device *dev, ddata = (uintptr_t)device_get_match_data(dev); if (ddata != whoami) { - dev_err(dev, "WHOAMI does not match device data: %u", whoami); + dev_err(dev, "WHOAMI does not match device data: %u\n", whoami); return -ENODEV; } @@ -867,7 +867,7 @@ static int sx9310_set_indio_dev_name(struct device *dev, indio_dev->name = "sx9311"; break; default: - dev_err(dev, "unexpected WHOAMI response: %u", whoami); + dev_err(dev, "unexpected WHOAMI response: %u\n", whoami); return -ENODEV; } @@ -896,7 +896,7 @@ static int sx9310_probe(struct i2c_client *client) ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &data->whoami); if (ret) { - dev_err(dev, "error in reading WHOAMI register: %d", ret); + dev_err(dev, "error in reading WHOAMI register: %d\n", ret); return ret; } From patchwork Tue Jul 28 15:12:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67D7E14E3 for ; Tue, 28 Jul 2020 15:13:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5004420786 for ; Tue, 28 Jul 2020 15:13:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="G8Xb29dO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730653AbgG1PN3 (ORCPT ); Tue, 28 Jul 2020 11:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730779AbgG1PN0 (ORCPT ); Tue, 28 Jul 2020 11:13:26 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97FC3C0619D2 for ; Tue, 28 Jul 2020 08:13:26 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id v6so5870813iow.11 for ; Tue, 28 Jul 2020 08:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y4C6kJxgm5TBz1yf5mhnYEeohqRErvGcIOy3qqF9KZw=; b=G8Xb29dOpciFEH1QxLsaCP0CK3QhkLCqoNwroDxUt1QwT67vhhcnxP2xOcNKh2k6f9 D4I1UJ+Y7gfLEA7S8wXT7BCy6GrCZIMnE9yHzCmpkOH78+K7vy+Z5IzNpGYi+WZCrZP2 QgbUZcUFNsbSbI+PXxBnJYunr0HV/PoG0q+fg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y4C6kJxgm5TBz1yf5mhnYEeohqRErvGcIOy3qqF9KZw=; b=JXZu5O07gOjkE5m9DZBjdd1iPfvkL/4ViVYXWp3wR6BT0qXEXg4drg5R7mRtMY3+gl O4HpFgYbfUJ2l0NGGuZ0lN4FS/b/hB4Cg8srwLlN+wFbs7nuQTcK2K9x2pNzhHdvUFlO CY1A4yggAAPbHDnmndTbwHtkT83319lwCPpZns2kPOCOKUdouwbvWgVa9sR2yXb0tCHe b+OH+d2hNcWM5kW7L8WBrZoDBdAFTBBlmBq1TUyENpzmaDiysJHGqxr7kdymM3Ya0l60 mBS7czLR9JVE0PHRmY2VwWpZk44r5ekUoD+7qVqnRaDvRANpqVMtxbhoVXXPxBmUdHuz XR6Q== X-Gm-Message-State: AOAM532qVSCQi80b43lxEXsGspzeGqV3avM2jBZ2eeNOPDNHEcKM/jV4 WFML+Cc5J5mW6zMapshkOryqUg== X-Google-Smtp-Source: ABdhPJxLFcoirM9ExI4o/TWJASWDKBlTJxgvvCrz9oB1hPwME+urF+MA+TXSGe245uOxHGkQ6qsBBA== X-Received: by 2002:a02:5883:: with SMTP id f125mr994489jab.50.1595949206066; Tue, 28 Jul 2020 08:13:26 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:25 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Douglas Anderson , Daniel Campello , Enrico Granata , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH 14/15] iio: sx9310: Drop channel_users[] Date: Tue, 28 Jul 2020 09:12:57 -0600 Message-Id: <20200728091057.14.I687e37031ecdd9e21078adf8d290c48b6d9d9a1e@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Stephen Boyd This struct member isn't used. Drop it. Fixes: 72ad02b15d63 ("iio: Add SEMTECH SX9310/9311 sensor driver") Signed-off-by: Stephen Boyd Reviewed-by: Douglas Anderson Reviewed-by: Daniel Campello Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- drivers/iio/proximity/sx9310.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 4553ee83a016a3..202018b726e32f 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -131,7 +131,6 @@ struct sx9310_data { struct completion completion; unsigned long chan_read; unsigned long chan_event; - int channel_users[SX9310_NUM_CHANNELS]; unsigned int whoami; }; From patchwork Tue Jul 28 15:12:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11689323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0517A913 for ; Tue, 28 Jul 2020 15:13:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFED420786 for ; Tue, 28 Jul 2020 15:13:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="d8eleb4M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730777AbgG1PNg (ORCPT ); Tue, 28 Jul 2020 11:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730691AbgG1PN2 (ORCPT ); Tue, 28 Jul 2020 11:13:28 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B954C061794 for ; Tue, 28 Jul 2020 08:13:28 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id k23so21064406iom.10 for ; Tue, 28 Jul 2020 08:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7g2DMS0FPIZ0c5BtsKEx2bDwtPiWXmFL4GsCilJV19I=; b=d8eleb4MBB+74R1FQdN2sLvMwPOupEBPNEhXpr/In2/on2ERcbEHLNR3MN4sMtCY05 fIlogS5Gf6IXBuMpceoXrgCKjfhKhFV7MtwSoPBvWnfmg0WeuppStmahExFke5V6klPt aTVh5lRzw6ZPFueGvBUn33rKXHIZZVLLNqaZ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7g2DMS0FPIZ0c5BtsKEx2bDwtPiWXmFL4GsCilJV19I=; b=gjX2wQAvcm4RTEpFEBUmZHMlcJ1y23Ww5G2ZREdEpqNUTiE4MRjAmusHJr+F8iF33e 9aRVH+VdOORxmVUAYrBZyzUsR7GzjOV/SdMwq/F8WYVWLm/kNy3TK2iyBsiWxmOs16V3 0CdJiKgt9T1kyVgwMirNTuIZAsotkRHqfpFO07Ebe/Vf7RXKHe1oOnIAIPLT1iJ5c1Q1 0XedfvQO9JZf4E9PJIfvAghIjmFIPL/mTG6FVhXbdyCRyp2Rc9XoQ/08JYl0HhFTcXbi J8QULFJVYFWYRw6wiLDg1xEIekGSpKVuxxB+afZ5EzxRVgbv/1KBGF+pttOVeYrlQG4D zSbg== X-Gm-Message-State: AOAM530J1lnL47mPny3TBo/1fCsPA7H7PLAMpXROsqpXvQdO0pwf2Q1T Z6jTC/cTazhD3wWOkVLPdbTDew== X-Google-Smtp-Source: ABdhPJw0FjZUaCtk3mItpKIJPN0aj5p9Lbxv8Jyx9ib1W0TOGX11VsA9cYlczInqsYM2F9YsK6/rEA== X-Received: by 2002:a02:ec4:: with SMTP id 187mr31580705jae.11.1595949207095; Tue, 28 Jul 2020 08:13:27 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id q70sm6399781ili.49.2020.07.28.08.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 08:13:26 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Douglas Anderson , Daniel Campello , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH 15/15] iio: sx9310: Enable vdd and svdd regulators at probe Date: Tue, 28 Jul 2020 09:12:58 -0600 Message-Id: <20200728091057.15.Iaf4d717d1908ef22c88922b556e1eb803ae019c6@changeid> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200728151258.1222876-1-campello@chromium.org> References: <20200724183954.1.I2e29ae25368ba8a72a9e44121cfbc36ead8ecc6b@changeid> <20200728151258.1222876-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Stephen Boyd Enable the main power supply (vdd) and digital IO power supply (svdd) during probe so that the i2c communication and device works properly on boards that aggressively power gate these supplies. Reviewed-by: Douglas Anderson Signed-off-by: Stephen Boyd Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- drivers/iio/proximity/sx9310.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 202018b726e32f..24a2360b6314ef 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -118,6 +119,7 @@ struct sx9310_data { struct i2c_client *client; struct iio_trigger *trig; struct regmap *regmap; + struct regulator_bulk_data supplies[2]; /* * Last reading of the proximity status for each channel. * We only send an event to user space when this changes. @@ -873,6 +875,13 @@ static int sx9310_set_indio_dev_name(struct device *dev, return 0; } +static void sx9310_regulator_disable(void *_data) +{ + struct sx9310_data *data = _data; + + regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies); +} + static int sx9310_probe(struct i2c_client *client) { int ret; @@ -886,6 +895,8 @@ static int sx9310_probe(struct i2c_client *client) data = iio_priv(indio_dev); data->client = client; + data->supplies[0].supply = "vdd"; + data->supplies[1].supply = "svdd"; mutex_init(&data->mutex); init_completion(&data->completion); @@ -893,6 +904,21 @@ static int sx9310_probe(struct i2c_client *client) if (IS_ERR(data->regmap)) return PTR_ERR(data->regmap); + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), + data->supplies); + if (ret) + return ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies); + if (ret) + return ret; + /* Must wait for Tpor time after initial power up */ + usleep_range(1000, 1100); + + ret = devm_add_action_or_reset(dev, sx9310_regulator_disable, data); + if (ret) + return ret; + ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &data->whoami); if (ret) { dev_err(dev, "error in reading WHOAMI register: %d\n", ret);