Skip to content

Commit aa286eb

Browse files
warped-rudijnettlet
authored andcommitted
MXC-CEC: Remove some more unneeded guards, variables and comments
Signed-off-by: Rudi <[email protected]>
1 parent 4bc7d89 commit aa286eb

File tree

1 file changed

+31
-50
lines changed

1 file changed

+31
-50
lines changed

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

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,22 @@
4747
#include "mxc_hdmi-cec.h"
4848

4949

50-
#define MAX_MESSAGE_LEN 17
50+
#define MAX_MESSAGE_LEN 17
5151

52-
#define MESSAGE_TYPE_RECEIVE_SUCCESS 1
52+
#define MESSAGE_TYPE_RECEIVE_SUCCESS 1
5353
#define MESSAGE_TYPE_NOACK 2
54-
#define MESSAGE_TYPE_DISCONNECTED 3
54+
#define MESSAGE_TYPE_DISCONNECTED 3
5555
#define MESSAGE_TYPE_CONNECTED 4
56-
#define MESSAGE_TYPE_SEND_SUCCESS 5
56+
#define MESSAGE_TYPE_SEND_SUCCESS 5
5757

58-
#define CEC_TX_INPROGRESS -1
59-
#define CEC_TX_AVAIL 0
58+
#define CEC_TX_INPROGRESS -1
59+
#define CEC_TX_AVAIL 0
6060

6161
struct hdmi_cec_priv {
6262
int receive_error;
6363
int send_error;
6464
u8 Logical_address;
6565
bool cec_state;
66-
u8 last_msg[MAX_MESSAGE_LEN];
67-
u8 msg_len;
6866
int tx_answer;
6967
u16 latest_cec_stat;
7068
u8 link_status;
@@ -234,11 +232,6 @@ static void mxc_hdmi_cec_worker(struct work_struct *work)
234232
hdmi_writeb(val, HDMI_IH_MUTE_CEC_STAT0);
235233
}
236234

237-
/*!
238-
* @brief open function for cec file operation
239-
*
240-
* @return 0 on success or negative error code on error
241-
*/
242235
static int hdmi_cec_open(struct inode *inode, struct file *filp)
243236
{
244237
mutex_lock(&hdmi_cec_data.lock);
@@ -258,10 +251,9 @@ static ssize_t hdmi_cec_read(struct file *file, char __user *buf, size_t count,
258251
loff_t *ppos)
259252
{
260253
struct hdmi_cec_event *event = NULL;
254+
261255
pr_debug("function : %s\n", __func__);
262256

263-
if (!open_count)
264-
return -ENODEV;
265257
mutex_lock(&hdmi_cec_data.lock);
266258
if (false == hdmi_cec_data.cec_state) {
267259
mutex_unlock(&hdmi_cec_data.lock);
@@ -303,8 +295,6 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
303295

304296
pr_debug("function : %s\n", __func__);
305297

306-
if (!open_count)
307-
return -ENODEV;
308298
mutex_lock(&hdmi_cec_data.lock);
309299
if (false == hdmi_cec_data.cec_state) {
310300
mutex_unlock(&hdmi_cec_data.lock);
@@ -332,8 +322,6 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
332322
val = hdmi_readb(HDMI_CEC_CTRL);
333323
val |= 0x01;
334324
hdmi_writeb(val, HDMI_CEC_CTRL);
335-
memcpy(hdmi_cec_data.last_msg, msg, msg_len);
336-
hdmi_cec_data.msg_len = msg_len;
337325
mutex_unlock(&hdmi_cec_data.lock);
338326

339327
ret = wait_event_interruptible_timeout(tx_cec_queue, hdmi_cec_data.tx_answer != CEC_TX_INPROGRESS, HZ);
@@ -347,9 +335,9 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
347335
/* msg correctly sent */
348336
ret = msg_len;
349337
else
350-
ret = -EIO;
338+
ret = -EIO;
351339

352-
tx_out:
340+
tx_out:
353341
hdmi_cec_data.tx_answer = CEC_TX_AVAIL;
354342
return ret;
355343
}
@@ -373,20 +361,15 @@ static void hdmi_stop_device(void)
373361
mutex_unlock(&hdmi_cec_data.lock);
374362
}
375363

376-
/*!
377-
* @brief IO ctrl function for vpu file operation
378-
* @param cmd IO ctrl command
379-
* @return 0 on success or negative error code on error
380-
*/
381364
static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
382365
u_long arg)
383366
{
384367
int ret = 0, status = 0;
385368
u8 val = 0;
386369
struct mxc_edid_cfg hdmi_edid_cfg;
370+
387371
pr_debug("function : %s\n", __func__);
388-
if (!open_count)
389-
return -ENODEV;
372+
390373
switch (cmd) {
391374
case HDMICEC_IOC_SETLOGICALADDRESS:
392375
mutex_lock(&hdmi_cec_data.lock);
@@ -443,13 +426,12 @@ static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
443426
return ret;
444427
}
445428

446-
/*!
447-
* @brief Release function for vpu file operation
448-
* @return 0 on success or negative error code on error
449-
*/
450429
static int hdmi_cec_release(struct inode *inode, struct file *filp)
451430
{
452431
struct hdmi_cec_event *event, *tmp_event;
432+
433+
pr_debug("function : %s\n", __func__);
434+
453435
mutex_lock(&hdmi_cec_data.lock);
454436
if (open_count) {
455437
open_count = 0;
@@ -479,7 +461,7 @@ static unsigned int hdmi_cec_poll(struct file *file, poll_table *wait)
479461
if (hdmi_cec_data.tx_answer == CEC_TX_AVAIL)
480462
mask = (POLLOUT | POLLWRNORM);
481463
if (!list_empty(&head))
482-
mask |= (POLLIN | POLLRDNORM);
464+
mask |= (POLLIN | POLLRDNORM);
483465
mutex_unlock(&hdmi_cec_data.lock);
484466
return mask;
485467
}
@@ -505,14 +487,14 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
505487

506488
hdmi_cec_major = register_chrdev(hdmi_cec_major, "mxc_hdmi_cec", &hdmi_cec_fops);
507489
if (hdmi_cec_major < 0) {
508-
dev_err(&pdev->dev, "hdmi_cec: unable to get a major for HDMI CEC\n");
490+
dev_err(&pdev->dev, "Unable to get a major for HDMI CEC\n");
509491
err = -EBUSY;
510492
goto out;
511493
}
512494

513495
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
514496
if (unlikely(res == NULL)) {
515-
dev_err(&pdev->dev, "hdmi_cec:No HDMI irq line provided\n");
497+
dev_err(&pdev->dev, "No HDMI irq line provided\n");
516498
goto err_out_chrdev;
517499
}
518500
spin_lock_init(&hdmi_cec_data.irq_lock);
@@ -522,7 +504,7 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
522504
err = devm_request_irq(&pdev->dev, irq, mxc_hdmi_cec_isr, IRQF_SHARED,
523505
dev_name(&pdev->dev), &hdmi_cec_data);
524506
if (err < 0) {
525-
dev_err(&pdev->dev, "hdmi_cec:Unable to request irq: %d\n", err);
507+
dev_err(&pdev->dev, "Unable to request irq: %d\n", err);
526508
goto err_out_chrdev;
527509
}
528510

@@ -532,16 +514,16 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
532514
goto err_out_chrdev;
533515
}
534516

535-
temp_class = device_create(hdmi_cec_class, NULL, MKDEV(hdmi_cec_major, 0),
536-
NULL, "mxc_hdmi_cec");
517+
temp_class = device_create(hdmi_cec_class, NULL,
518+
MKDEV(hdmi_cec_major, 0), NULL, "mxc_hdmi_cec");
537519
if (IS_ERR(temp_class)) {
538520
err = PTR_ERR(temp_class);
539521
goto err_out_class;
540522
}
541523

542524
pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
543525
if (IS_ERR(pinctrl)) {
544-
dev_err(&pdev->dev, "can't get/select CEC pinctrl\n");
526+
dev_err(&pdev->dev, "Can't get/select CEC pinctrl\n");
545527
goto err_out_class;
546528
}
547529

@@ -569,14 +551,13 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
569551

570552
static int hdmi_cec_dev_remove(struct platform_device *pdev)
571553
{
572-
if (hdmi_cec_data.cec_state)
573-
hdmi_stop_device();
574-
if (hdmi_cec_major > 0) {
575-
device_destroy(hdmi_cec_class, MKDEV(hdmi_cec_major, 0));
576-
class_destroy(hdmi_cec_class);
577-
unregister_chrdev(hdmi_cec_major, "mxc_hdmi_cec");
578-
hdmi_cec_major = 0;
579-
}
554+
hdmi_stop_device();
555+
556+
device_destroy(hdmi_cec_class, MKDEV(hdmi_cec_major, 0));
557+
class_destroy(hdmi_cec_class);
558+
unregister_chrdev(hdmi_cec_major, "mxc_hdmi_cec");
559+
hdmi_cec_major = 0;
560+
580561
return 0;
581562
}
582563

@@ -590,9 +571,9 @@ static struct platform_driver mxc_hdmi_cec_driver = {
590571
.probe = hdmi_cec_dev_probe,
591572
.remove = hdmi_cec_dev_remove,
592573
.driver = {
593-
.name = "mxc_hdmi_cec",
594-
.of_match_table = imx_hdmi_cec_match,
595-
},
574+
.name = "mxc_hdmi_cec",
575+
.of_match_table = imx_hdmi_cec_match,
576+
},
596577
};
597578

598579
module_platform_driver(mxc_hdmi_cec_driver);

0 commit comments

Comments
 (0)