* [PATCH 1/5] fb: hx8357: Change parameters of the write function to u8
[not found] <1360752028-7301-1-git-send-email-maxime.ripard@free-electrons.com>
@ 2013-02-13 10:40 ` Maxime Ripard
2013-02-13 10:40 ` [PATCH 2/5] fb: hx8357: Fix inverted parameters for kcalloc Maxime Ripard
` (3 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2013-02-13 10:40 UTC (permalink / raw)
To: linux-fbdev
Cc: joe, Andrew Morton, Richard Purdie, Florian Tobias Schandinat,
linux-kernel
Moving from void* to u8* removes the need for castslater on in the
function.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/video/backlight/hx8357.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index 00925c0..071525c 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -79,8 +79,8 @@ struct hx8357_data {
};
static int hx8357_spi_write_then_read(struct lcd_device *lcdev,
- void *txbuf, u16 txlen,
- void *rxbuf, u16 rxlen)
+ u8 *txbuf, u16 txlen,
+ u8 *rxbuf, u16 rxlen)
{
struct hx8357_data *lcd = lcd_get_data(lcdev);
struct spi_message msg;
@@ -102,7 +102,7 @@ static int hx8357_spi_write_then_read(struct lcd_device *lcdev,
}
for (i = 0; i < txlen; i++) {
- local_txbuf[i] = ((u8 *)txbuf)[i];
+ local_txbuf[i] = txbuf[i];
if (i > 0)
local_txbuf[i] |= 1 << 8;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/5] fb: hx8357: Fix inverted parameters for kcalloc
[not found] <1360752028-7301-1-git-send-email-maxime.ripard@free-electrons.com>
2013-02-13 10:40 ` [PATCH 1/5] fb: hx8357: Change parameters of the write function to u8 Maxime Ripard
@ 2013-02-13 10:40 ` Maxime Ripard
2013-02-13 10:40 ` [PATCH 3/5] fb: hx8357: Remove useless error message Maxime Ripard
` (2 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2013-02-13 10:40 UTC (permalink / raw)
To: linux-fbdev
Cc: joe, Andrew Morton, Richard Purdie, Florian Tobias Schandinat,
linux-kernel
The element size and the number of elements was inverted in the kcalloc
call.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/video/backlight/hx8357.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index 071525c..2691fd6 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -94,7 +94,7 @@ static int hx8357_spi_write_then_read(struct lcd_device *lcdev,
if (txlen) {
int i;
- local_txbuf = kcalloc(sizeof(*local_txbuf), txlen, GFP_KERNEL);
+ local_txbuf = kcalloc(txlen, sizeof(*local_txbuf), GFP_KERNEL);
if (!local_txbuf) {
dev_err(&lcdev->dev, "Couldn't allocate data buffer.\n");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/5] fb: hx8357: Remove useless error message
[not found] <1360752028-7301-1-git-send-email-maxime.ripard@free-electrons.com>
2013-02-13 10:40 ` [PATCH 1/5] fb: hx8357: Change parameters of the write function to u8 Maxime Ripard
2013-02-13 10:40 ` [PATCH 2/5] fb: hx8357: Fix inverted parameters for kcalloc Maxime Ripard
@ 2013-02-13 10:40 ` Maxime Ripard
2013-02-13 10:40 ` [PATCH 4/5] fb: hx8357: Remove trailing period Maxime Ripard
2013-02-13 10:40 ` [PATCH 5/5] fb: hx8357: Use static arrays for LCD configuration Maxime Ripard
4 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2013-02-13 10:40 UTC (permalink / raw)
To: linux-fbdev
Cc: joe, Andrew Morton, Richard Purdie, Florian Tobias Schandinat,
linux-kernel
In case of a failing allocation, a dump stack will be printed anyway, so
the dev_err is redundant.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/video/backlight/hx8357.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index 2691fd6..7c82561 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -96,10 +96,8 @@ static int hx8357_spi_write_then_read(struct lcd_device *lcdev,
local_txbuf = kcalloc(txlen, sizeof(*local_txbuf), GFP_KERNEL);
- if (!local_txbuf) {
- dev_err(&lcdev->dev, "Couldn't allocate data buffer.\n");
+ if (!local_txbuf)
return -ENOMEM;
- }
for (i = 0; i < txlen; i++) {
local_txbuf[i] = txbuf[i];
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/5] fb: hx8357: Remove trailing period
[not found] <1360752028-7301-1-git-send-email-maxime.ripard@free-electrons.com>
` (2 preceding siblings ...)
2013-02-13 10:40 ` [PATCH 3/5] fb: hx8357: Remove useless error message Maxime Ripard
@ 2013-02-13 10:40 ` Maxime Ripard
2013-02-13 10:40 ` [PATCH 5/5] fb: hx8357: Use static arrays for LCD configuration Maxime Ripard
4 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2013-02-13 10:40 UTC (permalink / raw)
To: linux-fbdev
Cc: joe, Andrew Morton, Richard Purdie, Florian Tobias Schandinat,
linux-kernel
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/video/backlight/hx8357.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index 7c82561..6da8ebe 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -120,7 +120,7 @@ static int hx8357_spi_write_then_read(struct lcd_device *lcdev,
ret = spi_sync(lcd->spi, &msg);
if (ret < 0)
- dev_err(&lcdev->dev, "Couldn't send SPI data.\n");
+ dev_err(&lcdev->dev, "Couldn't send SPI data\n");
if (txlen)
kfree(local_txbuf);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] fb: hx8357: Use static arrays for LCD configuration
[not found] <1360752028-7301-1-git-send-email-maxime.ripard@free-electrons.com>
` (3 preceding siblings ...)
2013-02-13 10:40 ` [PATCH 4/5] fb: hx8357: Remove trailing period Maxime Ripard
@ 2013-02-13 10:40 ` Maxime Ripard
4 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2013-02-13 10:40 UTC (permalink / raw)
To: linux-fbdev
Cc: joe, Andrew Morton, Richard Purdie, Florian Tobias Schandinat,
linux-kernel
This allows a smaller and less error-prone code by using static arrays
and the ARRAY_SIZE macro.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/video/backlight/hx8357.c | 173 +++++++++++++++++++++-----------------
1 file changed, 95 insertions(+), 78 deletions(-)
diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index 6da8ebe..a0482b5 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -78,6 +78,71 @@ struct hx8357_data {
int state;
};
+static u8 hx8357_seq_power[] = {
+ HX8357_SET_POWER, 0x44, 0x41, 0x06,
+};
+
+static u8 hx8357_seq_vcom[] = {
+ HX8357_SET_VCOM, 0x40, 0x10,
+};
+
+static u8 hx8357_seq_power_normal[] = {
+ HX8357_SET_POWER_NORMAL, 0x05, 0x12,
+};
+
+static u8 hx8357_seq_panel_driving[] = {
+ HX8357_SET_PANEL_DRIVING, 0x14, 0x3b, 0x00, 0x02, 0x11,
+};
+
+static u8 hx8357_seq_display_frame[] = {
+ HX8357_SET_DISPLAY_FRAME, 0x0c,
+};
+
+static u8 hx8357_seq_panel_related[] = {
+ HX8357_SET_PANEL_RELATED, 0x01,
+};
+
+static u8 hx8357_seq_undefined1[] = {
+ 0xea, 0x03, 0x00, 0x00,
+};
+
+static u8 hx8357_seq_undefined2[] = {
+ 0xeb, 0x40, 0x54, 0x26, 0xdb,
+};
+
+static u8 hx8357_seq_gamma[] = {
+ HX8357_SET_GAMMA, 0x00, 0x15, 0x00, 0x22, 0x00,
+ 0x08, 0x77, 0x26, 0x77, 0x22, 0x04, 0x00,
+};
+
+static u8 hx8357_seq_address_mode[] = {
+ HX8357_SET_ADDRESS_MODE, 0xc0,
+};
+
+static u8 hx8357_seq_pixel_format[] = {
+ HX8357_SET_PIXEL_FORMAT,
+ HX8357_SET_PIXEL_FORMAT_DPI_18BIT |
+ HX8357_SET_PIXEL_FORMAT_DBI_18BIT,
+};
+
+static u8 hx8357_seq_column_address[] = {
+ HX8357_SET_COLUMN_ADDRESS, 0x00, 0x00, 0x01, 0x3f,
+};
+
+static u8 hx8357_seq_page_address[] = {
+ HX8357_SET_PAGE_ADDRESS, 0x00, 0x00, 0x01, 0xdf,
+};
+
+static u8 hx8357_seq_rgb[] = {
+ HX8357_SET_RGB, 0x02,
+};
+
+static u8 hx8357_seq_display_mode[] = {
+ HX8357_SET_DISPLAY_MODE,
+ HX8357_SET_DISPLAY_MODE_RGB_THROUGH |
+ HX8357_SET_DISPLAY_MODE_RGB_INTERFACE,
+};
+
static int hx8357_spi_write_then_read(struct lcd_device *lcdev,
u8 *txbuf, u16 txlen,
u8 *rxbuf, u16 rxlen)
@@ -179,7 +244,6 @@ static int hx8357_exit_standby(struct lcd_device *lcdev)
static int hx8357_lcd_init(struct lcd_device *lcdev)
{
struct hx8357_data *lcd = lcd_get_data(lcdev);
- u8 buf[16];
int ret;
/*
@@ -198,125 +262,78 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
gpio_set_value(lcd->reset, 1);
msleep(120);
- buf[0] = HX8357_SET_POWER;
- buf[1] = 0x44;
- buf[2] = 0x41;
- buf[3] = 0x06;
- ret = hx8357_spi_write_array(lcdev, buf, 4);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_power,
+ ARRAY_SIZE(hx8357_seq_power));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_VCOM;
- buf[1] = 0x40;
- buf[2] = 0x10;
- ret = hx8357_spi_write_array(lcdev, buf, 3);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_vcom,
+ ARRAY_SIZE(hx8357_seq_vcom));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_POWER_NORMAL;
- buf[1] = 0x05;
- buf[2] = 0x12;
- ret = hx8357_spi_write_array(lcdev, buf, 3);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_power_normal,
+ ARRAY_SIZE(hx8357_seq_power_normal));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_PANEL_DRIVING;
- buf[1] = 0x14;
- buf[2] = 0x3b;
- buf[3] = 0x00;
- buf[4] = 0x02;
- buf[5] = 0x11;
- ret = hx8357_spi_write_array(lcdev, buf, 6);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_panel_driving,
+ ARRAY_SIZE(hx8357_seq_panel_driving));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_DISPLAY_FRAME;
- buf[1] = 0x0c;
- ret = hx8357_spi_write_array(lcdev, buf, 2);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_display_frame,
+ ARRAY_SIZE(hx8357_seq_display_frame));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_PANEL_RELATED;
- buf[1] = 0x01;
- ret = hx8357_spi_write_array(lcdev, buf, 2);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_panel_related,
+ ARRAY_SIZE(hx8357_seq_panel_related));
if (ret < 0)
return ret;
- buf[0] = 0xea;
- buf[1] = 0x03;
- buf[2] = 0x00;
- buf[3] = 0x00;
- ret = hx8357_spi_write_array(lcdev, buf, 4);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_undefined1,
+ ARRAY_SIZE(hx8357_seq_undefined1));
if (ret < 0)
return ret;
- buf[0] = 0xeb;
- buf[1] = 0x40;
- buf[2] = 0x54;
- buf[3] = 0x26;
- buf[4] = 0xdb;
- ret = hx8357_spi_write_array(lcdev, buf, 5);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_undefined2,
+ ARRAY_SIZE(hx8357_seq_undefined2));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_GAMMA;
- buf[1] = 0x00;
- buf[2] = 0x15;
- buf[3] = 0x00;
- buf[4] = 0x22;
- buf[5] = 0x00;
- buf[6] = 0x08;
- buf[7] = 0x77;
- buf[8] = 0x26;
- buf[9] = 0x77;
- buf[10] = 0x22;
- buf[11] = 0x04;
- buf[12] = 0x00;
- ret = hx8357_spi_write_array(lcdev, buf, 13);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_gamma,
+ ARRAY_SIZE(hx8357_seq_gamma));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_ADDRESS_MODE;
- buf[1] = 0xc0;
- ret = hx8357_spi_write_array(lcdev, buf, 2);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_address_mode,
+ ARRAY_SIZE(hx8357_seq_address_mode));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_PIXEL_FORMAT;
- buf[1] = HX8357_SET_PIXEL_FORMAT_DPI_18BIT |
- HX8357_SET_PIXEL_FORMAT_DBI_18BIT;
- ret = hx8357_spi_write_array(lcdev, buf, 2);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_pixel_format,
+ ARRAY_SIZE(hx8357_seq_pixel_format));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_COLUMN_ADDRESS;
- buf[1] = 0x00;
- buf[2] = 0x00;
- buf[3] = 0x01;
- buf[4] = 0x3f;
- ret = hx8357_spi_write_array(lcdev, buf, 5);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_column_address,
+ ARRAY_SIZE(hx8357_seq_column_address));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_PAGE_ADDRESS;
- buf[1] = 0x00;
- buf[2] = 0x00;
- buf[3] = 0x01;
- buf[4] = 0xdf;
- ret = hx8357_spi_write_array(lcdev, buf, 5);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_page_address,
+ ARRAY_SIZE(hx8357_seq_page_address));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_RGB;
- buf[1] = 0x02;
- ret = hx8357_spi_write_array(lcdev, buf, 2);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_rgb,
+ ARRAY_SIZE(hx8357_seq_rgb));
if (ret < 0)
return ret;
- buf[0] = HX8357_SET_DISPLAY_MODE;
- buf[1] = HX8357_SET_DISPLAY_MODE_RGB_THROUGH |
- HX8357_SET_DISPLAY_MODE_RGB_INTERFACE;
- ret = hx8357_spi_write_array(lcdev, buf, 2);
+ ret = hx8357_spi_write_array(lcdev, hx8357_seq_display_mode,
+ ARRAY_SIZE(hx8357_seq_display_mode));
if (ret < 0)
return ret;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-13 10:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1360752028-7301-1-git-send-email-maxime.ripard@free-electrons.com>
2013-02-13 10:40 ` [PATCH 1/5] fb: hx8357: Change parameters of the write function to u8 Maxime Ripard
2013-02-13 10:40 ` [PATCH 2/5] fb: hx8357: Fix inverted parameters for kcalloc Maxime Ripard
2013-02-13 10:40 ` [PATCH 3/5] fb: hx8357: Remove useless error message Maxime Ripard
2013-02-13 10:40 ` [PATCH 4/5] fb: hx8357: Remove trailing period Maxime Ripard
2013-02-13 10:40 ` [PATCH 5/5] fb: hx8357: Use static arrays for LCD configuration Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).