Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4202378imu; Sat, 19 Jan 2019 04:38:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN6YIPCivWApxk4W9yhyYtmrcLtU3zO/u1ld49aBprS7TINhto3D1GybeOmSEJ60SwhAmZkG X-Received: by 2002:a62:8d4f:: with SMTP id z76mr23752594pfd.2.1547901524003; Sat, 19 Jan 2019 04:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547901523; cv=none; d=google.com; s=arc-20160816; b=zJtYcAPeUcfes9o71GOXCMRi/OwPMZbIkdEgojMig/4IfsQvMoS7/oxQQ3z/awsTc4 5JBdpXGT+r5I+L1dwKqtD0XiL5qrszaE6QfBemRfIZ3xrA0Icq4trMa5VrWMsWbfuAso a2Fab15TnPVVmbzGd5lKqU3uwVqiuoJXC4LyaTW782z2PYAxuv79gGRv1g9eD1gjYI+w VWpmuPSySmNshc+Ohitkwlk5E9fD/drYBTM5FIcObqH5SBn98ffAkf/YCKf/KUOKcC8X MSjcUhrPR7VyKBcy8CH1l8tCZ8wA94xwxRNRHl3wp4g7Fi+JShffHDX45wCqiLNf7uIK 579w== 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=uFTBOHxnqCUPbadQymZ3mdmjgd4AjHv6OkdDBLVR+3Y=; b=L9vcMbgK1XdYtQEq4zRFQvSGB3swiUpfVVGjTtNXXmGBLt/+YthWb+PhbCq6MmoopR 231MOFsx5cp/GnqtN1HtVro/CMJo1AHXFXfC1ECs/rMSPRNKTRhV1k5hxsUd8zznsXAO fmFgtSutnGVoWZ2wEb27k8/yQVchS70ZQgYygmPYCvUflHhaGJtvRRlhaMYZDwIa3vva k3Psr2rx+epnyWkDw0g7YgGx//Oom+03iy4vlg1It+Ng7ZmpvvMKHBOvdG26iNwGrlNR eZjr/YhTlz0zw6VPf7aG+l5JMNfmCGdSey5sQOpxJzuXIS52SVOlV7Nwhm3N8sHU4pgQ X++g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ingics-com.20150623.gappssmtp.com header.s=20150623 header.b=L+TnCh1V; 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 w17si7256472pgl.6.2019.01.19.04.38.26; Sat, 19 Jan 2019 04:38:43 -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=L+TnCh1V; 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 S1728049AbfASMg5 (ORCPT + 99 others); Sat, 19 Jan 2019 07:36:57 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36189 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728015AbfASMg4 (ORCPT ); Sat, 19 Jan 2019 07:36:56 -0500 Received: by mail-pl1-f196.google.com with SMTP id g9so7593147plo.3 for ; Sat, 19 Jan 2019 04:36:56 -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=uFTBOHxnqCUPbadQymZ3mdmjgd4AjHv6OkdDBLVR+3Y=; b=L+TnCh1Vop5nq+EFY+04Ckc2Eop2yb4M2djUSMtajjJNzVp8IyhPvBzmg3lyFBG7IS OOtdg1pE5MMcGi0GbJ75tXSgZNtjq/RoUnA2kDn5DfSUub3EXPqfLQnMxyu1oJYy6urv W3oeUXK0ZmPrLXJuvUhngQRBAqTaLsQCx9TmV50wd6qMP3Bs2K0985LvTKFGbAWWC6QS ZSTQr0H3DK1tw4+SKuqiTfngRoHR/b3kZHn6KBh+alDu0YfeY/Y251/hpCfaG+qczjLh WinDi7waN/LuOHnsyUpHseriGk0N7ET9kNToWsqGYOBdhZLmO3Co+QoAKrH1dnIBkIZj 6FEg== 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=uFTBOHxnqCUPbadQymZ3mdmjgd4AjHv6OkdDBLVR+3Y=; b=NQD8ZiJ5idqbAswsFW2a8lPvtD3bNqeEqxYIPSc3xOROoArS+1i0g9Axcl/AX6sq6V znFTGgVIqqo+sUEjWEe4D/6M/V5gboFFQ6d43mz1Zf/2+R3fPKuQ7suOST5LHc7A44Z0 0rLqLVkwxrdi6HaW5aOFHy40/3bvv+MHYnusbYiEFZ5hjdNSSThIlj0qBK/eE55ziJZ2 xACrxyTgtthX0RqP/8cmDfR7Vb41VNP5xqf+xWMpvlIXGC71mdBSdbP9pXJ04+uGyVTZ 5pxRInTEQYE0FuDTd+OdpfTZoHV71paUWD0h+BiwHF5TjcmfjQ+k5OQVMz2DiCMuzre1 ztTg== X-Gm-Message-State: AJcUukdakvzyihhm5sAlttgUFWLfJfqboFSY8HNEjAgz4WHJpKL4A6sy itSM88uFOqqG8KfcECRj6aVYUg== X-Received: by 2002:a17:902:981:: with SMTP id 1mr22236009pln.142.1547901415683; Sat, 19 Jan 2019 04:36:55 -0800 (PST) Received: from localhost.localdomain (118-171-134-87.dynamic-ip.hinet.net. [118.171.134.87]) by smtp.gmail.com with ESMTPSA id m85sm11971004pfj.171.2019.01.19.04.36.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jan 2019 04:36:54 -0800 (PST) From: Axel Lin To: Mark Brown Cc: Charles Keepax , Liam Girdwood , linux-kernel@vger.kernel.org, Axel Lin Subject: [PATCH] regulator: arizona-ldo1: Convert to use regulator_linear_range for ldo1_hc Date: Sat, 19 Jan 2019 20:36:36 +0800 Message-Id: <20190119123636.19525-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 Signed-off-by: Axel Lin --- drivers/regulator/arizona-ldo1.c | 37 ++++++++------------------------ 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index b9a93049e41e..dfed6d3f03ad 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -40,30 +40,6 @@ struct arizona_ldo1 { struct gpio_desc *ena_gpiod; }; -static int arizona_ldo1_hc_list_voltage(struct regulator_dev *rdev, - unsigned int selector) -{ - if (selector >= rdev->desc->n_voltages) - return -EINVAL; - - if (selector == rdev->desc->n_voltages - 1) - return 1800000; - else - return rdev->desc->min_uV + (rdev->desc->uV_step * selector); -} - -static int arizona_ldo1_hc_map_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV) -{ - int sel; - - sel = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); - if (sel >= rdev->desc->n_voltages) - sel = rdev->desc->n_voltages - 1; - - return sel; -} - static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev, unsigned sel) { @@ -113,14 +89,19 @@ static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev) } static const struct regulator_ops arizona_ldo1_hc_ops = { - .list_voltage = arizona_ldo1_hc_list_voltage, - .map_voltage = arizona_ldo1_hc_map_voltage, + .list_voltage = regulator_list_voltage_linear_range, + .map_voltage = regulator_map_voltage_linear_range, .get_voltage_sel = arizona_ldo1_hc_get_voltage_sel, .set_voltage_sel = arizona_ldo1_hc_set_voltage_sel, .get_bypass = regulator_get_bypass_regmap, .set_bypass = regulator_set_bypass_regmap, }; +static const struct regulator_linear_range arizona_ldo1_hc_ranges[] = { + REGULATOR_LINEAR_RANGE(900000, 0, 0x6, 50000), + REGULATOR_LINEAR_RANGE(1800000, 0x7, 0x7, 0), +}; + static const struct regulator_desc arizona_ldo1_hc = { .name = "LDO1", .supply_name = "LDOVDD", @@ -129,8 +110,8 @@ static const struct regulator_desc arizona_ldo1_hc = { .bypass_reg = ARIZONA_LDO1_CONTROL_1, .bypass_mask = ARIZONA_LDO1_BYPASS, - .min_uV = 900000, - .uV_step = 50000, + .linear_ranges = arizona_ldo1_hc_ranges, + .n_linear_ranges = ARRAY_SIZE(arizona_ldo1_hc_ranges), .n_voltages = 8, .enable_time = 1500, .ramp_delay = 24000, -- 2.17.1