Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220607182338.344270-2-javierm@redhat.com

+15 -15
+2 -2
drivers/firmware/sysfb.c
··· 46 46 /* try to create a simple-framebuffer device */ 47 47 compatible = sysfb_parse_mode(si, &mode); 48 48 if (compatible) { 49 - ret = sysfb_create_simplefb(si, &mode); 50 - if (!ret) 49 + pd = sysfb_create_simplefb(si, &mode); 50 + if (!IS_ERR(pd)) 51 51 return 0; 52 52 } 53 53
+8 -8
drivers/firmware/sysfb_simplefb.c
··· 57 57 return false; 58 58 } 59 59 60 - __init int sysfb_create_simplefb(const struct screen_info *si, 61 - const struct simplefb_platform_data *mode) 60 + __init struct platform_device *sysfb_create_simplefb(const struct screen_info *si, 61 + const struct simplefb_platform_data *mode) 62 62 { 63 63 struct platform_device *pd; 64 64 struct resource res; ··· 76 76 base |= (u64)si->ext_lfb_base << 32; 77 77 if (!base || (u64)(resource_size_t)base != base) { 78 78 printk(KERN_DEBUG "sysfb: inaccessible VRAM base\n"); 79 - return -EINVAL; 79 + return ERR_PTR(-EINVAL); 80 80 } 81 81 82 82 /* ··· 93 93 length = mode->height * mode->stride; 94 94 if (length > size) { 95 95 printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n"); 96 - return -EINVAL; 96 + return ERR_PTR(-EINVAL); 97 97 } 98 98 length = PAGE_ALIGN(length); 99 99 ··· 104 104 res.start = base; 105 105 res.end = res.start + length - 1; 106 106 if (res.end <= res.start) 107 - return -EINVAL; 107 + return ERR_PTR(-EINVAL); 108 108 109 109 pd = platform_device_alloc("simple-framebuffer", 0); 110 110 if (!pd) 111 - return -ENOMEM; 111 + return ERR_PTR(-ENOMEM); 112 112 113 113 sysfb_apply_efi_quirks(pd); 114 114 ··· 124 124 if (ret) 125 125 goto err_put_device; 126 126 127 - return 0; 127 + return pd; 128 128 129 129 err_put_device: 130 130 platform_device_put(pd); 131 131 132 - return ret; 132 + return ERR_PTR(ret); 133 133 }
+5 -5
include/linux/sysfb.h
··· 72 72 73 73 bool sysfb_parse_mode(const struct screen_info *si, 74 74 struct simplefb_platform_data *mode); 75 - int sysfb_create_simplefb(const struct screen_info *si, 76 - const struct simplefb_platform_data *mode); 75 + struct platform_device *sysfb_create_simplefb(const struct screen_info *si, 76 + const struct simplefb_platform_data *mode); 77 77 78 78 #else /* CONFIG_SYSFB_SIMPLE */ 79 79 ··· 83 83 return false; 84 84 } 85 85 86 - static inline int sysfb_create_simplefb(const struct screen_info *si, 87 - const struct simplefb_platform_data *mode) 86 + static inline struct platform_device *sysfb_create_simplefb(const struct screen_info *si, 87 + const struct simplefb_platform_data *mode) 88 88 { 89 - return -EINVAL; 89 + return ERR_PTR(-EINVAL); 90 90 } 91 91 92 92 #endif /* CONFIG_SYSFB_SIMPLE */