On 2017-04-06 13:31, Michael Hennerich wrote:
On 06.04.2017 10:39, Peter Rosin wrote:
+static const struct regmap_config ltc4306_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = LTC_REG_SWITCH,
+ .volatile_reg = ltc4306_is_volatile_reg,
+ .cache_type = REGCACHE_RBTREE,
Did you consider REGCACHE_FLAT? There are very few registers and no hole
in the map, and maintaining a tree seems like total overkill.
There is no reason to use REGCACHE_FLAT, in our case it will be a single
node.
Ok, so that makes me wonder what need REGCACHE_FLAT satisfies? To me,
a flat regmap seems like a perfect fit here. Oh well...
+static int ltc4306_gpio_init(struct ltc4306 *data)
+{
+ struct device *dev = regmap_get_device(data->regmap);
+
+ if (!data->chip->num_gpios)
+ return 0;
+
+ data->gpiochip.label = dev_name(dev);
+ data->gpiochip.base = -1;
+ data->gpiochip.ngpio = data->chip->num_gpios;
+ data->gpiochip.parent = dev;
+ data->gpiochip.can_sleep = true;
+ data->gpiochip.direction_input = ltc4306_gpio_direction_input;
+ data->gpiochip.direction_output = ltc4306_gpio_direction_output;
I'm missing a get_direction op?
No - its purely optional - the vast majority of gpiochips don't
implement it.
linux/drivers/gpio$ grep -lr --include \*.c get_direction | wc
36 36 523
linux/drivers/gpio$ grep -Lr --include \*.c get_direction | wc
101 101 1461
Ok, but while optional, why not provide it? The implementation would
be about as simple as ltc4306_gpio_get, no?