From: Sam Ravnborg <sam@ravnborg.org>
To: Barebox List <barebox@lists.infradead.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Subject: [PATCH 5/6] atmel_lcdfb: move pdata init to a separate function
Date: Thu, 20 Jul 2017 22:05:25 +0200 [thread overview]
Message-ID: <20170720200526.19523-5-sam@ravnborg.org> (raw)
In-Reply-To: <20170720200103.GA16205@ravnborg.org>
Keep atmel_lcdc_register() readable by separating out
pdata handling in a helper function
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
drivers/video/atmel_lcdfb_core.c | 65 +++++++++++++++++++++++++---------------
1 file changed, 41 insertions(+), 24 deletions(-)
diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c
index cc065397d..87bddade4 100644
--- a/drivers/video/atmel_lcdfb_core.c
+++ b/drivers/video/atmel_lcdfb_core.c
@@ -278,31 +278,23 @@ static int power_control_init(struct device_d *dev,
return ret;
}
-int atmel_lcdc_register(struct device_d *dev, struct atmel_lcdfb_devdata *data)
+static int lcdfb_pdata_init(struct device_d *dev, struct atmel_lcdfb_info *sinfo)
{
- struct resource *iores;
- struct atmel_lcdfb_info *sinfo;
- struct atmel_lcdfb_platform_data *pdata = dev->platform_data;
- int ret = 0;
- int gpio;
+ struct atmel_lcdfb_platform_data *pdata;
struct fb_info *info;
+ bool active_low;
+ int gpio;
+ int ret;
- if (!pdata) {
- dev_err(dev, "missing platform_data\n");
- return -EINVAL;
- }
-
- sinfo = xzalloc(sizeof(*sinfo));
+ pdata = dev->platform_data;
/* If gpio == 0 (default in pdata) then we assume no power control */
gpio = pdata->gpio_power_control;
if (gpio == 0)
gpio = -1;
- ret = power_control_init(dev,
- sinfo,
- gpio,
- pdata->gpio_power_control_active_low);
+ active_low = pdata->gpio_power_control_active_low;
+ ret = power_control_init(dev, sinfo, gpio, active_low);
if (ret)
goto err;
@@ -311,23 +303,48 @@ int atmel_lcdc_register(struct device_d *dev, struct atmel_lcdfb_devdata *data)
sinfo->dmacon = pdata->default_dmacon;
sinfo->lcd_wiring_mode = pdata->lcd_wiring_mode;
sinfo->have_intensity_bit = pdata->have_intensity_bit;
+
+ info = &sinfo->info;
+ info->modes.modes = pdata->mode_list;
+ info->modes.num_modes = pdata->num_modes;
+ info->mode = &info->modes.modes[0];
+ info->xres = info->mode->xres;
+ info->yres = info->mode->yres;
+ info->bits_per_pixel = pdata->default_bpp;
+
+err:
+ return ret;
+}
+
+int atmel_lcdc_register(struct device_d *dev, struct atmel_lcdfb_devdata *data)
+{
+ struct resource *iores;
+ struct atmel_lcdfb_info *sinfo;
+ struct fb_info *info;
+ int ret = 0;
+
iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores))
return PTR_ERR(iores);
- sinfo->mmio = IOMEM(iores->start);
+ sinfo = xzalloc(sizeof(*sinfo));
sinfo->dev_data = data;
+ sinfo->mmio = IOMEM(iores->start);
- /* just init */
info = &sinfo->info;
info->priv = sinfo;
info->fbops = &atmel_lcdc_ops;
- info->modes.modes = pdata->mode_list;
- info->modes.num_modes = pdata->num_modes;
- info->mode = &info->modes.modes[0];
- info->xres = info->mode->xres;
- info->yres = info->mode->yres;
- info->bits_per_pixel = pdata->default_bpp;
+
+ if (dev->platform_data) {
+ ret = lcdfb_pdata_init(dev, sinfo);
+ if (ret) {
+ dev_err(dev, "failed to init lcdfb from pdata\n");
+ goto err;
+ }
+ } else {
+ dev_err(dev, "missing platform_data\n");
+ return -EINVAL;
+ }
/* Enable LCDC Clocks */
sinfo->bus_clk = clk_get(dev, "hck1");
--
2.12.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2017-07-20 20:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 20:01 [PATCH 0/6] Add DT support for at91_udc and atmel_lcdfb Sam Ravnborg
2017-07-20 20:05 ` [PATCH 1/6] at91_udc: add DT support Sam Ravnborg
2017-07-20 20:05 ` [PATCH 2/6] atmel_lcdfb: move dmacon, lcdcon2 to local data Sam Ravnborg
2017-07-20 20:05 ` [PATCH 3/6] atmel_lcdfb: move lcd_wiring_mode, have_intensity_bit " Sam Ravnborg
2017-07-20 20:05 ` [PATCH 4/6] atmel_lcdfb: define power_control gpio in platform_data Sam Ravnborg
2017-07-20 20:05 ` Sam Ravnborg [this message]
2017-07-20 20:05 ` [PATCH 6/6] atmel_lcdfb: add DT support Sam Ravnborg
2017-09-06 12:29 ` [PATCH 0/6] Add DT support for at91_udc and atmel_lcdfb Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170720200526.19523-5-sam@ravnborg.org \
--to=sam@ravnborg.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox