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

drm/ssd130x: Inline the ssd130x_buf_{alloc, free}() function helpers

There is only a single caller for both helper functions and these don't do
much other than allocate and free two buffers, so let's just inline them.

Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230726105433.389740-1-javierm@redhat.com

+20 -35
+20 -35
drivers/gpu/drm/solomon/ssd130x.c
··· 146 146 return container_of(drm, struct ssd130x_device, drm); 147 147 } 148 148 149 - static int ssd130x_buf_alloc(struct ssd130x_device *ssd130x) 150 - { 151 - unsigned int page_height = ssd130x->device_info->page_height; 152 - unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height); 153 - const struct drm_format_info *fi; 154 - unsigned int pitch; 155 - 156 - fi = drm_format_info(DRM_FORMAT_R1); 157 - if (!fi) 158 - return -EINVAL; 159 - 160 - pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width); 161 - 162 - ssd130x->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL); 163 - if (!ssd130x->buffer) 164 - return -ENOMEM; 165 - 166 - ssd130x->data_array = kcalloc(ssd130x->width, pages, GFP_KERNEL); 167 - if (!ssd130x->data_array) { 168 - kfree(ssd130x->buffer); 169 - return -ENOMEM; 170 - } 171 - 172 - return 0; 173 - } 174 - 175 - static void ssd130x_buf_free(struct ssd130x_device *ssd130x) 176 - { 177 - kfree(ssd130x->data_array); 178 - kfree(ssd130x->buffer); 179 - } 180 - 181 149 /* 182 150 * Helper to write data (SSD130X_DATA) to the device. 183 151 */ ··· 677 709 { 678 710 struct drm_device *drm = encoder->dev; 679 711 struct ssd130x_device *ssd130x = drm_to_ssd130x(drm); 712 + unsigned int page_height = ssd130x->device_info->page_height; 713 + unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height); 714 + const struct drm_format_info *fi; 715 + unsigned int pitch; 680 716 int ret; 681 717 682 718 ret = ssd130x_power_on(ssd130x); ··· 691 719 if (ret) 692 720 goto power_off; 693 721 694 - ret = ssd130x_buf_alloc(ssd130x); 695 - if (ret) 722 + fi = drm_format_info(DRM_FORMAT_R1); 723 + if (!fi) 696 724 goto power_off; 725 + 726 + pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width); 727 + 728 + ssd130x->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL); 729 + if (!ssd130x->buffer) 730 + goto power_off; 731 + 732 + ssd130x->data_array = kcalloc(ssd130x->width, pages, GFP_KERNEL); 733 + if (!ssd130x->data_array) { 734 + kfree(ssd130x->buffer); 735 + goto power_off; 736 + } 697 737 698 738 ssd130x_write_cmd(ssd130x, 1, SSD130X_DISPLAY_ON); 699 739 ··· 728 744 729 745 ssd130x_write_cmd(ssd130x, 1, SSD130X_DISPLAY_OFF); 730 746 731 - ssd130x_buf_free(ssd130x); 747 + kfree(ssd130x->data_array); 748 + kfree(ssd130x->buffer); 732 749 733 750 ssd130x_power_off(ssd130x); 734 751 }