From patchwork Mon Aug 3 23:41:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699263 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 30268912 for ; Mon, 3 Aug 2020 23:43:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5903120792 for ; Mon, 3 Aug 2020 23:43:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DcZwLeIU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgHCXnH (ORCPT ); Mon, 3 Aug 2020 19:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728413AbgHCXmB (ORCPT ); Mon, 3 Aug 2020 19:42:01 -0400 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BE0CC06174A for ; Mon, 3 Aug 2020 16:42:01 -0700 (PDT) Received: by mail-io1-xd36.google.com with SMTP id l1so40352721ioh.5 for ; Mon, 03 Aug 2020 16:42:01 -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=ySLfczwfPCSsE/wIMdBijYsg19z6IEGg8VtkjJac6SY=; b=DcZwLeIUcR1SxjgrjtGSRF0f2IaIwkE2cwYwmc4Wow/SeAyV4MiPpWcMB8TJ4eauEY vECMqzmfNeED0nATqni3SI8pI3puiGdsNq1GVvTO0Bj7MHYIgfiCJ8ddluTfnIG1OdBq 1T+YRqoNReDpWeeUGSo52zs2v/cybiX1wnn14= 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=ySLfczwfPCSsE/wIMdBijYsg19z6IEGg8VtkjJac6SY=; b=N4+xo1vmkduDu7cVyDtbJjSzPPAB4ee8FHRyBV/mjYWBpohkXcajD2v46REQY7NNWo /jzsWw0LdK/2Qw2D+Kua+HNUAb47A53gvxMl8ROH2e9QCfwQ09wms3ialZgs1QQ5DBTE hDUwbJXIFeiKgZHfYrcQq0ILKgFXcUtbGBBd6QLgbQz5R0x/A+0f75UowHKMUH2anvKv wRNIQlWRwFMfqgTT/IOSvz691Xq3Me6TNPxmOLW1NA105IdAKjDOZIrbRtsh5jQmE44S sf0BZX3CdYqNlQ8vjbf4ZvIm/PhJmnEBErMMnWrlMSBK56miteTNKxkyWU817b7+bWOW ezVg== X-Gm-Message-State: AOAM531LgjHlT2m1kDjbp5TSnXI/1EpQphDoZb+a+lzV85zbg8X5ed7b kEIKa8Y9MP4qZLcI47oNs4ZHCw== X-Google-Smtp-Source: ABdhPJzDGIe+hSIe7APq0Lc1WUsIPi4TvIWjSHUGZz5lkp3h7XL6rCOs1v64EAKNtBkCZCDJwqsRvA== X-Received: by 2002:a05:6638:2689:: with SMTP id o9mr2591145jat.37.1596498120365; Mon, 03 Aug 2020 16:42:00 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:00 -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 , Rob Herring , linux-iio@vger.kernel.org Subject: [PATCH v4 01/15] dt-bindings: iio: Add bindings for sx9310 sensor Date: Mon, 3 Aug 2020 17:41:40 -0600 Message-Id: <20200803131544.v4.1.I0925046377211b8b6f06764857f03b4ab592bddb@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 bindings for sx9310 sensor. Signed-off-by: Daniel Campello Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Rob Herring Reviewed-by: Douglas Anderson [swboyd@chromium.org: Add both regulators and make them optional] Signed-off-by: Stephen Boyd Reviewed-by: Rob Herring --- Changes in v4: None Changes in v3: None Changes in v2: - Added #io-channel-cells as a required property .../iio/proximity/semtech,sx9310.yaml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml new file mode 100644 index 00000000000000..5739074d3592fe --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/proximity/semtech,sx9310.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Semtech's SX9310 capacitive proximity sensor + +maintainers: + - Daniel Campello + +description: | + Semtech's SX9310/SX9311 capacitive proximity/button solution. + + Specifications about the devices can be found at: + https://www.semtech.com/products/smart-sensing/sar-sensors/sx9310 + +properties: + compatible: + enum: + - semtech,sx9310 + - semtech,sx9311 + + reg: + maxItems: 1 + + interrupts: + description: + The sole interrupt generated by the device used to announce the + preceding reading request has finished and that data is + available or that a close/far proximity event has happened. + maxItems: 1 + + vdd-supply: + description: Main power supply + + svdd-supply: + description: Host interface power supply + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + - "#io-channel-cells" + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + proximity@28 { + compatible = "semtech,sx9310"; + reg = <0x28>; + interrupt-parent = <&pio>; + interrupts = <5 IRQ_TYPE_LEVEL_LOW 5>; + vdd-supply = <&pp3300_a>; + svdd-supply = <&pp1800_prox>; + #io-channel-cells = <1>; + }; + }; From patchwork Mon Aug 3 23:41:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699259 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 A59CA912 for ; Mon, 3 Aug 2020 23:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4CBB20792 for ; Mon, 3 Aug 2020 23:43:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="et3ARAPG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbgHCXmC (ORCPT ); Mon, 3 Aug 2020 19:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728671AbgHCXmC (ORCPT ); Mon, 3 Aug 2020 19:42:02 -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 2D662C061756 for ; Mon, 3 Aug 2020 16:42:02 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id w12so26754010iom.4 for ; Mon, 03 Aug 2020 16:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sIIl/VU5YXegrBnTPNTCbVivL9PcrsrxVizrw7IQzuU=; b=et3ARAPGby82DcRnqprqn/jkAILGok/lAg4XeSPfYwMhXnzXVzaIY/14RaGe8TsmkO Pg0Hr5KiZYCl0f1X/3qKAn1GGuIUIM0F0DnHmyYBSqhOEC0d/GxzZZ4l0mOuuzayIF8J 16Xj6VfW406A2nLZrupL2/jx7CPiB9XqSqTnw= 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=sIIl/VU5YXegrBnTPNTCbVivL9PcrsrxVizrw7IQzuU=; b=rU9BvbgcrKey94sLQ2Q82kXuLjF5s5uwgeyMqN55hG0M9fLlwCVViX9+gUUc+HXVs4 iT4d7+51ILwzCX0lMeTiw3cp3D6d9XagsD2UrXripWFtYmIWEOMHFTOh36j0Y/x1USd4 0wm3Di4WxxDBxmScT2/lNdEvjtQEyLV4EAWHsDxoCTYHYPbPyw1ruF4MxJaNQo1/K13m Sl+aaLaejhYDHzxYwdPROWvOgLAaJRKpxuMLDhIlXA3tTy7Ws/cUT1X2OXJEBgGFDr/A uH0Ty4bToHuab3lIAfGS7ZbEznfe167FWWjUq+fjVEVkRpbTJ/8DKANr4zPnmwMx6yWX 86Tg== X-Gm-Message-State: AOAM530Xs0ocN3e1N8ixACow8NeJpw5yBGPudxypBQhZQPL8mHafRI+D aAw2G1AjlcrAPDdWJ/H9xAeE3g== X-Google-Smtp-Source: ABdhPJxzzF7xpdzVj8FVpsmo5w1pBIY3sVw22LFQdUEGe9B41AmBZTPs/bs631bV4Sc0TsapbmFrHg== X-Received: by 2002:a05:6638:25d3:: with SMTP id u19mr2445755jat.103.1596498121427; Mon, 03 Aug 2020 16:42:01 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:01 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Stephen Boyd , Andy Shevchenko , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v4 02/15] iio: sx9310: Update macros declarations Date: Mon, 3 Aug 2020 17:41:41 -0600 Message-Id: <20200803131544.v4.2.I30721195b2f20ec785715f7a2757930302a2a7e8@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: - Updated macro SX9310_REG_STAT1_COMPSTAT_MASK at call site. - Use FIELD_GET/FIELD_PREP instead of manual shift. Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 145 +++++++++++++++------------------ 1 file changed, 67 insertions(+), 78 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index d161f3061e353d..69db4cefe49f2a 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -33,45 +33,44 @@ #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_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 +81,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 +106,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 +115,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 +245,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 +286,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 +355,7 @@ 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 = FIELD_GET(SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK, val); msleep(sx9310_scan_period_table[val]); @@ -435,7 +429,7 @@ 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 = FIELD_GET(SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK, regval); *val = sx9310_samp_freq_table[regval].val; *val2 = sx9310_samp_freq_table[regval].val2; @@ -482,9 +476,10 @@ 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); + ret = regmap_update_bits( + data->regmap, SX9310_REG_PROX_CTRL0, + SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK, + FIELD_PREP(SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK, i)); mutex_unlock(&data->mutex); @@ -572,7 +567,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 +595,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 +608,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 +617,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 +742,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 +798,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; @@ -818,7 +807,7 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev) ret = regmap_read(data->regmap, SX9310_REG_STAT1, &val); if (ret < 0) goto out; - if (!(val & SX9310_COMPSTAT_MASK)) + if (!(val & SX9310_REG_STAT1_COMPSTAT_MASK)) break; } @@ -992,7 +981,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 Mon Aug 3 23:41:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699257 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 36DE1912 for ; Mon, 3 Aug 2020 23:43:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6318220792 for ; Mon, 3 Aug 2020 23:43:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="m9q+Mz9Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729278AbgHCXmx (ORCPT ); Mon, 3 Aug 2020 19:42:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728705AbgHCXmD (ORCPT ); Mon, 3 Aug 2020 19:42:03 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ECA1C06174A for ; Mon, 3 Aug 2020 16:42:03 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id w12so26754055iom.4 for ; Mon, 03 Aug 2020 16:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=muEpSfoCuV2CQqyvNh+4FTQlFWMtwM8V3UJRLf2lB9Q=; b=m9q+Mz9Zsu8ZnwuHZpehZE6IShE0IbrLzW1Vn+8DXk5TP2pk/gxU7X7+NMzSiHcbeg 46fN75ue3SKcnmNPvdZEQEci9EHf/D+P6RsIGPkdPJ+0JKJ6jmUE8VloSLf61eJi+JU9 pyRJOFXHmVrORxIwh698s5iWKPvzLtyPQF0So= 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=muEpSfoCuV2CQqyvNh+4FTQlFWMtwM8V3UJRLf2lB9Q=; b=J2T5jJ/gAEP1Oo7Sx3GViGbTE0v9i8cNlEgBr9kNbBG8zw0gmyOhhRncipulTc6/xc 0JTC0NbOkrjL+ZSiG6wD62v9kOag6wFsVw2T0FF2aFAqa1ppmi809Pmj7Y42HDHWW3c6 JLsyypUwuJQ9HUvAUku6MXWYlCWfd2nTVhhjekImCOhv9onz6TkXmqML+aNtbRjaL6eU RmpcHXpmFMF24SwvLxOv6RNT+Gn0EatOnuS2x8YaxJSOFZi877+vjLVU6OOyRCjyrKpr 7ewBGywC4A03mZvAbqob3FD6Bw3a1GZDJfQHXOFbksVkb4Nthzxo/v0y6/IHkfies8xO BK+Q== X-Gm-Message-State: AOAM5300TBMbQE8hnwQK5M65H6FNhKeaCbd1U7aHW3zDS4ybW8s8zYcn U5S4zwIy3EEjVtCYG53L9/YJCw== X-Google-Smtp-Source: ABdhPJwn0hmIvd4Egmn7+rn8BhEjPhygihmn++xjnF4YCf+dESCDH4zCHMx3CBzwXBwRSEhTi3ldcw== X-Received: by 2002:a05:6638:130d:: with SMTP id r13mr2417998jad.89.1596498122574; Mon, 03 Aug 2020 16:42:02 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:02 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Stephen Boyd , Andy Shevchenko , Douglas Anderson , Enrico Granata , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v4 03/15] iio: sx9310: Fix irq handling Date: Mon, 3 Aug 2020 17:41:42 -0600 Message-Id: <20200803131544.v4.3.Idbfcd2e92d2fd89b6ed2e83211bd3e6c06852c33@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Fixes enable/disable irq handling at various points. The driver needs to only enable/disable irqs if there is an actual irq handler installed. Signed-off-by: Daniel Campello Reviewed-by: Stephen Boyd --- Changes in v4: - Reverted condition check logic on enable/disable_irq methods. Changes in v3: - Moved irq presence check down to lower methods Changes in v2: - Reordered error handling on sx9310_resume() drivers/iio/proximity/sx9310.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 69db4cefe49f2a..3523ee5c8f0d2d 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -322,11 +322,15 @@ static int sx9310_put_event_channel(struct sx9310_data *data, int channel) static int sx9310_enable_irq(struct sx9310_data *data, unsigned int irq) { + if (!data->client->irq) + return 0; return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, irq); } static int sx9310_disable_irq(struct sx9310_data *data, unsigned int irq) { + if (!data->client->irq) + return 0; return regmap_update_bits(data->regmap, SX9310_REG_IRQ_MSK, irq, 0); } @@ -380,7 +384,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, mutex_unlock(&data->mutex); - if (data->client->irq > 0) { + if (data->client->irq) { ret = wait_for_completion_interruptible(&data->completion); reinit_completion(&data->completion); } else { @@ -1009,10 +1013,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 Mon Aug 3 23:41:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699255 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 E2F1C14E3 for ; Mon, 3 Aug 2020 23:42:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B35F2086A for ; Mon, 3 Aug 2020 23:42:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QmPh5nUP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729244AbgHCXmp (ORCPT ); Mon, 3 Aug 2020 19:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728842AbgHCXmF (ORCPT ); Mon, 3 Aug 2020 19:42:05 -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 2129DC06179F for ; Mon, 3 Aug 2020 16:42:04 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id g14so2869792iom.0 for ; Mon, 03 Aug 2020 16:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/FMp7t9zJsevOEX4yhVr5KoKILCcT3l3u0rcT+JXhAY=; b=QmPh5nUPZ/EESdkkBHbazCKwv58BbTK07a7ZwJHmzagU/Bz4f/E1vxoLzaRwdM18Ec zQL+cmXrtCJyMcJDC76O4BDu8yXMjiU4vSL3q775lP2gnzPpziQXmChMp8UmXGDoc9/r ZBGwYzEmn6I2arNS/DD88D7/M+xg1ZNcCF4lY= 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=/FMp7t9zJsevOEX4yhVr5KoKILCcT3l3u0rcT+JXhAY=; b=db1wA3din3zrM3Z1V4hVy9EQNxOFkbTM1nf5w42SlHGDVU7V4ilGY4/iT3WfR3s/1d 15Pul6u3RqPr+xY1CgYDmZIbAPL/qds7vyMy1jFaR/F3FtNju6Ol71kgY4kllyGFlyR3 gfwwzCe+fpEg5YgTxVwUpUZt6EhYhQPnOXHPgGWbPrEugH3NWHZ20oV2fN/+eKYFiHuq Otg4pgYZ1vQBK8M/mR0wVRoC4MiWGA11Wtbh3UWFVJrSSDyYvpiTtil3ruvrQW8BJKd6 wNSHPGllO167M1UD5iBQGiQmhdQ+sYIk3EVTlq7cP5ykHCVt+12LvHO4k8/EsYhKAHzP IZLA== X-Gm-Message-State: AOAM5300nFqyy2AX4/n7ajL46YcWdfGscxchXMKip6xQYrUCrPIbTFQn 7DiTaPOwSkg9NgzeB2xZPszU5w== X-Google-Smtp-Source: ABdhPJzjGK7YETFVd/XuYfzZTadZNnhp+w6G8pQCShVInAJwoMtBVMhKSEdDiv4NIJ6qjucNotgs0g== X-Received: by 2002:a02:b689:: with SMTP id i9mr2549762jam.59.1596498123575; Mon, 03 Aug 2020 16:42:03 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:03 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , kbuild test robot , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v4 04/15] iio: sx9310: Remove acpi and of table macros Date: Mon, 3 Aug 2020 17:41:43 -0600 Message-Id: <20200803131544.v4.4.I9bf713a86d6076b44441ef5f534f9c240271699a@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: - Added #include drivers/iio/proximity/sx9310.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 3523ee5c8f0d2d..3642d23cd5e6f4 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 @@ -1048,8 +1048,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 Mon Aug 3 23:41:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699253 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 08341912 for ; Mon, 3 Aug 2020 23:42:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33F522245C for ; Mon, 3 Aug 2020 23:42:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TApxXwtw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729240AbgHCXmp (ORCPT ); Mon, 3 Aug 2020 19:42:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728854AbgHCXmG (ORCPT ); Mon, 3 Aug 2020 19:42:06 -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 23139C0617A1 for ; Mon, 3 Aug 2020 16:42:05 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id g14so2869820iom.0 for ; Mon, 03 Aug 2020 16:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HF/T+OchjGUezOj0UEf10GFTQQZf+tbc2OMbxk27h9Y=; b=TApxXwtwUJD5o0HAtdrg2Jz7uDTJPwLEONeLNGUGJegRF0Nk9D0RgSBMoma06DanDL QWj/LON3kvvQKaJ4kbPOB2lRoKsf7oqpXhXWdDaXBiYWYSo2RmnQWP7lXDo6tWEcxMxP G8M97unhw629Lnr0CGS/vQcCjZImvZN2cu5po= 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=HF/T+OchjGUezOj0UEf10GFTQQZf+tbc2OMbxk27h9Y=; b=gQz5a1ImUOpCLHivAxpPKwmqgfQevKDSP1KxDMMKp4ffJGZRwJtErt3IL9Y+ueTORM YW4NnWbIL+04VoH9UtbXodPbDxy5DbCivkL4WIVtcaBcCndVKg2d0SMLBmxSQkOU9uAQ /bK14YkHFQT+Sj86L3XDaEtJjh8S914ekOvXEaTGtF00y9QDrIcNs0AYr2w0vqNe2cWn iSmdWGUKyDmP+lQcJOy+O5SiWupMd4mRbHhy4hyrhQVc4bt1488Xqj3O4lgyFUUzFke1 SWXsd6YIs26+nuTO+ZQnXnX/W/TxfgP4WH6r1dlkXNEHmfo43MFrn0UAcVPR+b6JUuRJ JszQ== X-Gm-Message-State: AOAM531vMCV1iDTesEbg5jNP0kmh3dXsks94p295AW2TYBOwbh4HY6dx 5CX+JO9ty248RWl+1p+olVvBHA== X-Google-Smtp-Source: ABdhPJzhywQXH6COC8ga0Wwqdg6aTz1UVteetpQVq6p9g/Wh4CbASpyytr/80InFhQsQbzE8n1vjCw== X-Received: by 2002:a02:70c3:: with SMTP id f186mr2517211jac.118.1596498124565; Mon, 03 Aug 2020 16:42:04 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:04 -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 v4 05/15] iio: sx9310: Change from .probe to .probe_new Date: Mon, 3 Aug 2020 17:41:44 -0600 Message-Id: <20200803131544.v4.5.Ieb5fdf7381764835dad0b3099c7b19ba754e4c47@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: - Added '\n' to dev_err() drivers/iio/proximity/sx9310.c | 39 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 3642d23cd5e6f4..c89a4e27201796 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -138,7 +138,7 @@ struct sx9310_data { struct completion completion; unsigned int chan_read, chan_event; int channel_users[SX9310_NUM_CHANNELS]; - int whoami; + unsigned int whoami; }; static const struct iio_event_spec sx9310_events[] = { @@ -857,24 +857,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: @@ -884,15 +875,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; @@ -918,8 +908,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; @@ -1032,8 +1021,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); @@ -1052,7 +1041,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 Mon Aug 3 23:41:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699251 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 8D37814E3 for ; Mon, 3 Aug 2020 23:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B928920792 for ; Mon, 3 Aug 2020 23:42:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YvGJRMe9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728891AbgHCXmo (ORCPT ); Mon, 3 Aug 2020 19:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbgHCXmG (ORCPT ); Mon, 3 Aug 2020 19:42:06 -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 242BAC06174A for ; Mon, 3 Aug 2020 16:42:06 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id g14so2869848iom.0 for ; Mon, 03 Aug 2020 16:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0H6GDwQS47ERB7u8LWsyFagTSOyltzG4Qky9evJTi+U=; b=YvGJRMe9hgg6bHXgr5Q+9G567B3apiE6/0BQm9bfXRIN291mlsDmpVcAG4tfkXQpr+ XmrWZEaFR1O+2Uic+hFh57CxAnmbss1Tu01L/8Pe77sVCKgQ5TQCldCQ9NULeOJ6QANk Yf7Gg01I06VJ7qULm0T12j3t+RtPDnJ+m63ck= 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=0H6GDwQS47ERB7u8LWsyFagTSOyltzG4Qky9evJTi+U=; b=s6hlx0pQnz1Vd2Avj8qCxEQ0fSz2D4erXF+OlFIYfMPFAuZ4AIImEmZ+bajV8iM73x cY8MjqzmJCng8QngwBNkS9i2F/t8AGTgIe58H7TFJ3516fhFIHQuX0Hvb7ppbX5lHN8Y 6K2k8vDEteZLiIi1R90wGFiGXA956ufJurL97+wPXlSrAaOxhG3F0MqZ924juh2fDjjl iK/aPPH4Mr+C0I9DW6sJxWoQSJoTAS4ZAP1HkU9vmUlpv4/6kUne89wpFFZvJRd6yfYF ZLQfSpxB2vX2fXzn7PbqxV1nqog1Zyjk/FnyCXv6cWxTc9ECuNp36i+PF4NnNUgaIyJZ ckPQ== X-Gm-Message-State: AOAM531rD8hbVbjsJibftFPtiDTC2s7nzENZKiEspdXp+CcEFVaa1ya5 SgH5AX9DosH8xjh9aEh70bHLZA== X-Google-Smtp-Source: ABdhPJyxUWQI6dJ4UGhK9UO9uoBheNt4jPRrhepNVLOo4S0/tVrUF1P/owG5srwtpyhy57Mg2XtX+w== X-Received: by 2002:a02:ce4b:: with SMTP id y11mr2510609jar.144.1596498125538; Mon, 03 Aug 2020 16:42:05 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:05 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Douglas Anderson , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Stephen Boyd , linux-iio@vger.kernel.org Subject: [PATCH v4 06/15] iio: sx9310: Fixes various memory handling Date: Mon, 3 Aug 2020 17:41:45 -0600 Message-Id: <20200803131544.v4.6.I8accffd77d616cb55b29bc3021cb0f5e1da3b68a@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Makes use __aligned(8) to ensure that the timestamp is correctly aligned when we call io_push_to_buffers_with_timestamp(). Also makes use of sizeof() for regmap_bulk_read instead of static value. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- Changes in v4: - Use pointer to buffer struct on iio_push_to_buffers_with_timestamp(). Changes in v3: - Changed buffer to struct type to align timestamp memory properly. Changes in v2: - Fixed commit message from "iio: sx9310: Align memory" drivers/iio/proximity/sx9310.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index c89a4e27201796..20a26b73b5ae90 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -131,8 +131,11 @@ struct sx9310_data { */ bool prox_stat[SX9310_NUM_CHANNELS]; bool trigger_enabled; - __be16 buffer[SX9310_NUM_CHANNELS + - 4]; /* 64-bit data + 64-bit timestamp */ + /* Ensure correct alignment of timestamp when present. */ + struct { + __be16 channels[SX9310_NUM_CHANNELS]; + s64 ts __aligned(8); + } buffer; /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; struct completion completion; @@ -343,7 +346,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)); } /* @@ -693,7 +696,7 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) if (ret < 0) goto out; - data->buffer[i++] = val; + data->buffer.channels[i++] = val; } iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, From patchwork Mon Aug 3 23:41:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699249 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 91C6314E3 for ; Mon, 3 Aug 2020 23:42:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B784622D05 for ; Mon, 3 Aug 2020 23:42:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XNDeIGNp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728926AbgHCXmh (ORCPT ); Mon, 3 Aug 2020 19:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728912AbgHCXmH (ORCPT ); Mon, 3 Aug 2020 19:42:07 -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 356CDC061757 for ; Mon, 3 Aug 2020 16:42:07 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id l17so40361922iok.7 for ; Mon, 03 Aug 2020 16:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bZtgyz4w9bioKhpkBgBZgXBORnt82DhjEIEidPD/D0c=; b=XNDeIGNp2H4ZbKTQ3i4Ti8f6et3wSK/SnNykPc+bdzRVUKA+SGd464nUM4ENll3c27 69/3TYIyyHmi4cZrJmyK+vmJJDIDz9yEBHdLjdtr0iz+pzS+9KUyewCQg4N8wf8UiBrh hZe6pLZ2DRm1jdBqN+wEnMvKvk2Y753T/sH5A= 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=bZtgyz4w9bioKhpkBgBZgXBORnt82DhjEIEidPD/D0c=; b=mldrxpmSnm1Bhh/ozo5fur1U0u+93bcT9jFdbRDz/iIhPfYPxKXvCrMS4WhNkGlQWR 4Xy9rwvNaFLWMfeQSawPyaRQGMOyuDm88mczT6ZmaayLL+4IodJ8Je5XJZLFiqA8loxA yv++i4df9VoR35gu+QIxAg9Re3wMpARGl7DR/VVh8Si57noouwteyWeLsfOce2NSIiyo ZMh5r4Lvmc38cD/6JynzEhPhiVZ3lj92qDFNMT+/fdOqe6s+mnNt8Ax5MTexgs+N/fZr wtJ7vFoxPw2wNLdLh6zT907c3jW2nDQ1PIyrptNocy3aJATRlxd+Sr7S0pQ22yBlr17R a0Cw== X-Gm-Message-State: AOAM530ydI18WzgC8LRjjZrT3fVGs3JVLsq+uhU5fgL/jBATnQJ+0GPb +QzoWtF7QXV2b55OUmoWSTINmw== X-Google-Smtp-Source: ABdhPJzcRmjkFF3frNBKgigwLZQlEiezRtbcaLOq4pOuDMxQ0MDjYIWPRUPDi1VetefN+u9EeKkoLA== X-Received: by 2002:a02:9185:: with SMTP id p5mr2491651jag.25.1596498126584; Mon, 03 Aug 2020 16:42:06 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:06 -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 v4 07/15] iio: sx9310: Use long instead of int for channel bitmaps Date: Mon, 3 Aug 2020 17:41:46 -0600 Message-Id: <20200803131544.v4.7.Iecaa50e469918a385b3e5dab375e442540ea2ad4@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Uses for_each_set_bit() macro to loop over channel bitmaps. Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko Reviewed-by: Stephen Boyd --- Changes in v4: None Changes in v3: - Added static assert for number of channels. Changes in v2: - Changed prox_stat to chan_prox_stat bitmap. drivers/iio/proximity/sx9310.c | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 20a26b73b5ae90..45569a0657060c 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -118,6 +118,7 @@ /* 4 hardware channels, as defined in STAT0: COMB, CS2, CS1 and CS0. */ #define SX9310_NUM_CHANNELS 4 +static_assert(SX9310_NUM_CHANNELS < BITS_PER_LONG); struct sx9310_data { /* Serialize access to registers and channel configuration */ @@ -129,7 +130,7 @@ struct sx9310_data { * Last reading of the proximity status for each channel. * We only send an event to user space when this changes. */ - bool prox_stat[SX9310_NUM_CHANNELS]; + unsigned long chan_prox_stat; bool trigger_enabled; /* Ensure correct alignment of timestamp when present. */ struct { @@ -139,7 +140,8 @@ struct sx9310_data { /* Remember enabled channels and sample rate during suspend. */ unsigned int suspend_ctrl0; struct completion completion; - unsigned int chan_read, chan_event; + unsigned long chan_read; + unsigned long chan_event; int channel_users[SX9310_NUM_CHANNELS]; unsigned int whoami; }; @@ -282,15 +284,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 +534,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 +543,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 +716,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 Mon Aug 3 23:41:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699247 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 92E7C912 for ; Mon, 3 Aug 2020 23:42:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBD7C206F6 for ; Mon, 3 Aug 2020 23:42:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QmyMqDJs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729206AbgHCXmh (ORCPT ); Mon, 3 Aug 2020 19:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728926AbgHCXmI (ORCPT ); Mon, 3 Aug 2020 19:42:08 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CCBDC06179F for ; Mon, 3 Aug 2020 16:42:08 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id j9so29251805ilc.11 for ; Mon, 03 Aug 2020 16:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=crpNFCNIy/zAlJwvXKSpz1wtCMZ2tFyOhrPvEeMN7o0=; b=QmyMqDJsmdR/d0fB+0WUIJaOqulAEaOjBgp/lrDRlz0p7lrJKCUcFnBnfOb7Y91dZe DQ1MAREQuOy2r1RgZ9eL+3ojvnp+93gwrGyErlxHOQTNoZwqzWQ9AVUApFjaZvY7Bg9P 7/NwBNBRrsNVh415wLN5DX6vEvx+fx9cQvTeA= 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=crpNFCNIy/zAlJwvXKSpz1wtCMZ2tFyOhrPvEeMN7o0=; b=W0QNdCr32I83MY8ugR9oHAKIXaSdHO/FheC2YlWlngm/gNvvO0ljN4DDCmIG+ZElL7 L8HBrHf6EUI4sVg5AAxnDv58VVOZQTrL3YK4skhBVDSYf7t+AAgr6Mt+BiH4eNpHy1np Zcs/o5EfTrksI5Sc5D7cQwbAtq+SIvc64CmWeA60BgBFYRvOXBO8UeY3jMBuHMGl0QrF XQQ/hSd86Z5jAyOIItpVJ7ITI/0T6RTfZnmbBM5BqsTuKVwR52ZGWG7M+EvBast4wsUY 8IuoschgKg8lKGiddJGMCkitnB1UMgHchgiUGukl0wH31mtdgaHL4W0rNhPtUfXNJ7ay od7Q== X-Gm-Message-State: AOAM530urzVHXCVbv2nrnfoisElJImq/RWbz2MVNv+OKqZfOIXjBzVDG tGBHCcGeR6ViPZK/6g+RM17LxQ== X-Google-Smtp-Source: ABdhPJxKJ6juB/6v9Cq2ZsqNdu0gCRw9v/ib+Mzpv7eRLhX8f32mNaCUvbn+3mKElRKyr3AgBqOsYw== X-Received: by 2002:a05:6e02:1203:: with SMTP id a3mr1935467ilq.85.1596498127516; Mon, 03 Aug 2020 16:42:07 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:07 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Daniel Campello , Andy Shevchenko , Stephen Boyd , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v4 08/15] iio: sx9310: Use regmap_read_poll_timeout() for compensation Date: Mon, 3 Aug 2020 17:41:47 -0600 Message-Id: <20200803131544.v4.8.Ia205f0b0363bf663db7704026b5b7036b9748c56@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Simplify compensation stage by using regmap_read_poll_timeout(). Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko Reviewed-by: Stephen Boyd --- Changes in v4: None Changes in v3: None Changes in v2: - Fixed dev_err() message drivers/iio/proximity/sx9310.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 45569a0657060c..9636a3beabeb36 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -798,7 +798,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; @@ -812,22 +812,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_REG_STAT1_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 Mon Aug 3 23:41:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699245 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 51B5C912 for ; Mon, 3 Aug 2020 23:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A9922086A for ; Mon, 3 Aug 2020 23:42:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kS6kSvUW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbgHCXmJ (ORCPT ); Mon, 3 Aug 2020 19:42:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728936AbgHCXmJ (ORCPT ); Mon, 3 Aug 2020 19:42:09 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03186C06174A for ; Mon, 3 Aug 2020 16:42:09 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id l1so40352972ioh.5 for ; Mon, 03 Aug 2020 16:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/skwDGOu2nehnv18qT3IFvoLq0QiOWOte/D4orwDVqQ=; b=kS6kSvUWuhPB6rHlgXKENziRqn8Xb+cvstktJgAj55sFgsPTsKaaID8UgizpA2plTv 2HSTbhdM+R7emETz84X8vU5jWlVsPQ6VrJ9oUFW65kKuNdmfi8UNLYXzxtSUWTmuWtBw EQPNO84AVaBO6qoCPs0USYGXM0iRCMi50JM0A= 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=/skwDGOu2nehnv18qT3IFvoLq0QiOWOte/D4orwDVqQ=; b=D8rmJ5XxJ+wYlrH+K9pk0jbPKzekocjFor80lgs4gOLqUCXElnVsbz+e0SNqfuqJYK UGxGq0PXg5Sa+jLSlTnTeYImqnkk5/EjJ909qhNypjisU7vIZ+Dg2nGdSATMPzYGE5au csGr8XIgdTfnRPU2ATjFEZsDvLXlS8oHX1AYBbdsDDLVjjScB0uHCBxAeZMS/b7WQxmU ZfiTOgysHct0LtLQmy7R3xK2Iu8T17jLKo0oQejvqJobey+34KZFP76F3M2W5BNWjrZx DbQWDSPeZiL1h1PMQLN6onw7d9ZsL3UFegjuPAipxK68cAFgjplHh9ZNE6dQTUrDT0/O jUig== X-Gm-Message-State: AOAM530wphxi5hniyFdMUZnIlYrLKOqG5dZJFPT/5V8ALZrDsQTTA4wX VyslANiJNhM2hEku9qo05q2PzQ== X-Google-Smtp-Source: ABdhPJyyzjip/hI2kd2WW3oXWVJy1Fk6QaKzYFBTkNRk51qp4ji3wfF3zEwqRMQEYDGmU+zdqbsziQ== X-Received: by 2002:a02:cc53:: with SMTP id i19mr2551216jaq.33.1596498128403; Mon, 03 Aug 2020 16:42:08 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:08 -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 v4 09/15] iio: sx9310: Update copyright Date: Mon, 3 Aug 2020 17:41:48 -0600 Message-Id: <20200803131544.v4.9.If88afce92bbc1e97a532874cca35e642a9566172@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 9636a3beabeb36..fa5009e39605ca 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 Mon Aug 3 23:41:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699233 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 32CAC912 for ; Mon, 3 Aug 2020 23:42:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 594B52177B for ; Mon, 3 Aug 2020 23:42:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="U2yUHmHh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728960AbgHCXmL (ORCPT ); Mon, 3 Aug 2020 19:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728951AbgHCXmK (ORCPT ); Mon, 3 Aug 2020 19:42:10 -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 EFEF0C061756 for ; Mon, 3 Aug 2020 16:42:09 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id g19so28304656ioh.8 for ; Mon, 03 Aug 2020 16:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cgcuBq5jHSYe9tQ6i4PG5OfxXeQhbT6N/XwGKE+NjOI=; b=U2yUHmHhcvu/mBtiyhM1jv7Ry0ocXHKyTp5EcP7Z3OwBPyxmH0aaBBawIEG1Zp+F/5 CoU5KUTT8loPxM5XOqUQpvUMbby0MmojztMTziPDZVRth8V6jRbvql3ZlgNjKVdQkWAw ps43BRoag7INeMVdoGvm3MVp6afTydpV5cQow= 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=cgcuBq5jHSYe9tQ6i4PG5OfxXeQhbT6N/XwGKE+NjOI=; b=nUtJDfZnfDP6Vsy4s54z64l6cfBVQ9mnDBF8gTxNID4zaNC79eewUFiJLzaOUGfV8M QC+opdWV/FGt3v8O4JxZ/clFVcrisuHQfi3xm0TfcJTPsEU35H6Zfkeo7Ce1Y8q4Ltbz 30VR7VrScMVvq4gbp30M0l0wPyhbZA5df6OWi3InzRxgXVGzZHlz9KMFQ3ReCRcFLUxT BpebbAYYH86KzhLpSBzc1B04is5pd5pLSHK+0YTsvPR29LCJHzZoga32CuYylPlAtUEG gUMaCL/XgZh8PXcYnqfQqfA0KwxiExYDOC20zWhYd2YOKrYMubh/VGkR060LhGAvOhQb 5TFg== X-Gm-Message-State: AOAM532GRJAT/kAfFnyWI8DualovZqaa7Mu34YaTY1WuvVrrrqyi5ZGT 2Fp8+kgtBNnv3HWP6CPUfBTcEw== X-Google-Smtp-Source: ABdhPJwv2fTnB+Rq2fK6YsQLu1jLeYv1LFlkDxw2Ajc1fqC4cDIIKUKd5EiTfyJkEJ7JRtntY3ZkEw== X-Received: by 2002:a02:84c1:: with SMTP id f59mr2565425jai.106.1596498129388; Mon, 03 Aug 2020 16:42:09 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:09 -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 v4 10/15] iio: sx9310: Simplify error return handling Date: Mon, 3 Aug 2020 17:41:49 -0600 Message-Id: <20200803131544.v4.10.I071b118136317d3ff77fc598079f21e4ed0e347f@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 56 +++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index fa5009e39605ca..563ab08de37051 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -346,7 +346,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)); @@ -362,7 +362,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 = FIELD_GET(SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK, val); @@ -375,17 +375,17 @@ static int sx9310_wait_for_sample(struct sx9310_data *data) static int sx9310_read_proximity(struct sx9310_data *data, const struct iio_chan_spec *chan, int *val) { - int ret = 0; + int ret; __be16 rawval; mutex_lock(&data->mutex); ret = sx9310_get_read_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out; ret = sx9310_enable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) + if (ret) goto out_put_channel; mutex_unlock(&data->mutex); @@ -399,22 +399,22 @@ static int sx9310_read_proximity(struct sx9310_data *data, mutex_lock(&data->mutex); - if (ret < 0) + if (ret) goto out_disable_irq; ret = sx9310_read_prox_data(data, chan, &rawval); - if (ret < 0) + if (ret) goto out_disable_irq; *val = sign_extend32(be16_to_cpu(rawval), (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); - if (ret < 0) + if (ret) goto out_put_channel; ret = sx9310_put_read_channel(data, chan->channel); - if (ret < 0) + if (ret) goto out; mutex_unlock(&data->mutex); @@ -436,7 +436,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 = FIELD_GET(SX9310_REG_PROX_CTRL0_SCANPERIOD_MASK, regval); @@ -538,7 +538,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; } @@ -572,7 +572,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; } @@ -615,20 +615,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); } } @@ -667,7 +667,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; @@ -696,7 +696,7 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private) indio_dev->masklength) { ret = sx9310_read_prox_data(data, &indio_dev->channels[bit], &val); - if (ret < 0) + if (ret) goto out; data->buffer.channels[i++] = val; @@ -803,13 +803,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, @@ -835,21 +835,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; } @@ -903,14 +903,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)); @@ -922,7 +922,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) { @@ -931,7 +931,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 = @@ -953,7 +953,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 Mon Aug 3 23:41:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699239 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 B913914E3 for ; Mon, 3 Aug 2020 23:42:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E454122CB2 for ; Mon, 3 Aug 2020 23:42:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="EDkTgSx3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728989AbgHCXmN (ORCPT ); Mon, 3 Aug 2020 19:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728962AbgHCXmL (ORCPT ); Mon, 3 Aug 2020 19:42:11 -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 E56A3C06174A for ; Mon, 3 Aug 2020 16:42:10 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id j8so28009969ioe.9 for ; Mon, 03 Aug 2020 16:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CCLYtffRrMc9qxywjxDgyRIEIRkAPxoHu8maaV5aJWg=; b=EDkTgSx3ByB9XWQ/01p1l86rRwnIRSTI0xhW+K2n3plr2QZRVutBXTYoeU5ec1W3Tz G5YVZTQ2k5BUmowPwuWDTF/OAHN3ftbuJF5LnKr1gR209vP7g7PKSjGRQwHaRz5Ub314 7rKLsxFW+Enn/59lDX+maCglGbigITKk6JCnM= 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=CCLYtffRrMc9qxywjxDgyRIEIRkAPxoHu8maaV5aJWg=; b=S7vD3XXQ3brSHpyVY0Zs9FOb0kwjLYRXwagm6B2MpXTgZIZOn2LP7Cvff6InEJ5C5c vl8jhytVq3vyvoULhAFkjd6lzqgm5Lzup/c80jOC+q8z2/828MN/8oz9o9ALAeL+qyxq 4de9SO7HOENxzNdxBCVqMbiDsP2eCU0+15JpoGbN2jpmgInSRAAXcXNBp9K6ktDT471t kgL14cwRCbeggxzMqRjDtWd5gf8M36M4rxrqAJmUtzTbwaEMSGiieeRAlyFEfe7hvnbW 9lI93CTr9vDcctVRRDpFbBWydz+Qq8IYSLCnxTBUsMVAQgKDG+BSS24i6T6NuJIFnOMc 57EA== X-Gm-Message-State: AOAM532DdMOL+KEV7oXQhszxNhXopfG9LjnpMUyUuHwcc0QnPRuLhBVc IQEFN1JgZ5s5wRVNbel/KovRhw== X-Google-Smtp-Source: ABdhPJzUdE3Zrr6eM+UfrKrRGosXuUSSmWv1dPrc4yWeMlpSOqKpmjaspKxf66hkmDj3OVUNcrJi1A== X-Received: by 2002:a05:6638:348:: with SMTP id x8mr2483365jap.62.1596498130366; Mon, 03 Aug 2020 16:42:10 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:10 -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 v4 11/15] iio: sx9310: Use variable to hold &client->dev Date: Mon, 3 Aug 2020 17:41:50 -0600 Message-Id: <20200803131544.v4.11.If9d9c0fe089e43ea2dbc7900b6d61cd05c66f1f7@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: - Added '\n' to dev_err() drivers/iio/proximity/sx9310.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 563ab08de37051..8b0e4d4eab5cf7 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -886,11 +886,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); @@ -904,17 +905,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; @@ -926,7 +926,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, @@ -934,29 +934,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 Mon Aug 3 23:41:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699241 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 0251B14E3 for ; Mon, 3 Aug 2020 23:42:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DEC520786 for ; Mon, 3 Aug 2020 23:42:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fDPbqbsV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729168AbgHCXma (ORCPT ); Mon, 3 Aug 2020 19:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728951AbgHCXmM (ORCPT ); Mon, 3 Aug 2020 19:42:12 -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 E9B15C06179F for ; Mon, 3 Aug 2020 16:42:11 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id v6so25113220iow.11 for ; Mon, 03 Aug 2020 16:42:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LZXl4w3kDSaErfg2y3h25IQlBp0Egyg38+/XFxCPJ8A=; b=fDPbqbsVIqwvebwhjnKfOdnJ0VZAH58mV9zMAwDqxwWIv94r98qP19gFWA8Kv9PkXh cl4LzqEudpJe48Af9e9RyOir4bsd6z11BMiyuhcb2wyYZ8pN+oNqQXIvyBgCEdEmktZZ zzXcmQw3RVqHDYQKY4IzrpSyT+yyH+2VONVGM= 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=LZXl4w3kDSaErfg2y3h25IQlBp0Egyg38+/XFxCPJ8A=; b=TxnMtj/sU8d2t4iwsagtbSIb24tAieJaYTTFeXygApyJzAJWUdSswfL4A/62BDnb/c LJO8mUl0D3n7Iv8EYwU5o42mFTn1Pt0i9hAMSe8q5anIwcZcLqQKc0AtjBHzTYkqLXv/ hVfcCbnGT5WCAg20hoeHjWtFKaVeI4NmkVZeMNCmDmNBAiHdCPs0eMQ9K4yxlSqIfn+a DqR0gkatTEGNpIr7DkwdN3UpM8FbdIqA+Sl3fBqo/lj8iFUUXuROQtZ1BoM5E8Zl8cFa iG8hKgKqrzI0WQkU7qE3/ivdnhxBvjzJWQTTMjU+fT5vp3CgTnGuSXzYYOne+hOIED0H ZyrQ== X-Gm-Message-State: AOAM533oP9u0cbENSK8vHZqelg8vykvdpCqQGQQxZ45nJUgWQM+LYve2 8KkAex3XhsRG3ie1aJfKZhkOGQ== X-Google-Smtp-Source: ABdhPJzoLMHeensVJ4IokfC6k8cATFGmmq4wlFwJMAEBG3ndJsiRW8PPv/xb9dHaPxCTW7raAkCGcg== X-Received: by 2002:a05:6638:138a:: with SMTP id w10mr2474380jad.36.1596498131329; Mon, 03 Aug 2020 16:42:11 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:10 -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 v4 12/15] iio: sx9310: Miscellaneous format fixes Date: Mon, 3 Aug 2020 17:41:51 -0600 Message-Id: <20200803131544.v4.12.I426355a035f0394dfccba5bb2bc6f8db872c4be3@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 8b0e4d4eab5cf7..6395f61b720658 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -90,28 +90,21 @@ #define SX9310_REG_SAR_CTRL2_SAROFFSET_DEFAULT 0x3c #define SX9310_REG_SENSOR_SEL 0x30 - #define SX9310_REG_USE_MSB 0x31 #define SX9310_REG_USE_LSB 0x32 - #define SX9310_REG_AVG_MSB 0x33 #define SX9310_REG_AVG_LSB 0x34 - #define SX9310_REG_DIFF_MSB 0x35 #define SX9310_REG_DIFF_LSB 0x36 - #define SX9310_REG_OFFSET_MSB 0x37 #define SX9310_REG_OFFSET_LSB 0x38 - #define SX9310_REG_SAR_MSB 0x39 #define SX9310_REG_SAR_LSB 0x3a - #define SX9310_REG_I2C_ADDR 0x40 #define SX9310_REG_PAUSE 0x41 #define SX9310_REG_WHOAMI 0x42 #define SX9310_WHOAMI_VALUE 0x01 #define SX9311_WHOAMI_VALUE 0x02 - #define SX9310_REG_RESET 0x7f #define SX9310_SOFT_RESET 0xde @@ -407,7 +400,7 @@ static int sx9310_read_proximity(struct sx9310_data *data, goto out_disable_irq; *val = sign_extend32(be16_to_cpu(rawval), - (chan->address == SX9310_REG_DIFF_MSB ? 11 : 15)); + chan->address == SX9310_REG_DIFF_MSB ? 11 : 15); ret = sx9310_disable_irq(data, SX9310_CONVDONE_IRQ); if (ret) @@ -434,8 +427,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; @@ -520,10 +514,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; } @@ -640,7 +633,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 = { @@ -971,7 +964,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; @@ -1017,21 +1009,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 Mon Aug 3 23:41:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699243 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 78A42912 for ; Mon, 3 Aug 2020 23:42:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2EE320786 for ; Mon, 3 Aug 2020 23:42:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SL4ZbGfu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728997AbgHCXma (ORCPT ); Mon, 3 Aug 2020 19:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728985AbgHCXmN (ORCPT ); Mon, 3 Aug 2020 19:42:13 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4BADC0617A1 for ; Mon, 3 Aug 2020 16:42:12 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id u126so3080379iod.12 for ; Mon, 03 Aug 2020 16:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TlOlrlXvKy/dxP8XanrvFTIVOHJ2xsZzzW4ZNNxbqnE=; b=SL4ZbGfufYoeiv5aV67FYPCP69iJJxf1kiGlEKyreAbc/PIQOChKSdcmC4ggJ9rFib ORIv7vnPS6aGFJyRJK17nsfXLtm74uFk/k/xf+ANBBvONcFSCEoBLD5ajgiJnsyv2Vmq 4L0suo+5A4JwHYrFO4brtS0zQn8nwpp3PHaS4= 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=TlOlrlXvKy/dxP8XanrvFTIVOHJ2xsZzzW4ZNNxbqnE=; b=CnKdDcmpDBJw6sYBHYr77k8PYD2N03V8EZXnFxlJuCxSo3v4HRYQmmNwlCbLWMzy2W fIHBaYMqkQJEJHJNUNbQcKrqXZi/EBu0nf+ZMxeFjOQRyAH3oRjhgl3oHsSJkCmPWt/a z9NkyLjkg8HyALjTlUxIKbcu1NT6snDuNGGwbSH9SkQRCd6Wx6SQViLZU43tHjM811ag yasJG+oGZAAI/BDhC4a0yiS2ZUHjweI2LIblI7jdRAJvtmeOw9OT9jDkRJQSe9IPk/R7 Hf/zRBhS2E93HNrNf5vSyYfCRitjrvN3WO1RV+zBK+42kT7VBIU+T3vqnqZe1kFbMvb7 XnsA== X-Gm-Message-State: AOAM530KVwyUSSGuhkrhrGkOV6f7sBILYwNd+6z7yRY0Ry0jwuYEFSvg ku8m5UP1ZvXqhuEYU8IKDwNKcA== X-Google-Smtp-Source: ABdhPJxFvy1b82IWfcWuSV5sTLUIYinGrrp2h7y5igwOEByQAXV7GORiw6dMaomMLjMkY1d8Kx/jow== X-Received: by 2002:a6b:8e8c:: with SMTP id q134mr2313383iod.147.1596498132308; Mon, 03 Aug 2020 16:42:12 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:11 -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 v4 13/15] iio: sx9310: Drop channel_users[] Date: Mon, 3 Aug 2020 17:41:52 -0600 Message-Id: <20200803131544.v4.13.Ia5c5fdbdfff576ab5d034cde46c25cc66a4baf50@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 6395f61b720658..2e0ea84dba2118 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -135,7 +135,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 Mon Aug 3 23:41:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699235 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 B783B14E3 for ; Mon, 3 Aug 2020 23:42:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1EF620786 for ; Mon, 3 Aug 2020 23:42:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="H5mu5GLE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729005AbgHCXmO (ORCPT ); Mon, 3 Aug 2020 19:42:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728995AbgHCXmN (ORCPT ); Mon, 3 Aug 2020 19:42:13 -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 D0454C061756 for ; Mon, 3 Aug 2020 16:42:13 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id t15so31441546iob.3 for ; Mon, 03 Aug 2020 16:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lln6JBYYKdkFr9fLVLldmukzP3b+qcX1x2upAv1i08M=; b=H5mu5GLEbAav9nWv/vcrIv0kD3UYIsL3qvoKbPqU02gHbkTG0Yw4Mai4/Xsr0ZAWbA zJXT4mQuuojDD1UV5GyyTD1XkLIEVCsKuSiKEPFHSeHgRmLD83RxMoV75LGx28K7RBy6 0Y2gAgqxnCLM0YmO/9/tMORLfLrEoEZYC8aXg= 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=Lln6JBYYKdkFr9fLVLldmukzP3b+qcX1x2upAv1i08M=; b=M5rt6nEjtNLQJIIif7jWmWbRs6QX63kK+/VZdqj4mllRk77NQxE/S6f9hHOjqDejV1 ctktF7EsqAs0P38/RLeRDftC00b1AY7HQyvyJsfPvofWVOnKCc4PsbrW0c19Slwzmtoh 7xEMrrQMjKcdxPkjicLefuOX2BCn6XSICCv6uZt4h0ICCY3FqsLq24s65pxnskd3x8Wg 2YRkLOG3a6SasAtK1wPU5NrWQgbl7elRfx25bYOmuwmTJk7uEww4yCYgqcS4eT3JTQUI bTcPuEAZrzkTzLmyJdSH05NyLuWMuBULdf1RdT14WKPbf39S1uNld6S/tVrsqf54jj1m tY8A== X-Gm-Message-State: AOAM5318cnIlB/Rgb4xycmYc6DFj2b97Z937yxLwRcIXsMqqU46ApsBH mAm2q/SEPQ0+VDSli1ReiTnFBw== X-Google-Smtp-Source: ABdhPJwbfKLAgwd0K36OIo7YxxvBfOar8ndgtPuTAxf05fkRkAywntsLzGTdLBgjVcA8fbm/DbBPKQ== X-Received: by 2002:a6b:b7ce:: with SMTP id h197mr2414554iof.60.1596498133234; Mon, 03 Aug 2020 16:42:13 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:12 -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 v4 14/15] iio: sx9310: Enable vdd and svdd regulators at probe Date: Mon, 3 Aug 2020 17:41:53 -0600 Message-Id: <20200803131544.v4.14.Ib7bdc8340021d8515b430498fb6686eedf22c9f2@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-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 v4: None Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 2e0ea84dba2118..a6e345bb9ffe5c 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. @@ -875,6 +877,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; @@ -888,6 +897,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); @@ -895,6 +906,21 @@ static int sx9310_probe(struct i2c_client *client) if (IS_ERR(data->regmap)) return PTR_ERR(data->regmap); + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), + data->supplies); + if (ret) + return ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies); + if (ret) + return ret; + /* Must wait for Tpor time after initial power up */ + usleep_range(1000, 1100); + + ret = devm_add_action_or_reset(dev, sx9310_regulator_disable, data); + if (ret) + return ret; + ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &data->whoami); if (ret) { dev_err(dev, "error in reading WHOAMI register: %d\n", ret); From patchwork Mon Aug 3 23:41:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11699237 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 43E65912 for ; Mon, 3 Aug 2020 23:42:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7006A20792 for ; Mon, 3 Aug 2020 23:42:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XCvS7meq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729139AbgHCXmY (ORCPT ); Mon, 3 Aug 2020 19:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729021AbgHCXmP (ORCPT ); Mon, 3 Aug 2020 19:42:15 -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 D7E7DC06174A for ; Mon, 3 Aug 2020 16:42:14 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id k23so40312582iom.10 for ; Mon, 03 Aug 2020 16:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=riJ3umw0V2+FfFxLjOBTqqOTzlRoPL8VdrC9Npn7RlM=; b=XCvS7meqieMCTnygetGwEK0pJso1pPfTOnD6XIxJZ3Uepl0ffi8YRsw/QlwSYrgHdg xnz7PgLuS2B57e3/UEnOuDehPoctgxNgnzt0F7ph/fyRZWG9cRN5sCO2WaPZfWM12LgA utsMT2ecb+ZKB9bHVVeTo57fv4AA5BnDnCk6w= 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=riJ3umw0V2+FfFxLjOBTqqOTzlRoPL8VdrC9Npn7RlM=; b=G5jKlEQNIWkd57+oDFOvBbT8KjgtDOHDMwOQdizlnSvOZmhUg5m6vR5/XxvurdPDQl HlK9KuHOSwqyzYg+wYgpe8C8uspnDgCutQuyYvf0TLkwdLYPBLvKx8EBWanherwunZRL 8kFl5G05QDv1IQh6NwdWI+XMeHbWoPHHjISOt/ccKljvcAG47fPDwUrT9YoLHh3xhZpz ScrErkq7mIfGw7dRKx5Ki6lT51nSSsmG4PpMvL/Clb1a63u7cGIZwW4J90fAfI8k5lnj ptktFa3XvyFDslSPu1aWfS9r7XXw/uyYQ+F6mengiw2dJbNrXDJClqf46s14z8gsSur5 YD3g== X-Gm-Message-State: AOAM532X/rYCqUy1vB58dEnT/MyV6Ma8809K/nuo38zNJR3knsHy6LqY pyGGIrB+/1Rsoz5nbcCPcuX+fg== X-Google-Smtp-Source: ABdhPJzZk3yQ+cOxunAhzmGr08Vzc3KwmOscO6pv6ZRnMceZ+QX863JCBZEYJ3pblsOKPp8aAi83ZA== X-Received: by 2002:a02:838e:: with SMTP id z14mr2649202jag.84.1596498134252; Mon, 03 Aug 2020 16:42:14 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id g2sm5468435ioe.4.2020.08.03.16.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 16:42:13 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Daniel Campello , Andy Shevchenko , Douglas Anderson , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v4 15/15] iio: sx9310: Use irq trigger flags from firmware Date: Mon, 3 Aug 2020 17:41:54 -0600 Message-Id: <20200803131544.v4.15.I4c344a6793007001bbb3c1c08e96d3acf893b36b@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200803234154.320400-1-campello@chromium.org> References: <20200803234154.320400-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Stephen Boyd We shouldn't need to set default irq trigger flags here as the firmware should have properly indicated the trigger type, i.e. level low, in the DT or ACPI tables. Signed-off-by: Stephen Boyd Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- Changes in v4: None Changes in v3: - Added irq trigger flags commit to the series. Changes in v2: None drivers/iio/proximity/sx9310.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index a6e345bb9ffe5c..9d1b35eee304ee 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -947,7 +947,7 @@ static int sx9310_probe(struct i2c_client *client) ret = devm_request_threaded_irq(dev, client->irq, sx9310_irq_handler, sx9310_irq_thread_handler, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, + IRQF_ONESHOT, "sx9310_event", indio_dev); if (ret) return ret;