[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120825151020.GB6520@opensource.wolfsonmicro.com>
Date: Sat, 25 Aug 2012 08:10:20 -0700
From: Mark Brown <broonie@...nsource.wolfsonmicro.com>
To: Krystian Garbaciak <krystian.garbaciak@...semi.com>
Cc: linux-kernel@...r.kernel.org, rtc-linux@...glegroups.com,
lm-sensors@...sensors.org, linux-input@...r.kernel.org,
linux-watchdog@...r.kernel.org, linux-leds@...r.kernel.org,
Samuel Ortiz <sameo@...ux.intel.com>,
Liam Girdwood <lrg@...com>,
Alessandro Zummo <a.zummo@...ertech.it>,
Jean Delvare <khali@...ux-fr.org>,
Guenter Roeck <linux@...ck-us.net>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Ashish Jangam <ashish.jangam@...tcummins.com>,
Andrew Jones <drjones@...hat.com>,
Donggeun Kim <dg77.kim@...sung.com>,
Philippe Rétornaz <philippe.retornaz@...l.ch>,
Wim Van Sebroeck <wim@...ana.be>,
Bryan Wu <bryan.wu@...onical.com>,
"Richard Purdie <rpurdie@...ys.net> Anthony Olech"
<anthony.olech@...semi.com>
Subject: Re: [RFC PATCH 2/8] regulator: Add Dialog DA906x voltage regulators
support.
On Fri, Aug 24, 2012 at 02:55:00PM +0100, Krystian Garbaciak wrote:
> +static int da906x_set_voltage(struct regulator_dev *rdev,
> + int min_uV, int max_uV, unsigned *selector)
> +{
> + struct da906x_regulator *regl = rdev_get_drvdata(rdev);
> + const struct field *fvol = ®l->info->voltage;
> + int ret;
> + unsigned val;
> +
> + val = regulator_map_voltage_linear(rdev, min_uV, max_uV);
> + if (val < 0)
> + return -EINVAL;
> +
> + val = (val + fvol->offset) << fvol->shift;
> + ret = da906x_reg_update(regl->hw, fvol->addr, fvol->mask, val);
> + if (ret >= 0)
> + *selector = val;
> +
> + return ret;
> +}
This is just set_voltage_sel_regmap().
> +static int da906x_enable(struct regulator_dev *rdev)
> +{
> + struct da906x_regulator *regl = rdev_get_drvdata(rdev);
> + int ret;
> +
> + if (regl->info->suspend.mask) {
> + /* Make sure to exit from suspend mode on enable */
> + ret = da906x_reg_clear_bits(regl->hw, regl->info->suspend.addr,
> + regl->info->suspend.mask);
> + if (ret < 0)
> + return ret;
> +
> + /* BUCKs need mode update after wake-up from suspend state. */
> + ret = da906x_update_mode_internal(regl, SYS_STATE_NORMAL);
> + if (ret < 0)
> + return ret;
> + }
> +
> + return regulator_enable_regmap(rdev);
If suspend_mask is optional the regulators using it should just use the
standard operation.
> +/* Regulator event handlers */
> +irqreturn_t da906x_ldo_lim_event(int irq, void *data)
By "event handler" you mean "interrupt"
> + bits = da906x_reg_read(hw, DA906X_REG_STATUS_D);
> + if (bits < 0)
> + return IRQ_HANDLED;
If you fail to detect an interrupt you report that you handled one...?
> + if (!da906x_pdata) {
> + dev_err(&pdev->dev, "No platform init data supplied\n");
> + return -ENODEV;
> + }
Platform data should be totally optional.
> + bcores_merged = (ret & DA906X_BCORE_MERGE) ? true : false;
> + bmem_bio_merged = (ret & DA906X_BUCK_MERGE) ? true : false;
The use of the ternery operation here is even worse than normal, you can
assign the values directly.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists