linux-xiaomi-chiron/include/linux/regulator
Douglas Anderson 1de452a0ed
regulator: core: Allow drivers to define their init data as const
Drivers tend to want to define the names of their regulators somewhere
in their source file as "static const". This means, inevitable, that
every driver out there open codes something like this:

static const char * const supply_names[] = {
 "vcc", "vccl",
};

static int get_regulators(struct my_data *data)
{
  int i;

  data->supplies = devm_kzalloc(...)
  if (!data->supplies)
    return -ENOMEM;

  for (i = 0; i < ARRAY_SIZE(supply_names); i++)
    data->supplies[i].supply = supply_names[i];

  return devm_regulator_bulk_get(data->dev,
                                 ARRAY_SIZE(supply_names),
				 data->supplies);
}

Let's make this more convenient by doing providing a helper that does
the copy.

I have chosen to have the "const" input structure here be the exact
same structure as the normal one passed to
devm_regulator_bulk_get(). This is slightly inefficent since the input
data can't possibly have anything useful for "ret" or consumer and
thus we waste 8 bytes per structure. This seems an OK tradeoff for not
introducing an extra structure.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20220726103631.v2.6.I38fc508a73135a5c1b873851f3553ff2a3a625f5@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-27 13:47:30 +01:00
..
act8865.h
arizona-ldo1.h
arizona-micsupp.h
consumer.h regulator: core: Allow drivers to define their init data as const 2022-07-27 13:47:30 +01:00
coupler.h regulator: move rdev_print helpers to internal.h 2021-06-21 13:08:39 +01:00
da9121.h regulator: da9121: Add support for device variants via devicetree 2020-12-01 12:18:00 +00:00
da9211.h
db8500-prcmu.h
driver.h regulator: Updates for v5.17 2022-01-11 12:17:45 -08:00
fan53555.h
fixed.h
gpio-regulator.h
lp872x.h regulator: lp872x: Remove lp872x_dvs_state 2021-10-21 14:17:49 +01:00
lp3971.h
lp3972.h
machine.h regulator: machine.h: fix kernel-doc "bad line" 2021-07-11 23:50:40 +01:00
max1586.h
max8649.h
max8660.h
max8952.h
max8973-regulator.h
mt6311.h
mt6315-regulator.h regulator: mt6315: Add support for MT6315 regulator 2021-02-08 11:48:48 +00:00
mt6323-regulator.h
mt6358-regulator.h regulator: mt6366: Add support for MT6366 regulator 2022-04-04 15:16:10 +01:00
mt6359-regulator.h regulator: mt6359: Add support for MT6359P regulator 2021-06-01 16:44:36 +01:00
mt6380-regulator.h
mt6397-regulator.h
of_regulator.h
pca9450.h regulator: pca9450: Make I2C Level Translator configurable 2022-05-03 13:47:36 +01:00
pfuze100.h regulator: pfuze100: Convert the driver to DT-only 2020-12-11 13:23:06 +00:00
tps6507x.h
tps51632-regulator.h
tps62360.h regulator: tps62360: replacing legacy gpio interface for gpiod 2021-10-21 14:18:42 +01:00
userspace-consumer.h