From: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel-team@lists.ubuntu.com
Cc: Axel Lin <axel.lin@gmail.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Subject: [PATCH 32/74] regulator: max8998: Convert to set_voltage_sel and regulator_map_voltage_linear
Date: Thu, 24 Jan 2013 01:26:44 -0200 [thread overview]
Message-ID: <1358998046-613-33-git-send-email-herton.krzesinski@canonical.com> (raw)
In-Reply-To: <1358998046-613-1-git-send-email-herton.krzesinski@canonical.com>
3.5.7.4 -stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <axel.lin@gmail.com>
commit baae019efe84b6d2c6d5e7e7e1c9cfa130ad6b2a upstream.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
---
drivers/regulator/max8998.c | 97 ++++++++++++-------------------------------
1 file changed, 27 insertions(+), 70 deletions(-)
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 105dafc..a1fa266 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -276,41 +276,18 @@ static int max8998_get_voltage_sel(struct regulator_dev *rdev)
return val;
}
-static int max8998_set_voltage_ldo(struct regulator_dev *rdev,
- int min_uV, int max_uV, unsigned *selector)
+static int max8998_set_voltage_ldo_sel(struct regulator_dev *rdev,
+ unsigned selector)
{
struct max8998_data *max8998 = rdev_get_drvdata(rdev);
struct i2c_client *i2c = max8998->iodev->i2c;
- int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
- const struct voltage_map_desc *desc;
- int ldo = rdev_get_id(rdev);
- int reg, shift = 0, mask, ret, i;
-
- if (ldo >= ARRAY_SIZE(ldo_voltage_map))
- return -EINVAL;
-
- desc = ldo_voltage_map[ldo];
- if (desc == NULL)
- return -EINVAL;
-
- if (max_vol < desc->min || min_vol > desc->max)
- return -EINVAL;
-
- if (min_vol < desc->min)
- min_vol = desc->min;
-
- i = DIV_ROUND_UP(min_vol - desc->min, desc->step);
-
- if (desc->min + desc->step*i > max_vol)
- return -EINVAL;
-
- *selector = i;
+ int reg, shift = 0, mask, ret;
ret = max8998_get_voltage_register(rdev, ®, &shift, &mask);
if (ret)
return ret;
- ret = max8998_update_reg(i2c, reg, i<<shift, mask<<shift);
+ ret = max8998_update_reg(i2c, reg, selector<<shift, mask<<shift);
return ret;
}
@@ -326,41 +303,18 @@ static inline void buck2_gpio_set(int gpio, int v)
gpio_set_value(gpio, v & 0x1);
}
-static int max8998_set_voltage_buck(struct regulator_dev *rdev,
- int min_uV, int max_uV, unsigned *selector)
+static int max8998_set_voltage_buck_sel(struct regulator_dev *rdev,
+ unsigned selector)
{
struct max8998_data *max8998 = rdev_get_drvdata(rdev);
struct max8998_platform_data *pdata =
dev_get_platdata(max8998->iodev->dev);
struct i2c_client *i2c = max8998->iodev->i2c;
- int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
- const struct voltage_map_desc *desc;
int buck = rdev_get_id(rdev);
int reg, shift = 0, mask, ret;
- int i, j, previous_sel;
+ int j, previous_sel;
static u8 buck1_last_val;
- if (buck >= ARRAY_SIZE(ldo_voltage_map))
- return -EINVAL;
-
- desc = ldo_voltage_map[buck];
-
- if (desc == NULL)
- return -EINVAL;
-
- if (max_vol < desc->min || min_vol > desc->max)
- return -EINVAL;
-
- if (min_vol < desc->min)
- min_vol = desc->min;
-
- i = DIV_ROUND_UP(min_vol - desc->min, desc->step);
-
- if (desc->min + desc->step*i > max_vol)
- return -EINVAL;
-
- *selector = i;
-
ret = max8998_get_voltage_register(rdev, ®, &shift, &mask);
if (ret)
return ret;
@@ -369,19 +323,19 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
/* Check if voltage needs to be changed */
/* if previous_voltage equal new voltage, return */
- if (previous_sel == i) {
+ if (previous_sel == selector) {
dev_dbg(max8998->dev, "No voltage change, old:%d, new:%d\n",
regulator_list_voltage_linear(rdev, previous_sel),
- regulator_list_voltage_linear(rdev, i));
+ regulator_list_voltage_linear(rdev, selector));
return ret;
}
switch (buck) {
case MAX8998_BUCK1:
dev_dbg(max8998->dev,
- "BUCK1, i:%d, buck1_vol1:%d, buck1_vol2:%d\n"
+ "BUCK1, selector:%d, buck1_vol1:%d, buck1_vol2:%d\n"
"buck1_vol3:%d, buck1_vol4:%d\n",
- i, max8998->buck1_vol[0], max8998->buck1_vol[1],
+ selector, max8998->buck1_vol[0], max8998->buck1_vol[1],
max8998->buck1_vol[2], max8998->buck1_vol[3]);
if (gpio_is_valid(pdata->buck1_set1) &&
@@ -390,7 +344,7 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
/* check if requested voltage */
/* value is already defined */
for (j = 0; j < ARRAY_SIZE(max8998->buck1_vol); j++) {
- if (max8998->buck1_vol[j] == i) {
+ if (max8998->buck1_vol[j] == selector) {
max8998->buck1_idx = j;
buck1_gpio_set(pdata->buck1_set1,
pdata->buck1_set2, j);
@@ -405,11 +359,11 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
max8998->buck1_idx = (buck1_last_val % 2) + 2;
dev_dbg(max8998->dev, "max8998->buck1_idx:%d\n",
max8998->buck1_idx);
- max8998->buck1_vol[max8998->buck1_idx] = i;
+ max8998->buck1_vol[max8998->buck1_idx] = selector;
ret = max8998_get_voltage_register(rdev, ®,
&shift,
&mask);
- ret = max8998_write_reg(i2c, reg, i);
+ ret = max8998_write_reg(i2c, reg, selector);
buck1_gpio_set(pdata->buck1_set1,
pdata->buck1_set2, max8998->buck1_idx);
buck1_last_val++;
@@ -419,20 +373,20 @@ buck1_exit:
gpio_get_value(pdata->buck1_set2));
break;
} else {
- ret = max8998_write_reg(i2c, reg, i);
+ ret = max8998_write_reg(i2c, reg, selector);
}
break;
case MAX8998_BUCK2:
dev_dbg(max8998->dev,
- "BUCK2, i:%d buck2_vol1:%d, buck2_vol2:%d\n"
- , i, max8998->buck2_vol[0], max8998->buck2_vol[1]);
+ "BUCK2, selector:%d buck2_vol1:%d, buck2_vol2:%d\n",
+ selector, max8998->buck2_vol[0], max8998->buck2_vol[1]);
if (gpio_is_valid(pdata->buck2_set3)) {
/* check if requested voltage */
/* value is already defined */
for (j = 0; j < ARRAY_SIZE(max8998->buck2_vol); j++) {
- if (max8998->buck2_vol[j] == i) {
+ if (max8998->buck2_vol[j] == selector) {
max8998->buck2_idx = j;
buck2_gpio_set(pdata->buck2_set3, j);
goto buck2_exit;
@@ -444,20 +398,21 @@ buck1_exit:
max8998_get_voltage_register(rdev,
®, &shift, &mask);
- ret = max8998_write_reg(i2c, reg, i);
- max8998->buck2_vol[max8998->buck2_idx] = i;
+ ret = max8998_write_reg(i2c, reg, selector);
+ max8998->buck2_vol[max8998->buck2_idx] = selector;
buck2_gpio_set(pdata->buck2_set3, max8998->buck2_idx);
buck2_exit:
dev_dbg(max8998->dev, "%s: SET3:%d\n", i2c->name,
gpio_get_value(pdata->buck2_set3));
} else {
- ret = max8998_write_reg(i2c, reg, i);
+ ret = max8998_write_reg(i2c, reg, selector);
}
break;
case MAX8998_BUCK3:
case MAX8998_BUCK4:
- ret = max8998_update_reg(i2c, reg, i<<shift, mask<<shift);
+ ret = max8998_update_reg(i2c, reg, selector<<shift,
+ mask<<shift);
break;
}
@@ -499,22 +454,24 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev,
static struct regulator_ops max8998_ldo_ops = {
.list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
.is_enabled = max8998_ldo_is_enabled,
.enable = max8998_ldo_enable,
.disable = max8998_ldo_disable,
.get_voltage_sel = max8998_get_voltage_sel,
- .set_voltage = max8998_set_voltage_ldo,
+ .set_voltage_sel = max8998_set_voltage_ldo_sel,
.set_suspend_enable = max8998_ldo_enable,
.set_suspend_disable = max8998_ldo_disable,
};
static struct regulator_ops max8998_buck_ops = {
.list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
.is_enabled = max8998_ldo_is_enabled,
.enable = max8998_ldo_enable,
.disable = max8998_ldo_disable,
.get_voltage_sel = max8998_get_voltage_sel,
- .set_voltage = max8998_set_voltage_buck,
+ .set_voltage_sel = max8998_set_voltage_buck_sel,
.set_voltage_time_sel = max8998_set_voltage_buck_time_sel,
.set_suspend_enable = max8998_ldo_enable,
.set_suspend_disable = max8998_ldo_disable,
--
1.7.9.5
next prev parent reply other threads:[~2013-01-24 3:41 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-24 3:26 [ 3.5.y.z extended stable ] Linux 3.5.7.4 stable review Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 01/74] usb: gadget: dummy: fix enumeration with g_multi Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 02/74] usb: musb: core: print new line in the driver banner again Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 03/74] ASoC: pcm: allow backend hardware to be freed in pause state Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 04/74] ASoC: wm2200: Fix setting dai format in wm2200_set_fmt Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 05/74] mac80211: fix ibss scanning Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 06/74] mac80211: use del_timer_sync for final sta cleanup timer deletion Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 07/74] mac80211: fix dtim_period in hidden SSID AP association Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 08/74] xhci: Handle HS bulk/ctrl endpoints that don't NAK Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 09/74] USB: Handle auto-transition from hot to warm reset Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 10/74] USB: Ignore xHCI Reset Device status Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 11/74] USB: Allow USB 3.0 ports to be disabled Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 12/74] USB: Increase reset timeout Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 13/74] USB: Ignore port state until reset completes Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 14/74] USB: Handle warm reset failure on empty port Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 15/74] xhci: Avoid "dead ports", add roothub port polling Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 16/74] ASoC: wm2200: Remove DSP B and left justified AIF modes Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 17/74] ASoC: wm5100: Remove DSP B and left justified formats Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 18/74] mwifiex: check wait_event_interruptible return value Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 19/74] ASoC: wm2000: Fix sense of speech clarity enable Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 20/74] drm/i915; Only increment the user-pin-count after successfully pinning the bo Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 21/74] samsung-laptop: Add quirk for broken acpi_video backlight on N250P Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 22/74] sony-laptop: fix SNC buffer calls when SN06 returns Integers Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 23/74] staging: r8712u: Add new device ID Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 24/74] b43: Fix firmware loading when driver is built into the kernel Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 25/74] staging: speakup: avoid out-of-range access in synth_init() Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 26/74] staging: speakup: avoid out-of-range access in synth_add() Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 27/74] staging: comedi: fix minimum AO period for NI 625x and NI 628x Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 28/74] staging: comedi: prevent auto-unconfig of manually configured devices Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 29/74] staging: comedi: comedi_test: fix race when cancelling command Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 30/74] regulator: max8997: Use uV in voltage_map_desc Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 31/74] regulator: max8998: Convert to regulator_list_voltage_linear() Herton Ronaldo Krzesinski
2013-01-24 3:26 ` Herton Ronaldo Krzesinski [this message]
2013-01-24 3:26 ` [PATCH 33/74] regulator: max8998: Use uV in voltage_map_desc Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 34/74] ALSA: pxa27x: fix ac97 cold reset Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 35/74] ALSA: pxa27x: fix ac97 warm reset Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 36/74] SUNRPC: Ensure we release the socket write lock if the rpc_task exits early Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 37/74] target: use correct sense code for LUN communication failure Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 38/74] Revert "ALSA: hda - Shut up pins at power-saving mode with Conexnat codecs" Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 39/74] regulator: max8998: Ensure enough delay time for max8998_set_voltage_buck_time_sel Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 40/74] radeon/kms: force rn50 chip to always report connected on analog output Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 41/74] tcm_fc: Do not indicate retry capability to initiators Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 42/74] tcm_fc: Do not report target role when target is not defined Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 43/74] target: Fix use-after-free in LUN RESET handling Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 44/74] target: Release se_cmd when LUN lookup fails for TMR Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 45/74] sh: Fix FDPIC binary loader Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 46/74] USB: option: Add new MEDIATEK PID support Herton Ronaldo Krzesinski
2013-01-24 3:26 ` [PATCH 47/74] USB: option: blacklist network interface on ZTE MF880 Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 48/74] USB: option: add Telekom Speedstick LTE II Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 49/74] USB: option: add Nexpring NP10T terminal id Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 50/74] Add CDC-ACM support for the CX93010-2x UCMxx USB Modem Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 51/74] USB: cdc-acm: Add support for "PSC Scanning, Magellan 800i" Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 52/74] USB: hub: handle claim of enabled remote wakeup after reset Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 53/74] mm: compaction: fix echo 1 > compact_memory return error issue Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 54/74] mm: use aligned zone start for pfn_to_bitidx calculation Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 55/74] mm: bootmem: fix free_all_bootmem_core() with odd bitmap alignment Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 56/74] audit: create explicit AUDIT_SECCOMP event type Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 57/74] USB: Add device quirk for Microsoft VX700 webcam Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 58/74] drm/nouveau: fix blank LVDS screen regression on pre-nv50 cards Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 59/74] drm/nv17-50: restore fence buffer on resume Herton Ronaldo Krzesinski
2013-01-24 17:36 ` Marcin Slusarz
2013-01-24 17:52 ` Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 60/74] usb: ftdi_sio: Crucible Technologies COMET Caller ID - pid added Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 61/74] udldrmfb: Fix EDID not working with monitors with EDID extension blocks Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 62/74] udldrmfb: udl_get_edid: usb_control_msg buffer must not be on the stack Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 63/74] udldrmfb: udl_get_edid: drop unneeded i-- Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 64/74] s390/time: fix sched_clock() overflow Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 65/74] rt2800usb: Add support for 2001:3c1e (D-Link DWA-125 rev B1) USB Wi-Fi adapter Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 66/74] drm/radeon: fix NULL pointer dereference in UMS mode Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 67/74] drm/radeon: fix a bogus kfree Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 68/74] ALSA: usb - fix race in creation of M-Audio Fast track pro driver Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 69/74] x86/Sandy Bridge: reserve pages when integrated graphics is present Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 70/74] USB: io_ti: Fix NULL dereference in chase_port() Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 71/74] intel-iommu: Prevent devices with RMRRs from being placed into SI Domain Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 72/74] igb: release already assigned MSI-X interrupts if setup fails Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 73/74] usb: chipidea: Allow disabling streaming not only in udc mode Herton Ronaldo Krzesinski
2013-01-24 3:27 ` [PATCH 74/74] [SCSI] sd: Reshuffle init_sd to avoid crash Herton Ronaldo Krzesinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358998046-613-33-git-send-email-herton.krzesinski@canonical.com \
--to=herton.krzesinski@canonical.com \
--cc=axel.lin@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=kernel-team@lists.ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®