aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@free.fr>2015-12-12 16:27:10 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2015-12-15 08:41:24 -0500
commitf3621a60b20d677b0a874df4311bb65337c4baf7 (patch)
tree3ceab110ab323b915ddd57f3d906ff1d02e014ec
parent5ec9653806baa5928ee01109004411e3bed376f2 (diff)
video: fbdev: pxafb: loosen the platform data bond
In order to prepare the transition to a mixed platform data and device-tree initialization, remove all the platform data references all over the driver. Copy the platform data into the internal structure of the pxafb, and only use this afterward. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/video/fbdev/pxafb.c54
-rw-r--r--drivers/video/fbdev/pxafb.h2
2 files changed, 36 insertions, 20 deletions
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index 94813af97f09..ed4b1a5dc306 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -457,7 +457,7 @@ static int pxafb_adjust_timing(struct pxafb_info *fbi,
457static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 457static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
458{ 458{
459 struct pxafb_info *fbi = container_of(info, struct pxafb_info, fb); 459 struct pxafb_info *fbi = container_of(info, struct pxafb_info, fb);
460 struct pxafb_mach_info *inf = dev_get_platdata(fbi->dev); 460 struct pxafb_mach_info *inf = fbi->inf;
461 int err; 461 int err;
462 462
463 if (inf->fixed_modes) { 463 if (inf->fixed_modes) {
@@ -1230,7 +1230,7 @@ static unsigned int __smart_timing(unsigned time_ns, unsigned long lcd_clk)
1230static void setup_smart_timing(struct pxafb_info *fbi, 1230static void setup_smart_timing(struct pxafb_info *fbi,
1231 struct fb_var_screeninfo *var) 1231 struct fb_var_screeninfo *var)
1232{ 1232{
1233 struct pxafb_mach_info *inf = dev_get_platdata(fbi->dev); 1233 struct pxafb_mach_info *inf = fbi->inf;
1234 struct pxafb_mode_info *mode = &inf->modes[0]; 1234 struct pxafb_mode_info *mode = &inf->modes[0];
1235 unsigned long lclk = clk_get_rate(fbi->clk); 1235 unsigned long lclk = clk_get_rate(fbi->clk);
1236 unsigned t1, t2, t3, t4; 1236 unsigned t1, t2, t3, t4;
@@ -1258,14 +1258,13 @@ static void setup_smart_timing(struct pxafb_info *fbi,
1258static int pxafb_smart_thread(void *arg) 1258static int pxafb_smart_thread(void *arg)
1259{ 1259{
1260 struct pxafb_info *fbi = arg; 1260 struct pxafb_info *fbi = arg;
1261 struct pxafb_mach_info *inf = dev_get_platdata(fbi->dev); 1261 struct pxafb_mach_info *inf = fbi->inf;
1262 1262
1263 if (!inf->smart_update) { 1263 if (!inf->smart_update) {
1264 pr_err("%s: not properly initialized, thread terminated\n", 1264 pr_err("%s: not properly initialized, thread terminated\n",
1265 __func__); 1265 __func__);
1266 return -EINVAL; 1266 return -EINVAL;
1267 } 1267 }
1268 inf = dev_get_platdata(fbi->dev);
1269 1268
1270 pr_debug("%s(): task starting\n", __func__); 1269 pr_debug("%s(): task starting\n", __func__);
1271 1270
@@ -1788,11 +1787,11 @@ decode_mode:
1788 fbi->video_mem_size = video_mem_size; 1787 fbi->video_mem_size = video_mem_size;
1789} 1788}
1790 1789
1791static struct pxafb_info *pxafb_init_fbinfo(struct device *dev) 1790static struct pxafb_info *pxafb_init_fbinfo(struct device *dev,
1791 struct pxafb_mach_info *inf)
1792{ 1792{
1793 struct pxafb_info *fbi; 1793 struct pxafb_info *fbi;
1794 void *addr; 1794 void *addr;
1795 struct pxafb_mach_info *inf = dev_get_platdata(dev);
1796 1795
1797 /* Alloc the pxafb_info and pseudo_palette in one step */ 1796 /* Alloc the pxafb_info and pseudo_palette in one step */
1798 fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL); 1797 fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL);
@@ -1801,6 +1800,7 @@ static struct pxafb_info *pxafb_init_fbinfo(struct device *dev)
1801 1800
1802 memset(fbi, 0, sizeof(struct pxafb_info)); 1801 memset(fbi, 0, sizeof(struct pxafb_info));
1803 fbi->dev = dev; 1802 fbi->dev = dev;
1803 fbi->inf = inf;
1804 1804
1805 fbi->clk = clk_get(dev, NULL); 1805 fbi->clk = clk_get(dev, NULL);
1806 if (IS_ERR(fbi->clk)) { 1806 if (IS_ERR(fbi->clk)) {
@@ -1852,10 +1852,9 @@ static struct pxafb_info *pxafb_init_fbinfo(struct device *dev)
1852} 1852}
1853 1853
1854#ifdef CONFIG_FB_PXA_PARAMETERS 1854#ifdef CONFIG_FB_PXA_PARAMETERS
1855static int parse_opt_mode(struct device *dev, const char *this_opt) 1855static int parse_opt_mode(struct device *dev, const char *this_opt,
1856 struct pxafb_mach_info *inf)
1856{ 1857{
1857 struct pxafb_mach_info *inf = dev_get_platdata(dev);
1858
1859 const char *name = this_opt+5; 1858 const char *name = this_opt+5;
1860 unsigned int namelen = strlen(name); 1859 unsigned int namelen = strlen(name);
1861 int res_specified = 0, bpp_specified = 0; 1860 int res_specified = 0, bpp_specified = 0;
@@ -1911,9 +1910,9 @@ done:
1911 return 0; 1910 return 0;
1912} 1911}
1913 1912
1914static int parse_opt(struct device *dev, char *this_opt) 1913static int parse_opt(struct device *dev, char *this_opt,
1914 struct pxafb_mach_info *inf)
1915{ 1915{
1916 struct pxafb_mach_info *inf = dev_get_platdata(dev);
1917 struct pxafb_mode_info *mode = &inf->modes[0]; 1916 struct pxafb_mode_info *mode = &inf->modes[0];
1918 char s[64]; 1917 char s[64];
1919 1918
@@ -1922,7 +1921,7 @@ static int parse_opt(struct device *dev, char *this_opt)
1922 if (!strncmp(this_opt, "vmem:", 5)) { 1921 if (!strncmp(this_opt, "vmem:", 5)) {
1923 video_mem_size = memparse(this_opt + 5, NULL); 1922 video_mem_size = memparse(this_opt + 5, NULL);
1924 } else if (!strncmp(this_opt, "mode:", 5)) { 1923 } else if (!strncmp(this_opt, "mode:", 5)) {
1925 return parse_opt_mode(dev, this_opt); 1924 return parse_opt_mode(dev, this_opt, inf);
1926 } else if (!strncmp(this_opt, "pixclock:", 9)) { 1925 } else if (!strncmp(this_opt, "pixclock:", 9)) {
1927 mode->pixclock = simple_strtoul(this_opt+9, NULL, 0); 1926 mode->pixclock = simple_strtoul(this_opt+9, NULL, 0);
1928 sprintf(s, "pixclock: %ld\n", mode->pixclock); 1927 sprintf(s, "pixclock: %ld\n", mode->pixclock);
@@ -2011,7 +2010,8 @@ static int parse_opt(struct device *dev, char *this_opt)
2011 return 0; 2010 return 0;
2012} 2011}
2013 2012
2014static int pxafb_parse_options(struct device *dev, char *options) 2013static int pxafb_parse_options(struct device *dev, char *options,
2014 struct pxafb_mach_info *inf)
2015{ 2015{
2016 char *this_opt; 2016 char *this_opt;
2017 int ret; 2017 int ret;
@@ -2023,7 +2023,7 @@ static int pxafb_parse_options(struct device *dev, char *options)
2023 2023
2024 /* could be made table driven or similar?... */ 2024 /* could be made table driven or similar?... */
2025 while ((this_opt = strsep(&options, ",")) != NULL) { 2025 while ((this_opt = strsep(&options, ",")) != NULL) {
2026 ret = parse_opt(dev, this_opt); 2026 ret = parse_opt(dev, this_opt, inf);
2027 if (ret) 2027 if (ret)
2028 return ret; 2028 return ret;
2029 } 2029 }
@@ -2095,19 +2095,33 @@ static void pxafb_check_options(struct device *dev, struct pxafb_mach_info *inf)
2095static int pxafb_probe(struct platform_device *dev) 2095static int pxafb_probe(struct platform_device *dev)
2096{ 2096{
2097 struct pxafb_info *fbi; 2097 struct pxafb_info *fbi;
2098 struct pxafb_mach_info *inf; 2098 struct pxafb_mach_info *inf, *pdata;
2099 struct resource *r; 2099 struct resource *r;
2100 int irq, ret; 2100 int i, irq, ret;
2101 2101
2102 dev_dbg(&dev->dev, "pxafb_probe\n"); 2102 dev_dbg(&dev->dev, "pxafb_probe\n");
2103 2103
2104 inf = dev_get_platdata(&dev->dev);
2105 ret = -ENOMEM; 2104 ret = -ENOMEM;
2106 fbi = NULL; 2105 pdata = dev_get_platdata(&dev->dev);
2106 inf = devm_kmalloc(&dev->dev, sizeof(*inf), GFP_KERNEL);
2107 if (!inf) 2107 if (!inf)
2108 goto failed; 2108 goto failed;
2109 if (pdata) {
2110 *inf = *pdata;
2111 inf->modes =
2112 devm_kmalloc_array(&dev->dev, pdata->num_modes,
2113 sizeof(inf->modes[0]), GFP_KERNEL);
2114 if (!inf->modes)
2115 goto failed;
2116 for (i = 0; i < inf->num_modes; i++)
2117 inf->modes[i] = pdata->modes[i];
2118 }
2119
2120 fbi = NULL;
2121 if (!pdata)
2122 goto failed;
2109 2123
2110 ret = pxafb_parse_options(&dev->dev, g_options); 2124 ret = pxafb_parse_options(&dev->dev, g_options, inf);
2111 if (ret < 0) 2125 if (ret < 0)
2112 goto failed; 2126 goto failed;
2113 2127
@@ -2125,7 +2139,7 @@ static int pxafb_probe(struct platform_device *dev)
2125 goto failed; 2139 goto failed;
2126 } 2140 }
2127 2141
2128 fbi = pxafb_init_fbinfo(&dev->dev); 2142 fbi = pxafb_init_fbinfo(&dev->dev, inf);
2129 if (!fbi) { 2143 if (!fbi) {
2130 /* only reason for pxafb_init_fbinfo to fail is kmalloc */ 2144 /* only reason for pxafb_init_fbinfo to fail is kmalloc */
2131 dev_err(&dev->dev, "Failed to initialize framebuffer device\n"); 2145 dev_err(&dev->dev, "Failed to initialize framebuffer device\n");
diff --git a/drivers/video/fbdev/pxafb.h b/drivers/video/fbdev/pxafb.h
index 26ba9fa3f737..5dc414e26fc8 100644
--- a/drivers/video/fbdev/pxafb.h
+++ b/drivers/video/fbdev/pxafb.h
@@ -167,6 +167,8 @@ struct pxafb_info {
167 167
168 void (*lcd_power)(int, struct fb_var_screeninfo *); 168 void (*lcd_power)(int, struct fb_var_screeninfo *);
169 void (*backlight_power)(int); 169 void (*backlight_power)(int);
170
171 struct pxafb_mach_info *inf;
170}; 172};
171 173
172#define TO_INF(ptr,member) container_of(ptr,struct pxafb_info,member) 174#define TO_INF(ptr,member) container_of(ptr,struct pxafb_info,member)