From patchwork Tue Jul 28 23:05:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690015 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 4A76214DD for ; Tue, 28 Jul 2020 23:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 335342177B for ; Tue, 28 Jul 2020 23:05:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SKhBdJvG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730024AbgG1XFk (ORCPT ); Tue, 28 Jul 2020 19:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729968AbgG1XFg (ORCPT ); Tue, 28 Jul 2020 19:05:36 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82DD7C061794 for ; Tue, 28 Jul 2020 16:05:35 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id c16so5930944ils.8 for ; Tue, 28 Jul 2020 16:05:35 -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=6UbKcDbB3X6w5o9gkXHnELQCPot6Q2IbpzB0zM07yDY=; b=SKhBdJvG0UM5JOyrKAx8HZBZddJMCkqyDbP5rFWuOh/S43s58G1ri0hLOPtNCLqrPV ++fRe2aA/JWneMi/STUwOySZemSZJ/m6SeCn6z0a4MREJk0vRhFRrSETGbLu8KOyiD9y mPfqhINQ0zjdVVnLVqGgevsmqdctmBLXod9PY= 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=6UbKcDbB3X6w5o9gkXHnELQCPot6Q2IbpzB0zM07yDY=; b=hhl77UpAE4aifJQEEjEF7+E3PMfK1Y7x45cokdWkVEGzaZQ02iiM7M033ta3JsMeZO 4pYJwoHaSTbSqnXP/W8LUX6R6gBo5CHb0rKtcW8yXpQkvDtEJWaKrmAZKOBoWbC2qJlL EAo0bR+uM/eFRBzrU8Mh0IIysv8tRZww8KA0w4zLzg+Ol/yJ27+4HL9sS8yukKfl8VGf X1hQzxxOMHNuHjb7oD4Y8nUFDjpHZqmBcieD04B1pfD9E+fpGPSSazVKm7oqY4JhkBPQ B7lmmLJN/aIrgW0Y1pCspktECXYUIWwCZIAjGhn1XAC/R6Ed1EQQxWKwVTM61Kp0F63e VjAQ== X-Gm-Message-State: AOAM533j4gpTgZQ0+egOUnKOUXq1AbaAWlzK01ArT8J5XAamrn8SAE/T k/uDWisi761A2rzRQD1kt6m3kg== X-Google-Smtp-Source: ABdhPJwPkaQmsiSi1gMOYFk0cbAYpLJiiPPRoPE7gOs4375sXdrF8EQ0ahxJWqNrYcscMnA2ZXD+nQ== X-Received: by 2002:a92:5f83:: with SMTP id i3mr22540021ill.251.1595977534814; Tue, 28 Jul 2020 16:05:34 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:34 -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 v2 01/14] dt-bindings: iio: Add bindings for sx9310 sensor Date: Tue, 28 Jul 2020 17:05:07 -0600 Message-Id: <20200728170317.v2.1.I0925046377211b8b6f06764857f03b4ab592bddb@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 --- 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 Tue Jul 28 23:05:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690045 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 A1DFD14DD for ; Tue, 28 Jul 2020 23:06:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D9C920829 for ; Tue, 28 Jul 2020 23:06:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nybQXuHE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730296AbgG1XGe (ORCPT ); Tue, 28 Jul 2020 19:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729974AbgG1XFg (ORCPT ); Tue, 28 Jul 2020 19:05:36 -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 7FB77C0619D6 for ; Tue, 28 Jul 2020 16:05:36 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id t18so17772465ilh.2 for ; Tue, 28 Jul 2020 16:05:36 -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=CHlkasNJ3mpK9suEh7YTJx+aXcFKhyEXr4ianS+4gGE=; b=nybQXuHEnNOyg3rwsBaU0NN12S1BRfih80VuVNeC+ap1IEN5Q2kKzZbIGd3O9zsryJ QVFMkzUWPYDY5cbD+XvAZOgmRXc8DrHi+bEbkPy2eDoAxxCBh88ArQObm1/anbxYg/1O 934rMCOzqz4E/VLzyAews2reKlI7DSs6raa+o= 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=CHlkasNJ3mpK9suEh7YTJx+aXcFKhyEXr4ianS+4gGE=; b=ozuQ3Yh8M5oafaExDxIBjl6gls7+xjRv/rPzzaYXp+x15FIq2zIL9Mdi/tC/ZjYaFX k+zsoNL3Kxs1TsgHvZn9GDKAcRtvgrC6pr+Gop2uJpzuySafssr9WXGSevKCk+HXua1c 3i6o0alnmYgUUednrBcbGPmWklLH3XvSqPs2Zl1Lh7bY4kIY4LoWibpEeu/1sAg9gOy6 5wIiCsWNMNFgHzonhpqHSoJQQ6+JWVrOQYQvXrPSr1UCkbSrqGN5i5oOiYhabWuL8dEu bi3CW8DkUCccXhCiehfhekR7EOmJ0/GRpw8DAdm3fpHv6LyugCn5sFERTDaq8cEhe98L CZRA== X-Gm-Message-State: AOAM531j4JlDPmq1jdoMa+2NVsJ6OFt97DCDlN4c/uzdq4e7xjCekTSR kG2PzAcsP+PHhv4sBOvaeaM1Wg== X-Google-Smtp-Source: ABdhPJyXsIb+F0H3JYvwadrJvZEGUtuy5z/sm0iUZ5VNAFlGTgELvkwBErIL+EnW+B76kspZ4a0K9A== X-Received: by 2002:a05:6e02:e05:: with SMTP id a5mr29074515ilk.92.1595977535779; Tue, 28 Jul 2020 16:05:35 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:35 -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 v2 02/14] iio: sx9310: Update macros declarations Date: Tue, 28 Jul 2020 17:05:08 -0600 Message-Id: <20200728170317.v2.2.I30721195b2f20ec785715f7a2757930302a2a7e8@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 Tue Jul 28 23:05:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690017 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 4BB791746 for ; Tue, 28 Jul 2020 23:05:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 343282083B for ; Tue, 28 Jul 2020 23:05:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TZWUiLVg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730045AbgG1XFl (ORCPT ); Tue, 28 Jul 2020 19:05:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729764AbgG1XFi (ORCPT ); Tue, 28 Jul 2020 19:05:38 -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 C1622C0619D8 for ; Tue, 28 Jul 2020 16:05:37 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id l17so7524325ilq.13 for ; Tue, 28 Jul 2020 16:05:37 -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=yB4ZXCGQ1JEGOfvNZP5XQymR9PIbmXgMQ7k1yBNC7+0=; b=TZWUiLVgdzBSVQ8ehHoWvxsFsvZOlwYh2RA995Xk0SeIB5lojUqfXW+jZP1U3n+GL2 Xk6KYQPdJ5DcwymB7zahDqTGP5gYuCp6GHTG/w7IwscCnQAKhrTt71EneVwZaS7j6s3b 13/gDZDeQhoqcejz1MLPILwrnjL9tieoKXsPs= 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=yB4ZXCGQ1JEGOfvNZP5XQymR9PIbmXgMQ7k1yBNC7+0=; b=JEIZXkWPTNa2OXQ9c2Bkds9isUV1noSxiYnJdeRIQZDOH19fBsBE8mIdYP2Iij7Tn9 7EJm7Civ4W/PkjPIToFGWf2QeXa6Y5aHvhTnh9KVt8nDdEqGQovdpK+UCyXBH3CfmRVa AziWdgaLw0AQF4u2XIWZN0RsEoXUPz/Zn7CRGWSQqvz3oQ9YfGX0kAbNRfTrQPInZkuB C/FJdQ7Y0rkit3QOY7sHMV86+lmdepRQjkEY4CK3LfXC6a0AD7WvsHA9bB8o2e47Dgbk im2bM7xESHe1rzqCncjmczC+lZkbYFeDchSrdNMYuG86lcbPPNGoMbR/TOBg/ng/rSlV lszg== X-Gm-Message-State: AOAM531SZpWduOIn6rWB/dXHgDqu9k4WO+PcwwJYCI1gPoMESMxyBzcb Cx98bApbzb61WZjglICtWhzM/Q== X-Google-Smtp-Source: ABdhPJxyqh6fZnwI/oBquEbPHEqKgLClPDF5XQaEKahEFm6sAgt/aLF0XyQguVSO3mWUe05YVJnOMg== X-Received: by 2002:a92:5f43:: with SMTP id t64mr4036524ilb.14.1595977536895; Tue, 28 Jul 2020 16:05:36 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:36 -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 v2 03/14] iio: sx9310: Fix irq handling Date: Tue, 28 Jul 2020 17:05:09 -0600 Message-Id: <20200728170317.v2.3.Idbfcd2e92d2fd89b6ed2e83211bd3e6c06852c33@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 --- Changes in v2: - Reordered error handling on sx9310_resume() drivers/iio/proximity/sx9310.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 07895d4b935d12..108d82ba81146e 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -376,13 +376,15 @@ static int sx9310_read_proximity(struct sx9310_data *data, if (ret < 0) goto out; - ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) - goto out_put_channel; + if (data->client->irq) { + ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); + if (ret) + goto out_put_channel; + } mutex_unlock(&data->mutex); - if (data->client->irq > 0) { + if (data->client->irq) { ret = wait_for_completion_interruptible(&data->completion); reinit_completion(&data->completion); } else { @@ -401,9 +403,11 @@ static int sx9310_read_proximity(struct sx9310_data *data, *val = sign_extend32(be16_to_cpu(rawval), (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); - ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) - goto out_put_channel; + if (data->client->irq) { + ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); + if (ret) + goto out_put_channel; + } ret = sx9310_put_read_channel(data, chan->channel); if (ret < 0) @@ -414,7 +418,8 @@ static int sx9310_read_proximity(struct sx9310_data *data, return IIO_VAL_INT; out_disable_irq: - sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); + if (data->client->irq) + sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); out_put_channel: sx9310_put_read_channel(data, chan->channel); out: @@ -1011,10 +1016,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 Tue Jul 28 23:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690039 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 DEB4B1746 for ; Tue, 28 Jul 2020 23:06:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6DCC20829 for ; Tue, 28 Jul 2020 23:06:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="BarEV0ov" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730079AbgG1XFm (ORCPT ); Tue, 28 Jul 2020 19:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730033AbgG1XFk (ORCPT ); Tue, 28 Jul 2020 19:05:40 -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 A67C2C0619DB for ; Tue, 28 Jul 2020 16:05:38 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id e64so22542508iof.12 for ; Tue, 28 Jul 2020 16:05:38 -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=Ckdl4rRSej+TpSQNUfdzpqHgfB1W1nhYEbGg+nzFza8=; b=BarEV0ovrLCUh0MdcCNuv9Iya/tsHqfYXc1+zb7Pr+Rgdv9Sr9OxrYmLSvCrGEC+an /huzljzKU+yIifhVNdt6i4SdeCPwgHzSMJ/52KURRXP11KIEgFhJ+DWKU/hCoANgTd5G yZgNmU9zkD2Ov5Vnw4m5O6ugjPKQekbh5sLH0= 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=Ckdl4rRSej+TpSQNUfdzpqHgfB1W1nhYEbGg+nzFza8=; b=e/z3PtIQJbQzsX735ePiRUrwrPxYJWdXRVp0y8dqo5VVZpWLLC7R9M3yQVfkOiJq9J eDJsuEqZ1wVbTiHQK9YiAA/9j4su2HLQcNfAjDGTO7cjQo6ItY6ZX9Vhzn21HBROGqZ9 8tPLmqVjThGxu3sC+KPFB7QdYLdiSkxGcRNTeRqohaE1N+s53eBzSokiUAoe1jns9qmx 0Was+CO0uSzHvpvRfF+C83a9D8vwif6YV8JLZJKQaWgNYlNHbMjg/9ptqqlFNb9Fxt9/ zLMCRKUHre7vp6jIBnMGjq+t/BNUKrmoJart6erM/3YsgOhd6sJpmUiRPe3HMW9n9ZzG wPLQ== X-Gm-Message-State: AOAM5334DsewZfQcQ8jsCd3n/iA/EkKUNRexSLtWtYdM+gIMeu9KuINk n1HLKyk2ydlF6p158xpPrTXR9A== X-Google-Smtp-Source: ABdhPJzGSH1oEOQzZQiA6n/X77Umratilf3Tp30+qtl4G3Ep3KRfzTXFX9YiySzRFD4aKYorhSkqcA== X-Received: by 2002:a05:6602:29c9:: with SMTP id z9mr30956817ioq.4.1595977538023; Tue, 28 Jul 2020 16:05:38 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:37 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , kbuild test robot , Andy Shevchenko , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH v2 04/14] iio: sx9310: Remove acpi and of table macros Date: Tue, 28 Jul 2020 17:05:10 -0600 Message-Id: <20200728170317.v2.4.I9bf713a86d6076b44441ef5f534f9c240271699a@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 108d82ba81146e..04b646ae8a1009 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 @@ -1051,8 +1051,8 @@ MODULE_DEVICE_TABLE(i2c, sx9310_id); static struct i2c_driver sx9310_driver = { .driver = { .name = "sx9310", - .acpi_match_table = ACPI_PTR(sx9310_acpi_match), - .of_match_table = of_match_ptr(sx9310_of_match), + .acpi_match_table = sx9310_acpi_match, + .of_match_table = sx9310_of_match, .pm = &sx9310_pm_ops, }, .probe = sx9310_probe, From patchwork Tue Jul 28 23:05:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690043 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 C33E6138A for ; Tue, 28 Jul 2020 23:06:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA90520A8B for ; Tue, 28 Jul 2020 23:06:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TKT5aUTJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730005AbgG1XGd (ORCPT ); Tue, 28 Jul 2020 19:06:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbgG1XFj (ORCPT ); Tue, 28 Jul 2020 19:05:39 -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 AB275C0619DD for ; Tue, 28 Jul 2020 16:05:39 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id q75so14421360iod.1 for ; Tue, 28 Jul 2020 16:05:39 -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=rFwKpOolil2cigK/Fi3S/MPo2NhowXWtQj+GOyuNS/c=; b=TKT5aUTJuFr6UoNYj4eTsHJGVckWaAjBanjyOyARCuOJnTfFVXPP4wufGorg5KdMu3 xGt6iqRvYVZAu/0e9aXOA0caHT8zPr4guxMP9L0qULqwu8I9qgmnTXMhvVE0h3jAC74K FJUvG+4VEXa3IR2FXFifykWWs28pVkTdavucw= 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=rFwKpOolil2cigK/Fi3S/MPo2NhowXWtQj+GOyuNS/c=; b=CYsxUJljB4C7Nh6wKvM4mF748rq1Arv8/8S4b87JU3IcuqAr4qaY8vRO/ffxL5zeKH K8OGW2BJz/ohB6rlE2Sw1dVkhcxu+tMG5adlFVySVlsr0g+jWEwQsJjLdPOh5TWUJshW 1w7qJe1A8ADWDY0hm+cl8C9umzPh+0QJ59icQ7hmKeuVlN5CvHWtYm/+KXfERjec95hH JyS5eTKeTQZ6CnnRoOS3orXiDUg6QHjBC9vBdWRUy8jwV1WhVcZk3FIY2eZP+7+ThU9d MFPcJlFjSQ22jx7cWHN6raOeAnQSEpeZ1JvWWKqriEfu8YkxJVUZKlrehKbjF7QISvLU pnYQ== X-Gm-Message-State: AOAM530VRBhXYW6iUFadSW8mmK0rRzg+xUo+hZV9H3/tzANwH8tARb4z q1q6PyOw7a1ofNIFdrUz9NPpeQ== X-Google-Smtp-Source: ABdhPJw3oJB71OoukounwSSpOZX9IysvOrjvnrfFdWaactsDXxmWmMqPd90CoQ6uWvd+N+teRdhMPw== X-Received: by 2002:a5d:9b86:: with SMTP id r6mr11454618iom.44.1595977539055; Tue, 28 Jul 2020 16:05:39 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:38 -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 v2 05/14] iio: sx9310: Change from .probe to .probe_new Date: Tue, 28 Jul 2020 17:05:11 -0600 Message-Id: <20200728170317.v2.5.Ieb5fdf7381764835dad0b3099c7b19ba754e4c47@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 04b646ae8a1009..bb007673f758d5 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[] = { @@ -860,24 +860,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: @@ -887,15 +878,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; @@ -921,8 +911,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; @@ -1035,8 +1024,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); @@ -1055,7 +1044,7 @@ static struct i2c_driver sx9310_driver = { .of_match_table = sx9310_of_match, .pm = &sx9310_pm_ops, }, - .probe = sx9310_probe, + .probe_new = sx9310_probe, .id_table = sx9310_id, }; module_i2c_driver(sx9310_driver); From patchwork Tue Jul 28 23:05:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690041 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 DC136138A for ; Tue, 28 Jul 2020 23:06:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4CD720829 for ; Tue, 28 Jul 2020 23:06:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="e8ovD5nr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730399AbgG1XGW (ORCPT ); Tue, 28 Jul 2020 19:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730041AbgG1XFk (ORCPT ); Tue, 28 Jul 2020 19:05:40 -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 A3755C0619D2 for ; Tue, 28 Jul 2020 16:05:40 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id i138so11814019ild.9 for ; Tue, 28 Jul 2020 16:05:40 -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=Nao6Sg98gC9dnjx3GEZXAl5nG7UIQ3Jxef2Bqt6ZzNA=; b=e8ovD5nrAw0AQrEDf9TwEgeiTLsCgrXKE5Ekm1aC8Awgru6PH0WKivHuShFoekmMu/ qr7V69nKAd4jLRDoypN2UneXhquWBepj2r1Qbkiy5ZdB6GOWPztLWa5nLvnLErk93K7D /FpDoxLelPIAedCwUr6BUZjQ4DMJ8WqwET9Dk= 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=Nao6Sg98gC9dnjx3GEZXAl5nG7UIQ3Jxef2Bqt6ZzNA=; b=DM6A33bJi2ukxRK/wNiTsAaXgEF6rBjQNuSnzQrcFf00GMcmbOD0VKmcEfXTgA2w9L I6CqayMAHacgOFOeCKQwQYlAC59yMUf08/5SP6VB3g5xkIPvY/GEe+t4b4LmLG85QUyf eg4ZsxsKddP+v3YExI24E0X9vXLF28qKoVleawRw20ZCyJv9NNSBjf+79R1+1vxIiNhf 1izAqJZDfePCVwNw8IVqaCQqUVxEM1rVBoKFwOQtImK+++jIiaA2/rE8fa1fWA7uNwo/ kV6c8mBZGFXoPca9ShH4Rhg/p2pPm9pB6jtNTsMirM9RixBXWdH9x/5LtoQruoVlPskU TEjg== X-Gm-Message-State: AOAM5303sjVJpdJArD/TgLrBSPLccSgGQbbh6/T8vk/sb4h7S2bOTQlN NjLZjFZX427ekOwzecTbhz5ksA== X-Google-Smtp-Source: ABdhPJyhLQiF4TVfnU30f3gpZuJ7l3ktbNkM+nWpgbh48zg3EVccqyu593QJwQZsJaHqAr6usPUyFg== X-Received: by 2002:a92:89da:: with SMTP id w87mr31763124ilk.236.1595977540032; Tue, 28 Jul 2020 16:05:40 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:39 -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 v2 06/14] iio: sx9310: Fixes various memory handling Date: Tue, 28 Jul 2020 17:05:12 -0600 Message-Id: <20200728170317.v2.6.I8accffd77d616cb55b29bc3021cb0f5e1da3b68a@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 --- Changes in v2: - Fixed commit message from "iio: sx9310: Align memory" 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 bb007673f758d5..75e85dcd6b3572 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -132,8 +132,8 @@ struct sx9310_data { */ bool prox_stat[SX9310_NUM_CHANNELS]; bool trigger_enabled; - __be16 buffer[SX9310_NUM_CHANNELS + - 4]; /* 64-bit data + 64-bit timestamp */ + /* 64-bit data + 64-bit timestamp buffer */ + __be16 buffer[SX9310_NUM_CHANNELS + 4] __aligned(8); /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; struct completion completion; @@ -340,7 +340,7 @@ static int sx9310_read_prox_data(struct sx9310_data *data, if (ret < 0) return ret; - return regmap_bulk_read(data->regmap, chan->address, val, 2); + return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val)); } /* From patchwork Tue Jul 28 23:05:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690019 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 ED86F1866 for ; Tue, 28 Jul 2020 23:05:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D66C720FC3 for ; Tue, 28 Jul 2020 23:05:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="NTvfTyzn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730115AbgG1XFn (ORCPT ); Tue, 28 Jul 2020 19:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730000AbgG1XFm (ORCPT ); Tue, 28 Jul 2020 19:05:42 -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 B0860C0619D7 for ; Tue, 28 Jul 2020 16:05:41 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id s21so17726728ilk.5 for ; Tue, 28 Jul 2020 16:05:41 -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=gkkN8dF77jbtS1vGZLg4Ft5o79OhcUacy/9BY4ij43c=; b=NTvfTyzn7yuKQsRu+f7oAnUCXZpGhRZoRB8qVTDQ/mZKTT+vPW9C2/Lj+5IFQ2V4rg aYTP6Z8ptRYcmAr9TYp8O0GRLE/GtHf3gac+lJrvk+yRNqCQn+Igx33pR43WqXzcD8zK 1zZe6AKgSfAXY/6EV4quJ2vUp5PvlVu7v+j+c= 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=gkkN8dF77jbtS1vGZLg4Ft5o79OhcUacy/9BY4ij43c=; b=bX43EWT+nuP0kxaDZEzjjdKdWBnfw1lF+0VscTq6A25ldyfZpuFClxRLQ8gOKc4y4Z 0tvK0hKM2AyhfA369RZVoOxERz1JCnpJSYJPUlBDCYxN1X1jyB4cLoda4PmJwNE/E8yY fjaCp6P+RkS4/mWsT69aCg21vPIu08Ct0CORNjpx5LXE6kp0AAvvhyxSVRJxzsQIiHs/ kKobPvzD3rYmimO/nLIhe2MTgh0cBAeKm3SMAO/YMFpqjjJWTxcmjmUw69uo8XXTHVXr +IFeyv1ADPeWQBjovQXk0cv5yRt4DbzqbunM+KqsOtqBkUroA0/0hgZ78D7coL1hO6U9 jqzA== X-Gm-Message-State: AOAM533aiQPDiI8w9TDdYNhpLZYOl0wX4FYpebPcnAV9NQ6WeB6MYVwX FccclbC//7y88PPIc26dXLO+jg== X-Google-Smtp-Source: ABdhPJwwBMw63Gwfsa7f0tG7V0aLbZBvOtdOhKVf5J+4ahjDGSafaGuy9o2zXCfMrynNvGfNx53k/Q== X-Received: by 2002:a92:2c10:: with SMTP id t16mr519626ile.24.1595977541097; Tue, 28 Jul 2020 16:05:41 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:40 -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 v2 07/14] iio: sx9310: Use long instead of int for channel bitmaps Date: Tue, 28 Jul 2020 17:05:13 -0600 Message-Id: <20200728170317.v2.7.Iecaa50e469918a385b3e5dab375e442540ea2ad4@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 --- Changes in v2: - Changed prox_stat to chan_prox_stat bitmap. drivers/iio/proximity/sx9310.c | 38 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 75e85dcd6b3572..1f04ab8507ec62 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -130,14 +130,15 @@ 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; /* 64-bit data + 64-bit timestamp buffer */ __be16 buffer[SX9310_NUM_CHANNELS + 4] __aligned(8); /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; struct completion completion; - unsigned int chan_read, chan_event; + unsigned long chan_read; + unsigned long chan_event; int channel_users[SX9310_NUM_CHANNELS]; unsigned int whoami; }; @@ -280,15 +281,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; } @@ -531,6 +533,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); @@ -539,24 +542,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) @@ -713,13 +715,13 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) static int sx9310_buffer_preenable(struct iio_dev *indio_dev) { struct sx9310_data *data = iio_priv(indio_dev); - unsigned int channels = 0; + unsigned long channels = 0; int bit, ret; mutex_lock(&data->mutex); for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) - channels |= BIT(indio_dev->channels[bit].channel); + __set_bit(indio_dev->channels[bit].channel, &channels); ret = sx9310_update_chan_en(data, channels, data->chan_event); mutex_unlock(&data->mutex); From patchwork Tue Jul 28 23:05:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690037 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 4D42B14DD for ; Tue, 28 Jul 2020 23:06:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35CA022BF3 for ; Tue, 28 Jul 2020 23:06:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KPZo9svr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730343AbgG1XGK (ORCPT ); Tue, 28 Jul 2020 19:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730099AbgG1XFm (ORCPT ); Tue, 28 Jul 2020 19:05:42 -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 A5B3FC0619D2 for ; Tue, 28 Jul 2020 16:05:42 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id z6so22615787iow.6 for ; Tue, 28 Jul 2020 16:05:42 -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=FEp/fFZW3elYu/pkDqjjA8tnLGEpyOC07ATo4jnbF9E=; b=KPZo9svrCrF01OxSNs6N5NzjDuZ7FBBnO9f4haOpB217QwgRevg0gt2MOZkS0vRfj6 iLt4hp6oLWtWdsWvW6kl7sA/4ipmjWov6aUAdtsq71ImxFeVFpZ6ekI26zgTxOoxLguq tjDJZlLLElS6D+a8F7xmt6UA7m3DMZtGeKgrU= 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=FEp/fFZW3elYu/pkDqjjA8tnLGEpyOC07ATo4jnbF9E=; b=bRXbC+vEjT1kMgbpJJHyFXXxuz6WYd6jFyE+VzuUZr9M+roGsmO+68JIS6t28OOTGK aoz8bd2XSDf1U3piu0/Nbrg5FSGpyfX0k9lm+k3vhel+/G1ZlmcIPWMh+tW7IkY3QvR1 Tq449bEvmL9ssqcxyP+nsKTzJQaNFLsCOvd3Jwxj/dOv67egYqI9kQfveH1dnWQExVqy Br1IeoQNT2A2sbcKr023EE4Z+i723Y8YqRflQlscsf8BpfSwMq93KatUqDT1vm6R7M6j T7jnOcBr8skRrdOUbGy84kAWB1LT8MHj8B4r/+A1mbxYP62zPjGTBw8ufFVbeLPr4UvD ENZQ== X-Gm-Message-State: AOAM5326e8XyC5YRRDEHCKuw6agyc11Xk3BTYQw1AJs/2MZn2snipT3i JvTYA36QqSAzeKqzz935hM+piA== X-Google-Smtp-Source: ABdhPJzy6X8ljGgWHEzVs0tHQaZilHQa742vHtg+q7KpkQiDkfzP8YGqJgfrfk2qFkCRtq2aSNLGnA== X-Received: by 2002:a6b:b748:: with SMTP id h69mr21738721iof.47.1595977542085; Tue, 28 Jul 2020 16:05:42 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:41 -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 v2 08/14] iio: sx9310: Use regmap_read_poll_timeout() for compensation Date: Tue, 28 Jul 2020 17:05:14 -0600 Message-Id: <20200728170317.v2.8.Ia205f0b0363bf663db7704026b5b7036b9748c56@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 --- 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 1f04ab8507ec62..f7f44fd9198499 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -797,7 +797,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; @@ -811,22 +811,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 Tue Jul 28 23:05:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690033 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 A4BFF138A for ; Tue, 28 Jul 2020 23:06:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CAD620829 for ; Tue, 28 Jul 2020 23:06:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DydXMiSr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730134AbgG1XFp (ORCPT ); Tue, 28 Jul 2020 19:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730110AbgG1XFn (ORCPT ); Tue, 28 Jul 2020 19:05:43 -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 A26F9C0619D5 for ; Tue, 28 Jul 2020 16:05:43 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id d18so22598225ion.0 for ; Tue, 28 Jul 2020 16:05:43 -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=8zrnzrCoKEWeE81dCToZoirYnah7fEgy4EeGaV1goVo=; b=DydXMiSrRsEIeUU7miQpFxxAjAhV7X+y3RskPpI3JZmndgPZPIdWf7BCTgEI6q3lFt Bpy+FSqb9bO5fOKtU/pA2yKz4dqJzjR8B913BA/9DzP3wTazmT28Wn6CNVmC95HiQPmg 70z+S9Xc0UcLL0BkhBfp8ABEELu7YQQkGX4iQ= 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=8zrnzrCoKEWeE81dCToZoirYnah7fEgy4EeGaV1goVo=; b=FBGMFNkgyJc+c+HBBFJ9McRlTffxoDuTWLiIHayG/aN7WS5EoXi8tmTtWjWRHP0zQy YBHdXDjICRw5/apFSukgf7qkYgC6LAXQM9eZNE4Hb1l/60U09Vkunziftn1wMwXmttME giSK+19YONgJNFAgbY+8hnBut+oa5zxLcamGL6cFna8y1+phKCiu0Vhcdqcixw2m2pt8 mYh+Jwf17VlFpQcrH3/AS5YH+wjgnFP+jkKJXqSstU/8Qkb99wVupHGdhn3vw+I0VZIy Y3JkqHNwmG9l20HwA7WS5tluSm3IWzA9mnQ/rwfOeDF3s+fvR9gDd+0RJ99Ax/3op1cB iKcg== X-Gm-Message-State: AOAM533PlOejeLnn3+IIDMJOTinm1pfNCWUngEFoF+TStKyTh99fsac4 R2V2ftjFFemkwy8Illw5G3TN1w== X-Google-Smtp-Source: ABdhPJyDvvNtb/jr2igDgSMFVbx6LJsI+vkgKiFAJh+OY/eCw9W1sc3ojZq633se1q8uIBVpYwjIaQ== X-Received: by 2002:a02:ca1a:: with SMTP id i26mr31673302jak.20.1595977543089; Tue, 28 Jul 2020 16:05:43 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:42 -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 v2 09/14] iio: sx9310: Update copyright Date: Tue, 28 Jul 2020 17:05:15 -0600 Message-Id: <20200728170317.v2.9.If88afce92bbc1e97a532874cca35e642a9566172@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 f7f44fd9198499..964fae90fefc25 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright 2018 Google LLC. + * Copyright 2020 Google LLC. * * Driver for Semtech's SX9310/SX9311 capacitive proximity/button solution. * Based on SX9500 driver and Semtech driver using the input framework * . - * Reworked April 2019 by Evan Green - * and January 2020 by Daniel Campello + * Reworked in April 2019 by Evan Green + * and in January 2020 by Daniel Campello . */ #include From patchwork Tue Jul 28 23:05:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690023 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 A548E1746 for ; Tue, 28 Jul 2020 23:05:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 884B92083E for ; Tue, 28 Jul 2020 23:05:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XIN03hww" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730149AbgG1XFq (ORCPT ); Tue, 28 Jul 2020 19:05:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730130AbgG1XFp (ORCPT ); Tue, 28 Jul 2020 19:05:45 -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 CB300C0619D2 for ; Tue, 28 Jul 2020 16:05:44 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id l1so22554326ioh.5 for ; Tue, 28 Jul 2020 16:05:44 -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=w9NYXEErfPlhUgTVpphUm6AV/grBnexP1fodtrhxNXw=; b=XIN03hwwvE69sJDFLKE1l1w88A9pUCi5GPv807heBJI0WEPBh1HhZZZlDj58prVFfx duK57zkihtaLHvS9WOu9I1gjC85IiIEbNBwX4/dxkmp/e0q5fmZ0wf+mxw5v/D93XXLo t88w7qsMaKOu+JT5E1k/hqUMNRBvQWNKDl7ds= 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=w9NYXEErfPlhUgTVpphUm6AV/grBnexP1fodtrhxNXw=; b=dX9lFM38FSnF8ZvujJ+u4t3GiDt7hf8rcw85P6/oPRMhd5PAOiEGYeDWdgzAV1WgfI 7JrDKrEWC9CbBQfZ8UNayLXJT1TMSGjfrQUN9YRJHaP01ckGfDpcB2ZEjqon8CwoDesE 05zMsNzsg32OqIeMOuchVUrX3E0Y5anshSyp4L9hYl6i2aftpv4rdGvZUPzhzl8bV63W X8NAdLw5bPb9HVkdJYCcwSVCBldxGM5UuRNghu+UAYbHgJGFWeGVarSaiLdd5FcInKLu GYgRnLEbU/UgtFhhyOkfQBgNrsWqPy3/ZUOS1Ve8+nu+U8RNshdS4veB5cAhQt2baI+u f/hQ== X-Gm-Message-State: AOAM533+A/lISwiJwk+d4RRLD1cSajQBD+BggnazJJ12FQ7akPM16lug NOQ8QwHX956RC5oPSPQUJS3Fly/JWadPfQ== X-Google-Smtp-Source: ABdhPJxEN2nczGNxV19TkDGq7QzPu0aAo8UERqBuaHBzN3yS9BhqFA05M8Xc04vq5wkVGkWcCRC4Ww== X-Received: by 2002:a02:9a05:: with SMTP id b5mr5000537jal.123.1595977544172; Tue, 28 Jul 2020 16:05:44 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:43 -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 v2 10/14] iio: sx9310: Simplify error return handling Date: Tue, 28 Jul 2020 17:05:16 -0600 Message-Id: <20200728170317.v2.10.I071b118136317d3ff77fc598079f21e4ed0e347f@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 v2: None drivers/iio/proximity/sx9310.c | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 964fae90fefc25..f43ca6a0acf2fc 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -339,7 +339,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)); @@ -355,7 +355,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) >> @@ -369,13 +369,13 @@ static int sx9310_wait_for_sample(struct sx9310_data *data) static int sx9310_read_proximity(struct sx9310_data *data, const struct iio_chan_spec *chan, int *val) { - int ret = 0; + int ret; __be16 rawval; mutex_lock(&data->mutex); ret = sx9310_get_read_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out; if (data->client->irq) { @@ -395,11 +395,11 @@ static int sx9310_read_proximity(struct sx9310_data *data, mutex_lock(&data->mutex); - if (ret < 0) + if (ret) goto out_disable_irq; ret = sx9310_read_prox_data(data, chan, &rawval); - if (ret < 0) + if (ret) goto out_disable_irq; *val = sign_extend32(be16_to_cpu(rawval), @@ -412,7 +412,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, } ret = sx9310_put_read_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out; mutex_unlock(&data->mutex); @@ -435,7 +435,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) >> @@ -537,7 +537,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; } @@ -571,7 +571,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; } @@ -614,20 +614,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); } } @@ -666,7 +666,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; @@ -695,7 +695,7 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) indio_dev->masklength) { ret = sx9310_read_prox_data(data, &indio_dev->channels[bit], &val); - if (ret < 0) + if (ret) goto out; data->buffer[i++] = val; @@ -802,13 +802,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, @@ -834,21 +834,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; } @@ -902,14 +902,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)); @@ -921,7 +921,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) { @@ -930,7 +930,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 = @@ -952,7 +952,7 @@ static int sx9310_probe(struct i2c_client *client) iio_pollfunc_store_time, sx9310_trigger_handler, &sx9310_buffer_setup_ops); - if (ret < 0) + if (ret) return ret; return devm_iio_device_register(&client->dev, indio_dev); From patchwork Tue Jul 28 23:05:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690035 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 EF2CA1746 for ; Tue, 28 Jul 2020 23:06:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7EC62083B for ; Tue, 28 Jul 2020 23:06:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="GqzmZka+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729997AbgG1XGC (ORCPT ); Tue, 28 Jul 2020 19:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730146AbgG1XFp (ORCPT ); Tue, 28 Jul 2020 19:05:45 -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 CBBF8C0619D2 for ; Tue, 28 Jul 2020 16:05:45 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id d18so22598309ion.0 for ; Tue, 28 Jul 2020 16:05:45 -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=RvUE4fgzf8wh42WxKcUFkplOf94kmyY3rLuYSWpv16M=; b=GqzmZka+iawWrW35r3zOl1sHdJcBj2BEYq+myO6YYTRT+NgrX/DOjXdEC2+vsCPkJr lGdDaZF145+cHIKk4ku4n046lon+Ta9KN7XLXXVsQW8VFmZfzBGBGz5k2rQjchWawbBa 0kNkP38j5QGlfPqmRCyJtDSHyEy0GurCj0608= 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=RvUE4fgzf8wh42WxKcUFkplOf94kmyY3rLuYSWpv16M=; b=d93ExO5y6k378zz8wrsv4cKkcKiGMv7OK32835Vv3X+e0bprBsAaJJdRevrt9Oe1RF 5FUEiUfr5EhekeuhL6bPHKAGseiy1LOk5vGMlAZwv1kaN0n9afPwdEPQ0Hr8V9XVnThf 3Zl/QY/X5YxHc/bNhpKv+LsSEp5sC1hWZcDFKSPllRpItwAU76IJy9uJM41S1NqJnpew fDBFb55U+lZdFyJyqHeqfWuCUDu0zOLCtvcoxnEwO0R1WSppnTGnpCZoaZHKf4aVm5zg 541+c1Si1u64BjWIYxOyNHGbrmspORRlSy2x6Daeh4daz7sMH94D2CKvtbtwcUKKEp7i 0NrQ== X-Gm-Message-State: AOAM530984faeqqgT7PGIwRLTMhOMbS07McAZQls1avmw0tgxr1zLHnz XJT+i7XBEYsjC0XxsJP+kGI5Jg== X-Google-Smtp-Source: ABdhPJyQOMAFeMDdZGuEFdgpQnhA9CS/UXR+D1g8OwPag1DusMdMAtJe/5wy6Oj90poMWp381XAfNw== X-Received: by 2002:a05:6602:228e:: with SMTP id d14mr22030784iod.33.1595977545169; Tue, 28 Jul 2020 16:05:45 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:44 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v2 11/14] iio: sx9310: Use variable to hold &client->dev Date: Tue, 28 Jul 2020 17:05:17 -0600 Message-Id: <20200728170317.v2.11.If9d9c0fe089e43ea2dbc7900b6d61cd05c66f1f7@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 f43ca6a0acf2fc..517ff76acd00a0 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -885,11 +885,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); @@ -903,17 +904,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; @@ -925,7 +925,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, @@ -933,29 +933,29 @@ static int sx9310_probe(struct i2c_client *client) if (ret) return ret; - data->trig = - devm_iio_trigger_alloc(&client->dev, "%s-dev%d", - indio_dev->name, indio_dev->id); + data->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", + indio_dev->name, + indio_dev->id); if (!data->trig) return -ENOMEM; - data->trig->dev.parent = &client->dev; + data->trig->dev.parent = dev; data->trig->ops = &sx9310_trigger_ops; iio_trigger_set_drvdata(data->trig, indio_dev); - ret = devm_iio_trigger_register(&client->dev, data->trig); + ret = devm_iio_trigger_register(dev, data->trig); if (ret) return ret; } - ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, iio_pollfunc_store_time, sx9310_trigger_handler, &sx9310_buffer_setup_ops); if (ret) return ret; - return devm_iio_device_register(&client->dev, indio_dev); + return devm_iio_device_register(dev, indio_dev); } static int __maybe_unused sx9310_suspend(struct device *dev) From patchwork Tue Jul 28 23:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690029 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 8917914DD for ; Tue, 28 Jul 2020 23:05:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C86920829 for ; Tue, 28 Jul 2020 23:05:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ar1Q0CC+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730273AbgG1XFz (ORCPT ); Tue, 28 Jul 2020 19:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730154AbgG1XFr (ORCPT ); Tue, 28 Jul 2020 19:05:47 -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 CEF83C0619D5 for ; Tue, 28 Jul 2020 16:05:46 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id e64so22542812iof.12 for ; Tue, 28 Jul 2020 16:05:46 -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=ZoIceDzyOzo8oSN5q+ZQ3kqnLsUP5CmBy4V/6mK8Uy8=; b=ar1Q0CC+7xS6v1htrVCRIy+QU+trBYqbuLah7n2UtdSyFb+O8HqzybyUm3bpGoPEbp PMJIFSTij9ZTGN5TiMLP+PuzoIEaCw4rCzIIjXPXVMTukw2+1BPSR7190LBw1UsCkBu1 d9rGSg/jNv4YRp3OVep6+BdwaOZIqjgihbsec= 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=ZoIceDzyOzo8oSN5q+ZQ3kqnLsUP5CmBy4V/6mK8Uy8=; b=lY4F7X3sY/JbxA8rtAAX4OQsVt7juoD89UE4xX9WTeJLh0KZciO6oR0rQa6BAIgDb0 ECkSfb/sw6RDuOG1m267O2DnvwU1+SS3gDueQsdfjQdEAVTW68tIzd2FKR0WGVl5oMna SDbTHz4B30t+srgolvbdxOsrlFW5m7BvAbcBsBfHcqpjoVo6rhuAgLeLzgOt7BTcJqbZ 3K8wZRAJr7L4b+Erw1Q4jfDTaadI6YQfMkma/R9x0KzHaCpaaMXTnvEbZ9mDQkQT9awi pe45RkU6l+EYIklY9QXdpdv5DWv07nLdUULjACWUZm7R9U6xxgNoYXvf40+9cxJ+m+Ec aqVg== X-Gm-Message-State: AOAM533PoNsY+N1v38fuNCwbEF87qxuJrKOTYV2iun/0imjtrqrpKVbc gsmHGb3pR+VTJ/CTlqFIFuWSuw== X-Google-Smtp-Source: ABdhPJxK7IVTA4qCh9UMWrQq2q73f27W1gI9ka/2ubR3CWpSum8+prox/b02gvSKoP23X2CH8yx2NA== X-Received: by 2002:a05:6638:250f:: with SMTP id v15mr12274154jat.75.1595977546193; Tue, 28 Jul 2020 16:05:46 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:45 -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 v2 12/14] iio: sx9310: Miscellaneous format fixes Date: Tue, 28 Jul 2020 17:05:18 -0600 Message-Id: <20200728170317.v2.12.I426355a035f0394dfccba5bb2bc6f8db872c4be3@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 517ff76acd00a0..b15ace422862ff 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 @@ -403,7 +396,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, goto out_disable_irq; *val = sign_extend32(be16_to_cpu(rawval), - (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); + chan->address == SX9310_REG_DIFF_MSB ? 11 : 15); if (data->client->irq) { ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); @@ -433,8 +426,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; @@ -519,10 +513,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; } @@ -639,7 +632,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 = { @@ -970,7 +963,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; @@ -1016,21 +1008,21 @@ static const struct dev_pm_ops sx9310_pm_ops = { static const struct acpi_device_id sx9310_acpi_match[] = { { "STH9310", SX9310_WHOAMI_VALUE }, { "STH9311", SX9311_WHOAMI_VALUE }, - {}, + {} }; MODULE_DEVICE_TABLE(acpi, sx9310_acpi_match); static const struct of_device_id sx9310_of_match[] = { { .compatible = "semtech,sx9310", (void *)SX9310_WHOAMI_VALUE }, { .compatible = "semtech,sx9311", (void *)SX9311_WHOAMI_VALUE }, - {}, + {} }; MODULE_DEVICE_TABLE(of, sx9310_of_match); static const struct i2c_device_id sx9310_id[] = { { "sx9310", SX9310_WHOAMI_VALUE }, { "sx9311", SX9311_WHOAMI_VALUE }, - {}, + {} }; MODULE_DEVICE_TABLE(i2c, sx9310_id); From patchwork Tue Jul 28 23:05:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690025 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 AD027138A for ; Tue, 28 Jul 2020 23:05:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 962182083E for ; Tue, 28 Jul 2020 23:05:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FEh+/Fwg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730239AbgG1XFu (ORCPT ); Tue, 28 Jul 2020 19:05:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730222AbgG1XFt (ORCPT ); Tue, 28 Jul 2020 19:05:49 -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 C278CC0619D8 for ; Tue, 28 Jul 2020 16:05:47 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id t18so17772805ilh.2 for ; Tue, 28 Jul 2020 16:05:47 -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=AM59jIQYU2CvWOeFM3ngOpDG1QHH1+7BTtSJzp1GFow=; b=FEh+/FwgUzqP+c5bzHLYHINr+d192UCaIZiMxxT67ECRBXi+JBTwyim6DMlrKBPLdM zyC8o+DppB6BHO2L4XRveDASnVzPOsbTxgLMwbhEHigBwLC0H1tvUJ+wNlRxLkBa4Ctw SmMveWRwhdCahFGFdsifE4Eqse1/dkEAvyq1A= 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=AM59jIQYU2CvWOeFM3ngOpDG1QHH1+7BTtSJzp1GFow=; b=rQhug996b0Z3ikxAI650GE65Y5fZNQ4Qm4CT5pHwFypflF2MO6hJf5rA9SxBoXwqtw z/iRiCC8PPPvGTdAQopI0PbXhfAeaq8hwUZfbGG9EHuQmE+Ej60JGVufGoOgk9Al24Jn nyAjkSy9CvIDhAi0+ugPSI9RJNiZl+mxCP7LgY2DK7ANHjwGBh4tzv5WLaNbtkYxtVRk wJvu+tATKd0JJu9yo3jnJLwcf2z+iqbVW5wC4xNLw9kO3G2fyXFOcUD16lTeyvAQAQs2 pl3JxUD+T976kpBc1YsPFH0m8a+6F4btH97zvLUz8VhRti2lRVep5AlYRAemzTS9a8R4 H10Q== X-Gm-Message-State: AOAM532BJOz9MNLHl5j3a1hPha5dnYxSUtrxQwUxAiiBoqL/zA69rr+B xL9jLkkMGhEjY1QyBkqhzqap8w== X-Google-Smtp-Source: ABdhPJxvRCgWq7gqc0hnPFB/W3nKDK5a7ATpFyEVwGjnraxwV/R33ljGYEyoojjknLpWN3J8FIqn9w== X-Received: by 2002:a92:89c9:: with SMTP id w70mr23431764ilk.250.1595977547204; Tue, 28 Jul 2020 16:05:47 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:46 -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 v2 13/14] iio: sx9310: Drop channel_users[] Date: Tue, 28 Jul 2020 17:05:19 -0600 Message-Id: <20200728170317.v2.13.Ia5c5fdbdfff576ab5d034cde46c25cc66a4baf50@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 b15ace422862ff..6607732edd034a 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -132,7 +132,6 @@ struct sx9310_data { struct completion completion; unsigned long chan_read; unsigned long chan_event; - int channel_users[SX9310_NUM_CHANNELS]; unsigned int whoami; }; From patchwork Tue Jul 28 23:05:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11690027 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 5FEBD14DD for ; Tue, 28 Jul 2020 23:05:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45FFF2083B for ; Tue, 28 Jul 2020 23:05:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QwM92j+b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730222AbgG1XFv (ORCPT ); Tue, 28 Jul 2020 19:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730230AbgG1XFt (ORCPT ); Tue, 28 Jul 2020 19:05:49 -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 C82FAC0619DB for ; Tue, 28 Jul 2020 16:05:48 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id s21so17726968ilk.5 for ; Tue, 28 Jul 2020 16:05:48 -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=OeAFLDuJ/KgJd+XW6ikx+c1G0tNORrQK8vXV6J41koI=; b=QwM92j+bBCFCVDC0lS9QQPgLQzr8ZMnuG/AFQscxKohzVKRTer1RN0iTDwecdKXnnc mbgswCsMW8UUSR053i98AqzT54c/xcrOegouKvpXmu7OxGUMXBAS98aSWRFt5+lRBEXQ bni4KT+n7grQZUwmirmTIUrk2griitv08iJ+w= 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=OeAFLDuJ/KgJd+XW6ikx+c1G0tNORrQK8vXV6J41koI=; b=uDMGLttNcQGg0zNdR7baiQ8q4ttX1Edw7TsOnXu6Umk2yuzSH5YGPwDTUUM+4trWT2 m1KvmZjmZDTPYLBnNZPzHQGKiOr5HsUzYfCo0Fa3gggeIiKk4aYrycfnaQ1uGRQpf5aL U1lzSLbQn3orNIcokTveByvk4dqCzcIIeoHZagyFVPftX2hs0eIoSd3JILhBBo575215 zx2ijXZsMz52PYePQnhPHIYnIPJHt9MN30wiNTRXP1DHDoRXYnu/eBX1fYeyEWEBJBt3 JDQQmWBLXbeHj8Ztn6tMVpLAOzRnqSlL1mDHbv4LuDWlCeuHtJ0unHPt6PJRqle0VZAW pvvA== X-Gm-Message-State: AOAM532gCui/rIzlXuQ1ThJLDM6VghTUnS6hZ8Z92nCCoEIZnQvog+IU dBwpX0FlWWjxzq3BWJMLsddADg== X-Google-Smtp-Source: ABdhPJzh8S09J9zsjrzxnNQsPfIv2wPdrEDHQ8sfMZnIY3dENChJQCpUn/EmtXk+F8YmyONSkgbHVA== X-Received: by 2002:a92:c7d0:: with SMTP id g16mr3004218ilk.101.1595977548184; Tue, 28 Jul 2020 16:05:48 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id w10sm148945ilo.10.2020.07.28.16.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 16:05:47 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Douglas Anderson , Daniel Campello , Andy Shevchenko , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v2 14/14] iio: sx9310: Enable vdd and svdd regulators at probe Date: Tue, 28 Jul 2020 17:05:20 -0600 Message-Id: <20200728170317.v2.14.Ib7bdc8340021d8515b430498fb6686eedf22c9f2@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200728230520.2011240-1-campello@chromium.org> References: <20200728151258.1222876-1-campello@chromium.org> <20200728230520.2011240-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 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 6607732edd034a..163b18f91955bd 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -119,6 +120,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. @@ -874,6 +876,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; @@ -887,6 +896,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); @@ -894,6 +905,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);