Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4248252imc; Mon, 25 Feb 2019 01:16:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IZrVpXVfPGoXoHuJK9wpJRTNI0igAxfCpWe3UE4mMMPe62pLIJVZgiZo6uPPyz1OWCxjXcb X-Received: by 2002:a17:902:8a91:: with SMTP id p17mr19478709plo.316.1551086177673; Mon, 25 Feb 2019 01:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551086177; cv=none; d=google.com; s=arc-20160816; b=dMbZ0iNU7Ks11K06P17N+oEJGonX+1Za0A9cXba6UYRDJE3pAFLDaLi3uGOijxzD3k Xu+DA6Zxa0JAAVBsjxFTgl2a02/0GQY8CNx5XBZHW426VTlLLwPhXJ1YxJjj1X3jSIe8 xdmyu9tODAdWL7Kcz8L4iQkaHNRyl/hxp5CY6LcJKr9X4PPeXom99cuKo2en7NCnmSTc nDbk+aptbLBIwTITqf07ei1lwF1bzsSWZIkaJDaN/tEgz80/NKWjzkbJbBzYoe0Ze8XL MkRTK6TZCEtk+vsxpWQZaq/E5HrRULRuaDyK4wcNprLYahjOYmcleh3R5+9o0jMsROOf WOYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=UpxBY7cksRBN49z6GdQZcO+xAJ0NwGNp0fRtgo2CD1E=; b=ZPVriB7JYa6moNjx8j0N57OvXj6SJwjwEQn16StcA6JVbWblYv6JerBsFkx5O9kC9j Vj37j9vD3J8EpzgoaRaAYDZu3lUV5Ie/ka6BG10EmUr+8/bOd48q4jypmFHmosr4rz8M /x7j367mnyqg2AkuLYX095pjxwemsGsM22dWff09LySdG9jhjxSmKfy5YveIrpxPrgOG OZQ9O4FylVLFgrpJAHOwSL6hWECwZMMxuFIoA2Bh87eoDqnSZgfyRdTMpPlajdczYAgn pdzm0EdwwwJ/Vu7VE3Ndf/CBic2HHU1KV9GAPheuUlGjA8oQYMYihpyBhmblzQtts3S3 ivjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ingics-com.20150623.gappssmtp.com header.s=20150623 header.b=IoOsvu6d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b60si9401184plc.95.2019.02.25.01.16.01; Mon, 25 Feb 2019 01:16:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ingics-com.20150623.gappssmtp.com header.s=20150623 header.b=IoOsvu6d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726492AbfBYJOF (ORCPT + 99 others); Mon, 25 Feb 2019 04:14:05 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36677 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbfBYJOF (ORCPT ); Mon, 25 Feb 2019 04:14:05 -0500 Received: by mail-pf1-f193.google.com with SMTP id n22so4223121pfa.3 for ; Mon, 25 Feb 2019 01:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=UpxBY7cksRBN49z6GdQZcO+xAJ0NwGNp0fRtgo2CD1E=; b=IoOsvu6d0lQiNN24fFoJB/9D/Aih6OuEOtbC3c7gtuEQVIZJmsnhQzw5YrhBt8tGmK +eDB2plNj8Uz/YweeSjGENTiesArgoymFKWH4kT+dS37MPt6jcvZOYkL/VGVcFPLqFuP SCXAZQQAOfzi71ii/FSAJYGj6LhO1zv+OkesPypu3oh2oKf64m9QxANiMjMizXPbesZn yZ5AJqvRI/ycgELEBJOiazxB79fidInDfd+Zu13xxoWPR49pLrjv5/XyOAFfvDq5ycnj Za6DVHGSp/R9hQMauFJte2UQ3XFE5MZtLRrNVv9YB9QbybkZD24YRb3kBkocDB0iNmTo Lvew== 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; bh=UpxBY7cksRBN49z6GdQZcO+xAJ0NwGNp0fRtgo2CD1E=; b=LhP6RD94Gu12PXB3yAVHrxHcPPqA7KIkMm2b1lqSMCSKVinxZ27DuqRvZRnTp8fMi3 dbb+ol1Lpw6YpxaWovJUBH2d+Kp/hjHp9KyoWcsuDs9U3fk/Sa2KEsAZVNMYpXid5YbM ux/IBemwEEmjNSMwGDoRZE/Z2ILwd9fjX6YCqeAqRb9ewdl7jXnPqkbSwRjkJAMhxt3G M9mIBekLpfJnQCnppFJ4cXUJGjYPEki/O/JnmewWdfHfjUYNoIwDwUYMh9kJP8ER7ooe rT2NQDvkMdolLAyRdhhwtHzqxJ/RN/TNpJGMtcsHNokaZL8l+0nrZS8kBlM/tP69Xv+D bcOQ== X-Gm-Message-State: AHQUAuanAgZaxFQ2jZKIvAW/D7m5Zsy5XNk2wdVBqnSfWYHzjisDKytt or8E7+PA8aWJNqaLl+1NB8zyzQ== X-Received: by 2002:aa7:8150:: with SMTP id d16mr19553971pfn.172.1551086044007; Mon, 25 Feb 2019 01:14:04 -0800 (PST) Received: from localhost.localdomain (36-239-237-193.dynamic-ip.hinet.net. [36.239.237.193]) by smtp.gmail.com with ESMTPSA id o76sm18474402pfa.156.2019.02.25.01.14.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 01:14:02 -0800 (PST) From: Axel Lin To: Mark Brown Cc: Liam Girdwood , linux-kernel@vger.kernel.org, Axel Lin Subject: [PATCH] regulator: arizona_ldo1: Simplify arizona_ldo1_hc_set/get_voltage_sel Date: Mon, 25 Feb 2019 17:13:49 +0800 Message-Id: <20190225091349.6159-1-axel.lin@ingics.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Setup .vsel_reg and .vsel_mask then we can use the standard set/get_voltage_sel_regmap helpers to simplify the code. Signed-off-by: Axel Lin --- drivers/regulator/arizona-ldo1.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index dfed6d3f03ad..bf3ab405eed1 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -43,8 +43,7 @@ struct arizona_ldo1 { static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev, unsigned sel) { - struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev); - struct regmap *regmap = ldo->regmap; + struct regmap *regmap = rdev_get_regmap(rdev); unsigned int val; int ret; @@ -61,16 +60,12 @@ static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev, if (val) return 0; - val = sel << ARIZONA_LDO1_VSEL_SHIFT; - - return regmap_update_bits(regmap, ARIZONA_LDO1_CONTROL_1, - ARIZONA_LDO1_VSEL_MASK, val); + return regulator_set_voltage_sel_regmap(rdev, sel); } static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev) { - struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev); - struct regmap *regmap = ldo->regmap; + struct regmap *regmap = rdev_get_regmap(rdev); unsigned int val; int ret; @@ -81,11 +76,7 @@ static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev) if (val & ARIZONA_LDO1_HI_PWR) return rdev->desc->n_voltages - 1; - ret = regmap_read(regmap, ARIZONA_LDO1_CONTROL_1, &val); - if (ret != 0) - return ret; - - return (val & ARIZONA_LDO1_VSEL_MASK) >> ARIZONA_LDO1_VSEL_SHIFT; + return regulator_get_voltage_sel_regmap(rdev); } static const struct regulator_ops arizona_ldo1_hc_ops = { @@ -108,6 +99,8 @@ static const struct regulator_desc arizona_ldo1_hc = { .type = REGULATOR_VOLTAGE, .ops = &arizona_ldo1_hc_ops, + .vsel_reg = ARIZONA_LDO1_CONTROL_1, + .vsel_mask = ARIZONA_LDO1_VSEL_MASK, .bypass_reg = ARIZONA_LDO1_CONTROL_1, .bypass_mask = ARIZONA_LDO1_BYPASS, .linear_ranges = arizona_ldo1_hc_ranges, -- 2.17.1