From patchwork Fri Jul 31 16:48:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11695215 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 36E0F6C1 for ; Fri, 31 Jul 2020 16:49:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F94B21744 for ; Fri, 31 Jul 2020 16:49:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QE1/qz/Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733035AbgGaQtA (ORCPT ); Fri, 31 Jul 2020 12:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733021AbgGaQs7 (ORCPT ); Fri, 31 Jul 2020 12:48:59 -0400 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E52FEC061574 for ; Fri, 31 Jul 2020 09:48:58 -0700 (PDT) Received: by mail-io1-xd32.google.com with SMTP id t15so23358962iob.3 for ; Fri, 31 Jul 2020 09:48:58 -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=GsrH317o9ZXCzgzy3uVli3vBl/8VqU/V+NLgYgRn16Y=; b=QE1/qz/YlrUfA1R7HhCBY9mGH1JfX7uFKfSueFy09R1h0SAlO/7Ex7dmLiMeD1+U1G 8UTq/wnJwQ8moxqOLjOY9JlfLOUx3lU/TyxNp312R8ddsUq4n4kySIOngY7Z1N8n6O3y wgdJt5FzMtUAWYKzT35a+ImqlNM5SwiVsHK+I= 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=GsrH317o9ZXCzgzy3uVli3vBl/8VqU/V+NLgYgRn16Y=; b=J/ic2SpS0HIgIKTBFiWkHAqDAp+B536tYHj9c5Ih2yftHAJdSAByb51yRKUyjUC6VX dhdXuuu5bpLc6kzAFg2EKvY6/x3QMK9Amm9NjExs6qOnaLvF3D1ST10crl/dDR3TRXTD pU91K+bWA6s0wyDklkS8wRDtXTZoX1OCtV2Y09XuMhTYMvVEE3uPRSqZSBQdncSxXk6G Q4epuodjvywIpVOW20uu7CyYFwCY6Rddmg718PvUAWFhKxXybVDHsJ6yF23gOmWci3qi BBERSamA9mZQBDYgIvZk3hGY9lvBxsI1UKQVAFGPB3qwUT+8fQ4qRbudC61eyvznzDOC Hf4w== X-Gm-Message-State: AOAM530LOgaM7RHCX40EgJkU0Lo3CfMpTGSBt6rikt9IOaTeMSWsFJYw yHfDxBrhres+rs7GAouAryAgJA== X-Google-Smtp-Source: ABdhPJwCOKctFj27OG+BseqGcoNN+41qJ80MB7hgJ79QNm6A4cruPdZcGfMZd4MUPL5TpNJrdcEqOA== X-Received: by 2002:a6b:bb43:: with SMTP id l64mr4404849iof.191.1596214138272; Fri, 31 Jul 2020 09:48:58 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:48:57 -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 v3 01/15] dt-bindings: iio: Add bindings for sx9310 sensor Date: Fri, 31 Jul 2020 10:48:38 -0600 Message-Id: <20200731104555.v3.1.I0925046377211b8b6f06764857f03b4ab592bddb@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 Reviewed-by: Rob Herring --- Changes in v3: None Changes in v2: - Added #io-channel-cells as a required property .../iio/proximity/semtech,sx9310.yaml | 65 +++++++++++++++++++ 1 file changed, 65 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..5739074d3592fe --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml @@ -0,0 +1,65 @@ +# 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 + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + - "#io-channel-cells" + +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>; + #io-channel-cells = <1>; + }; + }; From patchwork Fri Jul 31 16:48:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11695245 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 B7A346C1 for ; Fri, 31 Jul 2020 16:50:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 962612245C for ; Fri, 31 Jul 2020 16:50:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="JvsYnhep" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733056AbgGaQtB (ORCPT ); Fri, 31 Jul 2020 12:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733038AbgGaQtA (ORCPT ); Fri, 31 Jul 2020 12:49:00 -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 F31EAC061757 for ; Fri, 31 Jul 2020 09:48:59 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id a5so17040286ioa.13 for ; Fri, 31 Jul 2020 09:48:59 -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=LKIkrCHSlHiP9mdXJyXq26+gaHuBbJcyBgDB2tSCq48=; b=JvsYnhepMo8clUVA18lJhr4hTYhJfVTICy3x7LxeeGnQ828Q2DcAqv112c6WGC2SZH Nv9YFqJzltINaUfe0BO/sI5IIZauyEbwW3coWSBth12Ly/MEO43K6WVi4sVJUb7H1EKP vInp6ezs7BVriRaGjStqg0gotWNOJboRVF9dM= 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=LKIkrCHSlHiP9mdXJyXq26+gaHuBbJcyBgDB2tSCq48=; b=a0ZxoJ8QxSImwYZtvu8c3tvt0ayHZClS6+6epVvs4SMYGZs+BQ5cU54jY8NdFB/Pol q/BTNwoWxFEbUv1kLRLRdTbx2TxgrYy2DFbvBDiuTeWP/NuX501TD4LBaORA0soRIuqQ 0JiyxDIJJ/2ojE+umeRC+VPUcpuue3Z+GgXuASNoqenV5ESJSDpSy84EiIRXqGsTxT+J KPMaCDifpaup9f2vrTTtdNP3C+zUEubMPI6TFFwL1yxbrMGmLi4wzJcUEqruf/k2SzBS izFRDnh0p6kNCTl/76P7aRxyZUzEGFS+0zSTSPI2gvrkQIFuyfWPdE7Z08stIDebtAaW qJKg== X-Gm-Message-State: AOAM5334pCj2cZW/NfEQANtecZbBjcnH9RlpQ/y3K1H859pw5Fvqz3o8 T2fYhA6fvd58qtLJMBGjYp8+7A== X-Google-Smtp-Source: ABdhPJzILU8L74+W7y1aIxlUn8Dgjx9+X4goYczjgnYtLKaQ+OCJJQIsdi3exXg9AMMT8emrFOs9LA== X-Received: by 2002:a6b:b555:: with SMTP id e82mr4383529iof.56.1596214139299; Fri, 31 Jul 2020 09:48:59 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:48:58 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Stephen Boyd , Andy Shevchenko , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 02/15] iio: sx9310: Update macros declarations Date: Fri, 31 Jul 2020 10:48:39 -0600 Message-Id: <20200731104555.v3.2.I30721195b2f20ec785715f7a2757930302a2a7e8@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 --- Changes in v3: None Changes in v2: None 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 Fri Jul 31 16:48:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11695243 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 675426C1 for ; Fri, 31 Jul 2020 16:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5065D2245C for ; Fri, 31 Jul 2020 16:50:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="GdIxWKBq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387592AbgGaQt6 (ORCPT ); Fri, 31 Jul 2020 12:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733045AbgGaQtB (ORCPT ); Fri, 31 Jul 2020 12:49:01 -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 DF1DAC061574 for ; Fri, 31 Jul 2020 09:49:00 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id z6so32339040iow.6 for ; Fri, 31 Jul 2020 09:49:00 -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=fYfRtRWNJl9Yn2hyI+uBsjOjqoFWT79cyClOPwpH2dg=; b=GdIxWKBq8Nx+RFYfACUl5CdLRHgJ6yNDGaMOR99XLu1RRGcn+vTrIQHXoXHfT+jB4M LKMiZicp1+wFftkxIX7jZ7mmdXgJS/u0/P9hH4kdlLf3bPzyjSdttsBlwv5U1gphcgEm ydtGzFYm7eWucSJ12u01u+mFTDkKbrkwA+cL8= 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=fYfRtRWNJl9Yn2hyI+uBsjOjqoFWT79cyClOPwpH2dg=; b=aQorRcKBC8KacmNhFY/oXMjUe1F9wssJXUqKrnqtrlEveifHuXplTV87ecpf6wYUih 738RysNXi+7IP4eT1KVf8xM7QuoUv3nEpxzHCgbwuB/SbvcoANH0HA56IUM7A+XQsK+h +LJP9Lgc1IQOi4XJj07Nw9mmdr4R9ttSXTxo//Ep/8gr1onoI0KLaExp/RNSpW4FRMxa 5x5GmZf4w6HED+EWw8GJjYUbWMtnsJ2iN2z54ahlKSn1NHymE1rHgNl10SEZBwtTFAGQ j74yDJoJA+xmH72j9BozsBWR4NdZsXucl8CMYCdg3fZOQD7Eb4HIbFhZV4+bKqQaPdH6 na4w== X-Gm-Message-State: AOAM532Td9WTx49xwoqL2Gobk/iATYriwIy4WIMCFtNm7zOLqH/vts5X QQrp2E85rpIUNzWEtF1fuRkqaQ== X-Google-Smtp-Source: ABdhPJzwwlzQZYE4CzsXOSXHfiJmZOY3GnLWv89mBk6yUE97mxpy9XhELrZ/P6leUhKFdeIKJCsR3w== X-Received: by 2002:a6b:f911:: with SMTP id j17mr4297683iog.96.1596214140314; Fri, 31 Jul 2020 09:49:00 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:48:59 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH v3 03/15] iio: sx9310: Fix irq handling Date: Fri, 31 Jul 2020 10:48:40 -0600 Message-Id: <20200731104555.v3.3.Idbfcd2e92d2fd89b6ed2e83211bd3e6c06852c33@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 Reviewed-by: Stephen Boyd --- Changes in v3: - Moved irq presence check down to lower methods Changes in v2: - Reordered error handling on sx9310_resume() drivers/iio/proximity/sx9310.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 07895d4b935d12..c7a27c21c20cd1 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -323,12 +323,18 @@ static int sx9310_put_event_channel(struct sx9310_data *data, int channel) static int sx9310_enable_irq(struct sx9310_data *data, unsigned int irq) { - return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, irq); + if (data->client->irq) + return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, + irq); + return 0; } static int sx9310_disable_irq(struct sx9310_data *data, unsigned int irq) { - return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, 0); + if (data->client->irq) + return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, + 0); + return 0; } static int sx9310_read_prox_data(struct sx9310_data *data, @@ -382,7 +388,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, 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 { @@ -1011,10 +1017,11 @@ static int __maybe_unused sx9310_resume(struct device *dev) out: mutex_unlock(&data->mutex); + if (ret) + return ret; enable_irq(data->client->irq); - - return ret; + return 0; } static const struct dev_pm_ops sx9310_pm_ops = { From patchwork Fri Jul 31 16:48:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11695241 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 14A9E722 for ; Fri, 31 Jul 2020 16:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDC542245C for ; Fri, 31 Jul 2020 16:49:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VDUylHw0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387556AbgGaQtt (ORCPT ); Fri, 31 Jul 2020 12:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733091AbgGaQtC (ORCPT ); Fri, 31 Jul 2020 12:49:02 -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 481B7C06179F for ; Fri, 31 Jul 2020 09:49:02 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id g19so20211596ioh.8 for ; Fri, 31 Jul 2020 09:49:02 -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=RgjKsJ/JPsYNKlD2x2wTWCtu2t/OkQtd2UQoMK7szBQ=; b=VDUylHw0pzeNeA046zmOyuq5ZQOKM31CadNiZObdUZTtHvoH9bEAKeuo16GU1elr/v UcvL3AY1CL26t9RCboBHSgPzIrgGIIZmUJU17QgLjQXEt6pDtS6fORMLnCJyRKevFmQo l0aFn8N7+fvQtNV5cKwQ7RjZFNWlMFE+YFFO8= 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=RgjKsJ/JPsYNKlD2x2wTWCtu2t/OkQtd2UQoMK7szBQ=; b=fHAGlrtFfKGwbJQ4c/SA9NxLuW3mIOYpDg6eKHrb1gGmM7uE0jZmjEOPQkaz5V4AAD 1cLNVJHTNF6vmMugxC+M9+KSXyxR9Y+lyEVMdE+r2uW9ytGPde8qQhWu/YU1iCGen19f NGKNpn9HkurEYU2ymtNsMVAPWwWN7oxPzV5TPo/rjVeadRmcOF49TTN0JXZqrqpwecGy EWQhj0J+12A2Cikjeablt0pfVwq+11CsRvI6cXrNvIIwEVel154S2YvFI5yrf52I7S9r wPDgipqnHpAM1lVT+gg5av6EnCH6+lsqgKronZ0ONE+2lWpaFCHWSqAwr4ZwncC4Yom+ fCog== X-Gm-Message-State: AOAM531cDE2qD5xPpCqCtmwkbvjCaJ5YkVxWMKmNZi8zrO0qBe7TzWKy pRJKvq/CMF0x9me2d9YkQVKwZA== X-Google-Smtp-Source: ABdhPJwnfDE5+ese/5K+QCB69TQqRvvsEKhyp1n82sHzcFfQReen0AyMP7MmyprjNCRebh6tTj2a4g== X-Received: by 2002:a6b:185:: with SMTP id 127mr4494397iob.153.1596214141677; Fri, 31 Jul 2020 09:49:01 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:01 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , kbuild test robot , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 04/15] iio: sx9310: Remove acpi and of table macros Date: Fri, 31 Jul 2020 10:48:41 -0600 Message-Id: <20200731104555.v3.4.I9bf713a86d6076b44441ef5f534f9c240271699a@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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. Reported-by: kbuild test robot Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko Reviewed-by: Stephen Boyd --- Changes in v3: None Changes in v2: - Added #include 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 c7a27c21c20cd1..66f7050d63ae97 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -15,8 +15,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -1052,8 +1052,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 Fri Jul 31 16:48:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11695219 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 2FCCC6C1 for ; Fri, 31 Jul 2020 16:49:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1205F22B42 for ; Fri, 31 Jul 2020 16:49:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jYHgiVLG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731565AbgGaQtI (ORCPT ); Fri, 31 Jul 2020 12:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733121AbgGaQtD (ORCPT ); Fri, 31 Jul 2020 12:49:03 -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 373ACC0617A1 for ; Fri, 31 Jul 2020 09:49:03 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id q75so24133540iod.1 for ; Fri, 31 Jul 2020 09:49:03 -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=V3XXXr/NVFbGCC1s552cmz/bn1PN5K8vbmeSX/RmmQA=; b=jYHgiVLGCivn2lpFjTjutITT5r7/YUbo907n+JTdEXyCb1Oi7qDGABbh+LqutCFSbe 5fxC//D/hHepp1hReEI1Nf89X0dMpGjgTSevMXhE+iChXZubvfni9nOCfIOOVfMQd27T 6h0FxaFlLhUyZDs/P0eAX0WuCl4P5sTHz5EqQ= 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=V3XXXr/NVFbGCC1s552cmz/bn1PN5K8vbmeSX/RmmQA=; b=nyq1D3Bj4G2vNoAh2NOdgy4uZE/hGW2BHSzG5f1WKovhX253j8Wbcl9VEO63WpBTXL SA1fNBhB/2qHV2XTmbouBmMffgAE9Ta7g1ThjRqSVruHi9k+0/hDZ8AOyciqOXrFyYuJ gG4/yv8tUEfmr9sTgYhwu3J2gMAhEkjXZQdikHRNxf9bhUco4Sv/aBNrIwyx91VxdI1U B8DF8y+DpvuZQ8rK2FQRNiG04Tgtu/Q6n7rMBW3u8yRqeZAFAzxfoMp+8LJFW24JY4rd 1fuEbOv8P7CMvuYOHZi+uCtdEOP9WIbBB9Kdu0mAJ2IGRTwNip8DG3gC3tOdqxI4VkZw /AKQ== X-Gm-Message-State: AOAM530GKrpDNLibx4heewEKRdVrq39Rm/V5ytyQuYabZcYvTXqx5hqw OFDei5JJgq3YYQ6FF39bw9apNA== X-Google-Smtp-Source: ABdhPJwMh/TdbR8qXBpIumlJzrxe6FttNGIgLCMSpknQ3wVnexGeXAtyJY4eUK8Q3sCnzSttkAEDww== X-Received: by 2002:a02:2445:: with SMTP id q5mr6101205jae.104.1596214142669; Fri, 31 Jul 2020 09:49:02 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:02 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 05/15] iio: sx9310: Change from .probe to .probe_new Date: Fri, 31 Jul 2020 10:48:42 -0600 Message-Id: <20200731104555.v3.5.Ieb5fdf7381764835dad0b3099c7b19ba754e4c47@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 --- Changes in v3: None Changes in v2: - Added '\n' to dev_err() drivers/iio/proximity/sx9310.c | 39 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 66f7050d63ae97..2ed062d01634bc 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -139,7 +139,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[] = { @@ -861,24 +861,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\n", whoami); return -ENODEV; + } switch (whoami) { case SX9310_WHOAMI_VALUE: @@ -888,15 +879,14 @@ 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; } 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; @@ -922,8 +912,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; @@ -1036,8 +1025,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); @@ -1056,7 +1045,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 Fri Jul 31 16:48:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11695221 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 4BD86138C for ; Fri, 31 Jul 2020 16:49:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 344AE22B42 for ; Fri, 31 Jul 2020 16:49:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DpaVc2FJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733209AbgGaQtI (ORCPT ); Fri, 31 Jul 2020 12:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733159AbgGaQtH (ORCPT ); Fri, 31 Jul 2020 12:49:07 -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 3B147C0617A4 for ; Fri, 31 Jul 2020 09:49:04 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id g19so20211689ioh.8 for ; Fri, 31 Jul 2020 09:49:04 -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=BwAReB8lsy+rPQCZhZhulAU/mezw6aB9DphpfGrKsXA=; b=DpaVc2FJN7Swl31cGGDdLNd4QDLtExtHQj252cOFmNyIqooLOWYJmFglNMOr6wFov0 hdwQ++5zCA9AFeX1zD2mTLGt40tD3a6xg06PXhvTAsxQU5Ki6UiIi30bKx/5NIkDvoGd nBj/Fn/ui2Uqj1BdkQbufjE+j2eWvjszcgkE0= 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=BwAReB8lsy+rPQCZhZhulAU/mezw6aB9DphpfGrKsXA=; b=Plb9/cyEMsdRB3LH0I1ji125X3+kdZr5J2LYPvXgKPsYkTUBUlWtPWA8lPkZaiGIty x0rcXTkwm35/btOMQcjdKT2I/Knenb75ExCE7hLIqT5SrG9irLoaNsyPlhnLCgmVBYiu kLm5EmC4KI70qWuKiRQ6K33K+6Pb5zJ33oxjW2DwfSI3mMJX2VQm9UxfzrCVDKR1YZN+ 1JW2NRZwZKCQzkehZ9TBDgmVnfHUOKEEaKCbvV6PgZnfIRlNL1wU93jypYQ0sB1+0She ABAF5r7AfyDlpQWOvP5PeV6I1U1KFm1kpIMi5EU/lGT6pveIft/QU8eLGiTrCL5u2LnY XyBw== X-Gm-Message-State: AOAM530kiQOGuUvIRjAYAVLiQhyjpG8iwEJ2KyFzsAVlpQ6FaFrnlRA7 h3SNgxh6z9fbsJ/TK9vaxTF/mWRprQZBIg== X-Google-Smtp-Source: ABdhPJwDqDNbJYF/O0QOkukZA9dNH0oHiP8mGGylbwTNtnTYzUmKbKgFMs8zTehITqBwiQHyYFCEzw== X-Received: by 2002:a5e:c607:: with SMTP id f7mr4364214iok.2.1596214143665; Fri, 31 Jul 2020 09:49:03 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:03 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH v3 06/15] iio: sx9310: Fixes various memory handling Date: Fri, 31 Jul 2020 10:48:43 -0600 Message-Id: <20200731104555.v3.6.I8accffd77d616cb55b29bc3021cb0f5e1da3b68a@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 Makes use __aligned(8) to ensure that the timestamp is correctly aligned when we call io_push_to_buffers_with_timestamp(). Also makes use of sizeof() for regmap_bulk_read instead of static value. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- Changes in v3: - Changed buffer to struct type to align timestamp memory properly. Changes in v2: - Fixed commit message from "iio: sx9310: Align memory" drivers/iio/proximity/sx9310.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 2ed062d01634bc..c46584b4817b4a 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -132,8 +132,11 @@ struct sx9310_data { */ bool prox_stat[SX9310_NUM_CHANNELS]; bool trigger_enabled; - __be16 buffer[SX9310_NUM_CHANNELS + - 4]; /* 64-bit data + 64-bit timestamp */ + /* Ensure correct alignment of timestamp when present. */ + struct { + __be16 channels[SX9310_NUM_CHANNELS]; + s64 ts __aligned(8); + } buffer; /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; struct completion completion; @@ -346,7 +349,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)); } /* @@ -697,10 +700,10 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) if (ret < 0) goto out; - data->buffer[i++] = val; + data->buffer.channels[i++] = val; } - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer.channels, pf->timestamp); out: From patchwork Fri Jul 31 16:48: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: 11695239 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 74AC46C1 for ; Fri, 31 Jul 2020 16:49:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56D362245C for ; Fri, 31 Jul 2020 16:49:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dElXqIE1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733174AbgGaQtl (ORCPT ); Fri, 31 Jul 2020 12:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733150AbgGaQtH (ORCPT ); Fri, 31 Jul 2020 12:49:07 -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 4464EC0617AA for ; Fri, 31 Jul 2020 09:49:05 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id s21so25855226ilk.5 for ; Fri, 31 Jul 2020 09:49:05 -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=6WJOpih10G5LrQiOZLhDb5AlSl69gNb0B6aytvleDjw=; b=dElXqIE1198tbm2UIWdhAIl/ERxxwPIyJ7q5XwpfIpZhs2AEfBIy8WVfSyzcBfZ9kT e1ToeJHPAI1L5NPtszeDLtix5iJtBVWvjb+vszBohkfZc22qkSppM61JM6iAVof+KCeX HQ8nBfSPJ0LFwevvBLTnaLPIBQIcaTVEsQUBk= 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=6WJOpih10G5LrQiOZLhDb5AlSl69gNb0B6aytvleDjw=; b=c9s/HxQPJ/s7LKLY1vPQ/ji0qwHZW0IRM1NrxDmr7Q3DmcBeVz99NL+ZBTfWePyTUM bFVrApyofIlsbLbMCTkAMSnw3nUp3MCMqyQGraLch3ZeCNLA+ozkX3UNR7/VVvGrvksn EqPf65yzEO6e5a2I23HscuzMlfzjXkVAKG4U18F9gMaRTR7jqIPufSPDgUca3M01A7KC V62kmnFHGIWt2rOf35JzSQGouSWk2n5zwZ5CPh/qqxTL14aUpa/hklmz9f4KZJdRM+ma cXOPQzPIcBvswhP+4wgBUiFbdRdyiVUtUG+otQiLAFnL8Hic10mVbAVnRCJWhsrMaKX0 Pslw== X-Gm-Message-State: AOAM530cqSkWtRq10bCqjikTlvQ7loJxY8/1U8M90/SXWfGFVm5ucu/M Wr07b3zbmryKlLAAQT9xS2zMDg== X-Google-Smtp-Source: ABdhPJwHvu5de9YhcaASuVrSsByGsU4noAiiti5+DOgk/iNUZwZf4MC4Cuc/93Nh8PAr1hSfEm3aCQ== X-Received: by 2002:a92:d24a:: with SMTP id v10mr4743833ilg.224.1596214144611; Fri, 31 Jul 2020 09:49:04 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:04 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH v3 07/15] iio: sx9310: Use long instead of int for channel bitmaps Date: Fri, 31 Jul 2020 10:48:44 -0600 Message-Id: <20200731104555.v3.7.Iecaa50e469918a385b3e5dab375e442540ea2ad4@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 Reviewed-by: Stephen Boyd --- Changes in v3: - Added static assert for number of channels. Changes in v2: - Changed prox_stat to chan_prox_stat bitmap. drivers/iio/proximity/sx9310.c | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index c46584b4817b4a..8f80a4c20ac05e 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -119,6 +119,7 @@ /* 4 hardware channels, as defined in STAT0: COMB, CS2, CS1 and CS0. */ #define SX9310_NUM_CHANNELS 4 +static_assert(SX9310_NUM_CHANNELS < BITS_PER_LONG); struct sx9310_data { /* Serialize access to registers and channel configuration */ @@ -130,7 +131,7 @@ struct sx9310_data { * Last reading of the proximity status for each channel. * We only send an event to user space when this changes. */ - bool prox_stat[SX9310_NUM_CHANNELS]; + unsigned long chan_prox_stat; bool trigger_enabled; /* Ensure correct alignment of timestamp when present. */ struct { @@ -140,7 +141,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; }; @@ -283,15 +285,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; } @@ -535,6 +538,7 @@ static void sx9310_push_events(struct iio_dev *indio_dev) unsigned int val, chan; struct sx9310_data *data = iio_priv(indio_dev); s64 timestamp = iio_get_time_ns(indio_dev); + unsigned long prox_changed; /* Read proximity state on all channels */ ret = regmap_read(data->regmap, SX9310_REG_STAT0, &val); @@ -543,24 +547,23 @@ static void sx9310_push_events(struct iio_dev *indio_dev) return; } - for (chan = 0; chan < SX9310_NUM_CHANNELS; chan++) { + /* + * Only iterate over channels with changes on proximity status that have + * events enabled. + */ + prox_changed = (data->chan_prox_stat ^ val) & data->chan_event; + + for_each_set_bit(chan, &prox_changed, SX9310_NUM_CHANNELS) { int dir; u64 ev; - bool 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; - dir = new_prox ? IIO_EV_DIR_FALLING : IIO_EV_DIR_RISING; + dir = val & BIT(chan) ? IIO_EV_DIR_FALLING : IIO_EV_DIR_RISING; ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, chan, IIO_EV_TYPE_THRESH, dir); iio_push_event(indio_dev, ev, timestamp); - data->prox_stat[chan] = new_prox; } + data->chan_prox_stat = val; } static irqreturn_t sx9310_irq_thread_handler(int irq, void *private) @@ -717,13 +720,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 Fri Jul 31 16:48: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: 11695223 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 8964C722 for ; Fri, 31 Jul 2020 16:49:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 712DB22B42 for ; Fri, 31 Jul 2020 16:49:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="UttcU3N3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733225AbgGaQtJ (ORCPT ); Fri, 31 Jul 2020 12:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733161AbgGaQtH (ORCPT ); Fri, 31 Jul 2020 12:49:07 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 345CEC06138D for ; Fri, 31 Jul 2020 09:49:06 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id l1so32262457ioh.5 for ; Fri, 31 Jul 2020 09:49:06 -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=XHCUU2RRnfaW/xOy0tUCXIP889dh0URjbsp/iA2xySI=; b=UttcU3N3nttvXlJ8qC5xBWXsvsAh+sqFPzkIM8khtexWu++q35V94rnwGyOB6FqUHG j9Lf5QLydvMp2UmbUpFunMQKamV/WyYDR/Jz1b8x++OcDmZf6VwOUbwJa/FyYFaUNq3B VeEKOEjEzFrX7+XJJJsqxSonhDjt08GNWPIIE= 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=XHCUU2RRnfaW/xOy0tUCXIP889dh0URjbsp/iA2xySI=; b=RvUkoPSVkX/exdge7js12kAFFE/glWZRAyt1FmwqbBnBB2oxVQP/Q3TJkHYXPUeNxi zBhUfUKlItlRhcrlaNAW9X+l8DCab392EUFcdUbY5ilPT6A39aMtlCCzA/rdpVXW+lOi LsAEqqstRrJe0rdrQ9M4SloX9iB3C9J/A2n6foaJhrsaID93/zYmZJOMWUQJjI9trIBg B67CFnloTjhmBIuI4CecF2fy1VFs5iot2D+yPbksgz9XPbbFdvUFlTgiRLErPWEk210U mooYdY8g/mL2MWhK8ECTO+AK9qIZUwIcxShdcVA8dVK7XABxjCTti6PTXH+cNLezklLG xSCg== X-Gm-Message-State: AOAM532/fcOjtni2FPbRtUIE14O8kmvIAI9GpdLoQxKBPjaoJSyqRyy4 XJtiXo7XH8RvuM+Mfr23EdCf0A== X-Google-Smtp-Source: ABdhPJzIMn/W3JE/0PZaHnMNnre5jGWm2flk0DVLrUPQfgEdwiQciGPBXUWRGcZXYBqJdEes/zE9pQ== X-Received: by 2002:a02:7092:: with SMTP id f140mr6145335jac.8.1596214145596; Fri, 31 Jul 2020 09:49:05 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:05 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH v3 08/15] iio: sx9310: Use regmap_read_poll_timeout() for compensation Date: Fri, 31 Jul 2020 10:48:45 -0600 Message-Id: <20200731104555.v3.8.Ia205f0b0363bf663db7704026b5b7036b9748c56@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 Reviewed-by: Stephen Boyd --- Changes in v3: None Changes in v2: - Fixed dev_err() message 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 8f80a4c20ac05e..9f6292cc86146d 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -802,7 +802,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; @@ -816,22 +816,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, + "initial compensation timed out: 0x%02x\n", + val); + return ret; } -out: regmap_write(data->regmap, SX9310_REG_PROX_CTRL0, ctrl0); return ret; } From patchwork Fri Jul 31 16:48: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: 11695237 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 1F6086C1 for ; Fri, 31 Jul 2020 16:49:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07B572245C for ; Fri, 31 Jul 2020 16:49:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YhRnLi0k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730924AbgGaQtl (ORCPT ); Fri, 31 Jul 2020 12:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733180AbgGaQtH (ORCPT ); Fri, 31 Jul 2020 12:49:07 -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 3756AC06174A for ; Fri, 31 Jul 2020 09:49:07 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id j8so19933435ioe.9 for ; Fri, 31 Jul 2020 09:49:07 -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=kJxFQ5dicx/XdfMjNZsxOmoMpHKnwMI2oZ1xqNHvk7E=; b=YhRnLi0kUNL57DqqpZqj7QSpzSWeeRK75/1uhIBZH91Ny2l1EJFxkbrqSLgfXnFW5C VmN2t+phogi/sdui2npf1W399a2tUvJNs/d/E63wIMD8LJIY30S14yJBGcvkj1XR8Kyd JOUA6dec9CQhMz17YnM2kRyMlmb5uCCQard9w= 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=kJxFQ5dicx/XdfMjNZsxOmoMpHKnwMI2oZ1xqNHvk7E=; b=FqHx/3J6eISyib+F8DqrGhpmlnh9LritWwmydNf0vxwojMs5E9T40HpwpPouGI4MrV AwfA7R+J2NbE7VnptjvsBzWRfl9EoRT3eGUrhII31o5HWX6LAHAkpCyFP6hWVg3TG2X+ /mJQyrtCffeqCDLfvJKjiqgJuSRsgTuU4SMHMKzLKD08P+G3m1TprE1LGLeA1mZVPiOE PHGFrO2wKEMfJCOefgYmW6Nqyh/8JUz2i0mi04TGa6PMtosza3H19Bd7gOAd071tcYch z12o45QJerW0/9BROG+73x3f0BbrGkV1jtJ0LzxbhhGwch1+o22IGov2gKEPv0gsfZfI K9bw== X-Gm-Message-State: AOAM531DOX/G5bkl8UoVxYKKFgvkAKOfRQ2FpbyTL7tueRYl4BmknWYN 7aAO4RQOH3sYrLiAGMrCbQRCTw== X-Google-Smtp-Source: ABdhPJxphulmJ4n52qeAfu6XFsVF+xiIHnLgNMg7tfM3ebQTH0fDaz1WZm5ZuRohQLMVb4GpcVK00g== X-Received: by 2002:a6b:b215:: with SMTP id b21mr4371808iof.43.1596214146567; Fri, 31 Jul 2020 09:49:06 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:06 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH v3 09/15] iio: sx9310: Update copyright Date: Fri, 31 Jul 2020 10:48:46 -0600 Message-Id: <20200731104555.v3.9.If88afce92bbc1e97a532874cca35e642a9566172@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 --- Changes in v3: None Changes in v2: None 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 9f6292cc86146d..19253bf335437f 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 Fri Jul 31 16:48: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: 11695235 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 766D56C1 for ; Fri, 31 Jul 2020 16:49:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58F4B2245C for ; Fri, 31 Jul 2020 16:49:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gEWnmQe7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387492AbgGaQtg (ORCPT ); Fri, 31 Jul 2020 12:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733187AbgGaQtI (ORCPT ); Fri, 31 Jul 2020 12:49:08 -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 532ABC061757 for ; Fri, 31 Jul 2020 09:49:08 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id p16so15080240ile.0 for ; Fri, 31 Jul 2020 09:49:08 -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=9w9pB2CjOHY+yup6n8wzlDoJJhA1rCPptIKU5FHpGEo=; b=gEWnmQe7rjthCJk8GA1v7h8cTvZX/sEW/wTZQX7N8780I34BCKNtrhuKepHWrxhl0+ /E73ykx2tsvzo7v6HX0botKEy/jES7qEviypLtVunSXM4mDk8L8gCoMe6EITHDWZy2SR X1hVf289rHI4iUlnVPC46EhNGuy7DJqlurKlU= 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=9w9pB2CjOHY+yup6n8wzlDoJJhA1rCPptIKU5FHpGEo=; b=CE7nfGkSjipQj1YJ06uX53T26vVbgfMAhUSvkJik2BVX0P7lUJo4nzNM6OFm0peX4z 4VaNbo5SYqSZQdz6QZ14rjU3aCZVcIzyhoUZH2dppBLYvClZZJ5qVbA5OgppYTLZVOL4 F7Objxmv2PN2bbaP0fM6/Ep6/8U/6JjgddSduwA/xqRImoE++BhcPobhgZ+KH0y7vQtd EMWhk011yPJqJsd1ifuoDfzjzTvFDtSYUmDV4iBruqIH0/wbRbuqBnCEe+xZFKywEVa9 K91y1TdWorsCFUQ7tJ7/gzMqfeCoeGOk0/oXRnNglthTeVS4mBhQA+16dHtdYnQW3hA1 EkxA== X-Gm-Message-State: AOAM532Hs1wFSYE+vIvglPgStgjBmcq4w4k8kmp9IzXSORXyFmpcdDfQ PpejHiAC6jhx2CsGkSaca/59dw== X-Google-Smtp-Source: ABdhPJxpq9+x+e73sxsuCB9ucnOk+c0/mQCpzGD9RAQ1se/DiTY+gLU0XGYUcdmhl0pdm06vsNgd8Q== X-Received: by 2002:a92:6a0e:: with SMTP id f14mr4495870ilc.55.1596214147687; Fri, 31 Jul 2020 09:49:07 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:07 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 10/15] iio: sx9310: Simplify error return handling Date: Fri, 31 Jul 2020 10:48:47 -0600 Message-Id: <20200731104555.v3.10.I071b118136317d3ff77fc598079f21e4ed0e347f@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 Reviewed-by: Stephen Boyd --- Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 56 +++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 19253bf335437f..6c5425c6fe0d03 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -349,7 +349,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)); @@ -365,7 +365,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) >> @@ -379,17 +379,17 @@ 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; ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) + if (ret) goto out_put_channel; mutex_unlock(&data->mutex); @@ -403,22 +403,22 @@ 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), (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) + if (ret) goto out_put_channel; ret = sx9310_put_read_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out; mutex_unlock(&data->mutex); @@ -440,7 +440,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) >> @@ -542,7 +542,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; } @@ -576,7 +576,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; } @@ -619,20 +619,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); } } @@ -671,7 +671,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; @@ -700,7 +700,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.channels[i++] = val; @@ -807,13 +807,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, @@ -839,21 +839,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; } @@ -907,14 +907,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)); @@ -926,7 +926,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) { @@ -935,7 +935,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 = @@ -957,7 +957,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 Fri Jul 31 16:48: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: 11695225 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 2A4F8722 for ; Fri, 31 Jul 2020 16:49:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E60A22B40 for ; Fri, 31 Jul 2020 16:49:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Cusy9I04" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733301AbgGaQtQ (ORCPT ); Fri, 31 Jul 2020 12:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733244AbgGaQtJ (ORCPT ); Fri, 31 Jul 2020 12:49:09 -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 8BE11C0617A0 for ; Fri, 31 Jul 2020 09:49:09 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id t15so23359554iob.3 for ; Fri, 31 Jul 2020 09:49:09 -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=KYy6g4g12hDeaNHzULjsE2Gx5xOjOf8JvHxpoCRhqgA=; b=Cusy9I04L3C4Pk0XG3iyhL5cF11kukZlfyMtPKvU2HLhhoSOhTi6Z/ma3n9SCUECbl kvIkhlG4ksTkmp7nF0iAKbcCNpRgs7vJG5V6fcNIPkd1xi714JOXaIiPXx9BccC5mK8u tfQH+HRiNWNMWWwIFzBFza/O3HHY4F88w+8y4= 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=KYy6g4g12hDeaNHzULjsE2Gx5xOjOf8JvHxpoCRhqgA=; b=HTw9jifRXSrbWHCdCc6MD8MabmqZWn/JIVZOz+SNHOujwOyuou/aQ0pNGyP9QtPv47 L+V1CnKOU6BUw9rp2Nq3ytjUVULAArc50b/hTqnb0hxiynUidkvWBqmOfmYs9ULo1or4 Gi4FJ/gsXYlSnqLDjex8fUFkMVvPH0x44GL+UUU6Ka82NCYMjhYSIog8vWlZgT7qb4Oc q3ujQ0BsSyq8ptIF5jStm6Ae5yQizSPwpJ5DtRlLe6zPz4Lb8pPZTOwvI0Oh6bINsbZ7 Aa+UDYyiTy6/3eSw7KllMgZyHoyMHM+EOwHiV3d6YntQSGO91Nxa+USWVuE2/9rLB5Wz gAnw== X-Gm-Message-State: AOAM532DwJ+DpLH3LXWBbq+eTWMGmxl/K+ntfswKAZJCzk0O/ATD8syl hmIpzHW8kXdX7LjUZt+B7X6iHQ== X-Google-Smtp-Source: ABdhPJyKO2BFy/coo6T6rN0z/NhnWlfECEuyb9vgR9Qvikn+kFWqE8MjhZFuMBGRZVN+udxu87y71A== X-Received: by 2002:a5d:8a0c:: with SMTP id w12mr4381030iod.63.1596214148903; Fri, 31 Jul 2020 09:49:08 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:08 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 11/15] iio: sx9310: Use variable to hold &client->dev Date: Fri, 31 Jul 2020 10:48:48 -0600 Message-Id: <20200731104555.v3.11.If9d9c0fe089e43ea2dbc7900b6d61cd05c66f1f7@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 --- Changes in v3: None Changes in v2: - Added '\n' to dev_err() 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 6c5425c6fe0d03..feb5bbff56f447 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -890,11 +890,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); @@ -908,17 +909,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\n", 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; @@ -930,7 +930,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, @@ -938,29 +938,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 Fri Jul 31 16:48: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: 11695233 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 409E26C1 for ; Fri, 31 Jul 2020 16:49:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24C0C2245C for ; Fri, 31 Jul 2020 16:49:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="h3WVPQbW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732481AbgGaQtc (ORCPT ); Fri, 31 Jul 2020 12:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733265AbgGaQtK (ORCPT ); Fri, 31 Jul 2020 12:49:10 -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 8187DC0617A4 for ; Fri, 31 Jul 2020 09:49:10 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id y18so17431540ilp.10 for ; Fri, 31 Jul 2020 09:49:10 -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=Szr8vQBgnAdo0uSkwLncHv5GwbPLp29uufMShZ6hrY8=; b=h3WVPQbWDO2tL7iYy0c9x3LpTrdgejBzOtb9gsZ+0AU7+ykxsuPOxCfCQHsaktDF19 pKl9KggxLqp+gtK+zh1mFrwEnQGiUqVD86DAt5Zb6e8t6sHRaz70brtvTjGzU1Vp1qGX nDDjNtgS6LjZhDC1+wDvcQwXSZJmniUHcPJuw= 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=Szr8vQBgnAdo0uSkwLncHv5GwbPLp29uufMShZ6hrY8=; b=hs4grK960xRGjLwvTq54r2mzEcghlkOexjN+VKrQ/0wWymOYfjiRyxT5dSZOX4eOff hB8DktAqanNdl1bsZklvJgfF0G8WahlA1zUMnFjz+RqcTNxFNZyD9AHmDf+gg72cWMha dp7Ja8Em3OKHAw61qITGVlKiCypQFbBfG5QWkSSDiqRSpAhrzmXr3rDjuLq3GNnYC57F b4YOR2ONC667REdFb6lUgH5rP0R3B+tToBeIUHjU9cBYyTynl2BJBTYrxzXglUKA9vQQ gDGaUQi8jUg0Zpl68t8gewXd9WhnRTre/WNhw7MkUuHxI6147ndjBsJoUfzMJbZ1rVUM Ut1w== X-Gm-Message-State: AOAM530x5znhVUtI0L89dCTKM0M/xu1R7lvWeS8Klh3CkKaLBRZE7XKQ ktT6xYsELYEdAYEbIVoQ0FOb/w== X-Google-Smtp-Source: ABdhPJxARm584a2Pu21/M80t5hqGw2IX3fki32xnNDV0znolrrpdJF9IdmAlVtr2dBnN2LIggfJfaw== X-Received: by 2002:a05:6e02:e87:: with SMTP id t7mr4757187ilj.4.1596214149878; Fri, 31 Jul 2020 09:49:09 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:09 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 12/15] iio: sx9310: Miscellaneous format fixes Date: Fri, 31 Jul 2020 10:48:49 -0600 Message-Id: <20200731104555.v3.12.I426355a035f0394dfccba5bb2bc6f8db872c4be3@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 --- Changes in v3: None Changes in v2: None 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 feb5bbff56f447..886fcbd52703c5 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -91,28 +91,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 @@ -411,7 +404,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); ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); if (ret) @@ -438,8 +431,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; @@ -524,10 +518,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; } @@ -644,7 +637,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 = { @@ -975,7 +968,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; @@ -1021,21 +1013,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 Fri Jul 31 16:48: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: 11695231 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 1CE66722 for ; Fri, 31 Jul 2020 16:49:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 015832245C for ; Fri, 31 Jul 2020 16:49:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="C+UdcSQ0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729944AbgGaQtc (ORCPT ); Fri, 31 Jul 2020 12:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733270AbgGaQtL (ORCPT ); Fri, 31 Jul 2020 12:49:11 -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 73999C0617A9 for ; Fri, 31 Jul 2020 09:49:11 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id a5so17040892ioa.13 for ; Fri, 31 Jul 2020 09:49:11 -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=zNO8JDVb/SFk+MZRQqz5iQK8yjAhcQOAAqpSPIcW0Ic=; b=C+UdcSQ0iy59AKiSH7cnKdOWjWflQPoNxLtMMYkz74eaK+aBTfCoFNCUH/f1m1HoY6 r+Jgcgg29/0TPKYe3rZJiTqbMrWU1H0MJn/wsYZX2PrjVP1dv/XokPV0BfD5Z56Ub8qk mzgQmXKBCWymJwXPDZJFs0upDNEoaulOSUfPU= 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=zNO8JDVb/SFk+MZRQqz5iQK8yjAhcQOAAqpSPIcW0Ic=; b=LutkatmnaslpP97cFZC5YSnyynbgQ1F3ornPHi5Ye52F1bJWq2OGLe1rHPyS4o/IEA 1DrZclGG6yy+IJGnHntnIESi13eXllKBh3NzB139Zxykjngs/ahsjz0CHmsrfN7d13MY JvwiWRJFH7Pp4FlcyQBQAs/IdibeqbgWB4p9d1QOHHrlfWqzXfW+zLD2soGMVVeYKpfS maJmymPFiU/O++17joR3M/c/zKZ7nisbf7qiaopkyEweyqMLkOhoL4Q0RPc7/EJyFyIG 3YgS+M2a5bBnDhK9EdKxpoJuzPZieAJZwxmMSiYZukC3ZCqM9EM3HpQjo9Eg52iNB3oI kYgw== X-Gm-Message-State: AOAM530scxBvGm8ieABzNa+vU+tB/pUGOCHxyHu5o2JlWp9BGECLX2/H 12VEc+S/FDunqB7+bx51tPKDiw== X-Google-Smtp-Source: ABdhPJyDHx/DoVZfetBIrsHM9jFPgEOZ4dOXkmAYl7/UibvQxkW79QxjrjhXFar/WE+tm5T1r0xFJQ== X-Received: by 2002:a05:6602:1587:: with SMTP id e7mr4442835iow.203.1596214150868; Fri, 31 Jul 2020 09:49:10 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:10 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Douglas Anderson , Daniel Campello , Andy Shevchenko , Enrico Granata , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 13/15] iio: sx9310: Drop channel_users[] Date: Fri, 31 Jul 2020 10:48:50 -0600 Message-Id: <20200731104555.v3.13.Ia5c5fdbdfff576ab5d034cde46c25cc66a4baf50@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 --- Changes in v3: None Changes in v2: None 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 886fcbd52703c5..aa21f6f1a58e3c 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -136,7 +136,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 Fri Jul 31 16:48: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: 11695229 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 46153722 for ; Fri, 31 Jul 2020 16:49:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BCD622B3F for ; Fri, 31 Jul 2020 16:49:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mauPgZkR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387455AbgGaQtX (ORCPT ); Fri, 31 Jul 2020 12:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732542AbgGaQtP (ORCPT ); Fri, 31 Jul 2020 12:49:15 -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 7CB7CC06138E for ; Fri, 31 Jul 2020 09:49:12 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id r12so25851487ilh.4 for ; Fri, 31 Jul 2020 09:49:12 -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=iPeLJC5RmTN6zDPmUvW9ZmlL+f5oIqstFwOQkWarKhY=; b=mauPgZkR3yYh8jMCKGBfhJgq+IYZTD+hGEW8hqlsiaoHIDa0vLMFwZe4WfYVuZomqY jtRGoYgexlntCTpWBbHsCfNbM/gtMxMzcby/7U7qFV4QHjFfBeLy1uS1nbHKtvPAcszc U2e+TmFMkQcSkVnL1xYWl+W/FGUXTZwaFp4OY= 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=iPeLJC5RmTN6zDPmUvW9ZmlL+f5oIqstFwOQkWarKhY=; b=cHu93NBJoy3nPQNeWTji9Y3pCn08Iz3H7NBNiZYsLO8JCQp3XNSsMWlFlSOHE98MxF +WDMfJdGqF5N8II00F8FskZl0eFH3928Ek9rHWsS+fhd73af4EFZfuSxhpEhMeLPQOak 3nl0p6804MWKeDea83/GG8ukN+ssdKCXMo4zw+TbEi+jeCb4FxSXeUiW9lIje5sGZdpm 70yNu5swAWJETvqVWnMfnn8wAT+DvbuYeWQBqJhgpJr0VrJLy9F9GW6AiInamgnwcplK ROVaQ/MBVWsrx2NAFt6EyFT27z0cMfSNfPIQ6EB3C3BmcoKBYK4eWtNVVXZcV8xA+4Sk 8R5A== X-Gm-Message-State: AOAM531SJDJXpScfck0DEbmVnB0AkOum1sTazDJIRaQZaat0k+ko3m6M 9HkJGuQHY4Bdy5OkY9FkexIn3A== X-Google-Smtp-Source: ABdhPJwKKkMUhHTHs8liqqiZEw6QbqKsR0VH1EETQ++13b9+/gCqkxAPhTie6BCSmDUT+IdW8uzOrQ== X-Received: by 2002:a92:8b51:: with SMTP id i78mr4391748ild.179.1596214151902; Fri, 31 Jul 2020 09:49:11 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:11 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Douglas Anderson , Daniel Campello , Andy Shevchenko , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 14/15] iio: sx9310: Enable vdd and svdd regulators at probe Date: Fri, 31 Jul 2020 10:48:51 -0600 Message-Id: <20200731104555.v3.14.Ib7bdc8340021d8515b430498fb6686eedf22c9f2@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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. Signed-off-by: Stephen Boyd Reviewed-by: Douglas Anderson Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- Changes in v3: None Changes in v2: None 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 aa21f6f1a58e3c..a20cd6a4dad729 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -120,6 +121,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. @@ -879,6 +881,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; @@ -892,6 +901,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); @@ -899,6 +910,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); From patchwork Fri Jul 31 16:48: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: 11695227 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 BFABF6C1 for ; Fri, 31 Jul 2020 16:49:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A82142245C for ; Fri, 31 Jul 2020 16:49:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kc0NekPM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732542AbgGaQtY (ORCPT ); Fri, 31 Jul 2020 12:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733284AbgGaQtP (ORCPT ); Fri, 31 Jul 2020 12:49:15 -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 667E3C061290 for ; Fri, 31 Jul 2020 09:49:13 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id x1so5549040ilp.7 for ; Fri, 31 Jul 2020 09:49: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=AU7itzG3fOE6KUAsG0umiG6Zq2Rv0f3naycGhvQ89PE=; b=kc0NekPMGwS8K5ELb4t/cdoHr1nkTenMQzPABWn1cr20jAKOBFHBDXblbGi6/jlMab VvSoBIhoIeTnIDM9vklyuvivHkIuYLqbId7OIn6jCXkdD4u5xyhzFQH0rZGF1GAkGGFH PBQrxlHmjdyXVhHklFI9m+Ls05bQCyarvnS7Y= 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=AU7itzG3fOE6KUAsG0umiG6Zq2Rv0f3naycGhvQ89PE=; b=GOuQ44pPa6B4yJ9KEr7jCQjVANwMMs8HUVOqhH/9YKe3pKGmkgtXawcA69jKvYuTX3 e5tJ/0IA6di30nr/4wP/EfMGxoxQmqRgdlMlnn0amqyj7klaAlc2fNSC3HQ8X2MaPorE fJq4aKWYMGKut52czhwCiZrQMl8QjnKu8RgZ3LcOzcGitJjA0REl7DPHcrZUy+TjNuPx cH2GR25typ1ofsqVFpIKPHl24dyi9m0fZUz13D8DWPNnHwSYMUAwT3BUpRtNHDYPTjMO r5SAAeiuMZzkk8gy6UB62OV7WEDEB2beJXwb/3Wy8l7BSbJcJYK0Sk1ne1B86oXmtvWV LROw== X-Gm-Message-State: AOAM530Qe5tBqW+on8gY9n14uUpnGighjAhPyNPkm7UPKh8xok6DS1wm znjsDqhc7c62KzJVyFnYSYkCGg== X-Google-Smtp-Source: ABdhPJxy4WksgY5qoSLQIw0LnwfLVyLP2ng0Hl+eFA1fDlDDKYKjg4LCq/zbc/IBIuRgoUPxRHLFUQ== X-Received: by 2002:a92:4a09:: with SMTP id m9mr4783559ilf.79.1596214152801; Fri, 31 Jul 2020 09:49:12 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:12 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Daniel Campello , Andy Shevchenko , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 15/15] iio: sx9310: Use irq trigger flags from firmware Date: Fri, 31 Jul 2020 10:48:52 -0600 Message-Id: <20200731104555.v3.15.I4c344a6793007001bbb3c1c08e96d3acf893b36b@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-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 We shouldn't need to set default irq trigger flags here as the firmware should have properly indicated the trigger type, i.e. level low, in the DT or ACPI tables. Signed-off-by: Stephen Boyd Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- Changes in v3: - Added irq trigger flags commit to the series. Changes in v2: None drivers/iio/proximity/sx9310.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index a20cd6a4dad729..c41fa7f6558e3f 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -951,7 +951,7 @@ static int sx9310_probe(struct i2c_client *client) ret = devm_request_threaded_irq(dev, client->irq, sx9310_irq_handler, sx9310_irq_thread_handler, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, + IRQF_ONESHOT, "sx9310_event", indio_dev); if (ret) return ret;