From patchwork Sun Jan 6 08:37:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 1021053 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43XX400vzPz9sDL for ; Sun, 6 Jan 2019 19:38:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726553AbfAFIiG (ORCPT ); Sun, 6 Jan 2019 03:38:06 -0500 Received: from mx2.suse.de ([195.135.220.15]:57222 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726508AbfAFIiF (ORCPT ); Sun, 6 Jan 2019 03:38:05 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1C747ACFA; Sun, 6 Jan 2019 08:38:04 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-lpwan@lists.infradead.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andrea?= =?utf-8?b?cyBGw6RyYmVy?= , Ben Whitten , "David S. Miller" Subject: [PATCH lora-next 05/11] net: lora: sx130x: Fix regmap field toggles Date: Sun, 6 Jan 2019 09:37:48 +0100 Message-Id: <20190106083754.6004-6-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190106083754.6004-1-afaerber@suse.de> References: <20190106083754.6004-1-afaerber@suse.de> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When toggling the value of a regmap field, such as for F_RADIO_RST or F_EMERGENCY_FORCE_HOST_CTRL, we need to ensure it gets written out. Sadly the timing of the writes got lost in the regmap field conversion. Introduce an sx130x_field_force_write() helper for this. While at it, make trivial sx130x_field_write() static inline, too. Cc: Ben Whitten Signed-off-by: Andreas Färber --- drivers/net/lora/sx130x.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/lora/sx130x.c b/drivers/net/lora/sx130x.c index 4ba02836a35d..457f2396d9ee 100644 --- a/drivers/net/lora/sx130x.c +++ b/drivers/net/lora/sx130x.c @@ -174,12 +174,18 @@ const struct regmap_config sx130x_regmap_config = { }; EXPORT_SYMBOL_GPL(sx130x_regmap_config); -static int sx130x_field_write(struct sx130x_priv *priv, +static inline int sx130x_field_write(struct sx130x_priv *priv, enum sx130x_fields field_id, u8 val) { return regmap_field_write(priv->regmap_fields[field_id], val); } +static inline int sx130x_field_force_write(struct sx130x_priv *priv, + enum sx130x_fields field_id, u8 val) +{ + return regmap_field_force_write(priv->regmap_fields[field_id], val); +} + static int sx130x_soft_reset(struct sx130x_priv *priv) { int ret; @@ -373,7 +379,7 @@ static int sx130x_agc_calibrate(struct sx130x_priv *priv) return -EIO; } - ret = sx130x_field_write(priv, F_EMERGENCY_FORCE_HOST_CTRL, 0); + ret = sx130x_field_force_write(priv, F_EMERGENCY_FORCE_HOST_CTRL, 0); if (ret) { dev_err(priv->dev, "emergency force failed\n"); return ret; @@ -694,7 +700,7 @@ int sx130x_probe(struct device *dev) msleep(500); - ret = sx130x_field_write(priv, F_RADIO_RST, 1); + ret = sx130x_field_force_write(priv, F_RADIO_RST, 1); if (ret) { dev_err(dev, "radio assert reset failed (%d)\n", ret); return ret;