提交 22eb36b8 编写于 作者: A Arnd Bergmann 提交者: Greg Kroah-Hartman

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: NArnd Bergmann <arnd@arndb.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 26190d41
......@@ -158,7 +158,7 @@ static int set_var(struct fbtft_par *par)
* ON0 ON1 CN0 CN1 CN2 CN3 CN4 MN0 MN1 MN2 MN3 MN4 MN5 XXXX GC
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long mask[] = {
0x0f, 0x0f, 0x1f, 0x0f, 0x0f, 0x0f, 0x1f, 0x07, 0x07, 0x07,
......
......@@ -102,7 +102,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
* VRN0 VRN1 VRN2 VRN3 VRN4 VRN5 PRN0 PRN1 PKN0 PKN1 PKN2 PKN3 PKN4 CGM
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long mask[] = {
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x7f, 0x7f, 0x1f, 0x1f,
......
......@@ -118,7 +118,7 @@ static int set_var(struct fbtft_par *par)
}
/* gamma string format: */
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
write_reg(par, 0xE0,
curves[0], curves[1], curves[2], curves[3],
......
......@@ -202,7 +202,7 @@ static int set_var(struct fbtft_par *par)
#ifdef GAMMA_ADJ
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int gamma_adj(struct fbtft_par *par, unsigned long *curves)
static int gamma_adj(struct fbtft_par *par, u32 *curves)
{
unsigned long mask[] = {
0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
......
......@@ -221,7 +221,7 @@ static int set_var(struct fbtft_par *par)
* VRN0 VRN1 RN0 RN1 KN0 KN1 KN2 KN3 KN4 KN5
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long mask[] = {
0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
......
......@@ -215,7 +215,7 @@ static int set_var(struct fbtft_par *par)
* VRN0 VRN1 RN0 RN1 KN0 KN1 KN2 KN3 KN4 KN5
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long mask[] = {
0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
......
......@@ -121,7 +121,7 @@ static int set_var(struct fbtft_par *par)
* Negative: Par1 Par2 [...] Par15
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
int i;
......
......@@ -137,7 +137,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
return ret;
}
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
/* apply mask */
curves[0] &= 0x7F;
......
......@@ -130,7 +130,7 @@ static int set_var(struct fbtft_par *par)
* PKN0 PKN1 PKN2 PKN3 PKN4 PKN5 PKN6 PKN7 PRN8 PRN9 PRN10 PRN11 VRN0 VRN1
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long mask[] = {
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
......
......@@ -136,7 +136,7 @@ static int set_var(struct fbtft_par *par)
* VRN0 VRN1 PRN0 PRN1 PKN0 PKN1 PKN2 PKN3 PKN4 PKN5
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long mask[] = {
0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
......
......@@ -148,7 +148,7 @@ static int blank(struct fbtft_par *par, bool on)
}
/* Gamma is used to control Contrast */
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
curves[0] &= 0xFF;
/* Set Contrast Control for BANK0 */
......
......@@ -168,7 +168,7 @@ static int blank(struct fbtft_par *par, bool on)
}
/* Gamma is used to control Contrast */
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
/* apply mask */
curves[0] &= 0xFF;
......
......@@ -116,7 +116,7 @@ static int blank(struct fbtft_par *par, bool on)
* 0 = Setting of GS1 < Setting of GS2 < Setting of GS3.....<
* Setting of GS14 < Setting of GS15
*/
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
int i;
......
......@@ -122,7 +122,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
* Setting of GS63 has to be > Setting of GS62 +1
*
*/
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long tmp[GAMMA_NUM * GAMMA_LEN];
int i, acc = 0;
......
......@@ -117,7 +117,7 @@ static int set_var(struct fbtft_par *par)
* Setting of GS63 has to be > Setting of GS62 +1
*
*/
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
unsigned long tmp[GAMMA_NUM * GAMMA_LEN];
int i, acc = 0;
......
......@@ -143,7 +143,7 @@ static int set_var(struct fbtft_par *par)
* VRF0N VOS0N PK0N PK1N PK2N PK3N PK4N PK5N PK6N PK7N PK8N PK9N SELV0N SELV1N SELV62N SELV63N
*/
#define CURVE(num, idx) curves[num * par->gamma.num_values + idx]
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
int i, j;
......
......@@ -178,7 +178,7 @@ static int set_var(struct fbtft_par *par)
*
* Return: 0 on success, < 0 if error occurred.
*/
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
int i;
int j;
......
......@@ -130,7 +130,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
return ret;
}
static int set_gamma(struct fbtft_par *par, unsigned long *curves)
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
/* apply mask */
curves[0] &= 0x7F;
......
......@@ -661,7 +661,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
int vmem_size, i;
s16 *init_sequence = display->init_sequence;
char *gamma = display->gamma;
unsigned long *gamma_curves = NULL;
u32 *gamma_curves = NULL;
/* sanity check */
if (display->gamma_num * display->gamma_len >
......
......@@ -16,7 +16,7 @@ static int get_next_ulong(char **str_p, unsigned long *val, char *sep, int base)
return kstrtoul(p_val, base, val);
}
int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
int fbtft_gamma_parse_str(struct fbtft_par *par, u32 *curves,
const char *str, int size)
{
char *str_p, *curve_p = NULL;
......@@ -89,7 +89,7 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
}
static ssize_t
sprintf_gamma(struct fbtft_par *par, unsigned long *curves, char *buf)
sprintf_gamma(struct fbtft_par *par, u32 *curves, char *buf)
{
ssize_t len = 0;
unsigned int i, j;
......@@ -98,7 +98,7 @@ sprintf_gamma(struct fbtft_par *par, unsigned long *curves, char *buf)
for (i = 0; i < par->gamma.num_curves; i++) {
for (j = 0; j < par->gamma.num_values; j++)
len += scnprintf(&buf[len], PAGE_SIZE,
"%04lx ", curves[i * par->gamma.num_values + j]);
"%04x ", curves[i * par->gamma.num_values + j]);
buf[len - 1] = '\n';
}
mutex_unlock(&par->gamma.lock);
......@@ -112,7 +112,7 @@ static ssize_t store_gamma_curve(struct device *device,
{
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;
unsigned long tmp_curves[FBTFT_GAMMA_MAX_VALUES_TOTAL];
u32 tmp_curves[FBTFT_GAMMA_MAX_VALUES_TOTAL];
int ret;
ret = fbtft_gamma_parse_str(par, tmp_curves, buf, count);
......
......@@ -92,7 +92,7 @@ struct fbtft_ops {
void (*unregister_backlight)(struct fbtft_par *par);
int (*set_var)(struct fbtft_par *par);
int (*set_gamma)(struct fbtft_par *par, unsigned long *curves);
int (*set_gamma)(struct fbtft_par *par, u32 *curves);
};
/**
......@@ -231,7 +231,7 @@ struct fbtft_par {
s16 *init_sequence;
struct {
struct mutex lock;
unsigned long *curves;
u32 *curves;
int num_values;
int num_curves;
} gamma;
......
......@@ -19,7 +19,7 @@
void fbtft_sysfs_init(struct fbtft_par *par);
void fbtft_sysfs_exit(struct fbtft_par *par);
void fbtft_expand_debug_value(unsigned long *debug);
int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
int fbtft_gamma_parse_str(struct fbtft_par *par, u32 *curves,
const char *str, int size);
#endif /* __LINUX_FBTFT_INTERNAL_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册