Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/ssd130x: Use new regmap bulk write support to drop custom bus

Data writes for the ssd130x 4-wire SPI protocol need special handling, due
the Data/Command control (D/C) pin having to be toggled prior to the write.

The regmap API only allowed drivers to provide .reg_{read,write} callbacks
to do per register read/write, but didn't provide a way for drivers to do
the same for bulk read/writes.

For this reason, a custom regmap bus was used by the driver just to define
a bulk write callback that implements the D/C pin toggling. But the regmap
API has been extended to support defining bulk read/write handlers, so the
custom regmap bus is not needed anymore and could just be dropped.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220618174338.2253021-1-javierm@redhat.com

+5 -16
+5 -16
drivers/gpu/drm/solomon/ssd130x-spi.c
··· 18 18 struct gpio_desc *dc; 19 19 }; 20 20 21 - static const struct regmap_config ssd130x_spi_regmap_config = { 22 - .reg_bits = 8, 23 - .val_bits = 8, 24 - }; 25 - 26 21 /* 27 22 * The regmap bus .write handler, it is just a wrapper around spi_write() 28 23 * but toggling the Data/Command control pin (D/C#). Since for 4-wire SPI ··· 51 56 return -EOPNOTSUPP; 52 57 } 53 58 54 - /* 55 - * A custom bus is needed due the special write that toggles a D/C# pin, 56 - * another option could be to just have a .reg_write() callback but that 57 - * will prevent to do data writes in bulk. 58 - * 59 - * Once the regmap API is extended to support defining a bulk write handler 60 - * in the struct regmap_config, this can be simplified and the bus dropped. 61 - */ 62 - static struct regmap_bus regmap_ssd130x_spi_bus = { 59 + static const struct regmap_config ssd130x_spi_regmap_config = { 60 + .reg_bits = 8, 61 + .val_bits = 8, 63 62 .write = ssd130x_spi_write, 64 63 .read = ssd130x_spi_read, 64 + .can_multi_write = true, 65 65 }; 66 66 67 67 static int ssd130x_spi_probe(struct spi_device *spi) ··· 80 90 t->spi = spi; 81 91 t->dc = dc; 82 92 83 - regmap = devm_regmap_init(dev, &regmap_ssd130x_spi_bus, t, 84 - &ssd130x_spi_regmap_config); 93 + regmap = devm_regmap_init(dev, NULL, t, &ssd130x_spi_regmap_config); 85 94 if (IS_ERR(regmap)) 86 95 return PTR_ERR(regmap); 87 96