summaryrefslogtreecommitdiffstats
path: root/drivers/video/ssd1307fb.c
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2021-12-23 17:04:03 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-01-03 09:06:19 +0100
commitb8834a8fb109c759e224f323d4a61360c82e0701 (patch)
tree123e3a2da9830c3dda5451e4dfa8ab207319891b /drivers/video/ssd1307fb.c
parent576e37e0e1d6dd86065d3e9f7615156c5872393f (diff)
downloadbarebox-b8834a8fb109c759e224f323d4a61360c82e0701.tar.gz
barebox-b8834a8fb109c759e224f323d4a61360c82e0701.tar.xz
video: ssd1307fb: use function pointer for write
The function pointer is an abstraction the I2C accesses to be able to add other bus protocols underneath the driver. The functionality kind of reminds of regmap, but the driver does only write data and does not actually use registers. Therefore, using regmap with the register abstraction is not appropriate. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Link: https://lore.barebox.org/20211223160404.119970-8-m.tretter@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/video/ssd1307fb.c')
-rw-r--r--drivers/video/ssd1307fb.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c
index 1538a1b640..d0df073b8e 100644
--- a/drivers/video/ssd1307fb.c
+++ b/drivers/video/ssd1307fb.c
@@ -53,6 +53,16 @@ struct ssd1307fb_deviceinfo {
int need_chargepump;
};
+struct ssd1307fb_array {
+ u8 type;
+ u8 data[0];
+};
+
+struct ssd1307fb_par;
+
+typedef int (*ssd1307fb_write_array)(struct ssd1307fb_par *par,
+ struct ssd1307fb_array *array, u32 len);
+
struct ssd1307fb_par {
u32 com_invdir;
u32 com_lrremap;
@@ -73,11 +83,8 @@ struct ssd1307fb_par {
u32 seg_remap;
u32 vcomh;
u32 width;
-};
-struct ssd1307fb_array {
- u8 type;
- u8 data[0];
+ ssd1307fb_write_array write_array;
};
static struct ssd1307fb_array *ssd1307fb_alloc_array(u32 len, u8 type)
@@ -93,8 +100,8 @@ static struct ssd1307fb_array *ssd1307fb_alloc_array(u32 len, u8 type)
return array;
}
-static int ssd1307fb_write_array(struct ssd1307fb_par *par,
- struct ssd1307fb_array *array, u32 len)
+static int ssd1307fb_i2c_write_array(struct ssd1307fb_par *par,
+ struct ssd1307fb_array *array, u32 len)
{
struct i2c_client *client = par->client;
int ret;
@@ -121,7 +128,7 @@ static inline int ssd1307fb_write_cmd(struct ssd1307fb_par *par, u8 cmd)
array->data[0] = cmd;
- ret = ssd1307fb_write_array(par, array, 1);
+ ret = par->write_array(par, array, 1);
kfree(array);
return ret;
@@ -182,7 +189,7 @@ static void ssd1307fb_update_display(struct ssd1307fb_par *par)
}
}
- ssd1307fb_write_array(par, array, par->width * par->height / 8);
+ par->write_array(par, array, par->width * par->height / 8);
kfree(array);
}
@@ -414,6 +421,7 @@ static int ssd1307fb_probe(struct device_d *dev)
par->client = to_i2c_client(dev);
i2c_set_clientdata(par->client, par);
+ par->write_array = ssd1307fb_i2c_write_array;
par->reset = of_get_named_gpio_flags(node,
"reset-gpios", 0, &of_flags);
@@ -564,7 +572,7 @@ static int ssd1307fb_probe(struct device_d *dev)
}
}
- ssd1307fb_write_array(par, array, par->width * par->height / 8);
+ par->write_array(par, array, par->width * par->height / 8);
kfree(array);
dev_info(dev,