History log of /linux-master/drivers/staging/fbtft/fbtft-core.c
Revision Date Author Comments
# 7485b3e3 28-Feb-2024 Colin Ian King <colin.i.king@gmail.com>

staging: fbtft: remove unused variable 'count'

The variable count is being initialized and incremented but it is never
actually referenced in any other way. The variable is redundant and can
be removed.

Cleans up clang scan build warning:
drivers/staging/fbtft/fbtft-core.c:330:6: warning: variable 'count' set
but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20240229120114.219085-1-colin.i.king@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bbd25d72 07-Feb-2024 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

staging: fbtft: Follow renaming of SPI "master" to "controller"

In commit 8caab75fd2c2 ("spi: Generalize SPI "master" to "controller"")
some functions and struct members were renamed. To not break all drivers
compatibility macros were provided.

To be able to remove these compatibility macros push the renaming into
this driver.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/df79f22caf31d2c5ca2b15b33670323d1e1120c7.1707324794.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>


# c3ba2ada 28-Aug-2023 Thomas Zimmermann <tzimmermann@suse.de>

staging/fbtft: Use fb_ops helpers for deferred I/O

Generate callback functions for struct fb_ops with the fbdev macro
FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(). Initialize struct fb_ops to
the generated functions with an fbdev initializer macro.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230828132131.29295-9-tzimmermann@suse.de


# b1adff68 28-Aug-2023 Thomas Zimmermann <tzimmermann@suse.de>

staging/fbtft: Initialize fb_op struct as static const

Replace dynamic allocation of the fb_ops instance with static
allocation. Initialize the fields at module-load time. The owner
field changes to THIS_MODULE, as in all other fbdev drivers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230828132131.29295-8-tzimmermann@suse.de


# cdeb052c 15-Jul-2023 Thomas Zimmermann <tzimmermann@suse.de>

staging: Remove flag FBINFO_FLAG_DEFAULT from fbdev drivers

The flag FBINFO_FLAG_DEFAULT is 0 and has no effect, as struct
fbinfo.flags has been allocated to zero by framebuffer_alloc(). So do
not set it.

Flags should signal differences from the default values. After cleaning
up all occurrences of FBINFO_DEFAULT, the token will be removed.

v2:
* fix commit message (Miguel)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Teddy Wang <teddy.wang@siliconmotion.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230715185343.7193-13-tzimmermann@suse.de


# caa9d347 10-Mar-2023 Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>

staging: Replace all spi->chip_select and spi->cs_gpiod references with function call

Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod
members of struct spi_device to be an array. But changing the type of these
members to array would break the spi driver functionality. To make the
transition smoother introduced four new APIs to get/set the
spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and
spi->cs_gpiod references with get or set API calls.
While adding multi-cs support in further patches the chip_select & cs_gpiod
members of the spi_device structure would be converted to arrays & the
"idx" parameter of the APIs would be used as array index i.e.,
spi->chip_select[idx] & spi->cs_gpiod[idx] respectively.

Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20230310173217.3429788-6-amit.kumar-mahapatra@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 81e87888 27-Jul-2022 Peter Suti <peter.suti@streamunlimited.com>

staging: fbtft: core: set smem_len before fb_deferred_io_init call

The fbtft_framebuffer_alloc() calls fb_deferred_io_init() before
initializing info->fix.smem_len. It is set to zero by the
framebuffer_alloc() function. It will trigger a WARN_ON() at the
start of fb_deferred_io_init() and the function will not do anything.

Fixes: 856082f021a2 ("fbdev: defio: fix the pagelist corruption")
Signed-off-by: Peter Suti <peter.suti@streamunlimited.com>
Link: https://lore.kernel.org/r/20220727073550.1491126-1-peter.suti@streamunlimited.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 66d653c3 07-Jun-2022 Stephen Kitt <steve@sk2.org>

staging: ftbft: Use backlight helper

backlight_properties.fb_blank is deprecated. The states it represents
are handled by other properties; but instead of accessing those
properties directly, drivers should use the helpers provided by
backlight.h.

Instead of manually checking the power state in struct
backlight_properties, use backlight_is_blank().

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: Len Baker <len.baker@gmx.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-staging@lists.linux.dev
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20220607185516.1129900-1-steve@sk2.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e2d8b428 28-Apr-2022 Thomas Zimmermann <tzimmermann@suse.de>

fbdev: Use pageref offset for deferred-I/O writeback

Use pageref->offset instead of page->index for deferred-I/O writeback
where appropriate. Distinguishes between file-mapping offset and video-
memory offset. While at it, also remove unnecessary references to
struct page.

Fbdev's deferred-I/O code uses the two related page->index and
pageref->offset. The former is the page offset in the mapped file,
the latter is the byte offset in the video memory (or fbdev screen
buffer). It's the same value for fbdev drivers, but for DRM the values
can be different. Because GEM buffer objects are mapped at an offset
in the DRM device file, page->index has this offset added to it as well.
We currently don't hit this case in DRM, because all affected mappings
of GEM memory are performed with an internal, intermediate shadow buffer.

The value of page->index is required by page_mkclean(), which we
call to reset the mappings during the writeback phase of the deferred
I/O. The value of pageref->offset is for conveniently getting an offset
into video memory in fb helpers.

v4:
* fix commit message (Javier)

Suggested-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220429100834.18898-6-tzimmermann@suse.de


# e80eec1b 28-Apr-2022 Thomas Zimmermann <tzimmermann@suse.de>

fbdev: Rename pagelist to pagereflist for deferred I/O

Rename various instances of pagelist to pagereflist. The list now
stores pageref structures, so the new name is more appropriate.

In their write-back helpers, several fbdev drivers refer to the
pageref list in struct fb_deferred_io instead of using the one
supplied as argument to the function. Convert them over to the
supplied one. It's the same instance, so no change of behavior
occurs.

v4:
* fix commit message (Javier)

Suggested-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220429100834.18898-5-tzimmermann@suse.de


# 56c134f7 28-Apr-2022 Thomas Zimmermann <tzimmermann@suse.de>

fbdev: Track deferred-I/O pages in pageref struct

Store the per-page state for fbdev's deferred I/O in struct
fb_deferred_io_pageref. Maintain a list of pagerefs for the pages
that have to be written back to video memory. Update all affected
drivers.

As with pages before, fbdev acquires a pageref when an mmaped page
of the framebuffer is being written to. It holds the pageref in a
list of all currently written pagerefs until it flushes the written
pages to video memory. Writeback occurs periodically. After writeback
fbdev releases all pagerefs and builds up a new dirty list until the
next writeback occurs.

Using pagerefs has a number of benefits.

For pages of the framebuffer, the deferred I/O code used struct
page.lru as an entry into the list of dirty pages. The lru field is
owned by the page cache, which makes deferred I/O incompatible with
some memory pages (e.g., most notably DRM's GEM SHMEM allocator).
struct fb_deferred_io_pageref now provides an entry into a list of
dirty framebuffer pages, freeing lru for use with the page cache.

Drivers also assumed that struct page.index is the page offset into
the framebuffer. This is not true for DRM buffers, which are located
at various offset within a mapped area. struct fb_deferred_io_pageref
explicitly stores an offset into the framebuffer. struct page.index
is now only the page offset into the mapped area.

These changes will allow DRM to use fbdev deferred I/O without an
intermediate shadow buffer.

v3:
* use pageref->offset for sorting
* fix grammar in comment
v2:
* minor fixes in commit message

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220429100834.18898-3-tzimmermann@suse.de


# 59055851 28-Apr-2022 Thomas Zimmermann <tzimmermann@suse.de>

fbdev: Put mmap for deferred I/O into drivers

The fbdev mmap function fb_mmap() unconditionally overrides the
driver's implementation if deferred I/O has been activated. This
makes it hard to implement mmap with anything but a vmalloc()'ed
software buffer. That is specifically a problem for DRM, where
video memory is maintained by a memory manager.

Leave the mmap handling to drivers and expect them to call the
helper for deferred I/O by thmeselves.

v4:
* unlock mm_lock in fb_mmap() error path (Dan)
v3:
* fix warning if fb_mmap is missing (kernel test robot)
v2:
* print a helpful error message if the defio setup is
incorrect (Javier)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220429100834.18898-2-tzimmermann@suse.de


# 362e54e4 16-Mar-2022 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

staging: fbtft: Consider type of init sequence values in fbtft_init_display()

In the fbtft_init_display() the init sequence is printed for
the debug purposes. Unfortunately the current code doesn't take
into account that values in the buffer are of the s16 type.

Consider that and replace the printing code with fbtft_par_dbg_hex()
call.

Fixes: b888897014a9 ("staging/fbtft: Remove all strcpy() uses")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220316165351.58107-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0e8cf2be 16-Mar-2022 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

staging: fbtft: Constify buf parameter in fbtft_dbg_hex()

It's obvious that we don't and shouldn't modify buffer that
is about to be dumped. Constify parameter in fbtft_dbg_hex()
to make it clear.

Fixes: c296d5f9957c ("staging: fbtft: core support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220316165351.58107-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8c30e2d8 11-Feb-2022 Thomas Zimmermann <tzimmermann@suse.de>

fbdev: Don't sort deferred-I/O pages by default

Fbdev's deferred I/O sorts all dirty pages by default, which incurs a
significant overhead. Make the sorting step optional and update the few
drivers that require it. Use a FIFO list by default.

Most fbdev drivers with deferred I/O build a bounding rectangle around
the dirty pages or simply flush the whole screen. The only two affected
DRM drivers, generic fbdev and vmwgfx, both use a bounding rectangle.
In those cases, the exact order of the pages doesn't matter. The other
drivers look at the page index or handle pages one-by-one. The patch
sets the sort_pagelist flag for those, even though some of them would
probably work correctly without sorting. Driver maintainers should update
their driver accordingly.

Sorting pages by memory offset for deferred I/O performs an implicit
bubble-sort step on the list of dirty pages. The algorithm goes through
the list of dirty pages and inserts each new page according to its
index field. Even worse, list traversal always starts at the first
entry. As video memory is most likely updated scanline by scanline, the
algorithm traverses through the complete list for each updated page.

For example, with 1024x768x32bpp each page covers exactly one scanline.
Writing a single screen update from top to bottom requires updating
768 pages. With an average list length of 384 entries, a screen update
creates (768 * 384 =) 294912 compare operation.

Fix this by making the sorting step opt-in and update the few drivers
that require it. All other drivers work with unsorted page lists. Pages
are appended to the list. Therefore, in the common case of writing the
framebuffer top to bottom, pages are still sorted by offset, which may
have a positive effect on performance.

Playing a video [1] in mplayer's benchmark mode shows the difference
(i7-4790, FullHD, simpledrm, kernel with debugging).

mplayer -benchmark -nosound -vo fbdev ./big_buck_bunny_720p_stereo.ogg

With sorted page lists:

BENCHMARKs: VC: 32.960s VO: 73.068s A: 0.000s Sys: 2.413s = 108.441s
BENCHMARK%: VC: 30.3947% VO: 67.3802% A: 0.0000% Sys: 2.2251% = 100.0000%

With unsorted page lists:

BENCHMARKs: VC: 31.005s VO: 42.889s A: 0.000s Sys: 2.256s = 76.150s
BENCHMARK%: VC: 40.7156% VO: 56.3219% A: 0.0000% Sys: 2.9625% = 100.0000%

VC shows the overhead of video decoding, VO shows the overhead of the
video output. Using unsorted page lists reduces the benchmark's run time
by ~32s/~25%.

v2:
* Make sorted pagelists the special case (Sam)
* Comment on drivers' use of pagelist (Sam)
* Warn about the overhead in comment

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_stereo.ogg # [1]
Link: https://patchwork.freedesktop.org/patch/msgid/20220211094640.21632-3-tzimmermann@suse.de


# 7865dd24 05-Nov-2021 Noralf Trønnes <noralf@tronnes.org>

staging/fbtft: Fix backlight

Commit b4a1ed0cd18b ("fbdev: make FB_BACKLIGHT a tristate") forgot to
update fbtft breaking its backlight support when FB_BACKLIGHT is a module.

Since FB_TFT selects FB_BACKLIGHT there's no need for this conditional
so just remove it and we're good.

Fixes: b4a1ed0cd18b ("fbdev: make FB_BACKLIGHT a tristate")
Cc: <stable@vger.kernel.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Link: https://lore.kernel.org/r/20211105204358.2991-1-noralf@tronnes.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cb08d3d2 12-Oct-2021 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

staging: fbtft: Make fbtft_remove_common() return void

fbtft_remove_common() is only called with a non-NULL fb_info. (All
callers are in remove callbacks and the matching probe callbacks set
driver data accordingly.) So fbtft_remove_common() always returns zero.
Make it return void instead which makes it easier to see in the callers
that there is no error to handle.

Also the return value of platform and spi remove callbacks is ignored
anyway and not freeing resources in .remove() is a bad idea.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20211012153945.2651412-20-u.kleine-koenig@pengutronix.de
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 54af2893 04-Sep-2021 Srivathsa Dara <srivathsa729.8@gmail.com>

staging: fbtft: fbtft-core: fix 'trailing statements should be on next line' coding style error

Fix coding style error 'trailing statements should be on next line'

Signed-off-by: Srivathsa Dara <srivathsa729.8@gmail.com>
Link: https://lore.kernel.org/r/20210904080916.15476-1-srivathsa729.8@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f9d39971 01-Aug-2021 Len Baker <len.baker@gmx.com>

staging/fbtft: Fix braces coding style

Add braces to the "for" loop. This way, the kernel coding style is
followed.

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210801085155.3170-4-len.baker@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 31f0c349 01-Aug-2021 Len Baker <len.baker@gmx.com>

staging/fbtft: Remove unnecessary variable initialization

Remove the initialization of the variable "i" since it is written a few
lines later.

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210801085155.3170-3-len.baker@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b8888970 01-Aug-2021 Len Baker <len.baker@gmx.com>

staging/fbtft: Remove all strcpy() uses

strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. The safe replacement is strscpy() but in
this case it is simpler to use the "%*ph" format specifier.

Moreover, with the "0x%02X " in the sprintf followed by the strcat, the
msg buffer (now removed) can print 128/5 values (25 hex values). So, the
"%*ph" replacement won't cut output earlier than requested since this
format specifier can print up to 64 bytes.

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210801085155.3170-2-len.baker@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 37667f6e 03-May-2021 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

staging: fbtft: Don't spam logs when probe is deferred

When requesting GPIO line the probe can be deferred.
In such case don't spam logs with an error message.
This can be achieved by switching to dev_err_probe().

Fixes: c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface")
Cc: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210503172114.27891-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ec03c210 03-May-2021 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

staging: fbtft: Rectify GPIO handling

The infamous commit c440eee1a7a1 ("Staging: staging: fbtft: Switch to
the GPIO descriptor interface") broke GPIO handling completely.
It has already four commits to rectify and it seems not enough.
In order to fix the mess here we:

1) Set default to "inactive" for all requested pins

2) Fix CS#, RD#, and WR# pins polarity since it's active low
and GPIO descriptor interface takes it into consideration
from the Device Tree or ACPI

3) Consolidate chip activation (CS# assertion) under default
->reset() callback

To summarize the expectations about polarity for GPIOs:

RD# Low
WR# Low
CS# Low
RESET# Low
DC or RS High
RW High
Data 0 .. 15 High

See also Adafruit learning course [1] for the example of the schematics.

While at it, drop unneeded NULL checks, since GPIO API is tolerant to that.

[1]: https://learn.adafruit.com/adafruit-2-8-and-3-2-color-tft-touchscreen-breakout-v2/downloads

Fixes: 92e3e884887c ("Staging: fbtft: Fix GPIO handling")
Fixes: b918d1c27066 ("Staging: fbtft: Fix reset assertion when using gpio descriptor")
Fixes: dbc4f989c878 ("Staging: fbtft: Fix probing of gpio descriptor")
Fixes: c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface")
Cc: Jan Sebastian Götte <linux@jaseg.net>
Cc: Nishad Kamdar <nishadkamdar@gmail.com>
Reviewed-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210503172114.27891-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1293b4aa 15-Mar-2020 Deepak R Varma <mh12gx2825@gmail.com>

staging: fbtft: Reformat line over 80 characters

A long variable name beyond 80 characters extends into the next
line. Reformatting the line makes it more readable. Also adding an extra
line for the next instruction following current if block helps
understand it better.

Signed-off-by: Deepak R Varma <mh12gx2825@gmail.com>
Link: https://lore.kernel.org/r/027ccfa893feafc25da273b4b4de444d7a466cfd.1584314603.git.mh12gx2825@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4bcd9eae 21-Nov-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

fbtft: Fix the initialization from property algorithm

When converting to device property API the commit
8b2d3aeeb7ec ("fbtft: Make use of device property API")
mistakenly placed the reading of the first value inside the loop,
that jumps over value after initialization sequence or sleep commands.

Move the above mentioned reading outside of the loop to restore
correct behaviour.

Besides that, we are using pre-increment operation which may lead to
out of the boundary access at the end of sequence. Thus, allocate buffer
with an additional element at the end to prevent out of the boundary
access.

Fixes: 8b2d3aeeb7ec ("fbtft: Make use of device property API")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20191121140207.65089-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8b2d3aee 20-Nov-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

fbtft: Make use of device property API

Make use of device property API in this driver so that both OF based
system and ACPI based system can use this driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20191120095716.26628-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2494fd4c 20-Nov-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

fbtft: Drop useless #ifdef CONFIG_OF and dead code

First of all there is no need to guard GPIO request by CONFIG_OF.
It works for everybody independently on resource provider. While here,
rename the function to reflect the above.

Moreover, since we have a global dependency to OF, the rest of
conditional compilation is no-op, i.e. it's always be true.

Due to above drop useless #ifdef CONFIG_OF and therefore dead code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20191120095716.26628-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6753e795 20-Nov-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

fbtft: Describe function parameters in kernel-doc

Kernel documentation script complains that some of the function parameters
are not described:

drivers/staging/fbtft/fbtft-core.c:543: warning: Function parameter or member 'pdata' not described in 'fbtft_framebuffer_alloc'

Describe function parameters where it's appropriate.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20191120095716.26628-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 21f58548 20-Nov-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

fbtft: Make sure string is NULL terminated

New GCC warns about inappropriate use of strncpy():

drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_framebuffer_alloc’:
drivers/staging/fbtft/fbtft-core.c:665:2: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
665 | strncpy(info->fix.id, dev->driver->name, 16);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Later on the copy is being used with the assumption to be NULL terminated.
Make sure string is NULL terminated by switching to snprintf().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20191120095716.26628-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 91d6f911 11-Oct-2019 Michael Hennerich <michael.hennerich@analog.com>

staging: fbtft: fbtft-core: Fix last line displayed on fbcon

For the special case when fbtft_mkdirty() is called with with -1 for the y
coordinate, the height is truncated by 1.

This isn't required, and causes the last line to not update.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20191011112441.31003-1-alexandru.ardelean@analog.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5bdea606 29-Sep-2019 Navid Emamdoost <navid.emamdoost@gmail.com>

Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc

In fbtft_framebuffer_alloc the error handling path should take care of
releasing frame buffer after it is allocated via framebuffer_alloc, too.
Therefore, in two failure cases the goto destination is changed to
address this issue.

Fixes: c296d5f9957c ("staging: fbtft: core support")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@gmail.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20190930030949.28615-1-navid.emamdoost@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 92e3e884 17-Jul-2019 Jan Sebastian Götte <linux@jaseg.net>

Staging: fbtft: Fix GPIO handling

Commit c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor
interface") breaks GPIO handling. In several places, checks to only set
a GPIO if it was configured ended up backwards.
I have tested this fix. The fixed driver works with a ili9486
display connected to a raspberry pi via SPI.

Fixes: c440eee1a7a1d ("Staging: fbtft: Switch to the gpio descriptor interface")
Tested-by: Jan Sebastian Götte <linux@jaseg.net>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Jan Sebastian Götte <linux@jaseg.net>
Link: https://lore.kernel.org/r/75ada52f-afa1-08bc-d0ce-966fc1110e70@jaseg.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b918d1c2 15-Jul-2019 Phil Reid <preid@electromag.com.au>

Staging: fbtft: Fix reset assertion when using gpio descriptor

Typically gpiod_set_value calls would assert the reset line and
then release it using the symantics of:
gpiod_set_value(par->gpio.reset, 0);
... delay
gpiod_set_value(par->gpio.reset, 1);
And the gpio binding would specify the polarity.

Prior to conversion to gpiod calls the polarity in the DT
was ignored and assumed to be active low. Fix it so that
DT polarity is respected.

Fixes: c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface")
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Jan Sebastian Götte <linux@jaseg.net>
Signed-off-by: Phil Reid <preid@electromag.com.au>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1563236677-5045-3-git-send-email-preid@electromag.com.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# dbc4f989 15-Jul-2019 Phil Reid <preid@electromag.com.au>

Staging: fbtft: Fix probing of gpio descriptor

Conversion to use gpio descriptors broke all gpio lookups as
devm_gpiod_get_index was converted to use dev->driver->name for
the gpio name lookup. Fix this by using the name param. In
addition gpiod_get post-fixes the -gpios to the name so that
shouldn't be included in the call. However this then breaks the
of_find_property call to see if the gpio entry exists as all
fbtft treats all gpios as optional. So use devm_gpiod_get_index_optional
instead which achieves the same thing and is simpler.

Nishad confirmed the changes where only ever compile tested.

Fixes: c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface")
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Jan Sebastian Götte <linux@jaseg.net>
Signed-off-by: Phil Reid <preid@electromag.com.au>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1563236677-5045-2-git-send-email-preid@electromag.com.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# deb00d27 28-May-2019 Daniel Vetter <daniel.vetter@ffwll.ch>

fbdev: make unregister/unlink functions not fail

Except for driver bugs (which we'll catch with a WARN_ON) this is only
to report failures of the new driver taking over the console. There's
nothing the outgoing driver can do about that, and no one ever
bothered to actually look at these return values. So remove them all.

v2: fixup unregister_framebuffer in savagefb, fbtft, ivtvfb, and neofb
drivers, reported by kbuild.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Peter Rosin <peda@axentia.se>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-fbdev@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-19-daniel.vetter@ffwll.ch


# 1ba539d5 25-Feb-2019 Bhanusree Pola <bhanusreemahesh@gmail.com>

Staging: fbtft: Fix line over 80 characters

Fix the checkpatch.pl warning:
WARNING:line over 80 characters
Move Parameters to the next lines with proper alignment

Signed-off-by: Bhanusree Pola <bhanusreemahesh@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d0ff480a 25-Feb-2019 Bhanusree Pola <bhanusreemahesh@gmail.com>

Staging: fbtft: Extra blank line not required before '}'

Remove unnecesessary extra blank line before the closing brace,
to solve the checkpatch.pl check:
CHECK: Extra blank line not required before closing brace '}'

Signed-off-by: Bhanusree Pola <bhanusreemahesh@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c440eee1 16-Jan-2019 Nishad Kamdar <nishadkamdar@gmail.com>

Staging: fbtft: Switch to the gpio descriptor interface

This switches the fbtft driver to use GPIO descriptors
rather than numerical gpios:

Utilize the GPIO library's intrinsic handling of OF GPIOs
and polarity. If the line is flagged active low, gpiolib
will deal with this.

Remove gpios from platform device structure. Neither assign
statically numbers to gpios in platform device nor allow
gpios to be parsed as module parameters.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1b989094 07-Aug-2018 Leonardo Brás <leobras.c@gmail.com>

staging: fbtft: Add spaces around / - Style

Puts spaces around the /.

Signed-off-by: Leonardo Brás <leobras.c@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 333c7b94 07-Aug-2018 Leonardo Brás <leobras.c@gmail.com>

staging: fbtft: Fixes some alignment issues - Style

Fixes (most) alignment issues pointed by checkpatch.pl.

Signed-off-by: Leonardo Brás <leobras.c@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9adfe5c8 25-Apr-2018 Daniel Vetter <daniel.vetter@ffwll.ch>

staging: fbtft: Stop using BL_CORE_DRIVER1

Leaking driver internal tracking into the already massively confusing
backlight power tracking is really confusing.

Luckily we have already a drvdata structure, so fixing this is really
easy.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 78c00ccc 11-Jan-2018 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: fbtft: remove redundant license text

Now that the SPDX tag is in all fbtft files, that identifies the license
in a specific and legally-defined manner. So the extra GPL text wording
can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 783de57c 11-Jan-2018 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: fbtft: add SPDX identifiers

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Fix up the all of the staging fbtft drivers to have a proper SPDX
identifier, based on the license text in the file itself. The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9365f281 10-Jan-2018 Luis Gerhorst <luis.gerhorst@fau.de>

staging: fbtft: Fix indentation

This fixes the checkpatch message:

CHECK: Alignment should match open parenthesis
#1380: FILE: drivers/staging/fbtft/fbtft-core.c:1380:
+ dev_warn(dev,
+ "no default functions for regwidth=%d and buswidth=%d\n",

Signed-off-by: Luis Gerhorst <linux-kernel@luisgerhorst.de>
Signed-off-by: Jonny Schaefer <schaefer.jonny@gmail.com>
Acked-by: Alexander Wuerstlein <arw@cs.fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c3738b37 08-Jan-2018 Luis Gerhorst <linux-kernel@luisgerhorst.de>

drivers/fbtft: Remove unnecessary braces from if/else

The Linux kernel coding style states that braces should only be used
when necessary.

This fixes the checkpatch warning

WARNING: line over 80 characters
+ } else if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {

introduced by patch #1.

Signed-off-by: Luis Gerhorst <linux-kernel@luisgerhorst.de>
Acked-by: Jonny Schaefer <schaefer.jonny@gmail.com>
Acked-by: Alexander Wuerstlein <arw@cs.fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 17c9d1ba 08-Jan-2018 Luis Gerhorst <linux-kernel@luisgerhorst.de>

drivers/fbtft: Remove newline after else in else-if

This removes the following warning issued by checkpatch

WARNING: suspect code indent for conditional statements (8, 8)
+ } else
+ if (display->regwidth == 8 && display->buswidth == 9 && par->spi) {

Signed-off-by: Luis Gerhorst <linux-kernel@luisgerhorst.de>
Acked-by: Jonny Schaefer <schaefer.jonny@gmail.com>
Acked-by: Alexander Wuerstlein <arw@cs.fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0d0d4d21 17-Jul-2017 Dan Carpenter <dan.carpenter@oracle.com>

staging: fbtft: array underflow in fbtft_request_gpios_match()

"val" can be negative, so we'd write before the start of the
par->gpio.db[] array.

Fixes: c296d5f9957c ("staging: fbtft: core support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 60da7020 02-Mar-2017 Heiner Kallweit <hkallweit1@gmail.com>

staging: fbtft: add helper fbtft_write_buf_dc

Factor out setting DC GPIO and writing buffer content to helper
fbtft_write_buf_dc.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 18c61421 02-Mar-2017 Heiner Kallweit <hkallweit1@gmail.com>

staging: fbtft: improve a syslog message in fbtft_register_framebuffer

There are drivers like fb_sh1106 which allocate a txbuf less than 1 KiB.
In this case the message would include "0 KiB buffer memory" what
doesn't make sense and in general I doubt that there is any benefit in
informing the user about allocation of a very small buffer.

Therefore omit this message part if the buffer has less than 1 KiB.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0a859b31 22-Feb-2017 Joe Perches <joe@perches.com>

staging: fbtft: Make the pointers to s16 init arrays const

This allows making some of the actual arrays const.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 027bcc5d 16-Feb-2017 Gargi Sharma <gs051095@gmail.com>

staging: fbtft: Remove blank line

Remove blank line before closing brace to fix the checkpatch
issue blank lines aren't necessary before a close brace '}'.

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4da2f4b7 16-Feb-2017 Gargi Sharma <gs051095@gmail.com>

staging: fbtft: Match alignment with open parentheses

Indent code to match alignment with open parentheses, to
fix the checkpatch issue alignment should match open parenthesis.

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 22eb36b8 02-Feb-2017 Arnd Bergmann <arnd@arndb.de>

staging: fbtft: change 'gamma' array to u32

Having a local variable of 1024 bytes on 64-bit architectures is a bit
too much, and I ran into this warning while trying to see what functions
use the largest stack:

drivers/staging/fbtft/fbtft-sysfs.c: In function 'store_gamma_curve':
drivers/staging/fbtft/fbtft-sysfs.c:132:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]

As there is no need for 64-bit gamma values (on 32-bit architectures,
we don't use those either), I'm changing the type from 'unsigned long'
to 'u32' here, which cuts the required space in half everywhere.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ced04842 23-Jan-2017 Abdul Rauf <abdulraufmujahid@gmail.com>

staging: fbtft: fix checkpatch decimal permissions error

Fix the following errors:
Use 4 digit octal (0777) not decimal permissions

Signed-off-by: Abdul Rauf <abdulraufmujahid@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7c3eaadd 18-Jan-2017 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

staging: fbtft: remove custom DMA mapped buffer

There is no need to duplicate what SPI core already does, i.e. mapping buffers
for DMA capable transfers.

Remove all related pices of code.

Note, that code, besides its redundancy, was buggy: DMA address potentially can
be 0, SPI slave device has nothing to do with DMA capable device properties and
DMA mask in particular.

Suggested-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9ed2bfb3 18-Jan-2017 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

staging: fbtft: convert fbtft_reset() to be non-atomic

First of all, fbtft in current state doesn't allow to override GPIOs to be
optional, like "reset" one. It might be a bug somewhere, but rather out of
scope of this fix.

Second, not all GPIOs available on the board would be SoC based, some of them
might sit on I2C GPIO expanders, for example, on Intel Edison/Arduino, and thus
any communication with them might sleep.

Besides that using udelay() and mdelay() is kinda resource wasteful.

Summarize all of the above, convert fbtft_reset() function to non-atomic
variant by using gpio_set_value_cansleep(), usleep_range(), and msleep().

Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1007e613 08-Nov-2016 Maninder Singh <maninder.s2@samsung.com>

staging: fbtft: Fix 'line over 80 characters'

This patch fixes the following checkpatch.pl warning
WARNING: line over 80 characters

Signed-off-by: Maninder Singh <maninder.s2@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9f8e0562 07-Oct-2016 Joe Perches <joe@perches.com>

staging: fbtft: Convert int arrays to s16

These arrays use -1, -2, and -3 as initiators for various types of
writes to initialize hardware.

No values are used that conflict with using these arrays as s16
instead of int and reducing overall data is good.

$ size drivers/staging/fbtft/built-in.o*
text data bss dec hex filename
116120 32872 4152 153144 25638 drivers/staging/fbtft/built-in.o.new
116104 36344 6200 158648 26bb8 drivers/staging/fbtft/built-in.o.old

Miscellaneous:

o Realign some of the arrays to make reading a bit easier

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fc1e2c8e 02-Oct-2016 Ksenija Stanojevic <ksenija.stanojevic@gmail.com>

Staging: fbtft: Fix bug in fbtft-core

Commit 367e8560e8d7a62d96e9b1d644028a3816e04206 introduced a bug
in fbtft-core where fps is always 0, this is because variable
update_time is not assigned correctly.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Fixes: 367e8560e8d7 ("Staging: fbtbt: Replace timespec with ktime_t")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1c41494a 17-Jul-2016 Ming Yang <minos.future@gmail.com>

Staging: fbtft: fixed unsigned type warnings

Replace unsigned by unsigned int in fbtft driver. Issue found by
checkpatch.

Signed-off-by: Ming Yang <minos.future@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 175f5a41 09-Jun-2016 Michal Suchanek <hramrach@gmail.com>

staging: fbtft: do not allocate huge txbuf

txbuflen can be set to arbitrary value by user and it is also set
automagically to the maximum transfer size of the SPI master controller.

Do not allocate the buffer when larger than vmem. When my SPI master
controller reports maximum transfer size 16M the probe of fbtft fails.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Acked-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0c9ab986 25-Feb-2016 Amitoj Kaur Chawla <amitoj1606@gmail.com>

staging: fbtft: Use devm_kcalloc instead of devm_kzalloc

Replace devm_kzalloc with devm_kcalloc to ensure there are no integer
overflows from the multiplication of a number * sizeof

The following Coccinelle semantic patch was used to make this change:
//<smpl>
@@
expression dev,E1,E2,E3,E4;
@@

- devm_kzalloc(dev,E1*E2*sizeof(E3),E4)
+ devm_kcalloc(dev,E1*E2,sizeof(E3),E4)
//</smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 71e03f10 24-Feb-2016 Amitoj Kaur Chawla <amitoj1606@gmail.com>

staging: fbtft: Remove unnecessary spi_set_drvdata()

Unnecessary spi_set_drvdata() has been removed since the driver
core clears the driver data to NULL after device release or on
probe failure. There is no need to manually clear the device
driver data to NULL.

The Coccinelle semantic patch used to make this change is as follows:
@@
struct spi_device *spi;
@@
- spi_set_drvdata(spi, NULL);
// </smpl>

Due to this removal, variable `spi` was unused so dropped `spi`

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e4d1bff1 15-Feb-2016 Anchal Jain <anchalj109@gmail.com>

staging: fbtft: Fix block comment coding style

Add the required leading * on subsequent lines as well as
move the */ on a separate line. Checkpatch found this issue.

Signed-off-by: Anchal Jain <anchalj109@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a79cb390 20-Dec-2015 Priit Laes <plaes@plaes.org>

staging: fbtft: Use standard MIPI DCS command defines for fbtft driver

This patch makes use of the standard MIPI Display Command Set to remove
some of the magic constants found in source code.

Signed-off-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2fe9f8ca 21-Nov-2015 Nizam Haider <nizamhaider786@gmail.com>

Staging: fbtft: fbtft-core: Removed unnecessary checks

The driver core clears the driver data to NULL after device_release
or on probe failure.

Signed-off-by: Nizam Haider <nijamh@cdac.in>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4b6dc179 07-Oct-2015 Lars Svensson <lars1.svensson@sonymobile.com>

staging: fbtft: use alternate screen pointer

Member screen_base in struct fb_info is declared with __iomem
qualifier causing sparse warnings when used as a regular ponter.
To avoid the warnings, instead use alternate non-__iomem pointer,
screen_buffer, troughout the driver.

Signed-off-by: Lars Svensson <lars1.svensson@sonymobile.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 367e8560 07-Oct-2015 Ksenija Stanojevic <ksenija.stanojevic@gmail.com>

Staging: fbtbt: Replace timespec with ktime_t

struct timespec will overflow in year 2038, so replace it with
ktime_t. And replace functions that use struct timespec,
timespec_sub with ktime_sub. Also use monotonic time instead of real
time, by replacing getnstimeofday with ktime_get, to be more robust
against leap seconds and settimeofday() calls.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6f6347ef 30-Sep-2015 Shraddha Barke <shraddha.6596@gmail.com>

Staging: fbtft: Remove debug messages related to DEBUG_BACKLIGHT

Remove debug messages related to fbtft_par_dbg(DEBUG_BACKLIGHT.. )
as this info can be obtained using kernel function tracer

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 64ffdc38 21-Sep-2015 Shraddha Barke <shraddha.6596@gmail.com>

Staging: fbtft: Remove debug messages

Remove debug messages related to fbtft_par_dbg(DEBUG_INIT_DISPLAY.. )
as this info can be obtained using kernel function tracer

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cabb5b2a 25-Aug-2015 Stefan Wahren <stefan.wahren@i2se.com>

staging: fbtft: fix 9-bit SPI support detection

Since the result of the setup function isn't adequate to check
9-bit SPI support, we better check bits_per_word_mask. Btw this
change avoids a NULL pointer dereference with master drivers
without a separate setup function.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 94c0a544 03-Sep-2015 Anish Bhatt <anish7@gmail.com>

staging/fbtft : Add missing whitespace around operators

Add blank spaces around operators where recommended
by checkpatch.pl

Signed-off-by: Anish Bhatt <anish@chelsio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1014c2ce 03-Sep-2015 Anish Bhatt <anish7@gmail.com>

staging/fbtft : Fix multiple/missing blank line issues

Remove or add blank lines as recommended by checkpatch.pl

Signed-off-by: Anish Bhatt <anish@chelsio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e7322187 03-Sep-2015 Anish Bhatt <anish7@gmail.com>

staging/fbtft : Remove repeated set_addr_win debug messages

fbtft_par_dbg(DEBUG_SET_ADDR_WIN.. ) is repeated in every
set_addr_win() handler, this could be replicated by using the kernel
function tracer instead.

Signed-off-by: Anish Bhatt <anish@chelsio.com>
Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ed20c6fb 02-Sep-2015 Mike Rapoport <rppt@kernel.org>

staging: fbtft: fbtft_request_gpios: reduce nesting

Returning immediately if no platform_data or platform_data->gpios is
specified reduceis code nesting

Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c18d116d 02-Sep-2015 Mike Rapoport <rppt@kernel.org>

staging: fbtft: fbtft-core: define backlight_ops statically

instead of devm_kzalloc'ing them

Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e7f506bd 02-Sep-2015 Mike Rapoport <rppt@kernel.org>

staging: fbtft: remove unused bl_ops from fbtft_unregister_backlight

The only usage of bl_ops variable in fbtft_unregister_backlight function
was assigment of a value to that variable, therefore the assignment and
the variable itself can be safely removed

Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4a1a8383 02-Sep-2015 Anish Bhatt <anish7@gmail.com>

staging/fbtft : Remove FSF mailing address

checkpatch.pl recommends that this is no longer required.
Also replaces ASCII-art copyright notice with simple text

Signed-off-by: Anish Bhatt <anish@chelsio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ad6d8812 30-Jul-2015 Noralf Trønnes <noralf@tronnes.org>

staging: fbtft: core: Don't set device platform_data

Pass platform_data as an argument to fbtft_framebuffer_alloc()
instead of using dev->platform_data.

This fixes an issue where the device comes from Device Tree
and fbtft_probe_common() sets dev->platform_data to allocated
memory. When the module is reloaded, dev->platform_data points
to freed memory.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# dc4b2068 11-Jul-2015 Noralf Trønnes <noralf@tronnes.org>

staging: fbtft: Add reset to fbtft_init_display_dt()

When an init sequence is present in the Device Tree,
fbtft_init_display_dt() is used to initialize the display.
Add missing reset function call and activation of
chip select for parallel bus.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 11f2323a 09-Jun-2015 Sudip Mukherjee <sudipm.mukherjee@gmail.com>

staging: fbtft: fix build error

while building on i386 it gives a build warning about msg undeclared.

Fixes: e6ffd1ba55a4931c ("staging: fbtft: fix out of bound access")
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e6ffd1ba 04-Jun-2015 Sudip Mukherjee <sudipm.mukherjee@gmail.com>

staging: fbtft: fix out of bound access

str was 16 bytes but was mentioned as 128 in snprintf.
again msg is 128 bytes but not sufficient to hold the complete debug
message of register values.
Now removed the use of str, msg and print the register values from the
loop.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b38c760a 31-May-2015 Madhusudhanan Ravindran <mravindr@visteon.com>

staging: fbtft: replace fbtft_dev_dbg with standard dev_dbg call

This patch attempts to simplify the debugging using standard
dev_dbg call so that individual debug prints can be enabled or
disbled by dynamic debugging rather than using module params.

Signed-off-by: Madhusudhanan Ravindran <mravindr@visteon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8e1a4c7f 24-Apr-2015 Geert Uytterhoeven <geert@linux-m68k.org>

staging: fbtft: Disable DMA support if DMA is not available

If NO_DMA=y:

drivers/built-in.o: In function `fbtft_framebuffer_alloc':
(.text+0xb53cae): undefined reference to `dmam_alloc_coherent'

As DMA support is already optional, make it depend on HAS_DMA.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 92def781 20-Mar-2015 Masanari Iida <standby24x7@gmail.com>

staging: fbtft: Fix typo in fbtft

This patch fix spelling typo in comment and printk within fbtft

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d9fabbde 04-Mar-2015 Drew Fustini <pdp7pdp7@gmail.com>

Staging: fbtft: add header for internal functions

Remove extern keyword from function prototypes to suppress warning from
checkpatch.pl with --strict option: https://lkml.org/lkml/2013/7/23/422

fbtft maintainer Noralf Tronnes advised these functions are internal to
this module & suggested moving these prototypes to new internal.h file.
He also advised fbtft.h file will eventually live in include/linux/fbtft.h

Suggested-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Drew Fustini <pdp7pdp7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# aed1c72e 06-Mar-2015 Haneen Mohammed <hamohammed.sa@gmail.com>

Staging: fbtft: clean dev_err() logging

This patch removes __func__ from dev_err. dev_err includes information about:
(devcice, driver, specific instance of device, etc) in the log printout.
This was done using Coccinelle, with the following semantic patch:

@a@
expression E, R;
expression msg;
@@

dev_err(E, msg, __func__, R);

@script:python b@
e << a.msg;
y;
@@

if(e.find("%s: ") == True):
m = e.replace("%s: ", "", 1);
coccinelle.y = m;
elif(e.find("%s ") == True):
m = e.replace("%s ", "", 1);
coccinelle.y = m;
elif(e.find("%s:") == True):
m = e.replace("%s:", "", 1);
coccinelle.y = m;
else:
m = e.replace("%s", "",1);
coccinelle.y = m;

@c@
expression a.E, a.msg, a.R;
identifier b.y;
@@

- dev_err(E, msg, __func__, R);
+ dev_err(E, y, R);

Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6cb624ef 02-Mar-2015 Dilek Uzulmez <dilekuzulmez@gmail.com>

Staging: fbtft: Remove unnecessary 'out of memory' message.

This patch fixes checkpatch.pl warning in file fbtft-core.c
WARNING: Possible unnecessary 'out of memory' message

Signed-off-by: Dilek Uzulmez <dilekuzulmez@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6ba67a5a 02-Mar-2015 Yeliz Taneroglu <yeliztaneroglu@gmail.com>

Staging: fbtft-core: remove unnecessary line continuations

This fixes the checkpatch.pl warning:
WARNING: Avoid unnecessary line continuations

Signed-off-by: Yeliz Taneroglu <yeliztaneroglu@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3fed5bac 19-Feb-2015 Fabio Estevam <fabio.estevam@freescale.com>

staging: fbtft: fbtft-core: Use '%zu' to print 'size_t' format

When building for ARM64 the following build warning is seen:

drivers/staging/fbtft/fbtft-core.c:1004:4: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat=]

Use '%zu' to print 'size_t' format.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 11107ffe 27-Feb-2015 Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>

staging: fbtft: remove unused variable

This patch removes a variable that was simply used to
store the return value of a function call before
returning it.

The issue was detected and resolved using the following
coccinelle script:

@@
identifier len,f;
@@

-int len;
... when != len
when strict
-len =
+return
f(...);
-return len;

Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7e059db6 18-Feb-2015 Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>

staging: fbtft: fix space prohibited before that ','

This patch fixes the following checkpatch.pl error:
fix space prohibited before that ','

Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ed208436 22-Jan-2015 Krzysztof Adamski <k@japko.eu>

staging: fbtft: fbtft-core mark functions static

This fixes sparse warnings like:
warning: symbol XXX was not declared. Should it be static?

by declaring all local functions static.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c296d5f9 31-Dec-2014 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

staging: fbtft: core support

This commit adds the core fbtft framework from
https://github.com/notro/fbtft.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Noralf Tronnes <notro@tronnes.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>