diff options
| author | Himanshu Aggarwal <haggarwa@codeaurora.org> | 2016-10-04 09:55:31 +0530 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-10-09 23:21:05 -0700 |
| commit | 01e2708af568b31f68a8e31626370a951e35fdc8 (patch) | |
| tree | fad89d894264773af563f239d22a1990534fe578 /drivers/input/misc | |
| parent | 4e09168fe611b498b251b8e12560f453ff1e8920 (diff) | |
input: misc: pat9125: fix issues found in static analysis
Fix the following issues found in static analysis:
- missing blank lines after declarations
- unnecessary return in a void function
- exporting world writable files is usually an error
- block comments use * on subsequent and trailing lines
- Add DT binding description and vendor prefixe for the
driver.
- Add Linux Foundation copyright markings.
Change-Id: Id2ed9a6d4e31bd2acd3185bf7ef9c78f8a41cf36
Signed-off-by: Himanshu Aggarwal <haggarwa@codeaurora.org>
Signed-off-by: Vevek Venkatesan <vevekv@codeaurora.org>
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
Diffstat (limited to 'drivers/input/misc')
| -rw-r--r-- | drivers/input/misc/ots_pat9125/pat9125_linux_driver.c | 64 | ||||
| -rw-r--r-- | drivers/input/misc/ots_pat9125/pixart_ots.c | 31 | ||||
| -rw-r--r-- | drivers/input/misc/ots_pat9125/pixart_ots.h | 6 | ||||
| -rw-r--r-- | drivers/input/misc/ots_pat9125/pixart_platform.h | 12 |
4 files changed, 57 insertions, 56 deletions
diff --git a/drivers/input/misc/ots_pat9125/pat9125_linux_driver.c b/drivers/input/misc/ots_pat9125/pat9125_linux_driver.c index c909b213c077..0a93f11e2b7e 100644 --- a/drivers/input/misc/ots_pat9125/pat9125_linux_driver.c +++ b/drivers/input/misc/ots_pat9125/pat9125_linux_driver.c @@ -1,3 +1,8 @@ +/* drivers/input/misc/ots_pat9125/pat9125_linux_driver.c + * + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + */ #include <linux/kernel.h> #include <linux/input.h> @@ -26,11 +31,10 @@ static struct pat9125_linux_data_t pat9125data; static int pat9125_i2c_write(u8 reg, u8 *data, int len); static int pat9125_i2c_read(u8 reg, u8 *data); -/**************************************/ - extern unsigned char ReadData(unsigned char addr) { u8 data = 0xff; + pat9125_i2c_read(addr, &data); return data; } @@ -42,7 +46,6 @@ extern void delay_ms(int ms) { msleep(ms); } -/**************************************/ static int pat9125_i2c_write(u8 reg, u8 *data, int len) { u8 buf[20]; @@ -84,9 +87,11 @@ static int pat9125_i2c_read(u8 reg, u8 *data) buf[0] = reg; - /* If everything went ok (i.e. 1 msg transmitted), - return #bytes transmitted, else error code. - thus if transmit is ok return value 1 */ + /* + * If everything went ok (i.e. 1 msg transmitted), + *return #bytes transmitted, else error code. + * thus if transmit is ok return value 1 + */ rc = i2c_master_send(pat9125data.client, buf, 1); if (rc != 1) { pr_debug( @@ -115,7 +120,6 @@ void pixart_pat9125_ist(void) static irqreturn_t pixart_pat9125_irq(int irq, void *handle) { -/* "cat /proc/kmsg" to see kernel message */ pixart_pat9125_ist(); return IRQ_HANDLED; } @@ -139,36 +143,29 @@ static int pat9125_start(void) static void pat9125_stop(void) { - pr_debug(">>> %s (%d)\n", __func__, __LINE__); free_irq(pat9125data.irq, &pat9125data); } static ssize_t pat9125_fops_read(struct file *filp, char *buf, size_t count, loff_t *l) { - pr_debug(">>> %s (%d)\n", __func__, __LINE__); return 0; } static ssize_t pat9125_fops_write(struct file *filp, const char *buf, size_t count, loff_t *f_ops) { - pr_debug(">>> %s (%d)\n", __func__, __LINE__); return 0; } static long pat9125_fops_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -/* static int pat9125_fops_ioctl(struct inode *inode, - struct file *file, unsigned int cmd, unsigned long arg) */ { - pr_debug(">>> %s (%d)\n", __func__, __LINE__); return 0; } static int pat9125_fops_open(struct inode *inode, struct file *filp) { - pr_debug(">>> %s (%d)\n", __func__, __LINE__); return 0; } @@ -209,6 +206,7 @@ static ssize_t pat9125_test_store(struct device *dev, /* example(in console): echo w 12 34 > rw_reg */ if (*p == 'w') { long write_addr, write_data; + p += 2; if (!kstrtol(p, 16, &write_addr)) { p += 3; @@ -222,10 +220,12 @@ static ssize_t pat9125_test_store(struct device *dev, /* example(in console): echo r 12 > rw_reg */ } else if (*p == 'r') { long read_addr; + p += 2; if (!kstrtol(p, 16, &read_addr)) { int data = 0; + data = ReadData((u8)read_addr); pr_debug( "r 0x%x 0x%x\n", @@ -246,21 +246,19 @@ static ssize_t pat9125_test_show( } static DEVICE_ATTR( test, - S_IRUGO | S_IWUGO , pat9125_test_show, pat9125_test_store); + S_IRUGO | S_IWUSR | S_IWGRP, pat9125_test_show, pat9125_test_store); static struct device_attribute *pat9125_attr_list[] = { &dev_attr_test, }; - -/*----------------------------------------------------------------------------*/ static int pat9125_create_attr(struct device *dev) { int idx, err = 0; - int num = (int)(sizeof(pat9125_attr_list)/sizeof(pat9125_attr_list[0])); + int num = ARRAY_SIZE(pat9125_attr_list); + if (!dev) return -EINVAL; - - for (idx = 0; idx < num; idx++) { + for (idx = 0; idx < num; idx++) { err = device_create_file(dev, pat9125_attr_list[idx]); if (err) { pr_debug( @@ -269,21 +267,6 @@ static int pat9125_create_attr(struct device *dev) break; } } - - return err; -} -/*----------------------------------------------------------------------------*/ -static int pat9125_delete_attr(struct device *dev) -{ - - int idx , err = 0; - int num = (int)(sizeof(pat9125_attr_list)/sizeof(pat9125_attr_list[0])); - if (!dev) - return -EINVAL; - - for (idx = 0; idx < num; idx++) - device_remove_file(dev, pat9125_attr_list[idx]); - return err; } @@ -360,7 +343,7 @@ static int pat9125_i2c_probe( goto error_return; if (!pat9125_start()) - goto error_return; + goto error_return; return 0; @@ -400,7 +383,7 @@ static const struct dev_pm_ops pat9125_pm_ops = { .resume = pat9125_resume }; -static struct of_device_id pixart_pat9125_match_table[] = { +static const struct of_device_id pixart_pat9125_match_table[] = { { .compatible = "pixart,pat9125",}, { }, }; @@ -436,7 +419,7 @@ static int pat9125_init_input_data(void) pat9125data.pat9125_input_dev = input_allocate_device(); if (!pat9125data.pat9125_input_dev) { - pr_debug( + pr_debug( "%s (%d) : could not allocate mouse input device\n", __func__, __LINE__); return -ENOMEM; @@ -462,10 +445,6 @@ static int pat9125_init_input_data(void) static int __init pat9125_linux_init(void) { - pr_debug("%s (%d) :init module\n", __func__, __LINE__); - pr_debug("Date : %s\n", __DATE__); - pr_debug("Time : %s\n", __TIME__); - return i2c_add_driver(&pat9125_i2c_driver); } @@ -477,7 +456,6 @@ static void __exit pat9125_linux_exit(void) pr_debug("%s (%d) : exit module\n", __func__, __LINE__); pat9125_stop(); misc_register(&pat9125_device); - pat9125_delete_attr(pat9125data.pat9125_device); i2c_del_driver(&pat9125_i2c_driver); } diff --git a/drivers/input/misc/ots_pat9125/pixart_ots.c b/drivers/input/misc/ots_pat9125/pixart_ots.c index 3ec8de9d2149..70736197de3c 100644 --- a/drivers/input/misc/ots_pat9125/pixart_ots.c +++ b/drivers/input/misc/ots_pat9125/pixart_ots.c @@ -1,3 +1,8 @@ +/* drivers/input/misc/ots_pat9125/pixart_ots.c + * + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + */ #include "pixart_ots.h" @@ -7,22 +12,29 @@ bool OTS_Sensor_Init(void) { unsigned char sensor_pid = 0, read_id_ok = 0; - /* Read sensor_pid in address 0x00 to check if the - serial link is valid, read value should be 0x31. */ + /* + * Read sensor_pid in address 0x00 to check if the + * serial link is valid, read value should be 0x31. + */ sensor_pid = ReadData(0x00); if (sensor_pid == 0x31) { read_id_ok = 1; - /* PAT9125 sensor recommended settings: */ - /* switch to bank0, not allowed to perform OTS_RegWriteRead */ + /* + *PAT9125 sensor recommended settings: + * switch to bank0, not allowed to perform OTS_RegWriteRead + */ WriteData(0x7F, 0x00); - /* software reset (i.e. set bit7 to 1). - It will reset to 0 automatically */ - /* so perform OTS_RegWriteRead is not allowed. */ + /* + * software reset (i.e. set bit7 to 1). + * It will reset to 0 automatically + * so perform OTS_RegWriteRead is not allowed. + */ WriteData(0x06, 0x97); - delay_ms(1); /* delay 1ms */ + /* delay 1ms */ + delay_ms(1); /* disable write protect */ OTS_WriteRead(0x09, 0x5A); @@ -48,6 +60,7 @@ bool OTS_Sensor_Init(void) static void OTS_WriteRead(uint8_t address, uint8_t wdata) { uint8_t read_value; + do { /* Write data to specified address */ WriteData(address, wdata); @@ -55,6 +68,4 @@ static void OTS_WriteRead(uint8_t address, uint8_t wdata) read_value = ReadData(address); /* Check if the data is correctly written */ } while (read_value != wdata); - return; } - diff --git a/drivers/input/misc/ots_pat9125/pixart_ots.h b/drivers/input/misc/ots_pat9125/pixart_ots.h index a1429a7954ee..ba1da1396ad1 100644 --- a/drivers/input/misc/ots_pat9125/pixart_ots.h +++ b/drivers/input/misc/ots_pat9125/pixart_ots.h @@ -1,3 +1,9 @@ +/* drivers/input/misc/ots_pat9125/pixart_ots.h + * + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + */ + #ifndef _PIXART_OTS_H_ #define _PIXART_OTS_H_ diff --git a/drivers/input/misc/ots_pat9125/pixart_platform.h b/drivers/input/misc/ots_pat9125/pixart_platform.h index 12e6337aac5a..a025fd06343e 100644 --- a/drivers/input/misc/ots_pat9125/pixart_platform.h +++ b/drivers/input/misc/ots_pat9125/pixart_platform.h @@ -1,7 +1,13 @@ +/* drivers/input/misc/ots_pat9125/pixart_platform.h + * + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + */ + #ifndef _PIXART_PLATFORM_ #define _PIXART_PLATFORM_ -#include <linux/input.h> /* BUS_SPI */ +#include <linux/input.h> #include <linux/pm.h> #include <linux/spi/spi.h> #include <linux/module.h> @@ -9,8 +15,8 @@ #include <linux/irq.h> #include <linux/gpio.h> #include <linux/of_gpio.h> -#include <linux/delay.h> -#include <linux/types.h> +#include <linux/delay.h> +#include <linux/types.h> /* extern functions */ extern unsigned char ReadData(unsigned char addr); |
