firmware: sysfb: Make sysfb_create_simplefb() return a pdev pointer

This function just returned 0 on success or an errno code on error, but it
could be useful for sysfb_init() callers to have a pointer to the device.
Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220607182338.344270-2-javierm@redhat.com
parent f17c655c
...@@ -46,8 +46,8 @@ static __init int sysfb_init(void) ...@@ -46,8 +46,8 @@ static __init int sysfb_init(void)
/* try to create a simple-framebuffer device */ /* try to create a simple-framebuffer device */
compatible = sysfb_parse_mode(si, &mode); compatible = sysfb_parse_mode(si, &mode);
if (compatible) { if (compatible) {
ret = sysfb_create_simplefb(si, &mode); pd = sysfb_create_simplefb(si, &mode);
if (!ret) if (!IS_ERR(pd))
return 0; return 0;
} }
......
...@@ -57,8 +57,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si, ...@@ -57,8 +57,8 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
return false; return false;
} }
__init int sysfb_create_simplefb(const struct screen_info *si, __init struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
const struct simplefb_platform_data *mode) const struct simplefb_platform_data *mode)
{ {
struct platform_device *pd; struct platform_device *pd;
struct resource res; struct resource res;
...@@ -76,7 +76,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si, ...@@ -76,7 +76,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
base |= (u64)si->ext_lfb_base << 32; base |= (u64)si->ext_lfb_base << 32;
if (!base || (u64)(resource_size_t)base != base) { if (!base || (u64)(resource_size_t)base != base) {
printk(KERN_DEBUG "sysfb: inaccessible VRAM base\n"); printk(KERN_DEBUG "sysfb: inaccessible VRAM base\n");
return -EINVAL; return ERR_PTR(-EINVAL);
} }
/* /*
...@@ -93,7 +93,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si, ...@@ -93,7 +93,7 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
length = mode->height * mode->stride; length = mode->height * mode->stride;
if (length > size) { if (length > size) {
printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n"); printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
return -EINVAL; return ERR_PTR(-EINVAL);
} }
length = PAGE_ALIGN(length); length = PAGE_ALIGN(length);
...@@ -104,11 +104,11 @@ __init int sysfb_create_simplefb(const struct screen_info *si, ...@@ -104,11 +104,11 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
res.start = base; res.start = base;
res.end = res.start + length - 1; res.end = res.start + length - 1;
if (res.end <= res.start) if (res.end <= res.start)
return -EINVAL; return ERR_PTR(-EINVAL);
pd = platform_device_alloc("simple-framebuffer", 0); pd = platform_device_alloc("simple-framebuffer", 0);
if (!pd) if (!pd)
return -ENOMEM; return ERR_PTR(-ENOMEM);
sysfb_apply_efi_quirks(pd); sysfb_apply_efi_quirks(pd);
...@@ -124,10 +124,10 @@ __init int sysfb_create_simplefb(const struct screen_info *si, ...@@ -124,10 +124,10 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
if (ret) if (ret)
goto err_put_device; goto err_put_device;
return 0; return pd;
err_put_device: err_put_device:
platform_device_put(pd); platform_device_put(pd);
return ret; return ERR_PTR(ret);
} }
...@@ -72,8 +72,8 @@ static inline void sysfb_apply_efi_quirks(struct platform_device *pd) ...@@ -72,8 +72,8 @@ static inline void sysfb_apply_efi_quirks(struct platform_device *pd)
bool sysfb_parse_mode(const struct screen_info *si, bool sysfb_parse_mode(const struct screen_info *si,
struct simplefb_platform_data *mode); struct simplefb_platform_data *mode);
int sysfb_create_simplefb(const struct screen_info *si, struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
const struct simplefb_platform_data *mode); const struct simplefb_platform_data *mode);
#else /* CONFIG_SYSFB_SIMPLE */ #else /* CONFIG_SYSFB_SIMPLE */
...@@ -83,10 +83,10 @@ static inline bool sysfb_parse_mode(const struct screen_info *si, ...@@ -83,10 +83,10 @@ static inline bool sysfb_parse_mode(const struct screen_info *si,
return false; return false;
} }
static inline int sysfb_create_simplefb(const struct screen_info *si, static inline struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
const struct simplefb_platform_data *mode) const struct simplefb_platform_data *mode)
{ {
return -EINVAL; return ERR_PTR(-EINVAL);
} }
#endif /* CONFIG_SYSFB_SIMPLE */ #endif /* CONFIG_SYSFB_SIMPLE */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment