Skip to content

Commit a2d6114

Browse files
warped-rudijnettlet
authored andcommitted
MXC-CEC: Rename variables, minor code style cleanups
Signed-off-by: Rudi <[email protected]>
1 parent 90267d1 commit a2d6114

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

drivers/mxc/hdmi-cec/mxc_hdmi-cec.c

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@
7575
HDMI_IH_CEC_STAT0_ARB_LOST)
7676

7777
struct hdmi_cec_priv {
78-
int receive_error;
79-
int send_error;
80-
u8 Logical_address;
81-
u8 cec_state;
78+
int receive_error;
79+
int send_error;
8280
int tx_answer;
8381
u32 cec_stat0;
82+
u8 logical_address;
83+
u8 is_started;
8484
u8 link_status;
85+
u8 open_count;
8586
spinlock_t irq_lock;
8687
struct work_struct hdmi_cec_work;
8788
struct mutex lock;
@@ -95,19 +96,18 @@ struct hdmi_cec_event {
9596
};
9697

9798

98-
static LIST_HEAD(head);
99+
static LIST_HEAD(ev_pending);
99100

100101
static int hdmi_cec_irq;
101102
static int hdmi_cec_major;
102103
static struct class *hdmi_cec_class;
103104
static struct hdmi_cec_priv hdmi_cec_data;
104-
static u8 open_count;
105105
static u8 want_start;
106106
static u8 link_status;
107107
static u8 is_initialized;
108108

109-
static wait_queue_head_t hdmi_cec_queue;
110-
static wait_queue_head_t tx_cec_queue;
109+
static wait_queue_head_t rx_queue;
110+
static wait_queue_head_t tx_queue;
111111

112112
static u32 get_hpd_stat(struct hdmi_cec_priv *hdmi_cec)
113113
{
@@ -138,7 +138,7 @@ static irqreturn_t mxc_hdmi_cec_isr(int irq, void *data)
138138
hdmi_writeb(cec_stat, HDMI_IH_CEC_STAT0);
139139

140140
if ((cec_stat & ~CEC_STAT0_MASK_DEFAULT) == 0) {
141-
if (hdmi_cec->cec_state)
141+
if (hdmi_cec->is_started)
142142
hdmi_writeb(CEC_STAT0_MASK_DEFAULT, HDMI_IH_MUTE_CEC_STAT0);
143143
spin_unlock_irqrestore(&hdmi_cec->irq_lock, flags);
144144
return IRQ_NONE;
@@ -159,13 +159,13 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
159159
u8 i = 0;
160160
struct hdmi_cec_event *event = NULL;
161161

162-
if (!open_count)
162+
if (!hdmi_cec_data.open_count)
163163
return;
164164

165165
/* The current transmission is successful (for initiator only). */
166166
if (cec_stat & HDMI_IH_CEC_STAT0_DONE) {
167167
hdmi_cec_data.tx_answer = cec_stat;
168-
wake_up(&tx_cec_queue);
168+
wake_up(&tx_queue);
169169
}
170170

171171
/*EOM is detected so that the received data is ready in the receiver data buffer*/
@@ -187,15 +187,15 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
187187
event->msg[i] = hdmi_readb(HDMI_CEC_RX_DATA0+i);
188188
hdmi_writeb(0x0, HDMI_CEC_LOCK);
189189
mutex_lock(&hdmi_cec_data.lock);
190-
list_add_tail(&event->list, &head);
190+
list_add_tail(&event->list, &ev_pending);
191191
mutex_unlock(&hdmi_cec_data.lock);
192-
wake_up(&hdmi_cec_queue);
192+
wake_up(&rx_queue);
193193
}
194194

195195
/* An error is detected on cec line (for initiator only). */
196196
if (cec_stat & HDMI_IH_CEC_STAT0_ERROR_INIT) {
197197
hdmi_cec_data.tx_answer = cec_stat;
198-
wake_up(&tx_cec_queue);
198+
wake_up(&tx_queue);
199199
return;
200200
}
201201
/* A frame is not acknowledged in a directly addressed message.
@@ -205,7 +205,7 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
205205
if (cec_stat & HDMI_IH_CEC_STAT0_NACK) {
206206
hdmi_cec_data.send_error++;
207207
hdmi_cec_data.tx_answer = cec_stat;
208-
wake_up(&tx_cec_queue);
208+
wake_up(&tx_queue);
209209
}
210210

211211
/* An error is notified by a follower.
@@ -227,9 +227,9 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
227227
memset(event, 0, sizeof(struct hdmi_cec_event));
228228
event->event_type = MESSAGE_TYPE_CONNECTED;
229229
mutex_lock(&hdmi_cec_data.lock);
230-
list_add_tail(&event->list, &head);
230+
list_add_tail(&event->list, &ev_pending);
231231
mutex_unlock(&hdmi_cec_data.lock);
232-
wake_up(&hdmi_cec_queue);
232+
wake_up(&rx_queue);
233233
}
234234
/*HDMI cable disconnected*/
235235
if (cec_stat & CEC_STAT0_EX_DISCONNECTED) {
@@ -242,9 +242,9 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
242242
memset(event, 0, sizeof(struct hdmi_cec_event));
243243
event->event_type = MESSAGE_TYPE_DISCONNECTED;
244244
mutex_lock(&hdmi_cec_data.lock);
245-
list_add_tail(&event->list, &head);
245+
list_add_tail(&event->list, &ev_pending);
246246
mutex_unlock(&hdmi_cec_data.lock);
247-
wake_up(&hdmi_cec_queue);
247+
wake_up(&rx_queue);
248248
}
249249
}
250250

@@ -256,22 +256,22 @@ static void mxc_hdmi_cec_worker(struct work_struct *work)
256256

257257
spin_lock_irqsave(&hdmi_cec_data.irq_lock, flags);
258258
hdmi_cec_data.cec_stat0 = 0;
259-
if (hdmi_cec_data.cec_state)
259+
if (hdmi_cec_data.is_started)
260260
hdmi_writeb(CEC_STAT0_MASK_DEFAULT, HDMI_IH_MUTE_CEC_STAT0);
261261
spin_unlock_irqrestore(&hdmi_cec_data.irq_lock, flags);
262262
}
263263

264-
static int hdmi_cec_open(struct inode *inode, struct file *filp)
264+
static int hdmi_cec_open(struct inode *inode, struct file *file)
265265
{
266266
mutex_lock(&hdmi_cec_data.lock);
267-
if (open_count) {
267+
if (hdmi_cec_data.open_count) {
268268
mutex_unlock(&hdmi_cec_data.lock);
269269
return -EBUSY;
270270
}
271-
open_count = 1;
272-
filp->private_data = (void *)(&hdmi_cec_data);
273-
hdmi_cec_data.Logical_address = 15;
274-
hdmi_cec_data.cec_state = false;
271+
hdmi_cec_data.open_count = 1;
272+
file->private_data = (void *)(&hdmi_cec_data);
273+
hdmi_cec_data.logical_address = 15;
274+
hdmi_cec_data.is_started = false;
275275
mutex_unlock(&hdmi_cec_data.lock);
276276
return 0;
277277
}
@@ -284,26 +284,26 @@ static ssize_t hdmi_cec_read(struct file *file, char __user *buf, size_t count,
284284
pr_debug("function : %s\n", __func__);
285285

286286
mutex_lock(&hdmi_cec_data.lock);
287-
if (!hdmi_cec_data.cec_state) {
287+
if (!hdmi_cec_data.is_started) {
288288
mutex_unlock(&hdmi_cec_data.lock);
289289
return -EACCES;
290290
}
291291

292-
if (list_empty(&head)) {
292+
if (list_empty(&ev_pending)) {
293293
if (file->f_flags & O_NONBLOCK) {
294294
mutex_unlock(&hdmi_cec_data.lock);
295295
return -EAGAIN;
296296
} else {
297297
do {
298298
mutex_unlock(&hdmi_cec_data.lock);
299-
if (wait_event_interruptible(hdmi_cec_queue, (!list_empty(&head))))
299+
if (wait_event_interruptible(rx_queue, !list_empty(&ev_pending)))
300300
return -ERESTARTSYS;
301301
mutex_lock(&hdmi_cec_data.lock);
302-
} while (list_empty(&head));
302+
} while (list_empty(&ev_pending));
303303
}
304304
}
305305

306-
event = list_first_entry(&head, struct hdmi_cec_event, list);
306+
event = list_first_entry(&ev_pending, struct hdmi_cec_event, list);
307307
list_del(&event->list);
308308
mutex_unlock(&hdmi_cec_data.lock);
309309
if (copy_to_user(buf, event,
@@ -320,19 +320,19 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
320320
{
321321
int ret = 0;
322322
u8 i, msg_len, val;
323-
u8 msg[MAX_MESSAGE_LEN] = { 0 };
323+
u8 msg[MAX_MESSAGE_LEN];
324324

325325
pr_debug("function : %s\n", __func__);
326326

327327
mutex_lock(&hdmi_cec_data.lock);
328328

329-
if (!hdmi_cec_data.cec_state)
329+
if (!hdmi_cec_data.is_started)
330330
ret = -EACCES;
331331
else if (hdmi_cec_data.tx_answer != CEC_TX_AVAIL)
332332
ret = -EBUSY;
333333
else if (count > MAX_MESSAGE_LEN)
334334
ret = -EINVAL;
335-
else if (copy_from_user(&msg, buf, count))
335+
else if (copy_from_user(msg, buf, count))
336336
ret = -EACCES;
337337

338338
if (ret) {
@@ -354,7 +354,7 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
354354
mutex_unlock(&hdmi_cec_data.lock);
355355

356356
ret = wait_event_interruptible_timeout(
357-
tx_cec_queue, hdmi_cec_data.tx_answer != CEC_TX_INPROGRESS, HZ);
357+
tx_queue, hdmi_cec_data.tx_answer != CEC_TX_INPROGRESS, HZ);
358358

359359
if (ret < 0) {
360360
ret = -ERESTARTSYS;
@@ -419,7 +419,7 @@ static void hdmi_cec_start_device(void)
419419
hdmi_writeb(val, HDMI_CEC_MASK);
420420
hdmi_writeb(val, HDMI_IH_MUTE_CEC_STAT0);
421421
hdmi_cec_data.link_status = link_status;
422-
hdmi_cec_data.cec_state = true;
422+
hdmi_cec_data.is_started = true;
423423

424424
spin_unlock_irqrestore(&hdmi_cec_data.irq_lock, flags);
425425
}
@@ -436,7 +436,7 @@ static void hdmi_cec_stop_device(void)
436436

437437
spin_lock_irqsave(&hdmi_cec_data.irq_lock, flags);
438438

439-
hdmi_cec_data.cec_state = false;
439+
hdmi_cec_data.is_started = false;
440440
hdmi_writeb(0x10, HDMI_CEC_CTRL);
441441
val = CEC_STAT0_MASK_ALL;
442442
hdmi_writeb(val, HDMI_CEC_MASK);
@@ -450,7 +450,7 @@ static void hdmi_cec_stop_device(void)
450450
spin_unlock_irqrestore(&hdmi_cec_data.irq_lock, flags);
451451
}
452452

453-
static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
453+
static long hdmi_cec_ioctl(struct file *file, u_int cmd,
454454
u_long arg)
455455
{
456456
int ret = 0, status = 0;
@@ -462,18 +462,18 @@ static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
462462
switch (cmd) {
463463
case HDMICEC_IOC_SETLOGICALADDRESS:
464464
mutex_lock(&hdmi_cec_data.lock);
465-
if (!hdmi_cec_data.cec_state) {
465+
if (!hdmi_cec_data.is_started) {
466466
mutex_unlock(&hdmi_cec_data.lock);
467467
pr_err("Trying to set logical address while not started\n");
468468
return -EACCES;
469469
}
470-
hdmi_cec_data.Logical_address = (u8)arg;
471-
if (hdmi_cec_data.Logical_address <= 7) {
472-
val = 1 << hdmi_cec_data.Logical_address;
470+
hdmi_cec_data.logical_address = (u8)arg;
471+
if (hdmi_cec_data.logical_address <= 7) {
472+
val = 1 << hdmi_cec_data.logical_address;
473473
hdmi_writeb(val, HDMI_CEC_ADDR_L);
474474
hdmi_writeb(0, HDMI_CEC_ADDR_H);
475-
} else if (hdmi_cec_data.Logical_address > 7 && hdmi_cec_data.Logical_address <= 15) {
476-
val = 1 << (hdmi_cec_data.Logical_address - 8);
475+
} else if (hdmi_cec_data.logical_address > 7 && hdmi_cec_data.logical_address <= 15) {
476+
val = 1 << (hdmi_cec_data.logical_address - 8);
477477
hdmi_writeb(val, HDMI_CEC_ADDR_H);
478478
hdmi_writeb(0, HDMI_CEC_ADDR_L);
479479
} else
@@ -501,20 +501,20 @@ static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
501501
return ret;
502502
}
503503

504-
static int hdmi_cec_release(struct inode *inode, struct file *filp)
504+
static int hdmi_cec_release(struct inode *inode, struct file *file)
505505
{
506506
struct hdmi_cec_event *event, *tmp_event;
507507

508508
pr_debug("function : %s\n", __func__);
509509

510510
mutex_lock(&hdmi_cec_data.lock);
511-
if (open_count) {
512-
open_count = 0;
513-
hdmi_cec_data.cec_state = false;
514-
hdmi_cec_data.Logical_address = 15;
511+
if (hdmi_cec_data.open_count) {
512+
hdmi_cec_data.open_count = 0;
513+
hdmi_cec_data.is_started = false;
514+
hdmi_cec_data.logical_address = 15;
515515

516516
/* Flush eventual events which have not been read by user space */
517-
list_for_each_entry_safe(event, tmp_event, &head, list) {
517+
list_for_each_entry_safe(event, tmp_event, &ev_pending, list) {
518518
list_del(&event->list);
519519
vfree(event);
520520
}
@@ -530,12 +530,12 @@ static unsigned int hdmi_cec_poll(struct file *file, poll_table *wait)
530530

531531
pr_debug("function : %s\n", __func__);
532532

533-
poll_wait(file, &hdmi_cec_queue, wait);
533+
poll_wait(file, &rx_queue, wait);
534534

535535
mutex_lock(&hdmi_cec_data.lock);
536536
if (hdmi_cec_data.tx_answer == CEC_TX_AVAIL)
537537
mask = (POLLOUT | POLLWRNORM);
538-
if (!list_empty(&head))
538+
if (!list_empty(&ev_pending))
539539
mask |= (POLLIN | POLLRDNORM);
540540
mutex_unlock(&hdmi_cec_data.lock);
541541
return mask;
@@ -592,15 +592,15 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
592592
goto err_out_class;
593593
}
594594

595-
INIT_LIST_HEAD(&head);
595+
INIT_LIST_HEAD(&ev_pending);
596596

597-
init_waitqueue_head(&hdmi_cec_queue);
598-
init_waitqueue_head(&tx_cec_queue);
597+
init_waitqueue_head(&rx_queue);
598+
init_waitqueue_head(&tx_queue);
599599

600600
mutex_init(&hdmi_cec_data.lock);
601601
spin_lock_init(&hdmi_cec_data.irq_lock);
602602

603-
hdmi_cec_data.Logical_address = 15;
603+
hdmi_cec_data.logical_address = 15;
604604
hdmi_cec_data.tx_answer = CEC_TX_AVAIL;
605605
INIT_WORK(&hdmi_cec_data.hdmi_cec_work, mxc_hdmi_cec_worker);
606606

0 commit comments

Comments
 (0)