summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/staging/panel/panel.c
diff options
context:
space:
mode:
authorJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-04-11 10:41:07 +0300
committerJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-04-13 08:17:18 +0300
commite09b41010ba33a20a87472ee821fa407a5b8da36 (patch)
treed10dc367189862e7ca5c592f033dc3726e1df4e3 /kernel/drivers/staging/panel/panel.c
parentf93b97fd65072de626c074dbe099a1fff05ce060 (diff)
These changes are the raw update to linux-4.4.6-rt14. Kernel sources
are taken from kernel.org, and rt patch from the rt wiki download page. During the rebasing, the following patch collided: Force tick interrupt and get rid of softirq magic(I70131fb85). Collisions have been removed because its logic was found on the source already. Change-Id: I7f57a4081d9deaa0d9ccfc41a6c8daccdee3b769 Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'kernel/drivers/staging/panel/panel.c')
-rw-r--r--kernel/drivers/staging/panel/panel.c186
1 files changed, 98 insertions, 88 deletions
diff --git a/kernel/drivers/staging/panel/panel.c b/kernel/drivers/staging/panel/panel.c
index ea54fb4ec..70b8f4fab 100644
--- a/kernel/drivers/staging/panel/panel.c
+++ b/kernel/drivers/staging/panel/panel.c
@@ -71,7 +71,7 @@
#define KEYPAD_BUFFER 64
/* poll the keyboard this every second */
-#define INPUT_POLL_TIME (HZ/50)
+#define INPUT_POLL_TIME (HZ / 50)
/* a key starts to repeat after this times INPUT_POLL_TIME */
#define KEYPAD_REP_START (10)
/* a key repeats this times INPUT_POLL_TIME */
@@ -576,7 +576,6 @@ static int keypad_enabled = NOT_SET;
module_param(keypad_enabled, int, 0000);
MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead");
-
static const unsigned char *lcd_char_conv;
/* for some LCD drivers (ks0074) we need a charset conversion table. */
@@ -775,22 +774,24 @@ static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val)
/* sleeps that many milliseconds with a reschedule */
static void long_sleep(int ms)
{
- if (in_interrupt()) {
+ if (in_interrupt())
mdelay(ms);
- } else {
- __set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout((ms * HZ + 999) / 1000);
- }
+ else
+ schedule_timeout_interruptible(msecs_to_jiffies(ms));
}
-/* send a serial byte to the LCD panel. The caller is responsible for locking
- if needed. */
+/*
+ * send a serial byte to the LCD panel. The caller is responsible for locking
+ * if needed.
+ */
static void lcd_send_serial(int byte)
{
int bit;
- /* the data bit is set on D0, and the clock on STROBE.
- * LCD reads D0 on STROBE's rising edge. */
+ /*
+ * the data bit is set on D0, and the clock on STROBE.
+ * LCD reads D0 on STROBE's rising edge.
+ */
for (bit = 0; bit < 8; bit++) {
bits.cl = BIT_CLR; /* CLK low */
panel_set_bits();
@@ -907,8 +908,10 @@ static void lcd_gotoxy(void)
{
lcd_write_cmd(LCD_CMD_SET_DDRAM_ADDR
| (lcd.addr.y ? lcd.hwidth : 0)
- /* we force the cursor to stay at the end of the
- line if it wants to go farther */
+ /*
+ * we force the cursor to stay at the end of the
+ * line if it wants to go farther
+ */
| ((lcd.addr.x < lcd.bwidth) ? lcd.addr.x &
(lcd.hwidth - 1) : lcd.bwidth - 1));
}
@@ -916,7 +919,7 @@ static void lcd_gotoxy(void)
static void lcd_print(char c)
{
if (lcd.addr.x < lcd.bwidth) {
- if (lcd_char_conv != NULL)
+ if (lcd_char_conv)
c = lcd_char_conv[(unsigned char)c];
lcd_write_data(c);
lcd.addr.x++;
@@ -1114,9 +1117,9 @@ static inline int handle_lcd_special_code(void)
break;
case '*':
/* flash back light using the keypad timer */
- if (scan_timer.function != NULL) {
- if (lcd.light_tempo == 0
- && ((lcd.flags & LCD_FLAG_L) == 0))
+ if (scan_timer.function) {
+ if (lcd.light_tempo == 0 &&
+ ((lcd.flags & LCD_FLAG_L) == 0))
lcd_backlight(1);
lcd.light_tempo = FLASH_LIGHT_TEMPO;
}
@@ -1196,7 +1199,7 @@ static inline int handle_lcd_special_code(void)
char value;
int addr;
- if (strchr(esc, ';') == NULL)
+ if (!strchr(esc, ';'))
break;
esc++;
@@ -1242,7 +1245,7 @@ static inline int handle_lcd_special_code(void)
}
case 'x': /* gotoxy : LxXXX[yYYY]; */
case 'y': /* gotoxy : LyYYY[xXXX]; */
- if (strchr(esc, ';') == NULL)
+ if (!strchr(esc, ';'))
break;
while (*esc) {
@@ -1292,8 +1295,10 @@ static inline int handle_lcd_special_code(void)
if (lcd.flags & (LCD_FLAG_L))
lcd_backlight(1);
else if (lcd.light_tempo == 0)
- /* switch off the light only when the tempo
- lighting is gone */
+ /*
+ * switch off the light only when the tempo
+ * lighting is gone
+ */
lcd_backlight(0);
}
}
@@ -1321,8 +1326,10 @@ static void lcd_write_char(char c)
case '\b':
/* go back one char and clear it */
if (lcd.addr.x > 0) {
- /* check if we're not at the
- end of the line */
+ /*
+ * check if we're not at the
+ * end of the line
+ */
if (lcd.addr.x < lcd.bwidth)
/* back one char */
lcd_write_cmd(LCD_CMD_SHIFT);
@@ -1338,8 +1345,10 @@ static void lcd_write_char(char c)
lcd_clear_fast();
break;
case '\n':
- /* flush the remainder of the current line and
- go to the beginning of the next line */
+ /*
+ * flush the remainder of the current line and
+ * go to the beginning of the next line
+ */
for (; lcd.addr.x < lcd.bwidth; lcd.addr.x++)
lcd_write_data(' ');
lcd.addr.x = 0;
@@ -1362,8 +1371,10 @@ static void lcd_write_char(char c)
}
}
- /* now we'll see if we're in an escape mode and if the current
- escape sequence can be understood. */
+ /*
+ * now we'll see if we're in an escape mode and if the current
+ * escape sequence can be understood.
+ */
if (lcd.esc_seq.len >= 2) {
int processed = 0;
@@ -1386,8 +1397,10 @@ static void lcd_write_char(char c)
}
/* LCD special escape codes */
- /* flush the escape sequence if it's been processed
- or if it is getting too long. */
+ /*
+ * flush the escape sequence if it's been processed
+ * or if it is getting too long.
+ */
if (processed || (lcd.esc_seq.len >= LCD_ESCAPE_LEN))
lcd.esc_seq.len = -1;
} /* escape codes */
@@ -1401,8 +1414,10 @@ static ssize_t lcd_write(struct file *file,
for (; count-- > 0; (*ppos)++, tmp++) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
- /* let's be a little nice with other processes
- that need some CPU */
+ /*
+ * let's be a little nice with other processes
+ * that need some CPU
+ */
schedule();
if (get_user(c, tmp))
@@ -1457,8 +1472,10 @@ static void panel_lcd_print(const char *s)
if (lcd.enabled && lcd.initialized) {
for (; count-- > 0; tmp++) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
- /* let's be a little nice with other processes
- that need some CPU */
+ /*
+ * let's be a little nice with other processes
+ * that need some CPU
+ */
schedule();
lcd_write_char(*tmp);
@@ -1632,9 +1649,11 @@ static void lcd_init(void)
pin_to_bits(lcd.pins.da, lcd_bits[LCD_PORT_D][LCD_BIT_DA],
lcd_bits[LCD_PORT_C][LCD_BIT_DA]);
- /* before this line, we must NOT send anything to the display.
+ /*
+ * before this line, we must NOT send anything to the display.
* Since lcd_init_display() needs to write data, we have to
- * enable mark the LCD initialized just before. */
+ * enable mark the LCD initialized just before.
+ */
lcd.initialized = true;
lcd_init_display();
@@ -1768,12 +1787,13 @@ static void phys_scan_contacts(void)
phys_read |= (pmask_t) gndmask << 40;
if (bitmask != gndmask) {
- /* since clearing the outputs changed some inputs, we know
+ /*
+ * since clearing the outputs changed some inputs, we know
* that some input signals are currently tied to some outputs.
* So we'll scan them.
*/
for (bit = 0; bit < 8; bit++) {
- bitval = 1 << bit;
+ bitval = BIT(bit);
if (!(scan_mask_o & bitval)) /* skip unused bits */
continue;
@@ -1784,8 +1804,10 @@ static void phys_scan_contacts(void)
}
w_dtr(pprt, oldval); /* disable all outputs */
}
- /* this is easy: use old bits when they are flapping,
- * use new ones when stable */
+ /*
+ * this is easy: use old bits when they are flapping,
+ * use new ones when stable
+ */
phys_curr = (phys_prev & (phys_read ^ phys_read_prev)) |
(phys_read & ~(phys_read ^ phys_read_prev));
}
@@ -1821,7 +1843,7 @@ static inline int input_state_high(struct logical_input *input)
if ((input->type == INPUT_TYPE_STD) &&
(input->high_timer == 0)) {
input->high_timer++;
- if (input->u.std.press_fct != NULL)
+ if (input->u.std.press_fct)
input->u.std.press_fct(input->u.std.press_data);
} else if (input->type == INPUT_TYPE_KBD) {
/* will turn on the light */
@@ -1901,7 +1923,7 @@ static inline void input_state_falling(struct logical_input *input)
if (input->type == INPUT_TYPE_STD) {
void (*release_fct)(int) = input->u.std.release_fct;
- if (release_fct != NULL)
+ if (release_fct)
release_fct(input->u.std.release_data);
} else if (input->type == INPUT_TYPE_KBD) {
char *release_str = input->u.kbd.release_str;
@@ -1985,14 +2007,14 @@ static void panel_scan_timer(void)
if (lcd.enabled && lcd.initialized) {
if (keypressed) {
- if (lcd.light_tempo == 0
- && ((lcd.flags & LCD_FLAG_L) == 0))
+ if (lcd.light_tempo == 0 &&
+ ((lcd.flags & LCD_FLAG_L) == 0))
lcd_backlight(1);
lcd.light_tempo = FLASH_LIGHT_TEMPO;
} else if (lcd.light_tempo > 0) {
lcd.light_tempo--;
- if (lcd.light_tempo == 0
- && ((lcd.flags & LCD_FLAG_L) == 0))
+ if (lcd.light_tempo == 0 &&
+ ((lcd.flags & LCD_FLAG_L) == 0))
lcd_backlight(0);
}
}
@@ -2002,7 +2024,7 @@ static void panel_scan_timer(void)
static void init_scan_timer(void)
{
- if (scan_timer.function != NULL)
+ if (scan_timer.function)
return; /* already started */
setup_timer(&scan_timer, (void *)&panel_scan_timer, 0);
@@ -2037,12 +2059,12 @@ static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value,
return 0; /* input name not found */
neg = (in & 1); /* odd (lower) names are negated */
in >>= 1;
- im |= (1 << in);
+ im |= BIT(in);
name++;
if (isdigit(*name)) {
out = *name - '0';
- om |= (1 << out);
+ om |= BIT(out);
} else if (*name == '-') {
out = 8;
} else {
@@ -2190,6 +2212,8 @@ static struct notifier_block panel_notifier = {
static void panel_attach(struct parport *port)
{
+ struct pardev_cb panel_cb;
+
if (port->number != parport)
return;
@@ -2199,11 +2223,12 @@ static void panel_attach(struct parport *port)
return;
}
- pprt = parport_register_device(port, "panel", NULL, NULL, /* pf, kf */
- NULL,
- /*PARPORT_DEV_EXCL */
- 0, (void *)&pprt);
- if (pprt == NULL) {
+ memset(&panel_cb, 0, sizeof(panel_cb));
+ panel_cb.private = &pprt;
+ /* panel_cb.flags = 0 should be PARPORT_DEV_EXCL? */
+
+ pprt = parport_register_dev_model(port, "panel", &panel_cb, 0);
+ if (!pprt) {
pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n",
__func__, port->number, parport);
return;
@@ -2250,28 +2275,35 @@ static void panel_detach(struct parport *port)
__func__, port->number, parport);
return;
}
+ if (scan_timer.function)
+ del_timer_sync(&scan_timer);
- unregister_reboot_notifier(&panel_notifier);
+ if (pprt) {
+ if (keypad.enabled) {
+ misc_deregister(&keypad_dev);
+ keypad_initialized = 0;
+ }
- if (keypad.enabled && keypad_initialized) {
- misc_deregister(&keypad_dev);
- keypad_initialized = 0;
- }
+ if (lcd.enabled) {
+ panel_lcd_print("\x0cLCD driver " PANEL_VERSION
+ "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
+ misc_deregister(&lcd_dev);
+ lcd.initialized = false;
+ }
- if (lcd.enabled && lcd.initialized) {
- misc_deregister(&lcd_dev);
- lcd.initialized = false;
+ /* TODO: free all input signals */
+ parport_release(pprt);
+ parport_unregister_device(pprt);
+ pprt = NULL;
+ unregister_reboot_notifier(&panel_notifier);
}
-
- parport_release(pprt);
- parport_unregister_device(pprt);
- pprt = NULL;
}
static struct parport_driver panel_driver = {
.name = "panel",
- .attach = panel_attach,
+ .match_port = panel_attach,
.detach = panel_detach,
+ .devmodel = true,
};
/* init function */
@@ -2398,28 +2430,6 @@ static int __init panel_init_module(void)
static void __exit panel_cleanup_module(void)
{
-
- if (scan_timer.function != NULL)
- del_timer_sync(&scan_timer);
-
- if (pprt != NULL) {
- if (keypad.enabled) {
- misc_deregister(&keypad_dev);
- keypad_initialized = 0;
- }
-
- if (lcd.enabled) {
- panel_lcd_print("\x0cLCD driver " PANEL_VERSION
- "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
- misc_deregister(&lcd_dev);
- lcd.initialized = false;
- }
-
- /* TODO: free all input signals */
- parport_release(pprt);
- parport_unregister_device(pprt);
- pprt = NULL;
- }
parport_unregister_driver(&panel_driver);
}