[PATCH] net: korina: cast KSEG0 address to pointer in kfree

2020-10-18 Thread Valentin Vidic
Fixes gcc warning:

passing argument 1 of 'kfree' makes pointer from integer without a cast

Fixes: 3af5f0f5c74e ("net: korina: fix kfree of rx/tx descriptor array")
Reported-by: kernel test robot 
Signed-off-by: Valentin Vidic 
---
 drivers/net/ethernet/korina.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index af441d699a57..bf48f0ded9c7 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1113,7 +1113,7 @@ static int korina_probe(struct platform_device *pdev)
return rc;
 
 probe_err_register:
-   kfree(KSEG0ADDR(lp->td_ring));
+   kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
 probe_err_td_ring:
iounmap(lp->tx_dma_regs);
 probe_err_dma_tx:
@@ -1133,7 +1133,7 @@ static int korina_remove(struct platform_device *pdev)
iounmap(lp->eth_regs);
iounmap(lp->rx_dma_regs);
iounmap(lp->tx_dma_regs);
-   kfree(KSEG0ADDR(lp->td_ring));
+   kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
 
unregister_netdev(bif->dev);
free_netdev(bif->dev);
-- 
2.20.1



[PATCH v2] net: korina: fix kfree of rx/tx descriptor array

2020-10-11 Thread Valentin Vidic
kmalloc returns KSEG0 addresses so convert back from KSEG1
in kfree. Also make sure array is freed when the driver is
unloaded from the kernel.

Fixes: ef11291bcd5f ("Add support the Korina (IDT RC32434) Ethernet MAC")
Signed-off-by: Valentin Vidic 
---
 v2: convert kfree address back to KSEG0

 drivers/net/ethernet/korina.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index 03e034918d14..af441d699a57 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1113,7 +1113,7 @@ static int korina_probe(struct platform_device *pdev)
return rc;
 
 probe_err_register:
-   kfree(lp->td_ring);
+   kfree(KSEG0ADDR(lp->td_ring));
 probe_err_td_ring:
iounmap(lp->tx_dma_regs);
 probe_err_dma_tx:
@@ -1133,6 +1133,7 @@ static int korina_remove(struct platform_device *pdev)
iounmap(lp->eth_regs);
iounmap(lp->rx_dma_regs);
iounmap(lp->tx_dma_regs);
+   kfree(KSEG0ADDR(lp->td_ring));
 
unregister_netdev(bif->dev);
free_netdev(bif->dev);
-- 
2.20.1



[PATCH] net: korina: free array used for rx/tx descriptors

2020-10-11 Thread Valentin Vidic
Memory was not freed when driver is unloaded from the kernel.

Signed-off-by: Valentin Vidic 
---
 drivers/net/ethernet/korina.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index 03e034918d14..99146145f020 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1133,6 +1133,7 @@ static int korina_remove(struct platform_device *pdev)
iounmap(lp->eth_regs);
iounmap(lp->rx_dma_regs);
iounmap(lp->tx_dma_regs);
+   kfree(lp->td_ring);
 
unregister_netdev(bif->dev);
free_netdev(bif->dev);
-- 
2.20.1



[PATCH] coding-style.rst: cleanup new text

2020-06-01 Thread Valentin Vidic
Remove doubled word: "...than the parent and are are placed..."

Signed-off-by: Valentin Vidic 
---
 Documentation/process/coding-style.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/process/coding-style.rst 
b/Documentation/process/coding-style.rst
index 17a8e584f15f..bd73e1b5c111 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -90,9 +90,9 @@ Statements longer than 80 columns should be broken into 
sensible chunks,
 unless exceeding 80 columns significantly increases readability and does
 not hide information.
 
-Descendants are always substantially shorter than the parent and are
-are placed substantially to the right.  A very commonly used style
-is to align descendants to a function open parenthesis.
+Descendants are always substantially shorter than the parent and are placed
+substantially to the right.  A very commonly used style is to align descendants
+to a function open parenthesis.
 
 These same rules are applied to function headers with a long argument list.
 
-- 
2.20.1



[PATCH] s390/sclp_vt220: Fix console name to match device

2020-05-19 Thread Valentin Vidic
Console name reported in /proc/consoles:

  ttyS1-W- (EC p  )4:65

does not match device name:

  crw--w1 root root4,  65 May 17 12:18 /dev/ttysclp0

so debian-installer gets confused and fails to start.

Signed-off-by: Valentin Vidic 
Cc: sta...@vger.kernel.org
---
 drivers/s390/char/sclp_vt220.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 3f9a6ef650fa..3c2ed6d01387 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -35,8 +35,8 @@
 #define SCLP_VT220_MINOR   65
 #define SCLP_VT220_DRIVER_NAME "sclp_vt220"
 #define SCLP_VT220_DEVICE_NAME "ttysclp"
-#define SCLP_VT220_CONSOLE_NAME"ttyS"
-#define SCLP_VT220_CONSOLE_INDEX   1   /* console=ttyS1 */
+#define SCLP_VT220_CONSOLE_NAME"ttysclp"
+#define SCLP_VT220_CONSOLE_INDEX   0   /* console=ttysclp0 */
 
 /* Representation of a single write request */
 struct sclp_vt220_request {
-- 
2.20.1



[PATCH] net: usb: sr9800: fix uninitialized local variable

2019-10-15 Thread Valentin Vidic
Make sure res does not contain random value if the call to
sr_read_cmd fails for some reason.

Reported-by: syzbot+f1842130bbcfb335b...@syzkaller.appspotmail.com
Signed-off-by: Valentin Vidic 
---
 drivers/net/usb/sr9800.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index c5d4a0060124..681e0def6356 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -335,7 +335,7 @@ static void sr_set_multicast(struct net_device *net)
 static int sr_mdio_read(struct net_device *net, int phy_id, int loc)
 {
struct usbnet *dev = netdev_priv(net);
-   __le16 res;
+   __le16 res = 0;
 
mutex_lock(>phy_mutex);
sr_set_sw_mii(dev);
-- 
2.20.1



[PATCH] media: cxusb: fix uninitialized local variable

2019-10-15 Thread Valentin Vidic
Make sure ircode does not contain random values if the call to
cxusb_ctrl_msg fails for some reason.

Reported-by: syzbot+98730b985cad4931a...@syzkaller.appspotmail.com
Signed-off-by: Valentin Vidic 
---
 drivers/media/usb/dvb-usb/cxusb.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index f02fa0a67aa4..afcd88dd96c0 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -519,7 +519,7 @@ static int cxusb_d680_dmb_streaming_ctrl(struct 
dvb_usb_adapter *adap,
 
 static int cxusb_rc_query(struct dvb_usb_device *d)
 {
-   u8 ircode[4];
+   u8 ircode[4] = { 0 };
 
cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
 
@@ -531,7 +531,7 @@ static int cxusb_rc_query(struct dvb_usb_device *d)
 
 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d)
 {
-   u8 ircode[4];
+   u8 ircode[4] = { 0 };
struct i2c_msg msg = {
.addr = 0x6b,
.flags = I2C_M_RD,
@@ -550,7 +550,7 @@ static int cxusb_bluebird2_rc_query(struct dvb_usb_device 
*d)
 
 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d)
 {
-   u8 ircode[2];
+   u8 ircode[2] = { 0 };
 
if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
return 0;
@@ -989,7 +989,7 @@ static int cxusb_dee1601_frontend_attach(struct 
dvb_usb_adapter *adap)
 
 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
 {
-   u8 ircode[4];
+   u8 ircode[4] = { 0 };
int i;
struct i2c_msg msg = {
.addr = 0x6b,
-- 
2.20.1



[PATCH] usb: iowarrior: fix access to freed data structure

2019-10-08 Thread Valentin Vidic
struct iowarrior gets freed prematurely in iowarrior_release while
it is still being referenced from usb_interface, so let only
iowarrior_disconnect call iowarrior_delete.

Fixes: KMSAN: uninit-value in iowarrior_disconnect
Reported-by: syzbot+0761012cebf7bdb38...@syzkaller.appspotmail.com
Signed-off-by: Valentin Vidic 
---
 drivers/usb/misc/iowarrior.c | 35 +++
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index f5bed9f29e56..0492ea76c4bf 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -638,7 +638,6 @@ static int iowarrior_open(struct inode *inode, struct file 
*file)
 static int iowarrior_release(struct inode *inode, struct file *file)
 {
struct iowarrior *dev;
-   int retval = 0;
 
dev = file->private_data;
if (!dev)
@@ -650,27 +649,23 @@ static int iowarrior_release(struct inode *inode, struct 
file *file)
mutex_lock(>mutex);
 
if (dev->opened <= 0) {
-   retval = -ENODEV;   /* close called more than once */
mutex_unlock(>mutex);
-   } else {
-   dev->opened = 0;/* we're closing now */
-   retval = 0;
-   if (dev->present) {
-   /*
-  The device is still connected so we only shutdown
-  pending read-/write-ops.
-*/
-   usb_kill_urb(dev->int_in_urb);
-   wake_up_interruptible(>read_wait);
-   wake_up_interruptible(>write_wait);
-   mutex_unlock(>mutex);
-   } else {
-   /* The device was unplugged, cleanup resources */
-   mutex_unlock(>mutex);
-   iowarrior_delete(dev);
-   }
+   return -ENODEV; /* close called more than once */
}
-   return retval;
+
+   dev->opened = 0;/* we're closing now */
+   if (dev->present) {
+   /*
+* The device is still connected so we only shutdown
+* pending read/write ops.
+*/
+   usb_kill_urb(dev->int_in_urb);
+   wake_up_interruptible(>read_wait);
+   wake_up_interruptible(>write_wait);
+   }
+
+   mutex_unlock(>mutex);
+   return 0;
 }
 
 static __poll_t iowarrior_poll(struct file *file, poll_table * wait)
-- 
2.20.1



[PATCH v3 4/4] staging: exfat: add millisecond support

2019-09-08 Thread Valentin Vidic
Use create_time_ms and modify_time_ms fields to store the millisecond
part of the file timestamp with the precision of 10 ms.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index d21f68d786b8..d6e33a485d5f 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1139,6 +1139,7 @@ void exfat_set_entry_size(struct dentry_t *p_entry, u64 
size)
 void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
 {
+   u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry;
 
@@ -1146,6 +1147,7 @@ void fat_get_entry_time(struct dentry_t *p_entry, struct 
timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+   ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
@@ -1159,11 +1161,17 @@ void fat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
tp->day  = (d & 0x001F);
tp->mon  = (d >> 5) & 0x000F;
tp->year = (d >> 9);
+
+   if (ms >= 1000) {
+   ms -= 1000;
+   tp->sec++;
+   }
 }
 
 void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
  u8 mode)
 {
+   u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct file_dentry_t *ep = (struct file_dentry_t *)p_entry;
 
@@ -1171,10 +1179,12 @@ void exfat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+   ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
d = GET16_A(ep->modify_date);
+   ms = ep->modify_time_ms * 10;
break;
case TM_ACCESS:
t = GET16_A(ep->access_time);
@@ -1188,21 +1198,32 @@ void exfat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
tp->day  = (d & 0x001F);
tp->mon  = (d >> 5) & 0x000F;
tp->year = (d >> 9);
+
+   if (ms >= 1000) {
+   ms -= 1000;
+   tp->sec++;
+   }
 }
 
 void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
 {
+   u8 ms;
u16 t, d;
struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry;
 
t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1);
d = (tp->year <<  9) | (tp->mon << 5) |  tp->day;
 
+   ms = tp->millisec;
+   if (tp->sec & 1)
+   ms += 1000;
+
switch (mode) {
case TM_CREATE:
SET16_A(ep->create_time, t);
SET16_A(ep->create_date, d);
+   ep->create_time_ms = ms / 10;
break;
case TM_MODIFY:
SET16_A(ep->modify_time, t);
@@ -1214,20 +1235,27 @@ void fat_set_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
 void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
  u8 mode)
 {
+   u8 ms;
u16 t, d;
struct file_dentry_t *ep = (struct file_dentry_t *)p_entry;
 
t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1);
d = (tp->year <<  9) | (tp->mon << 5) |  tp->day;
 
+   ms = tp->millisec;
+   if (tp->sec & 1)
+   ms += 1000;
+
switch (mode) {
case TM_CREATE:
SET16_A(ep->create_time, t);
SET16_A(ep->create_date, d);
+   ep->create_time_ms = ms / 10;
break;
case TM_MODIFY:
SET16_A(ep->modify_time, t);
SET16_A(ep->modify_date, d);
+   ep->modify_time_ms = ms / 10;
break;
case TM_ACCESS:
SET16_A(ep->access_time, t);
-- 
2.20.1



[PATCH v3 2/4] staging: exfat: drop duplicate date_time_t struct

2019-09-08 Thread Valentin Vidic
Use timestamp_t for everything and cleanup duplicate code.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h   |  35 +++---
 drivers/staging/exfat/exfat_super.c | 158 
 2 files changed, 55 insertions(+), 138 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 0aa14dea4e09..58e1e889779f 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -241,16 +241,6 @@ static inline u16 get_row_index(u16 i)
 #define UNI_PAR_DIR_NAME"\0.\0."
 #endif
 
-struct date_time_t {
-   u16  Year;
-   u16  Month;
-   u16  Day;
-   u16  Hour;
-   u16  Minute;
-   u16  Second;
-   u16  MilliSecond;
-};
-
 struct part_info_t {
u32  Offset;/* start sector number of the partition */
u32  Size;  /* in sectors */
@@ -289,6 +279,16 @@ struct file_id_t {
u32  hint_last_clu;
 };
 
+struct timestamp_t {
+   u16  millisec;   /* 0 ~ 999  */
+   u16  sec;/* 0 ~ 59   */
+   u16  min;/* 0 ~ 59   */
+   u16  hour;   /* 0 ~ 23   */
+   u16  day;/* 1 ~ 31   */
+   u16  mon;/* 1 ~ 12   */
+   u16  year;   /* 0 ~ 127 (since 1980) */
+};
+
 struct dir_entry_t {
char Name[MAX_NAME_LENGTH * MAX_CHARSET_SIZE];
 
@@ -298,18 +298,9 @@ struct dir_entry_t {
u32 Attr;
u64 Size;
u32 NumSubdirs;
-   struct date_time_t CreateTimestamp;
-   struct date_time_t ModifyTimestamp;
-   struct date_time_t AccessTimestamp;
-};
-
-struct timestamp_t {
-   u16  sec;/* 0 ~ 59   */
-   u16  min;/* 0 ~ 59   */
-   u16  hour;   /* 0 ~ 23   */
-   u16  day;/* 1 ~ 31   */
-   u16  mon;/* 1 ~ 12   */
-   u16  year;   /* 0 ~ 127 (since 1980) */
+   struct timestamp_t CreateTimestamp;
+   struct timestamp_t ModifyTimestamp;
+   struct timestamp_t AccessTimestamp;
 };
 
 /* MS_DOS FAT partition boot record (512 bytes) */
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 3a58907caf7c..54b6c2ff3c96 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -56,16 +56,16 @@ static void exfat_write_super(struct super_block *sb);
 #define UNIX_SECS_21084354819200L
 
 /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
-static void exfat_time_fat2unix(struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_fat2unix(struct timespec64 *ts, struct timestamp_t *tp)
 {
-   ts->tv_sec = mktime64(tp->Year + 1980, tp->Month + 1, tp->Day,
- tp->Hour, tp->Minute, tp->Second);
+   ts->tv_sec = mktime64(tp->year + 1980, tp->mon + 1, tp->day,
+ tp->hour, tp->min, tp->sec);
 
-   ts->tv_nsec = tp->MilliSecond * NSEC_PER_MSEC;
+   ts->tv_nsec = tp->millisec * NSEC_PER_MSEC;
 }
 
 /* Convert linear UNIX date to a FAT time/date pair. */
-static void exfat_time_unix2fat(struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_unix2fat(struct timespec64 *ts, struct timestamp_t *tp)
 {
time64_t second = ts->tv_sec;
struct tm tm;
@@ -73,69 +73,42 @@ static void exfat_time_unix2fat(struct timespec64 *ts, 
struct date_time_t *tp)
time64_to_tm(second, 0, );
 
if (second < UNIX_SECS_1980) {
-   tp->MilliSecond = 0;
-   tp->Second  = 0;
-   tp->Minute  = 0;
-   tp->Hour= 0;
-   tp->Day = 1;
-   tp->Month   = 1;
-   tp->Year= 0;
+   tp->millisec= 0;
+   tp->sec = 0;
+   tp->min = 0;
+   tp->hour= 0;
+   tp->day = 1;
+   tp->mon = 1;
+   tp->year= 0;
return;
}
 
if (second >= UNIX_SECS_2108) {
-   tp->MilliSecond = 999;
-   tp->Second  = 59;
-   tp->Minute  = 59;
-   tp->Hour= 23;
-   tp->Day = 31;
-   tp->Month   = 12;
-   tp->Year= 127;
+   tp->millisec= 999;
+   tp->sec = 59;
+   tp->min = 59;
+   tp->hour= 23;
+   tp->day = 31;
+   tp->mon = 12;
+   tp->year= 127;
return;

[PATCH v3 1/4] staging: exfat: drop unused function parameter

2019-09-08 Thread Valentin Vidic
sbi parameter not used inside the function so remove it.
Also cleanup unused variables generated by this change.

Signed-off-by: Valentin Vidic 
---
v2: split up into multiple patches
v3: split up some more
fix if statement braces
add utc offset fields

 drivers/staging/exfat/exfat_super.c | 20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 60dfea73a7a4..3a58907caf7c 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -56,8 +56,7 @@ static void exfat_write_super(struct super_block *sb);
 #define UNIX_SECS_21084354819200L
 
 /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
-static void exfat_time_fat2unix(struct exfat_sb_info *sbi,
-   struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_fat2unix(struct timespec64 *ts, struct date_time_t *tp)
 {
ts->tv_sec = mktime64(tp->Year + 1980, tp->Month + 1, tp->Day,
  tp->Hour, tp->Minute, tp->Second);
@@ -66,8 +65,7 @@ static void exfat_time_fat2unix(struct exfat_sb_info *sbi,
 }
 
 /* Convert linear UNIX date to a FAT time/date pair. */
-static void exfat_time_unix2fat(struct exfat_sb_info *sbi,
-   struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_unix2fat(struct timespec64 *ts, struct date_time_t *tp)
 {
time64_t second = ts->tv_sec;
struct tm tm;
@@ -3349,9 +3347,9 @@ static int exfat_fill_inode(struct inode *inode, struct 
file_id_t *fid)
inode->i_blocks = ((i_size_read(inode) + (p_fs->cluster_size - 1))
& ~((loff_t)p_fs->cluster_size - 1)) >> 9;
 
-   exfat_time_fat2unix(sbi, >i_mtime, );
-   exfat_time_fat2unix(sbi, >i_ctime, );
-   exfat_time_fat2unix(sbi, >i_atime, );
+   exfat_time_fat2unix(>i_mtime, );
+   exfat_time_fat2unix(>i_ctime, );
+   exfat_time_fat2unix(>i_atime, );
 
return 0;
 }
@@ -3412,8 +3410,6 @@ static void exfat_destroy_inode(struct inode *inode)
 
 static int exfat_write_inode(struct inode *inode, struct writeback_control 
*wbc)
 {
-   struct super_block *sb = inode->i_sb;
-   struct exfat_sb_info *sbi = EXFAT_SB(sb);
struct dir_entry_t info;
 
if (inode->i_ino == EXFAT_ROOT_INO)
@@ -3422,9 +3418,9 @@ static int exfat_write_inode(struct inode *inode, struct 
writeback_control *wbc)
info.Attr = exfat_make_attr(inode);
info.Size = i_size_read(inode);
 
-   exfat_time_unix2fat(sbi, >i_mtime, );
-   exfat_time_unix2fat(sbi, >i_ctime, );
-   exfat_time_unix2fat(sbi, >i_atime, );
+   exfat_time_unix2fat(>i_mtime, );
+   exfat_time_unix2fat(>i_ctime, );
+   exfat_time_unix2fat(>i_atime, );
 
ffsWriteStat(inode, );
 
-- 
2.20.1



[PATCH v3 3/4] staging: exfat: drop unused field access_time_ms

2019-09-08 Thread Valentin Vidic
Spec defines that UtcOffset fields should start in this
position instead.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h  | 6 --
 drivers/staging/exfat/exfat_core.c | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 58e1e889779f..9b75c5d3f072 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -444,8 +444,10 @@ struct file_dentry_t {
u8   access_date[2];
u8   create_time_ms;
u8   modify_time_ms;
-   u8   access_time_ms;
-   u8   reserved2[9];
+   u8   create_utc_offset;
+   u8   modify_utc_offset;
+   u8   access_utc_offset;
+   u8   reserved2[7];
 };
 
 /* MS-DOS EXFAT stream extension directory entry (32 bytes) */
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 995358cc7c79..d21f68d786b8 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1456,7 +1456,9 @@ void init_file_entry(struct file_dentry_t *ep, u32 type)
exfat_set_entry_time((struct dentry_t *)ep, tp, TM_ACCESS);
ep->create_time_ms = 0;
ep->modify_time_ms = 0;
-   ep->access_time_ms = 0;
+   ep->create_utc_offset = 0;
+   ep->modify_utc_offset = 0;
+   ep->access_utc_offset = 0;
 }
 
 void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 
size)
-- 
2.20.1



[PATCH v2 3/3] staging: exfat: add millisecond support

2019-09-08 Thread Valentin Vidic
Use create_time_ms modify_time_ms fields to store the millisecond
part of the file timestamp with the precision of 10 ms.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 8476eeedba83..e87119fa8c0a 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1139,6 +1139,7 @@ void exfat_set_entry_size(struct dentry_t *p_entry, u64 
size)
 void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
 {
+   u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry;
 
@@ -1146,6 +1147,7 @@ void fat_get_entry_time(struct dentry_t *p_entry, struct 
timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+   ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
@@ -1159,11 +1161,17 @@ void fat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
tp->day  = (d & 0x001F);
tp->mon  = (d >> 5) & 0x000F;
tp->year = (d >> 9);
+
+   if (ms >= 1000) {
+   ms -= 1000;
+   tp->sec++;
+   }
 }
 
 void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
  u8 mode)
 {
+   u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct file_dentry_t *ep = (struct file_dentry_t *)p_entry;
 
@@ -1171,10 +1179,12 @@ void exfat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+   ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
d = GET16_A(ep->modify_date);
+   ms = ep->modify_time_ms * 10;
break;
case TM_ACCESS:
t = GET16_A(ep->access_time);
@@ -1188,21 +1198,33 @@ void exfat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
tp->day  = (d & 0x001F);
tp->mon  = (d >> 5) & 0x000F;
tp->year = (d >> 9);
+
+   if (ms >= 1000) {
+   ms -= 1000;
+   tp->sec++;
+   }
 }
 
 void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
 {
+   u8 ms;
u16 t, d;
struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry;
 
t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1);
d = (tp->year <<  9) | (tp->mon << 5) |  tp->day;
 
+   ms = tp->millisec;
+   if (tp->sec & 1) {
+   ms += 1000;
+   }
+
switch (mode) {
case TM_CREATE:
SET16_A(ep->create_time, t);
SET16_A(ep->create_date, d);
+   ep->create_time_ms = ms / 10;
break;
case TM_MODIFY:
SET16_A(ep->modify_time, t);
@@ -1214,20 +1236,28 @@ void fat_set_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
 void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
  u8 mode)
 {
+   u8 ms;
u16 t, d;
struct file_dentry_t *ep = (struct file_dentry_t *)p_entry;
 
t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1);
d = (tp->year <<  9) | (tp->mon << 5) |  tp->day;
 
+   ms = tp->millisec;
+   if (tp->sec & 1) {
+   ms += 1000;
+   }
+
switch (mode) {
case TM_CREATE:
SET16_A(ep->create_time, t);
SET16_A(ep->create_date, d);
+   ep->create_time_ms = ms / 10;
break;
case TM_MODIFY:
SET16_A(ep->modify_time, t);
SET16_A(ep->modify_date, d);
+   ep->modify_time_ms = ms / 10;
break;
case TM_ACCESS:
SET16_A(ep->access_time, t);
-- 
2.20.1



[PATCH v2 2/3] staging: exfat: drop unused field access_time_ms

2019-09-08 Thread Valentin Vidic
Not used in the exfat-fuse implementation and spec defines
this position should hold the value for CreateUtcOffset.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h  | 3 +--
 drivers/staging/exfat/exfat_core.c | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 58e1e889779f..6491ea034928 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -444,8 +444,7 @@ struct file_dentry_t {
u8   access_date[2];
u8   create_time_ms;
u8   modify_time_ms;
-   u8   access_time_ms;
-   u8   reserved2[9];
+   u8   reserved2[10];
 };
 
 /* MS-DOS EXFAT stream extension directory entry (32 bytes) */
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 995358cc7c79..8476eeedba83 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1456,7 +1456,6 @@ void init_file_entry(struct file_dentry_t *ep, u32 type)
exfat_set_entry_time((struct dentry_t *)ep, tp, TM_ACCESS);
ep->create_time_ms = 0;
ep->modify_time_ms = 0;
-   ep->access_time_ms = 0;
 }
 
 void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 
size)
-- 
2.20.1



[PATCH v2 1/3] staging: exfat: drop duplicate date_time_t struct

2019-09-08 Thread Valentin Vidic
Use timestamp_t for everything and cleanup duplicate code.

Signed-off-by: Valentin Vidic 
---
v2: split up into multiple patches

 drivers/staging/exfat/exfat.h   |  35 +++---
 drivers/staging/exfat/exfat_super.c | 174 
 2 files changed, 61 insertions(+), 148 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 0aa14dea4e09..58e1e889779f 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -241,16 +241,6 @@ static inline u16 get_row_index(u16 i)
 #define UNI_PAR_DIR_NAME"\0.\0."
 #endif
 
-struct date_time_t {
-   u16  Year;
-   u16  Month;
-   u16  Day;
-   u16  Hour;
-   u16  Minute;
-   u16  Second;
-   u16  MilliSecond;
-};
-
 struct part_info_t {
u32  Offset;/* start sector number of the partition */
u32  Size;  /* in sectors */
@@ -289,6 +279,16 @@ struct file_id_t {
u32  hint_last_clu;
 };
 
+struct timestamp_t {
+   u16  millisec;   /* 0 ~ 999  */
+   u16  sec;/* 0 ~ 59   */
+   u16  min;/* 0 ~ 59   */
+   u16  hour;   /* 0 ~ 23   */
+   u16  day;/* 1 ~ 31   */
+   u16  mon;/* 1 ~ 12   */
+   u16  year;   /* 0 ~ 127 (since 1980) */
+};
+
 struct dir_entry_t {
char Name[MAX_NAME_LENGTH * MAX_CHARSET_SIZE];
 
@@ -298,18 +298,9 @@ struct dir_entry_t {
u32 Attr;
u64 Size;
u32 NumSubdirs;
-   struct date_time_t CreateTimestamp;
-   struct date_time_t ModifyTimestamp;
-   struct date_time_t AccessTimestamp;
-};
-
-struct timestamp_t {
-   u16  sec;/* 0 ~ 59   */
-   u16  min;/* 0 ~ 59   */
-   u16  hour;   /* 0 ~ 23   */
-   u16  day;/* 1 ~ 31   */
-   u16  mon;/* 1 ~ 12   */
-   u16  year;   /* 0 ~ 127 (since 1980) */
+   struct timestamp_t CreateTimestamp;
+   struct timestamp_t ModifyTimestamp;
+   struct timestamp_t AccessTimestamp;
 };
 
 /* MS_DOS FAT partition boot record (512 bytes) */
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 60dfea73a7a4..54b6c2ff3c96 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -56,18 +56,16 @@ static void exfat_write_super(struct super_block *sb);
 #define UNIX_SECS_21084354819200L
 
 /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
-static void exfat_time_fat2unix(struct exfat_sb_info *sbi,
-   struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_fat2unix(struct timespec64 *ts, struct timestamp_t *tp)
 {
-   ts->tv_sec = mktime64(tp->Year + 1980, tp->Month + 1, tp->Day,
- tp->Hour, tp->Minute, tp->Second);
+   ts->tv_sec = mktime64(tp->year + 1980, tp->mon + 1, tp->day,
+ tp->hour, tp->min, tp->sec);
 
-   ts->tv_nsec = tp->MilliSecond * NSEC_PER_MSEC;
+   ts->tv_nsec = tp->millisec * NSEC_PER_MSEC;
 }
 
 /* Convert linear UNIX date to a FAT time/date pair. */
-static void exfat_time_unix2fat(struct exfat_sb_info *sbi,
-   struct timespec64 *ts, struct date_time_t *tp)
+static void exfat_time_unix2fat(struct timespec64 *ts, struct timestamp_t *tp)
 {
time64_t second = ts->tv_sec;
struct tm tm;
@@ -75,69 +73,42 @@ static void exfat_time_unix2fat(struct exfat_sb_info *sbi,
time64_to_tm(second, 0, );
 
if (second < UNIX_SECS_1980) {
-   tp->MilliSecond = 0;
-   tp->Second  = 0;
-   tp->Minute  = 0;
-   tp->Hour= 0;
-   tp->Day = 1;
-   tp->Month   = 1;
-   tp->Year= 0;
+   tp->millisec= 0;
+   tp->sec = 0;
+   tp->min = 0;
+   tp->hour= 0;
+   tp->day = 1;
+   tp->mon = 1;
+   tp->year= 0;
return;
}
 
if (second >= UNIX_SECS_2108) {
-   tp->MilliSecond = 999;
-   tp->Second  = 59;
-   tp->Minute  = 59;
-   tp->Hour= 23;
-   tp->Day = 31;
-   tp->Month   = 12;
-   tp->Year= 127;
+   tp->millisec= 999;
+   tp->sec = 59;
+   tp->min = 59;
+   tp->hour= 23;
+   tp->day

[PATCH v3 1/3] staging: exfat: cleanup spacing for operators

2019-09-08 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: spaces preferred around that '-' (ctx:VxV)
  CHECK: spaces preferred around that '+' (ctx:VxV)
  CHECK: spaces preferred around that '*' (ctx:VxV)
  CHECK: spaces preferred around that '|' (ctx:VxV)

Signed-off-by: Valentin Vidic 
---
v2: Use constants where possible
v3: Split up changes of constants

 drivers/staging/exfat/exfat.h   |  2 +-
 drivers/staging/exfat/exfat_core.c  | 76 ++---
 drivers/staging/exfat/exfat_super.c | 44 -
 3 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 0aa14dea4e09..6c12f2d79f4d 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -159,7 +159,7 @@
 /* Upcase table macro */
 #define HIGH_INDEX_BIT (8)
 #define HIGH_INDEX_MASK(0xFF00)
-#define LOW_INDEX_BIT  (16-HIGH_INDEX_BIT)
+#define LOW_INDEX_BIT  (16 - HIGH_INDEX_BIT)
 #define UTBL_ROW_COUNT BIT(LOW_INDEX_BIT)
 #define UTBL_COL_COUNT BIT(HIGH_INDEX_BIT)
 
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 995358cc7c79..8fb4ce16010c 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -230,7 +230,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
hint_clu = p_chain->dir;
if (hint_clu == CLUSTER_32(~0)) {
-   hint_clu = test_alloc_bitmap(sb, p_fs->clu_srch_ptr-2);
+   hint_clu = test_alloc_bitmap(sb, p_fs->clu_srch_ptr - 2);
if (hint_clu == CLUSTER_32(~0))
return 0;
} else if (hint_clu >= p_fs->num_clusters) {
@@ -242,7 +242,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
p_chain->dir = CLUSTER_32(~0);
 
-   while ((new_clu = test_alloc_bitmap(sb, hint_clu-2)) != CLUSTER_32(~0)) 
{
+   while ((new_clu = test_alloc_bitmap(sb, hint_clu - 2)) != 
CLUSTER_32(~0)) {
if (new_clu != hint_clu) {
if (p_chain->flags == 0x03) {
exfat_chain_cont_cluster(sb, p_chain->dir,
@@ -251,7 +251,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
}
 
-   if (set_alloc_bitmap(sb, new_clu-2) != FFS_SUCCESS)
+   if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS)
return -1;
 
num_clusters++;
@@ -324,7 +324,7 @@ void fat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
if (do_relse) {
sector = START_SECTOR(clu);
for (i = 0; i < p_fs->sectors_per_clu; i++)
-   buf_release(sb, sector+i);
+   buf_release(sb, sector + i);
}
 
prev = clu;
@@ -367,10 +367,10 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
if (do_relse) {
sector = START_SECTOR(clu);
for (i = 0; i < p_fs->sectors_per_clu; i++)
-   buf_release(sb, sector+i);
+   buf_release(sb, sector + i);
}
 
-   if (clr_alloc_bitmap(sb, clu-2) != FFS_SUCCESS)
+   if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
break;
clu++;
 
@@ -384,10 +384,10 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
if (do_relse) {
sector = START_SECTOR(clu);
for (i = 0; i < p_fs->sectors_per_clu; i++)
-   buf_release(sb, sector+i);
+   buf_release(sb, sector + i);
}
 
-   if (clr_alloc_bitmap(sb, clu-2) != FFS_SUCCESS)
+   if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
break;
 
if (FAT_read(sb, clu, ) == -1)
@@ -491,7 +491,7 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 
chain, s32 len)
return;
 
while (len > 1) {
-   if (FAT_write(sb, chain, chain+1) < 0)
+   if (FAT_write(sb, chain, chain + 1) < 0)
break;
chain++;
len--;
@@ -538,7 +538,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
p_fs->map_clu  = GET32_A(ep->start_clu);
map_size = (u32) GET64_A(ep->size);
 
-   p_fs->map_sectors = ((map_size-1) >> 
p_bd->sector_size_bits) + 1;
+  

[PATCH v3 2/3] staging: exfat: cleanup spacing for casts

2019-09-08 Thread Valentin Vidic
Fix checkpatch.pl warnings:

  CHECK: No space is necessary after a cast

Signed-off-by: Valentin Vidic 
---
v2: Use constants where possible
v3: Split up changes of constants

 drivers/staging/exfat/exfat_core.c  | 88 ++---
 drivers/staging/exfat/exfat_super.c | 66 +++---
 2 files changed, 77 insertions(+), 77 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 8fb4ce16010c..8965e8453fcb 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -204,7 +204,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -215,7 +215,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
}
 
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -273,7 +273,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -293,7 +293,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
 
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -337,7 +337,7 @@ void fat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
 
} while (clu != CLUSTER_32(~0));
 
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -396,7 +396,7 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
} while ((clu != CLUSTER_32(0)) && (clu != CLUSTER_32(~0)));
}
 
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -473,7 +473,7 @@ s32 exfat_count_used_clusters(struct super_block *sb)
map_i = map_b = 0;
 
for (i = 2; i < p_fs->num_clusters; i += 8) {
-   k = *(((u8 *) p_fs->vol_amap[map_i]->b_data) + map_b);
+   k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b);
count += used_bit[k];
 
if ((++map_b) >= p_bd->sector_size) {
@@ -536,7 +536,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
 
if (ep->flags == 0x0) {
p_fs->map_clu  = GET32_A(ep->start_clu);
-   map_size = (u32) GET64_A(ep->size);
+   map_size = (u32)GET64_A(ep->size);
 
p_fs->map_sectors = ((map_size - 1) >> 
p_bd->sector_size_bits) + 1;
 
@@ -601,7 +601,7 @@ s32 set_alloc_bitmap(struct super_block *sb, u32 clu)
 
sector = START_SECTOR(p_fs->map_clu) + i;
 
-   exfat_bitmap_set((u8 *) p_fs->vol_amap[i]->b_data, b);
+   exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b);
 
return sector_write(sb, sector, p_fs->vol_amap[i], 0);
 }
@@ -623,7 +623,7 @@ s32 clr_alloc_bitmap(struct super_block *sb, u32 clu)
 
sector = START_SECTOR(p_fs->map_clu) + i;
 
-   exfat_bitmap_clear((u8 *) p_fs->vol_amap[i]->b_data, b);
+   exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b);
 
return sector_write(sb, sector, p_fs->vol_amap[i], 0);
 
@@ -655,7 +655,7 @@ u32 test_alloc_bitmap(struct super_block *sb, u32 clu)
map_b = (clu >> 3) & p_bd->sector_size_mask;
 
for (i = 2; i < p_fs->num_clusters; i += 8) {
-   k = *(((u8 *) p_fs->vol_amap[map_i]->b_data) + map_b);
+   k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b);
if (clu_mask > 0) {
k |= clu_mask;
clu_mask = 0;
@@ -728,7 +728,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
sector++;
 
for (i = 0; i < p_bd->sector_size &

[PATCH v3 3/3] staging: exfat: use integer constants

2019-09-08 Thread Valentin Vidic
Replace manually generated values with predefined constants.

Signed-off-by: Valentin Vidic 
---
v2: Use constants where possible
v3: Split up changes of constants

 drivers/staging/exfat/exfat_core.c  | 18 +-
 drivers/staging/exfat/exfat_super.c |  8 
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 8965e8453fcb..6eee2aa06bd7 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -204,7 +204,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32)~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -215,7 +215,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
}
 
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32)~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -273,7 +273,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32)~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -293,7 +293,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
 
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32)~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -337,7 +337,7 @@ void fat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
 
} while (clu != CLUSTER_32(~0));
 
-   if (p_fs->used_clusters != (u32)~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -396,7 +396,7 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
} while ((clu != CLUSTER_32(0)) && (clu != CLUSTER_32(~0)));
}
 
-   if (p_fs->used_clusters != (u32)~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -3064,7 +3064,7 @@ s32 fat16_mount(struct super_block *sb, struct 
pbr_sector_t *p_pbr)
 
p_fs->vol_flag = VOL_CLEAN;
p_fs->clu_srch_ptr = 2;
-   p_fs->used_clusters = (u32)~0;
+   p_fs->used_clusters = UINT_MAX;
 
p_fs->fs_func = _fs_func;
 
@@ -3117,7 +3117,7 @@ s32 fat32_mount(struct super_block *sb, struct 
pbr_sector_t *p_pbr)
 
p_fs->vol_flag = VOL_CLEAN;
p_fs->clu_srch_ptr = 2;
-   p_fs->used_clusters = (u32)~0;
+   p_fs->used_clusters = UINT_MAX;
 
p_fs->fs_func = _fs_func;
 
@@ -3192,7 +3192,7 @@ s32 exfat_mount(struct super_block *sb, struct 
pbr_sector_t *p_pbr)
 
p_fs->vol_flag = (u32)GET16(p_bpb->vol_flags);
p_fs->clu_srch_ptr = 2;
-   p_fs->used_clusters = (u32)~0;
+   p_fs->used_clusters = UINT_MAX;
 
p_fs->fs_func = _fs_func;
 
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 1cb0ec06c54e..610f20683611 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -502,7 +502,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct 
vol_info_t *info)
/* acquire the lock for file system critical section */
down(_fs->v_sem);
 
-   if (p_fs->used_clusters == (u32)~0)
+   if (p_fs->used_clusters == UINT_MAX)
p_fs->used_clusters = p_fs->fs_func->count_used_clusters(sb);
 
info->FatType = p_fs->vol_type;
@@ -3503,7 +3503,7 @@ static int exfat_statfs(struct dentry *dentry, struct 
kstatfs *buf)
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
struct vol_info_t info;
 
-   if (p_fs->used_clusters == (u32)~0) {
+   if (p_fs->used_clusters == UINT_MAX) {
if (ffsGetVolInfo(sb, ) == FFS_MEDIAERR)
return -EIO;
 
@@ -3678,7 +3678,7 @@ static int parse_options(char *options, int silent, int 
*debug,
opts->fs_uid = current_uid();
opts->fs_gid = current_gid();
opts->fs_fmask = opts->fs_dmask = current->fs->umask;
-   opts->allow_utime = (unsigned short)-1;
+   opts->allow_utime = U16_

[PATCH] staging: exfat: add millisecond support

2019-09-08 Thread Valentin Vidic
Drop duplicated date_time_t struct and add millisecond handling for
create and modify time. Also drop millisecond field for access time
since it is not defined in the the spec.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h   |  38 +++---
 drivers/staging/exfat/exfat_core.c  |  31 -
 drivers/staging/exfat/exfat_super.c | 174 
 3 files changed, 92 insertions(+), 151 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 0aa14dea4e09..6491ea034928 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -241,16 +241,6 @@ static inline u16 get_row_index(u16 i)
 #define UNI_PAR_DIR_NAME"\0.\0."
 #endif
 
-struct date_time_t {
-   u16  Year;
-   u16  Month;
-   u16  Day;
-   u16  Hour;
-   u16  Minute;
-   u16  Second;
-   u16  MilliSecond;
-};
-
 struct part_info_t {
u32  Offset;/* start sector number of the partition */
u32  Size;  /* in sectors */
@@ -289,6 +279,16 @@ struct file_id_t {
u32  hint_last_clu;
 };
 
+struct timestamp_t {
+   u16  millisec;   /* 0 ~ 999  */
+   u16  sec;/* 0 ~ 59   */
+   u16  min;/* 0 ~ 59   */
+   u16  hour;   /* 0 ~ 23   */
+   u16  day;/* 1 ~ 31   */
+   u16  mon;/* 1 ~ 12   */
+   u16  year;   /* 0 ~ 127 (since 1980) */
+};
+
 struct dir_entry_t {
char Name[MAX_NAME_LENGTH * MAX_CHARSET_SIZE];
 
@@ -298,18 +298,9 @@ struct dir_entry_t {
u32 Attr;
u64 Size;
u32 NumSubdirs;
-   struct date_time_t CreateTimestamp;
-   struct date_time_t ModifyTimestamp;
-   struct date_time_t AccessTimestamp;
-};
-
-struct timestamp_t {
-   u16  sec;/* 0 ~ 59   */
-   u16  min;/* 0 ~ 59   */
-   u16  hour;   /* 0 ~ 23   */
-   u16  day;/* 1 ~ 31   */
-   u16  mon;/* 1 ~ 12   */
-   u16  year;   /* 0 ~ 127 (since 1980) */
+   struct timestamp_t CreateTimestamp;
+   struct timestamp_t ModifyTimestamp;
+   struct timestamp_t AccessTimestamp;
 };
 
 /* MS_DOS FAT partition boot record (512 bytes) */
@@ -453,8 +444,7 @@ struct file_dentry_t {
u8   access_date[2];
u8   create_time_ms;
u8   modify_time_ms;
-   u8   access_time_ms;
-   u8   reserved2[9];
+   u8   reserved2[10];
 };
 
 /* MS-DOS EXFAT stream extension directory entry (32 bytes) */
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 995358cc7c79..e87119fa8c0a 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1139,6 +1139,7 @@ void exfat_set_entry_size(struct dentry_t *p_entry, u64 
size)
 void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
u8 mode)
 {
+   u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry;
 
@@ -1146,6 +1147,7 @@ void fat_get_entry_time(struct dentry_t *p_entry, struct 
timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+   ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
@@ -1159,11 +1161,17 @@ void fat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
tp->day  = (d & 0x001F);
tp->mon  = (d >> 5) & 0x000F;
tp->year = (d >> 9);
+
+   if (ms >= 1000) {
+   ms -= 1000;
+   tp->sec++;
+   }
 }
 
 void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp,
  u8 mode)
 {
+   u8 ms = 0;
u16 t = 0x00, d = 0x21;
struct file_dentry_t *ep = (struct file_dentry_t *)p_entry;
 
@@ -1171,10 +1179,12 @@ void exfat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
case TM_CREATE:
t = GET16_A(ep->create_time);
d = GET16_A(ep->create_date);
+   ms = ep->create_time_ms * 10;
break;
case TM_MODIFY:
t = GET16_A(ep->modify_time);
d = GET16_A(ep->modify_date);
+   ms = ep->modify_time_ms * 10;
break;
case TM_ACCESS:
t = GET16_A(ep->access_time);
@@ -1188,21 +1198,33 @@ void exfat_get_entry_time(struct dentry_t *p_entry, 
struct timestamp_t *tp,
tp->day  = (d & 0x001F);
tp->mon  = (d >> 5) & 0x000F;
tp

[PATCH 2/2 v2] staging: exfat: cleanup casts

2019-09-07 Thread Valentin Vidic
Use constants and fix checkpatch.pl warnings:

  CHECK: No space is necessary after a cast

Signed-off-by: Valentin Vidic 
---
v2: Use constants where possible

 drivers/staging/exfat/exfat_core.c  | 94 ++---
 drivers/staging/exfat/exfat_super.c | 66 ++--
 2 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 8fb4ce16010c..6eee2aa06bd7 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -204,7 +204,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -215,7 +215,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
}
 
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -273,7 +273,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -293,7 +293,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
 
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -337,7 +337,7 @@ void fat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
 
} while (clu != CLUSTER_32(~0));
 
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -396,7 +396,7 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
} while ((clu != CLUSTER_32(0)) && (clu != CLUSTER_32(~0)));
}
 
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != UINT_MAX)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -473,7 +473,7 @@ s32 exfat_count_used_clusters(struct super_block *sb)
map_i = map_b = 0;
 
for (i = 2; i < p_fs->num_clusters; i += 8) {
-   k = *(((u8 *) p_fs->vol_amap[map_i]->b_data) + map_b);
+   k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b);
count += used_bit[k];
 
if ((++map_b) >= p_bd->sector_size) {
@@ -536,7 +536,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
 
if (ep->flags == 0x0) {
p_fs->map_clu  = GET32_A(ep->start_clu);
-   map_size = (u32) GET64_A(ep->size);
+   map_size = (u32)GET64_A(ep->size);
 
p_fs->map_sectors = ((map_size - 1) >> 
p_bd->sector_size_bits) + 1;
 
@@ -601,7 +601,7 @@ s32 set_alloc_bitmap(struct super_block *sb, u32 clu)
 
sector = START_SECTOR(p_fs->map_clu) + i;
 
-   exfat_bitmap_set((u8 *) p_fs->vol_amap[i]->b_data, b);
+   exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b);
 
return sector_write(sb, sector, p_fs->vol_amap[i], 0);
 }
@@ -623,7 +623,7 @@ s32 clr_alloc_bitmap(struct super_block *sb, u32 clu)
 
sector = START_SECTOR(p_fs->map_clu) + i;
 
-   exfat_bitmap_clear((u8 *) p_fs->vol_amap[i]->b_data, b);
+   exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b);
 
return sector_write(sb, sector, p_fs->vol_amap[i], 0);
 
@@ -655,7 +655,7 @@ u32 test_alloc_bitmap(struct super_block *sb, u32 clu)
map_b = (clu >> 3) & p_bd->sector_size_mask;
 
for (i = 2; i < p_fs->num_clusters; i += 8) {
-   k = *(((u8 *) p_fs->vol_amap[map_i]->b_data) + map_b);
+   k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b);
if (clu_mask > 0) {
k |= clu_mask;
clu_mask = 0;
@@ -728,7 +728,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
sector++;
 
for (i = 0; i < p_bd->sector_size && index <= 

[PATCH 1/2] staging: exfat: cleanup spacing for operators

2019-09-07 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: spaces preferred around that '-' (ctx:VxV)
  CHECK: spaces preferred around that '+' (ctx:VxV)
  CHECK: spaces preferred around that '*' (ctx:VxV)
  CHECK: spaces preferred around that '|' (ctx:VxV)

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h   |  2 +-
 drivers/staging/exfat/exfat_core.c  | 76 ++---
 drivers/staging/exfat/exfat_super.c | 44 -
 3 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 0aa14dea4e09..6c12f2d79f4d 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -159,7 +159,7 @@
 /* Upcase table macro */
 #define HIGH_INDEX_BIT (8)
 #define HIGH_INDEX_MASK(0xFF00)
-#define LOW_INDEX_BIT  (16-HIGH_INDEX_BIT)
+#define LOW_INDEX_BIT  (16 - HIGH_INDEX_BIT)
 #define UTBL_ROW_COUNT BIT(LOW_INDEX_BIT)
 #define UTBL_COL_COUNT BIT(HIGH_INDEX_BIT)
 
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 995358cc7c79..8fb4ce16010c 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -230,7 +230,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
hint_clu = p_chain->dir;
if (hint_clu == CLUSTER_32(~0)) {
-   hint_clu = test_alloc_bitmap(sb, p_fs->clu_srch_ptr-2);
+   hint_clu = test_alloc_bitmap(sb, p_fs->clu_srch_ptr - 2);
if (hint_clu == CLUSTER_32(~0))
return 0;
} else if (hint_clu >= p_fs->num_clusters) {
@@ -242,7 +242,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
p_chain->dir = CLUSTER_32(~0);
 
-   while ((new_clu = test_alloc_bitmap(sb, hint_clu-2)) != CLUSTER_32(~0)) 
{
+   while ((new_clu = test_alloc_bitmap(sb, hint_clu - 2)) != 
CLUSTER_32(~0)) {
if (new_clu != hint_clu) {
if (p_chain->flags == 0x03) {
exfat_chain_cont_cluster(sb, p_chain->dir,
@@ -251,7 +251,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
}
 
-   if (set_alloc_bitmap(sb, new_clu-2) != FFS_SUCCESS)
+   if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS)
return -1;
 
num_clusters++;
@@ -324,7 +324,7 @@ void fat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
if (do_relse) {
sector = START_SECTOR(clu);
for (i = 0; i < p_fs->sectors_per_clu; i++)
-   buf_release(sb, sector+i);
+   buf_release(sb, sector + i);
}
 
prev = clu;
@@ -367,10 +367,10 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
if (do_relse) {
sector = START_SECTOR(clu);
for (i = 0; i < p_fs->sectors_per_clu; i++)
-   buf_release(sb, sector+i);
+   buf_release(sb, sector + i);
}
 
-   if (clr_alloc_bitmap(sb, clu-2) != FFS_SUCCESS)
+   if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
break;
clu++;
 
@@ -384,10 +384,10 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
if (do_relse) {
sector = START_SECTOR(clu);
for (i = 0; i < p_fs->sectors_per_clu; i++)
-   buf_release(sb, sector+i);
+   buf_release(sb, sector + i);
}
 
-   if (clr_alloc_bitmap(sb, clu-2) != FFS_SUCCESS)
+   if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
break;
 
if (FAT_read(sb, clu, ) == -1)
@@ -491,7 +491,7 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 
chain, s32 len)
return;
 
while (len > 1) {
-   if (FAT_write(sb, chain, chain+1) < 0)
+   if (FAT_write(sb, chain, chain + 1) < 0)
break;
chain++;
len--;
@@ -538,7 +538,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
p_fs->map_clu  = GET32_A(ep->start_clu);
map_size = (u32) GET64_A(ep->size);
 
-   p_fs->map_sectors = ((map_size-1) >> 
p_bd->sector_size_bits) + 1;
+   p_fs->map_sectors = ((map_size - 1) >> 
p_bd->sect

[PATCH 2/2] staging: exfat: cleanup spacing for casts

2019-09-07 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: No space is necessary after a cast

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 88 ++---
 drivers/staging/exfat/exfat_super.c | 66 +++---
 2 files changed, 77 insertions(+), 77 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 8fb4ce16010c..64b89ae5af84 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -204,7 +204,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -215,7 +215,7 @@ s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc,
}
 
p_fs->clu_srch_ptr = new_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
return num_clusters;
@@ -273,7 +273,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
 
if ((--num_alloc) == 0) {
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -293,7 +293,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
 
p_fs->clu_srch_ptr = hint_clu;
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters += num_clusters;
 
p_chain->size += num_clusters;
@@ -337,7 +337,7 @@ void fat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
 
} while (clu != CLUSTER_32(~0));
 
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -396,7 +396,7 @@ void exfat_free_cluster(struct super_block *sb, struct 
chain_t *p_chain,
} while ((clu != CLUSTER_32(0)) && (clu != CLUSTER_32(~0)));
}
 
-   if (p_fs->used_clusters != (u32) ~0)
+   if (p_fs->used_clusters != (u32)~0)
p_fs->used_clusters -= num_clusters;
 }
 
@@ -473,7 +473,7 @@ s32 exfat_count_used_clusters(struct super_block *sb)
map_i = map_b = 0;
 
for (i = 2; i < p_fs->num_clusters; i += 8) {
-   k = *(((u8 *) p_fs->vol_amap[map_i]->b_data) + map_b);
+   k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b);
count += used_bit[k];
 
if ((++map_b) >= p_bd->sector_size) {
@@ -536,7 +536,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
 
if (ep->flags == 0x0) {
p_fs->map_clu  = GET32_A(ep->start_clu);
-   map_size = (u32) GET64_A(ep->size);
+   map_size = (u32)GET64_A(ep->size);
 
p_fs->map_sectors = ((map_size - 1) >> 
p_bd->sector_size_bits) + 1;
 
@@ -601,7 +601,7 @@ s32 set_alloc_bitmap(struct super_block *sb, u32 clu)
 
sector = START_SECTOR(p_fs->map_clu) + i;
 
-   exfat_bitmap_set((u8 *) p_fs->vol_amap[i]->b_data, b);
+   exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b);
 
return sector_write(sb, sector, p_fs->vol_amap[i], 0);
 }
@@ -623,7 +623,7 @@ s32 clr_alloc_bitmap(struct super_block *sb, u32 clu)
 
sector = START_SECTOR(p_fs->map_clu) + i;
 
-   exfat_bitmap_clear((u8 *) p_fs->vol_amap[i]->b_data, b);
+   exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b);
 
return sector_write(sb, sector, p_fs->vol_amap[i], 0);
 
@@ -655,7 +655,7 @@ u32 test_alloc_bitmap(struct super_block *sb, u32 clu)
map_b = (clu >> 3) & p_bd->sector_size_mask;
 
for (i = 2; i < p_fs->num_clusters; i += 8) {
-   k = *(((u8 *) p_fs->vol_amap[map_i]->b_data) + map_b);
+   k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b);
if (clu_mask > 0) {
k |= clu_mask;
clu_mask = 0;
@@ -728,7 +728,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
sector++;
 
for (i = 0; i < p_bd->sector_size && index <= 0x; i += 2) {
-   uni = GET16

[PATCH v2] staging: exfat: cleanup explicit comparisons to NULL

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Comparison to NULL could be written "expr"
  CHECK: Comparison to NULL could be written "!expr"

Signed-off-by: Valentin Vidic 
---
v2: fix gcc warning in strsep call

 drivers/staging/exfat/exfat_core.c  | 34 -
 drivers/staging/exfat/exfat_super.c | 58 ++---
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index da8c58149c35..995358cc7c79 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -100,7 +100,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag)
p_fs->vol_flag = new_flag;
 
if (p_fs->vol_type == EXFAT) {
-   if (p_fs->pbr_bh == NULL) {
+   if (!p_fs->pbr_bh) {
if (sector_read(sb, p_fs->PBR_sector,
_fs->pbr_bh, 1) != FFS_SUCCESS)
return;
@@ -543,7 +543,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
p_fs->vol_amap = 
kmalloc_array(p_fs->map_sectors,
   sizeof(struct 
buffer_head *),
   GFP_KERNEL);
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return FFS_MEMORYERR;
 
sector = START_SECTOR(p_fs->map_clu);
@@ -685,7 +685,7 @@ void sync_alloc_bitmap(struct super_block *sb)
int i;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
 
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return;
 
for (i = 0; i < p_fs->map_sectors; i++)
@@ -714,7 +714,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -750,11 +750,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,
sizeof(u16), GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -794,7 +794,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -812,12 +812,12 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,

sizeof(u16),

GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -1640,7 +1640,7 @@ struct dentry_t *get_entry_with_sector(struct super_block 
*sb, sector_t sector,
 
buf = buf_getblk(sb, sector);
 
-   if (buf == NULL)
+   if (!buf)
return NULL;
 
return (struct dentry_t *)(buf + offset);
@@ -1658,10 +1658,10 @@ struct dentry_t *get_entry_in_dir(struct super_block 
*sb, struc

[PATCH] staging: exfat: drop local TRUE/FALSE defines

2019-09-03 Thread Valentin Vidic
Replace with bool where it makes sense. Also drop unused local
variable lossy in fat_find_dir_entry.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h   |  3 --
 drivers/staging/exfat/exfat_core.c  | 81 +++--
 drivers/staging/exfat/exfat_nls.c   |  2 +-
 drivers/staging/exfat/exfat_super.c | 18 ---
 4 files changed, 53 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 816681d1103a..0aa14dea4e09 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -86,9 +86,6 @@
 #define CLUSTER_16(x)  ((u16)(x))
 #define CLUSTER_32(x)  ((u32)(x))
 
-#define FALSE  0
-#define TRUE   1
-
 #define START_SECTOR(x)
\
sector_t)((x) - 2)) << p_fs->sectors_per_clu_bits) +\
 p_fs->data_start_sector)
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 1246afcffb8d..1630f16459a3 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -705,7 +705,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
struct buffer_head *tmp_bh = NULL;
sector_t end_sector = num_sectors + sector;
 
-   u8  skip = FALSE;
+   boolskip = false;
u32 index = 0;
u16 uni = 0;
u16 **upcase_table;
@@ -742,11 +742,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
index += uni;
pr_debug("to 0x%X (amount of 0x%X)\n",
 index, uni);
-   skip = FALSE;
+   skip = false;
} else if (uni == index) {
index++;
} else if (uni == 0x) {
-   skip = TRUE;
+   skip = true;
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
@@ -787,7 +787,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
u32 j;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
 
-   u8  skip = FALSE;
+   boolskip = false;
u32 index = 0;
u16 uni = 0;
u16 **upcase_table;
@@ -804,11 +804,11 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
pr_debug("skip from 0x%X ", index);
index += uni;
pr_debug("to 0x%X (amount of 0x%X)\n", index, uni);
-   skip = FALSE;
+   skip = false;
} else if (uni == index) {
index++;
} else if (uni == 0x) {
-   skip = TRUE;
+   skip = true;
} else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
@@ -1399,7 +1399,7 @@ void init_dos_entry(struct dos_dentry_t *ep, u32 type, 
u32 start_clu)
 void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 
*uniname)
 {
int i;
-   u8 end = FALSE;
+   bool end = false;
 
fat_set_entry_type((struct dentry_t *) ep, TYPE_EXTEND);
ep->order = (u8) order;
@@ -1411,7 +1411,7 @@ void init_ext_entry(struct ext_dentry_t *ep, s32 order, 
u8 chksum, u16 *uniname)
if (!end) {
SET16(ep->unicode_0_4+i, *uniname);
if (*uniname == 0x0)
-   end = TRUE;
+   end = true;
else
uniname++;
} else {
@@ -1423,7 +1423,7 @@ void init_ext_entry(struct ext_dentry_t *ep, s32 order, 
u8 chksum, u16 *uniname)
if (!end) {
SET16_A(ep->unicode_5_10 + i, *uniname);
if (*uniname == 0x0)
-   end = TRUE;
+   end = true;
else
uniname++;
} else {
@@ -1435,7 +1435,7 @@ void init_ext_entry(struct ext_dentry_t *ep, s32 order, 
u8 chksum, u16 *uniname)
if (!end) {
SET16_A(ep->unicode_11_12 + i, *uniname);
if (*uniname == 0x0)
-   end = TRUE;
+   end = true;
else
uniname++;
} else {
@@ -2146,8 +2146,9 @@ s32 fat_find_dir_entry(struct super_block *sb, struct 
chain_t *p_dir,
   struct uni_name

[PATCH] staging: exfat: cleanup explicit comparisons to NULL

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Comparison to NULL could be written "expr"
  CHECK: Comparison to NULL could be written "!expr"

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 34 -
 drivers/staging/exfat/exfat_super.c | 58 ++---
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 46b9f4455da1..7b39544cdaf1 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -100,7 +100,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag)
p_fs->vol_flag = new_flag;
 
if (p_fs->vol_type == EXFAT) {
-   if (p_fs->pbr_bh == NULL) {
+   if (!p_fs->pbr_bh) {
if (sector_read(sb, p_fs->PBR_sector,
_fs->pbr_bh, 1) != FFS_SUCCESS)
return;
@@ -543,7 +543,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
p_fs->vol_amap = 
kmalloc_array(p_fs->map_sectors,
   sizeof(struct 
buffer_head *),
   GFP_KERNEL);
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return FFS_MEMORYERR;
 
sector = START_SECTOR(p_fs->map_clu);
@@ -685,7 +685,7 @@ void sync_alloc_bitmap(struct super_block *sb)
int i;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
 
-   if (p_fs->vol_amap == NULL)
+   if (!p_fs->vol_amap)
return;
 
for (i = 0; i < p_fs->map_sectors; i++)
@@ -714,7 +714,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -750,11 +750,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,
sizeof(u16), GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -794,7 +794,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
 
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
-   if (upcase_table == NULL)
+   if (!upcase_table)
return FFS_MEMORYERR;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
@@ -812,12 +812,12 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
pr_debug("alloc = 0x%X\n", col_index);
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,

sizeof(u16),

GFP_KERNEL);
-   if (upcase_table[col_index] == NULL) {
+   if (!upcase_table[col_index]) {
ret = FFS_MEMORYERR;
goto error;
}
@@ -1640,7 +1640,7 @@ struct dentry_t *get_entry_with_sector(struct super_block 
*sb, sector_t sector,
 
buf = buf_getblk(sb, sector);
 
-   if (buf == NULL)
+   if (!buf)
return NULL;
 
return (struct dentry_t *)(buf + offset);
@@ -1658,10 +1658,10 @@ struct dentry_t *get_entry_in_dir(struct super_block 
*sb, struct chain_t *p_dir,
 
b

[PATCH] staging: exfat: fix spelling errors in comments

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: 'consistancy' may be misspelled - perhaps 'consistency'?
  CHECK: 'stuct' may be misspelled - perhaps 'struct'?

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 2 +-
 drivers/staging/exfat/exfat_super.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 46b9f4455da1..67e43499d522 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -1754,7 +1754,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct 
super_block *sb,
while (num_entries) {
/*
 * instead of copying whole sector, we will check every entry.
-* this will provide minimum stablity and consistancy.
+* this will provide minimum stablity and consistency.
 */
entry_type = p_fs->fs_func->get_entry_type(ep);
 
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 881cd85cf677..56d673ecb70c 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -480,7 +480,7 @@ static int ffsMountVol(struct super_block *sb)
goto out;
}
 
-   /* fill fs_stuct */
+   /* fill fs_struct */
for (i = 0; i < 53; i++)
if (p_pbr->bpb[i])
break;
-- 
2.20.1



[PATCH] staging: exfat: cleanup braces for if/else statements

2019-09-03 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Unbalanced braces around else statement
  CHECK: braces {} should be used on all arms of this statement

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat_core.c  | 12 ++--
 drivers/staging/exfat/exfat_super.c | 16 +---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 46b9f4455da1..1246afcffb8d 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -743,11 +743,11 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
pr_debug("to 0x%X (amount of 0x%X)\n",
 index, uni);
skip = FALSE;
-   } else if (uni == index)
+   } else if (uni == index) {
index++;
-   else if (uni == 0x)
+   } else if (uni == 0x) {
skip = TRUE;
-   else { /* uni != index , uni != 0x */
+   } else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
if (upcase_table[col_index] == NULL) {
@@ -805,11 +805,11 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
index += uni;
pr_debug("to 0x%X (amount of 0x%X)\n", index, uni);
skip = FALSE;
-   } else if (uni == index)
+   } else if (uni == index) {
index++;
-   else if (uni == 0x)
+   } else if (uni == 0x) {
skip = TRUE;
-   else { /* uni != index , uni != 0x */
+   } else { /* uni != index , uni != 0x */
u16 col_index = get_col_index(index);
 
if (upcase_table[col_index] == NULL) {
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 881cd85cf677..e44b860e35e8 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -344,8 +344,10 @@ static int exfat_cmpi(const struct dentry *dentry, 
unsigned int len,
if (t == NULL) {
if (strncasecmp(name->name, str, alen) == 0)
return 0;
-   } else if (nls_strnicmp(t, name->name, str, alen) == 0)
-   return 0;
+   } else {
+   if (nls_strnicmp(t, name->name, str, alen) == 0)
+   return 0;
+   }
}
return 1;
 }
@@ -999,7 +1001,7 @@ static int ffsWriteFile(struct inode *inode, struct 
file_id_t *fid,
   _clu);
if (num_alloced == 0)
break;
-   else if (num_alloced < 0) {
+   if (num_alloced < 0) {
ret = FFS_MEDIAERR;
goto out;
}
@@ -1248,9 +1250,9 @@ static int ffsTruncateFile(struct inode *inode, u64 
old_size, u64 new_size)
p_fs->fs_func->set_entry_clu0(ep2, CLUSTER_32(0));
}
 
-   if (p_fs->vol_type != EXFAT)
+   if (p_fs->vol_type != EXFAT) {
buf_modify(sb, sector);
-   else {
+   } else {
update_dir_checksum_with_entry_set(sb, es);
release_entry_set(es);
}
@@ -1561,9 +1563,9 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
fid->attr = attr;
p_fs->fs_func->set_entry_attr(ep, attr);
 
-   if (p_fs->vol_type != EXFAT)
+   if (p_fs->vol_type != EXFAT) {
buf_modify(sb, sector);
-   else {
+   } else {
update_dir_checksum_with_entry_set(sb, es);
release_entry_set(es);
}
-- 
2.20.1



[PATCH] staging: exfat: cleanup blank line warnings

2019-09-02 Thread Valentin Vidic
Fixes checkpatch.pl warnings:

  CHECK: Please don't use multiple blank lines
  CHECK: Blank lines aren't necessary after an open brace '{'
  CHECK: Please use a blank line after function/struct/union/enum
 declarations

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h   | 1 +
 drivers/staging/exfat/exfat_core.c  | 4 
 drivers/staging/exfat/exfat_super.c | 1 -
 3 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index bae180e10609..e41754bbdeab 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -170,6 +170,7 @@ static inline u16 get_col_index(u16 i)
 {
return i >> LOW_INDEX_BIT;
 }
+
 static inline u16 get_row_index(u16 i)
 {
return i & ~HIGH_INDEX_MASK;
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 9f76ca175c80..46b9f4455da1 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -11,7 +11,6 @@
 #include 
 #include "exfat.h"
 
-
 static void __set_sb_dirty(struct super_block *sb)
 {
struct exfat_sb_info *sbi = EXFAT_SB(sb);
@@ -1711,7 +1710,6 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct 
super_block *sb,
if (ret != FFS_SUCCESS)
return NULL;
 
-
/* byte offset in cluster */
byte_offset &= p_fs->cluster_size - 1;
 
@@ -1726,7 +1724,6 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct 
super_block *sb,
if (buf == NULL)
goto err_out;
 
-
ep = (struct dentry_t *)(buf + off);
entry_type = p_fs->fs_func->get_entry_type(ep);
 
@@ -1853,7 +1850,6 @@ void release_entry_set(struct entry_set_cache_t *es)
kfree(es);
 }
 
-
 static s32 __write_partial_entries_in_entry_set(struct super_block *sb,
struct entry_set_cache_t *es,
sector_t sec, s32 off, u32 
count)
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index d9787635a373..15970b34e38f 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -3017,7 +3017,6 @@ static void exfat_truncate(struct inode *inode, loff_t 
old_size)
 
 static int exfat_setattr(struct dentry *dentry, struct iattr *attr)
 {
-
struct exfat_sb_info *sbi = EXFAT_SB(dentry->d_sb);
struct inode *inode = dentry->d_inode;
unsigned int ia_valid;
-- 
2.20.1



[PATCH] staging: exfat: use BIT macro for defining sizes

2019-09-02 Thread Valentin Vidic
Fixes checkpatch.pl warning:

  CHECK: Prefer using the BIT macro

Signed-off-by: Valentin Vidic 
---
 drivers/staging/exfat/exfat.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index bae180e10609..f71d4e8c0c8e 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -163,8 +163,8 @@
 #define HIGH_INDEX_BIT (8)
 #define HIGH_INDEX_MASK(0xFF00)
 #define LOW_INDEX_BIT  (16-HIGH_INDEX_BIT)
-#define UTBL_ROW_COUNT (1<

Re: [PATCH] n_tty: update comment for WAKEUP_CHARS define

2019-01-02 Thread Valentin Vidic
On Wed, Jan 02, 2019 at 07:48:42AM +0100, Jiri Slaby wrote:
> On 29. 12. 18, 13:48, Valentin Vidic wrote:
> > Give a better descriptions of what WAKEUP_CHARS represents.
> > 
> > Signed-off-by: Valentin Vidic 
> 
> I am not a native speaker, but this is much better than the current text.
> 
> Acked-by: Jiri Slaby 
> 
> BTW this text is copy from/to all the other WAKEUP_CHARS
> locations. Care to fix them all?

Yes, I've seen other instances of WAKEUP_CHARS but they don't look like
the same thing, for example:

rocket_int.h:/* number of characters left in xmit buffer before we ask for more 
*/
rocket_int.h:#define WAKEUP_CHARS 256

rocket.c:   if (info->xmit_cnt < WAKEUP_CHARS) {
rocket.c:   tty_wakeup(tty);

Maybe the instance in n_tty.c could use a better name instead?

-- 
Valentin


[PATCH] n_tty: update comment for WAKEUP_CHARS define

2018-12-29 Thread Valentin Vidic
Give a better descriptions of what WAKEUP_CHARS represents.

Signed-off-by: Valentin Vidic 
---
 drivers/tty/n_tty.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 3ad460219fd6..1dfbd45746da 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -50,8 +50,10 @@
 #include 
 #include 
 
-
-/* number of characters left in xmit buffer before select has we have room */
+/*
+ * Until this number of characters is queued in the xmit buffer, select will
+ * return "we have room for writes".
+ */
 #define WAKEUP_CHARS 256
 
 /*
-- 
2.20.1



Re: [PATCH] xen-blkback: Switch to closed state after releasing the backing device

2018-09-05 Thread Valentin Vidic
On Wed, Sep 05, 2018 at 01:35:15PM +0200, Valentin Vidic wrote:
> > AFAICT, this will cause the backend to never switch to 'Closed' state
> > until the toolstack sets online to 0, which is not good IMO.
> > 
> > If for example a frontend decides to close a device, the backend will
> > stay in state 'Closing' until the toolstack actually removes the disk
> > by setting online to 0.
> > 
> > This will prevent resetting blk connections, as blkback will refuse to
> > switch to state XenbusStateInitWait unless it's at XenbusStateClosed
> > (see the XenbusStateInitialising case in frontend_changed), which will
> > never be reached with your patch.

Would it be possible to call xen_vbd_free before the state change?

case XenbusStateClosed:
xen_blkif_disconnect(be->blkif);
xen_vbd_free(>blkif->vbd);
xenbus_switch_state(dev, XenbusStateClosed);

-- 
Valentin


Re: [PATCH] xen-blkback: Switch to closed state after releasing the backing device

2018-09-05 Thread Valentin Vidic
On Wed, Sep 05, 2018 at 01:35:15PM +0200, Valentin Vidic wrote:
> > AFAICT, this will cause the backend to never switch to 'Closed' state
> > until the toolstack sets online to 0, which is not good IMO.
> > 
> > If for example a frontend decides to close a device, the backend will
> > stay in state 'Closing' until the toolstack actually removes the disk
> > by setting online to 0.
> > 
> > This will prevent resetting blk connections, as blkback will refuse to
> > switch to state XenbusStateInitWait unless it's at XenbusStateClosed
> > (see the XenbusStateInitialising case in frontend_changed), which will
> > never be reached with your patch.

Would it be possible to call xen_vbd_free before the state change?

case XenbusStateClosed:
xen_blkif_disconnect(be->blkif);
xen_vbd_free(>blkif->vbd);
xenbus_switch_state(dev, XenbusStateClosed);

-- 
Valentin


[PATCH] staging: pi433: cleanup comments in rf69.h

2018-06-25 Thread Valentin Vidic
Fixes checkpatch warning:

  WARNING: line over 80 characters

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index c131ffbdc2db..d80c41966d39 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -20,10 +20,11 @@
 #include "rf69_enum.h"
 #include "rf69_registers.h"
 
-#define F_OSC  3200  /* in Hz */
-#define FREQUENCY  43392 /* in Hz, modifying this value impacts CE 
certification */
-#define FIFO_SIZE  66  /* in byte */
-#define FIFO_THRESHOLD 15  /* in byte */
+/* NOTE: Modifying FREQUENCY value impacts CE certification */
+#define F_OSC  3200/* Hz */
+#define FREQUENCY  43392   /* Hz */
+#define FIFO_SIZE  66  /* bytes */
+#define FIFO_THRESHOLD 15  /* bytes */
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
-- 
2.18.0.rc2



[PATCH] staging: pi433: cleanup comments in rf69.h

2018-06-25 Thread Valentin Vidic
Fixes checkpatch warning:

  WARNING: line over 80 characters

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index c131ffbdc2db..d80c41966d39 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -20,10 +20,11 @@
 #include "rf69_enum.h"
 #include "rf69_registers.h"
 
-#define F_OSC  3200  /* in Hz */
-#define FREQUENCY  43392 /* in Hz, modifying this value impacts CE 
certification */
-#define FIFO_SIZE  66  /* in byte */
-#define FIFO_THRESHOLD 15  /* in byte */
+/* NOTE: Modifying FREQUENCY value impacts CE certification */
+#define F_OSC  3200/* Hz */
+#define FREQUENCY  43392   /* Hz */
+#define FIFO_SIZE  66  /* bytes */
+#define FIFO_THRESHOLD 15  /* bytes */
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
-- 
2.18.0.rc2



[PATCH] staging: pi433: add SPDX-License-Identifier tag

2018-06-25 Thread Valentin Vidic
Use GPL-2.0+ based on the license text in each of the files.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c   | 1 +
 drivers/staging/pi433/pi433_if.h   | 3 ++-
 drivers/staging/pi433/rf69.c   | 1 +
 drivers/staging/pi433/rf69.h   | 3 ++-
 drivers/staging/pi433/rf69_enum.h  | 3 ++-
 drivers/staging/pi433/rf69_registers.h | 3 ++-
 6 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index b061f77dda41..e2b8a518dafe 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * userspace interface for pi433 radio module
  *
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index b6e214c29ddf..0e0c1b0ab1a6 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * include/linux/TODO
  *
  * userspace interface for pi433 radio module
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..e4a1e64c868a 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * abstraction of the spi interface of HopeRf rf69 radio module
  *
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index c131ffbdc2db..2cec9a9c34d2 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * hardware abstraction/register access for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 493bd0025453..de3b7e32dad7 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * enumerations for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
diff --git a/drivers/staging/pi433/rf69_registers.h 
b/drivers/staging/pi433/rf69_registers.h
index 33fd91518bb0..ea19c1ca7509 100644
--- a/drivers/staging/pi433/rf69_registers.h
+++ b/drivers/staging/pi433/rf69_registers.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * register description for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
-- 
2.18.0.rc2



[PATCH] staging: pi433: add SPDX-License-Identifier tag

2018-06-25 Thread Valentin Vidic
Use GPL-2.0+ based on the license text in each of the files.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c   | 1 +
 drivers/staging/pi433/pi433_if.h   | 3 ++-
 drivers/staging/pi433/rf69.c   | 1 +
 drivers/staging/pi433/rf69.h   | 3 ++-
 drivers/staging/pi433/rf69_enum.h  | 3 ++-
 drivers/staging/pi433/rf69_registers.h | 3 ++-
 6 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index b061f77dda41..e2b8a518dafe 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * userspace interface for pi433 radio module
  *
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index b6e214c29ddf..0e0c1b0ab1a6 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * include/linux/TODO
  *
  * userspace interface for pi433 radio module
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..e4a1e64c868a 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * abstraction of the spi interface of HopeRf rf69 radio module
  *
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index c131ffbdc2db..2cec9a9c34d2 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * hardware abstraction/register access for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 493bd0025453..de3b7e32dad7 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * enumerations for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
diff --git a/drivers/staging/pi433/rf69_registers.h 
b/drivers/staging/pi433/rf69_registers.h
index 33fd91518bb0..ea19c1ca7509 100644
--- a/drivers/staging/pi433/rf69_registers.h
+++ b/drivers/staging/pi433/rf69_registers.h
@@ -1,4 +1,5 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0+
+ *
  * register description for HopeRf rf69 radio module
  *
  * Copyright (C) 2016 Wolf-Entwicklungen
-- 
2.18.0.rc2



[PATCH v3] staging: pi433: replace simple switch statements

2018-06-24 Thread Valentin Vidic
Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic 
---
v2: use correct type for const arrays
v3: add missing static keyword for af_map

 drivers/staging/pi433/rf69.c | 233 ++-
 1 file changed, 93 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..341d6901a801 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg,
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   switch (mode) {
-   case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_TRANSMIT);
-   case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_RECEIVE);
-   case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SYNTHESIZER);
-   case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_STANDBY);
-   case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SLEEP);
-   default:
+   static const u8 mode_map[] = {
+   [transmit] = OPMODE_MODE_TRANSMIT,
+   [receive] = OPMODE_MODE_RECEIVE,
+   [synthesizer] = OPMODE_MODE_SYNTHESIZER,
+   [standby] = OPMODE_MODE_STANDBY,
+   [mode_sleep] = OPMODE_MODE_SLEEP,
+   };
+
+   if (unlikely(mode >= ARRAY_SIZE(mode_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  mode_map[mode]);
+
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
@@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8 
data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   switch (modulation) {
-   case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_OOK);
-   case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_FSK);
-   default:
+   static const u8 modulation_map[] = {
+   [OOK] = DATAMODUL_MODULATION_TYPE_OOK,
+   [FSK] = DATAMODUL_MODULATION_TYPE_FSK,
+   };
+
+   if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
+
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  modulation_map[modulation]);
 }
 
 static enum modulation rf69_get_modulation(struct spi_device *spi)
@@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, 
u8 power_level)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (pa_ramp) {
-   case ramp3400:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
-   case ramp2000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
-   case ramp1000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
-   case ramp500:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
-   case ramp250:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
-   case ramp125:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
-   case ramp100:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
-   case ramp62:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
-   case ramp50:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
-   case ramp40:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
-   case ramp31:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_31);
-   case ramp25:
-   retu

[PATCH v3] staging: pi433: replace simple switch statements

2018-06-24 Thread Valentin Vidic
Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic 
---
v2: use correct type for const arrays
v3: add missing static keyword for af_map

 drivers/staging/pi433/rf69.c | 233 ++-
 1 file changed, 93 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..341d6901a801 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg,
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   switch (mode) {
-   case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_TRANSMIT);
-   case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_RECEIVE);
-   case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SYNTHESIZER);
-   case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_STANDBY);
-   case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SLEEP);
-   default:
+   static const u8 mode_map[] = {
+   [transmit] = OPMODE_MODE_TRANSMIT,
+   [receive] = OPMODE_MODE_RECEIVE,
+   [synthesizer] = OPMODE_MODE_SYNTHESIZER,
+   [standby] = OPMODE_MODE_STANDBY,
+   [mode_sleep] = OPMODE_MODE_SLEEP,
+   };
+
+   if (unlikely(mode >= ARRAY_SIZE(mode_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  mode_map[mode]);
+
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
@@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8 
data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   switch (modulation) {
-   case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_OOK);
-   case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_FSK);
-   default:
+   static const u8 modulation_map[] = {
+   [OOK] = DATAMODUL_MODULATION_TYPE_OOK,
+   [FSK] = DATAMODUL_MODULATION_TYPE_FSK,
+   };
+
+   if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
+
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  modulation_map[modulation]);
 }
 
 static enum modulation rf69_get_modulation(struct spi_device *spi)
@@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, 
u8 power_level)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (pa_ramp) {
-   case ramp3400:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
-   case ramp2000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
-   case ramp1000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
-   case ramp500:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
-   case ramp250:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
-   case ramp125:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
-   case ramp100:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
-   case ramp62:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
-   case ramp50:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
-   case ramp40:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
-   case ramp31:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_31);
-   case ramp25:
-   retu

[PATCH v2] staging: pi433: replace simple switch statements

2018-06-24 Thread Valentin Vidic
Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic 
---
v2: use correct type for const arrays

 drivers/staging/pi433/rf69.c | 233 ++-
 1 file changed, 93 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..6bfffe8b8bae 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg,
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   switch (mode) {
-   case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_TRANSMIT);
-   case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_RECEIVE);
-   case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SYNTHESIZER);
-   case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_STANDBY);
-   case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SLEEP);
-   default:
+   static const u8 mode_map[] = {
+   [transmit] = OPMODE_MODE_TRANSMIT,
+   [receive] = OPMODE_MODE_RECEIVE,
+   [synthesizer] = OPMODE_MODE_SYNTHESIZER,
+   [standby] = OPMODE_MODE_STANDBY,
+   [mode_sleep] = OPMODE_MODE_SLEEP,
+   };
+
+   if (unlikely(mode >= ARRAY_SIZE(mode_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  mode_map[mode]);
+
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
@@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8 
data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   switch (modulation) {
-   case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_OOK);
-   case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_FSK);
-   default:
+   static const u8 modulation_map[] = {
+   [OOK] = DATAMODUL_MODULATION_TYPE_OOK,
+   [FSK] = DATAMODUL_MODULATION_TYPE_FSK,
+   };
+
+   if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
+
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  modulation_map[modulation]);
 }
 
 static enum modulation rf69_get_modulation(struct spi_device *spi)
@@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, 
u8 power_level)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (pa_ramp) {
-   case ramp3400:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
-   case ramp2000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
-   case ramp1000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
-   case ramp500:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
-   case ramp250:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
-   case ramp125:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
-   case ramp100:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
-   case ramp62:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
-   case ramp50:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
-   case ramp40:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
-   case ramp31:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_31);
-   case ramp25:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_25);

[PATCH v2] staging: pi433: replace simple switch statements

2018-06-24 Thread Valentin Vidic
Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic 
---
v2: use correct type for const arrays

 drivers/staging/pi433/rf69.c | 233 ++-
 1 file changed, 93 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..6bfffe8b8bae 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg,
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   switch (mode) {
-   case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_TRANSMIT);
-   case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_RECEIVE);
-   case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SYNTHESIZER);
-   case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_STANDBY);
-   case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SLEEP);
-   default:
+   static const u8 mode_map[] = {
+   [transmit] = OPMODE_MODE_TRANSMIT,
+   [receive] = OPMODE_MODE_RECEIVE,
+   [synthesizer] = OPMODE_MODE_SYNTHESIZER,
+   [standby] = OPMODE_MODE_STANDBY,
+   [mode_sleep] = OPMODE_MODE_SLEEP,
+   };
+
+   if (unlikely(mode >= ARRAY_SIZE(mode_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  mode_map[mode]);
+
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
@@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8 
data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   switch (modulation) {
-   case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_OOK);
-   case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_FSK);
-   default:
+   static const u8 modulation_map[] = {
+   [OOK] = DATAMODUL_MODULATION_TYPE_OOK,
+   [FSK] = DATAMODUL_MODULATION_TYPE_FSK,
+   };
+
+   if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
+
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  modulation_map[modulation]);
 }
 
 static enum modulation rf69_get_modulation(struct spi_device *spi)
@@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, 
u8 power_level)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (pa_ramp) {
-   case ramp3400:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
-   case ramp2000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
-   case ramp1000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
-   case ramp500:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
-   case ramp250:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
-   case ramp125:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
-   case ramp100:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
-   case ramp62:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
-   case ramp50:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
-   case ramp40:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
-   case ramp31:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_31);
-   case ramp25:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_25);

[PATCH] staging: pi433: replace simple switch statements

2018-06-24 Thread Valentin Vidic
Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.c | 233 ++-
 1 file changed, 93 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..1488ffd441df 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg,
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   switch (mode) {
-   case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_TRANSMIT);
-   case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_RECEIVE);
-   case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SYNTHESIZER);
-   case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_STANDBY);
-   case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SLEEP);
-   default:
+   static const int mode_map[] = {
+   [transmit] = OPMODE_MODE_TRANSMIT,
+   [receive] = OPMODE_MODE_RECEIVE,
+   [synthesizer] = OPMODE_MODE_SYNTHESIZER,
+   [standby] = OPMODE_MODE_STANDBY,
+   [mode_sleep] = OPMODE_MODE_SLEEP,
+   };
+
+   if (unlikely(mode >= ARRAY_SIZE(mode_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  mode_map[mode]);
+
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
@@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8 
data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   switch (modulation) {
-   case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_OOK);
-   case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_FSK);
-   default:
+   static const int modulation_map[] = {
+   [OOK] = DATAMODUL_MODULATION_TYPE_OOK,
+   [FSK] = DATAMODUL_MODULATION_TYPE_FSK,
+   };
+
+   if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
+
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  modulation_map[modulation]);
 }
 
 static enum modulation rf69_get_modulation(struct spi_device *spi)
@@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, 
u8 power_level)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (pa_ramp) {
-   case ramp3400:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
-   case ramp2000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
-   case ramp1000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
-   case ramp500:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
-   case ramp250:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
-   case ramp125:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
-   case ramp100:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
-   case ramp62:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
-   case ramp50:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
-   case ramp40:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
-   case ramp31:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_31);
-   case ramp25:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_25);
-   case ramp20:
-   retu

[PATCH] staging: pi433: replace simple switch statements

2018-06-24 Thread Valentin Vidic
Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.c | 233 ++-
 1 file changed, 93 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 90280e9b006d..1488ffd441df 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -111,27 +111,22 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg,
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   switch (mode) {
-   case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_TRANSMIT);
-   case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_RECEIVE);
-   case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SYNTHESIZER);
-   case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_STANDBY);
-   case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
-  OPMODE_MODE_SLEEP);
-   default:
+   static const int mode_map[] = {
+   [transmit] = OPMODE_MODE_TRANSMIT,
+   [receive] = OPMODE_MODE_RECEIVE,
+   [synthesizer] = OPMODE_MODE_SYNTHESIZER,
+   [standby] = OPMODE_MODE_STANDBY,
+   [mode_sleep] = OPMODE_MODE_SLEEP,
+   };
+
+   if (unlikely(mode >= ARRAY_SIZE(mode_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  mode_map[mode]);
+
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
@@ -145,19 +140,19 @@ int rf69_set_data_mode(struct spi_device *spi, u8 
data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   switch (modulation) {
-   case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_OOK);
-   case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL,
-  MASK_DATAMODUL_MODULATION_TYPE,
-  DATAMODUL_MODULATION_TYPE_FSK);
-   default:
+   static const int modulation_map[] = {
+   [OOK] = DATAMODUL_MODULATION_TYPE_OOK,
+   [FSK] = DATAMODUL_MODULATION_TYPE_FSK,
+   };
+
+   if (unlikely(modulation >= ARRAY_SIZE(modulation_map))) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
+
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  modulation_map[modulation]);
 }
 
 static enum modulation rf69_get_modulation(struct spi_device *spi)
@@ -373,43 +368,30 @@ int rf69_set_output_power_level(struct spi_device *spi, 
u8 power_level)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (pa_ramp) {
-   case ramp3400:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
-   case ramp2000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
-   case ramp1000:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_1000);
-   case ramp500:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_500);
-   case ramp250:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_250);
-   case ramp125:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_125);
-   case ramp100:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_100);
-   case ramp62:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_62);
-   case ramp50:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_50);
-   case ramp40:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_40);
-   case ramp31:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_31);
-   case ramp25:
-   return rf69_write_reg(spi, REG_PARAMP, PARAMP_25);
-   case ramp20:
-   retu

Re: rf69_set_deviation in rf69.c (pi433 driver)

2018-06-22 Thread Valentin Vidic
On Thu, Jun 21, 2018 at 10:03:45PM -0400, Hugo Lefeuvre wrote:
> I'll prepare a patch addressing both issues. However I don't own test devices
> so it would be really great if you could test it !

I have two pi433 devices now so I should be able to tests things,
just let me know...

-- 
Valentin


Re: rf69_set_deviation in rf69.c (pi433 driver)

2018-06-22 Thread Valentin Vidic
On Thu, Jun 21, 2018 at 10:03:45PM -0400, Hugo Lefeuvre wrote:
> I'll prepare a patch addressing both issues. However I don't own test devices
> so it would be really great if you could test it !

I have two pi433 devices now so I should be able to tests things,
just let me know...

-- 
Valentin


[PATCH v2] staging: pi433: cleanup tx_fifo locking

2018-04-19 Thread Valentin Vidic
pi433_write requires locking due to multiple writers.  After acquiring
the lock check if enough free space is available in the kfifo to write
the whole message. This check should prevent partial writes to tx_fifo
so kfifo_reset is not needed anymore.

pi433_tx_thread is the only reader so it does not require locking
after kfifo_reset is removed.

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
v2: print a warning if partial fifo write happens

 drivers/staging/pi433/pi433_if.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..2a05eff88469 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
 
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
-   struct mutextx_fifo_lock; // TODO: check, whether necessary 
or obsolete
+   struct mutextx_fifo_lock; /* serialize userspace writers */
struct task_struct  *tx_task_struct;
wait_queue_head_t   tx_wait_queue;
u8  free_in_fifo;
@@ -589,19 +589,15 @@ pi433_tx_thread(void *data)
 * - size of message
 * - message
 */
-   mutex_lock(>tx_fifo_lock);
-
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
@@ -634,7 +630,6 @@ pi433_tx_thread(void *data)
   sizeof(device->buffer) - position);
dev_dbg(device->dev,
"read %d message byte(s) from fifo queue.", retval);
-   mutex_unlock(>tx_fifo_lock);
 
/* if rx is active, we need to interrupt the waiting for
 * incoming telegrams, to be able to send something.
@@ -818,7 +813,7 @@ pi433_write(struct file *filp, const char __user *buf,
struct pi433_instance   *instance;
struct pi433_device *device;
int retval;
-   unsigned intcopied;
+   unsigned intrequired, available, copied;
 
instance = filp->private_data;
device = instance->device;
@@ -833,6 +828,16 @@ pi433_write(struct file *filp, const char __user *buf,
 * - message
 */
mutex_lock(>tx_fifo_lock);
+
+   required = sizeof(instance->tx_cfg) + sizeof(size_t) + count;
+   available = kfifo_avail(>tx_fifo);
+   if (required > available) {
+   dev_dbg(device->dev, "write to fifo failed: %d bytes required 
but %d available",
+   required, available);
+   mutex_unlock(>tx_fifo_lock);
+   return -EAGAIN;
+   }
+
retval = kfifo_in(>tx_fifo, >tx_cfg,
  sizeof(instance->tx_cfg));
if (retval != sizeof(instance->tx_cfg))
@@ -855,8 +860,8 @@ pi433_write(struct file *filp, const char __user *buf,
return copied;
 
 abort:
-   dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
-   kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
discard already stored, valid entries
+   dev_warn(device->dev,
+"write to fifo failed, non recoverable: 0x%x", retval);
mutex_unlock(>tx_fifo_lock);
return -EAGAIN;
 }
-- 
2.17.0



[PATCH v2] staging: pi433: cleanup tx_fifo locking

2018-04-19 Thread Valentin Vidic
pi433_write requires locking due to multiple writers.  After acquiring
the lock check if enough free space is available in the kfifo to write
the whole message. This check should prevent partial writes to tx_fifo
so kfifo_reset is not needed anymore.

pi433_tx_thread is the only reader so it does not require locking
after kfifo_reset is removed.

Signed-off-by: Valentin Vidic 
---
v2: print a warning if partial fifo write happens

 drivers/staging/pi433/pi433_if.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..2a05eff88469 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
 
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
-   struct mutextx_fifo_lock; // TODO: check, whether necessary 
or obsolete
+   struct mutextx_fifo_lock; /* serialize userspace writers */
struct task_struct  *tx_task_struct;
wait_queue_head_t   tx_wait_queue;
u8  free_in_fifo;
@@ -589,19 +589,15 @@ pi433_tx_thread(void *data)
 * - size of message
 * - message
 */
-   mutex_lock(>tx_fifo_lock);
-
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
@@ -634,7 +630,6 @@ pi433_tx_thread(void *data)
   sizeof(device->buffer) - position);
dev_dbg(device->dev,
"read %d message byte(s) from fifo queue.", retval);
-   mutex_unlock(>tx_fifo_lock);
 
/* if rx is active, we need to interrupt the waiting for
 * incoming telegrams, to be able to send something.
@@ -818,7 +813,7 @@ pi433_write(struct file *filp, const char __user *buf,
struct pi433_instance   *instance;
struct pi433_device *device;
int retval;
-   unsigned intcopied;
+   unsigned intrequired, available, copied;
 
instance = filp->private_data;
device = instance->device;
@@ -833,6 +828,16 @@ pi433_write(struct file *filp, const char __user *buf,
 * - message
 */
mutex_lock(>tx_fifo_lock);
+
+   required = sizeof(instance->tx_cfg) + sizeof(size_t) + count;
+   available = kfifo_avail(>tx_fifo);
+   if (required > available) {
+   dev_dbg(device->dev, "write to fifo failed: %d bytes required 
but %d available",
+   required, available);
+   mutex_unlock(>tx_fifo_lock);
+   return -EAGAIN;
+   }
+
retval = kfifo_in(>tx_fifo, >tx_cfg,
  sizeof(instance->tx_cfg));
if (retval != sizeof(instance->tx_cfg))
@@ -855,8 +860,8 @@ pi433_write(struct file *filp, const char __user *buf,
return copied;
 
 abort:
-   dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
-   kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
discard already stored, valid entries
+   dev_warn(device->dev,
+"write to fifo failed, non recoverable: 0x%x", retval);
mutex_unlock(>tx_fifo_lock);
return -EAGAIN;
 }
-- 
2.17.0



Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-19 Thread Valentin Vidic
On Thu, Apr 19, 2018 at 11:25:19AM +0200, Marcus Wolf wrote:
> let me know, what you like to have. For sure with just one station and
> no other 433MHz equipment, options for testing are quite limited.

I can get Rpi3 and with two shields test 433MHz communication between
Rpi2 and Rpi3.

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-19 Thread Valentin Vidic
On Thu, Apr 19, 2018 at 11:25:19AM +0200, Marcus Wolf wrote:
> let me know, what you like to have. For sure with just one station and
> no other 433MHz equipment, options for testing are quite limited.

I can get Rpi3 and with two shields test 433MHz communication between
Rpi2 and Rpi3.

-- 
Valentin


[PATCH] staging: pi433: use help in Kconfig description

2018-04-15 Thread Valentin Vidic
Fixes checkpatch warning:

  WARNING: prefer 'help' over '---help---' for new help texts

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/Kconfig b/drivers/staging/pi433/Kconfig
index 87c2ee192cca..c7340129dd4c 100644
--- a/drivers/staging/pi433/Kconfig
+++ b/drivers/staging/pi433/Kconfig
@@ -1,7 +1,7 @@
 config PI433
 tristate "Pi433 - a 433MHz radio module for Raspberry Pi"
 depends on SPI
----help---
+help
   This option allows you to enable support for the radio module Pi433.
 
   Pi433 is a shield that fits onto the GPIO header of a Raspberry Pi
-- 
2.17.0



[PATCH] staging: pi433: use help in Kconfig description

2018-04-15 Thread Valentin Vidic
Fixes checkpatch warning:

  WARNING: prefer 'help' over '---help---' for new help texts

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/Kconfig b/drivers/staging/pi433/Kconfig
index 87c2ee192cca..c7340129dd4c 100644
--- a/drivers/staging/pi433/Kconfig
+++ b/drivers/staging/pi433/Kconfig
@@ -1,7 +1,7 @@
 config PI433
 tristate "Pi433 - a 433MHz radio module for Raspberry Pi"
 depends on SPI
----help---
+help
   This option allows you to enable support for the radio module Pi433.
 
   Pi433 is a shield that fits onto the GPIO header of a Raspberry Pi
-- 
2.17.0



Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-12 Thread Valentin Vidic
On Sun, Apr 08, 2018 at 05:22:46PM +0200, Marcus Wolf wrote:
> Regarding your patch, I did not understand, why you did not remove
> the mutex_lock in pi433_write. Wasn't it the goal to remove it?

Is it possible for more than one userspace program to open the pi433
device and send messages?  In that case more than one pi433_write
could be running and it needs to hold a mutex_lock before calling
kfifo_in.

> Below find a proposal of pi433_write function, I wrote on base
> of my outdated (!), private repo. It is not compiled and not tested.
> Since there is no more handling in case of an error (as well in the
> propsal as in your patch), I removed the error handling completely.
> I only do a test to detect proplems while writing to the tx_fifo,
> but (like in your patch) do nothing for solving, just printing a line.
> If this unexpected situation will occur (most probably never),
> the tx_fifo will be (and stay) out of sync until driver gets unloaded.
> We have to decide, whether we can stay with that. Like written above,
> I thinkt the benefits are great, the chance of such kind of error
> very low.
> What do you think?

Yes, if there is only one writer and it checks the available size,
kfifo_in should not fail.  The only problem might be copy_from_user
but perhaps that is also quite unlikely.  A workaround for that could
be to copy the data into a temporary kernel buffer first and than
start kfifo writes using only kernel memory.

> It could be discussed, whether it is better to return EMSGSIZE or
> EAGAIN on the first check. On the one hand, there is a problem with
> the message size, on the other hand (if message isn't generally too
> big) after a while, there should be some more space available in
> fifo, so EAGAIN may be better choice.

EAGAIN does seem better unless the message is too big to ever fit
in the kfifo.

>   if (retval != required ) {
>   dev_dbg(device->dev, "write to fifo failed, reason unknown, non 
> recoverable.");
>   return -EAGAIN;
>   }

Maybe this should be dev_warn or even dev_crit if the driver is not
usable anymore when this happens?  The error message should than also
be adjusted to EBADF or something similar.

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-12 Thread Valentin Vidic
On Sun, Apr 08, 2018 at 05:22:46PM +0200, Marcus Wolf wrote:
> Regarding your patch, I did not understand, why you did not remove
> the mutex_lock in pi433_write. Wasn't it the goal to remove it?

Is it possible for more than one userspace program to open the pi433
device and send messages?  In that case more than one pi433_write
could be running and it needs to hold a mutex_lock before calling
kfifo_in.

> Below find a proposal of pi433_write function, I wrote on base
> of my outdated (!), private repo. It is not compiled and not tested.
> Since there is no more handling in case of an error (as well in the
> propsal as in your patch), I removed the error handling completely.
> I only do a test to detect proplems while writing to the tx_fifo,
> but (like in your patch) do nothing for solving, just printing a line.
> If this unexpected situation will occur (most probably never),
> the tx_fifo will be (and stay) out of sync until driver gets unloaded.
> We have to decide, whether we can stay with that. Like written above,
> I thinkt the benefits are great, the chance of such kind of error
> very low.
> What do you think?

Yes, if there is only one writer and it checks the available size,
kfifo_in should not fail.  The only problem might be copy_from_user
but perhaps that is also quite unlikely.  A workaround for that could
be to copy the data into a temporary kernel buffer first and than
start kfifo writes using only kernel memory.

> It could be discussed, whether it is better to return EMSGSIZE or
> EAGAIN on the first check. On the one hand, there is a problem with
> the message size, on the other hand (if message isn't generally too
> big) after a while, there should be some more space available in
> fifo, so EAGAIN may be better choice.

EAGAIN does seem better unless the message is too big to ever fit
in the kfifo.

>   if (retval != required ) {
>   dev_dbg(device->dev, "write to fifo failed, reason unknown, non 
> recoverable.");
>   return -EAGAIN;
>   }

Maybe this should be dev_warn or even dev_crit if the driver is not
usable anymore when this happens?  The error message should than also
be adjusted to EBADF or something similar.

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-12 Thread Valentin Vidic
On Sun, Apr 08, 2018 at 04:15:30PM +0200, Marcus Wolf wrote:
> The hardware of Pi433 is working with every Raspberry Pi (on zero, you
> need to solder the GPIO-pins) and with several other fruits like banana
> pi. The only thing is, that you need different versions of the driver,
> according to the processor, mounted on your fruit.
> 
> If you'd like to test more then ther is no hang up or crash, you will
> need a second party. You could use a 433MHz socket for testing TX or a
> 433 thermometer for testing RX. An example code for communication with a
> socket is available on the Pi433 productpage (www.pi433.de). The sample
> for the thermometer isn't published yet (as always lack of time).
> 
> If you want to test more deeply (using different features of the Rf69
> chip or even do some long time testing, you have more options, if you
> use to Pis with Pi433.
> 
> Just let me know, what you'd like to do and what equipment, you need.

At the moment I have Rpi2 but not any other 433MHz equipment, so I
could only do some basic testing unfortunately.  In case I get the
new Rpi3 some time soon I would be able to do something better.

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-12 Thread Valentin Vidic
On Sun, Apr 08, 2018 at 04:15:30PM +0200, Marcus Wolf wrote:
> The hardware of Pi433 is working with every Raspberry Pi (on zero, you
> need to solder the GPIO-pins) and with several other fruits like banana
> pi. The only thing is, that you need different versions of the driver,
> according to the processor, mounted on your fruit.
> 
> If you'd like to test more then ther is no hang up or crash, you will
> need a second party. You could use a 433MHz socket for testing TX or a
> 433 thermometer for testing RX. An example code for communication with a
> socket is available on the Pi433 productpage (www.pi433.de). The sample
> for the thermometer isn't published yet (as always lack of time).
> 
> If you want to test more deeply (using different features of the Rf69
> chip or even do some long time testing, you have more options, if you
> use to Pis with Pi433.
> 
> Just let me know, what you'd like to do and what equipment, you need.

At the moment I have Rpi2 but not any other 433MHz equipment, so I
could only do some basic testing unfortunately.  In case I get the
new Rpi3 some time soon I would be able to do something better.

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-25 Thread Valentin Vidic
On Sun, Mar 25, 2018 at 03:12:52PM +0200, Marcus Wolf wrote:
> I am not at home the next two weeks. So I can do a codereading on
> Easter, but testing will not take place earlier then mid/end of April :-(
> 
> If you are interested, I can provide you an engineering sample of Pi433.

Sure, let me know which version of Rpi it supports and if I need two
to test communication.

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-25 Thread Valentin Vidic
On Sun, Mar 25, 2018 at 03:12:52PM +0200, Marcus Wolf wrote:
> I am not at home the next two weeks. So I can do a codereading on
> Easter, but testing will not take place earlier then mid/end of April :-(
> 
> If you are interested, I can provide you an engineering sample of Pi433.

Sure, let me know which version of Rpi it supports and if I need two
to test communication.

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-25 Thread Valentin Vidic
On Sun, Mar 25, 2018 at 03:00:09PM +0200, Marcus Wolf wrote:
> Unfortunaly I can't find the time to have a closer look on the code this
> weekend - still busy with tax stuff :-(
> 
> Idea sounds great. I'll try to look at the code and think about it
> during Easter hollidays.

No problem, there is no hurry. But please do test the patch I sent yesterday:

  [PATCH] staging: pi433: cleanup tx_fifo locking

As I don't have the hardware this is just compile tested now :)

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-25 Thread Valentin Vidic
On Sun, Mar 25, 2018 at 03:00:09PM +0200, Marcus Wolf wrote:
> Unfortunaly I can't find the time to have a closer look on the code this
> weekend - still busy with tax stuff :-(
> 
> Idea sounds great. I'll try to look at the code and think about it
> during Easter hollidays.

No problem, there is no hurry. But please do test the patch I sent yesterday:

  [PATCH] staging: pi433: cleanup tx_fifo locking

As I don't have the hardware this is just compile tested now :)

-- 
Valentin


[PATCH] staging: pi433: cleanup tx_fifo locking

2018-03-24 Thread Valentin Vidic
pi433_write requires locking due to multiple kfifo writers.  After
acquiring the lock check if enough free space is available in the kfifo
to write the whole message. This check should prevent partial writes to
kfifo so kfifo_reset is not needed anymore.

pi433_tx_thread is the only kfifo reader so it does not require locking
after kfifo_reset is also removed.

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/pi433_if.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..97239b0eb322 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
 
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
-   struct mutextx_fifo_lock; // TODO: check, whether necessary 
or obsolete
+   struct mutextx_fifo_lock; /* serialize multiple writers */
struct task_struct  *tx_task_struct;
wait_queue_head_t   tx_wait_queue;
u8  free_in_fifo;
@@ -589,19 +589,15 @@ pi433_tx_thread(void *data)
 * - size of message
 * - message
 */
-   mutex_lock(>tx_fifo_lock);
-
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
@@ -634,7 +630,6 @@ pi433_tx_thread(void *data)
   sizeof(device->buffer) - position);
dev_dbg(device->dev,
"read %d message byte(s) from fifo queue.", retval);
-   mutex_unlock(>tx_fifo_lock);
 
/* if rx is active, we need to interrupt the waiting for
 * incoming telegrams, to be able to send something.
@@ -818,7 +813,7 @@ pi433_write(struct file *filp, const char __user *buf,
struct pi433_instance   *instance;
struct pi433_device *device;
int retval;
-   unsigned intcopied;
+   unsigned intrequired, available, copied;
 
instance = filp->private_data;
device = instance->device;
@@ -833,6 +828,16 @@ pi433_write(struct file *filp, const char __user *buf,
 * - message
 */
mutex_lock(>tx_fifo_lock);
+
+   required = sizeof(instance->tx_cfg) + sizeof(size_t) + count;
+   available = kfifo_avail(>tx_fifo);
+   if (required > available) {
+   dev_dbg(device->dev, "write to fifo failed: %d bytes required 
but %d available",
+   required, available);
+   mutex_unlock(>tx_fifo_lock);
+   return -EAGAIN;
+   }
+
retval = kfifo_in(>tx_fifo, >tx_cfg,
  sizeof(instance->tx_cfg));
if (retval != sizeof(instance->tx_cfg))
@@ -856,7 +861,6 @@ pi433_write(struct file *filp, const char __user *buf,
 
 abort:
dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
-   kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
discard already stored, valid entries
mutex_unlock(>tx_fifo_lock);
return -EAGAIN;
 }
-- 
2.16.2



[PATCH] staging: pi433: cleanup tx_fifo locking

2018-03-24 Thread Valentin Vidic
pi433_write requires locking due to multiple kfifo writers.  After
acquiring the lock check if enough free space is available in the kfifo
to write the whole message. This check should prevent partial writes to
kfifo so kfifo_reset is not needed anymore.

pi433_tx_thread is the only kfifo reader so it does not require locking
after kfifo_reset is also removed.

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..97239b0eb322 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
 
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
-   struct mutextx_fifo_lock; // TODO: check, whether necessary 
or obsolete
+   struct mutextx_fifo_lock; /* serialize multiple writers */
struct task_struct  *tx_task_struct;
wait_queue_head_t   tx_wait_queue;
u8  free_in_fifo;
@@ -589,19 +589,15 @@ pi433_tx_thread(void *data)
 * - size of message
 * - message
 */
-   mutex_lock(>tx_fifo_lock);
-
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
@@ -634,7 +630,6 @@ pi433_tx_thread(void *data)
   sizeof(device->buffer) - position);
dev_dbg(device->dev,
"read %d message byte(s) from fifo queue.", retval);
-   mutex_unlock(>tx_fifo_lock);
 
/* if rx is active, we need to interrupt the waiting for
 * incoming telegrams, to be able to send something.
@@ -818,7 +813,7 @@ pi433_write(struct file *filp, const char __user *buf,
struct pi433_instance   *instance;
struct pi433_device *device;
int retval;
-   unsigned intcopied;
+   unsigned intrequired, available, copied;
 
instance = filp->private_data;
device = instance->device;
@@ -833,6 +828,16 @@ pi433_write(struct file *filp, const char __user *buf,
 * - message
 */
mutex_lock(>tx_fifo_lock);
+
+   required = sizeof(instance->tx_cfg) + sizeof(size_t) + count;
+   available = kfifo_avail(>tx_fifo);
+   if (required > available) {
+   dev_dbg(device->dev, "write to fifo failed: %d bytes required 
but %d available",
+   required, available);
+   mutex_unlock(>tx_fifo_lock);
+   return -EAGAIN;
+   }
+
retval = kfifo_in(>tx_fifo, >tx_cfg,
  sizeof(instance->tx_cfg));
if (retval != sizeof(instance->tx_cfg))
@@ -856,7 +861,6 @@ pi433_write(struct file *filp, const char __user *buf,
 
 abort:
dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
-   kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
discard already stored, valid entries
mutex_unlock(>tx_fifo_lock);
return -EAGAIN;
 }
-- 
2.16.2



[PATCH] kfifo: fix comment

2018-03-23 Thread Valentin Vidic
Cleanup unusual formatting in the note about locking.

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 include/linux/kfifo.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index e251533a5939..89fc8dc7bf38 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -41,11 +41,11 @@
  */
 
 /*
- * Note about locking : There is no locking required until only * one reader
- * and one writer is using the fifo and no kfifo_reset() will be * called
- *  kfifo_reset_out() can be safely used, until it will be only called
+ * Note about locking: There is no locking required until only one reader
+ * and one writer is using the fifo and no kfifo_reset() will be called.
+ * kfifo_reset_out() can be safely used, until it will be only called
  * in the reader thread.
- *  For multiple writer and one reader there is only a need to lock the writer.
+ * For multiple writer and one reader there is only a need to lock the writer.
  * And vice versa for only one writer and multiple reader there is only a need
  * to lock the reader.
  */
-- 
2.16.2



[PATCH] kfifo: fix comment

2018-03-23 Thread Valentin Vidic
Cleanup unusual formatting in the note about locking.

Signed-off-by: Valentin Vidic 
---
 include/linux/kfifo.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index e251533a5939..89fc8dc7bf38 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -41,11 +41,11 @@
  */
 
 /*
- * Note about locking : There is no locking required until only * one reader
- * and one writer is using the fifo and no kfifo_reset() will be * called
- *  kfifo_reset_out() can be safely used, until it will be only called
+ * Note about locking: There is no locking required until only one reader
+ * and one writer is using the fifo and no kfifo_reset() will be called.
+ * kfifo_reset_out() can be safely used, until it will be only called
  * in the reader thread.
- *  For multiple writer and one reader there is only a need to lock the writer.
+ * For multiple writer and one reader there is only a need to lock the writer.
  * And vice versa for only one writer and multiple reader there is only a need
  * to lock the reader.
  */
-- 
2.16.2



Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
On Fri, Mar 23, 2018 at 07:00:27PM +0100, Valentin Vidic wrote:
> You are right, here is what kfifo.h says:
> 
> /*
>  * Note about locking : There is no locking required until only * one reader
>  * and one writer is using the fifo and no kfifo_reset() will be * called
>  *  kfifo_reset_out() can be safely used, until it will be only called
>  * in the reader thread.
>  *  For multiple writer and one reader there is only a need to lock the 
> writer.
>  * And vice versa for only one writer and multiple reader there is only a need
>  * to lock the reader.
>  */
> 
> In the case of pi433 there is only one reader (pi433_tx_thread) and
> there is no need for a lock there. But the char device (pi433_write)
> might have multiple writers so we leave the mutex just in that function?

Ah, but there is a kfifo_reset call in pi433_write that requires a
mutex for both readers and writers:

"Usage of kfifo_reset is dangerous. It should be only called when the
fifo is exclusived locked or when it is secured that no other thread is
accessing the fifo."

Also kfifo_reset_out would probably not help here:

"The usage of kfifo_reset_out is safe until it will be only called from
the reader thread and there is only one concurrent reader. Otherwise it
is dangerous and must be handled in the same way as kfifo_reset."

But I have an idea to remove this kfifo_reset call in pi433_write
handling partial message writes:

  kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to discard 
already stored, valid entries

The writer could acquire the lock and than use kfifo_avail to check if
there is enough space to write the whole message.  What do you think?

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
On Fri, Mar 23, 2018 at 07:00:27PM +0100, Valentin Vidic wrote:
> You are right, here is what kfifo.h says:
> 
> /*
>  * Note about locking : There is no locking required until only * one reader
>  * and one writer is using the fifo and no kfifo_reset() will be * called
>  *  kfifo_reset_out() can be safely used, until it will be only called
>  * in the reader thread.
>  *  For multiple writer and one reader there is only a need to lock the 
> writer.
>  * And vice versa for only one writer and multiple reader there is only a need
>  * to lock the reader.
>  */
> 
> In the case of pi433 there is only one reader (pi433_tx_thread) and
> there is no need for a lock there. But the char device (pi433_write)
> might have multiple writers so we leave the mutex just in that function?

Ah, but there is a kfifo_reset call in pi433_write that requires a
mutex for both readers and writers:

"Usage of kfifo_reset is dangerous. It should be only called when the
fifo is exclusived locked or when it is secured that no other thread is
accessing the fifo."

Also kfifo_reset_out would probably not help here:

"The usage of kfifo_reset_out is safe until it will be only called from
the reader thread and there is only one concurrent reader. Otherwise it
is dangerous and must be handled in the same way as kfifo_reset."

But I have an idea to remove this kfifo_reset call in pi433_write
handling partial message writes:

  kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to discard 
already stored, valid entries

The writer could acquire the lock and than use kfifo_avail to check if
there is enough space to write the whole message.  What do you think?

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
On Fri, Mar 23, 2018 at 04:38:50PM +0100, Marcus Wolf wrote:
> I had no time to work on the code for monthes now and the memorisation
> of my thoughts when I was programming that (approx. one year ago) is
> quite pale.
> 
> As far as I remember, I read something, that the fifo has an integrated
> protection, so no external protection is needed. But absolutely unsure.
> 
> If I will find some time within the next days, I'll have a look at the
> code and try to recall.
> 
> But the most important thing already took place: We started thinking
> about it :-)

You are right, here is what kfifo.h says:

/*
 * Note about locking : There is no locking required until only * one reader
 * and one writer is using the fifo and no kfifo_reset() will be * called
 *  kfifo_reset_out() can be safely used, until it will be only called
 * in the reader thread.
 *  For multiple writer and one reader there is only a need to lock the writer.
 * And vice versa for only one writer and multiple reader there is only a need
 * to lock the reader.
 */

In the case of pi433 there is only one reader (pi433_tx_thread) and
there is no need for a lock there. But the char device (pi433_write)
might have multiple writers so we leave the mutex just in that function?

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
On Fri, Mar 23, 2018 at 04:38:50PM +0100, Marcus Wolf wrote:
> I had no time to work on the code for monthes now and the memorisation
> of my thoughts when I was programming that (approx. one year ago) is
> quite pale.
> 
> As far as I remember, I read something, that the fifo has an integrated
> protection, so no external protection is needed. But absolutely unsure.
> 
> If I will find some time within the next days, I'll have a look at the
> code and try to recall.
> 
> But the most important thing already took place: We started thinking
> about it :-)

You are right, here is what kfifo.h says:

/*
 * Note about locking : There is no locking required until only * one reader
 * and one writer is using the fifo and no kfifo_reset() will be * called
 *  kfifo_reset_out() can be safely used, until it will be only called
 * in the reader thread.
 *  For multiple writer and one reader there is only a need to lock the writer.
 * And vice versa for only one writer and multiple reader there is only a need
 * to lock the reader.
 */

In the case of pi433 there is only one reader (pi433_tx_thread) and
there is no need for a lock there. But the char device (pi433_write)
might have multiple writers so we leave the mutex just in that function?

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
On Fri, Mar 23, 2018 at 11:22:39AM +0100, Marcus Wolf wrote:
> could you please decribe in short words, why you think, that hte lock
> isn't obsolete?
> 
> I wasn't sure, but close to remove the lock. That's why I putted the
> comment.

Sure, if pi433_tx_thread runs on one CPU it might be possible
to call pi433_write concurrently on another CPU and they would
both modify tx_fifo.  But maybe there is some other protection
in place that would prevent this?

-- 
Valentin


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
On Fri, Mar 23, 2018 at 11:22:39AM +0100, Marcus Wolf wrote:
> could you please decribe in short words, why you think, that hte lock
> isn't obsolete?
> 
> I wasn't sure, but close to remove the lock. That's why I putted the
> comment.

Sure, if pi433_tx_thread runs on one CPU it might be possible
to call pi433_write concurrently on another CPU and they would
both modify tx_fifo.  But maybe there is some other protection
in place that would prevent this?

-- 
Valentin


[PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
Removes TODO for tx_fifo_lock as tx_fifo is modified from
both pi433_tx_thread and pi433_write.

Fixes checkpatch warning:

  CHECK: struct mutex definition without comment

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..f6f106a3ff8e 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
 
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
-   struct mutextx_fifo_lock; // TODO: check, whether necessary 
or obsolete
+   struct mutextx_fifo_lock; /* serialize access to tx_fifo */
struct task_struct  *tx_task_struct;
wait_queue_head_t   tx_wait_queue;
u8  free_in_fifo;
@@ -100,7 +100,7 @@ struct pi433_device {
u32 rx_bytes_to_drop;
u32 rx_bytes_dropped;
unsigned intrx_position;
-   struct mutexrx_lock;
+   struct mutexrx_lock; /* serialize read requests */
wait_queue_head_t   rx_wait_queue;
 
/* fifo wait queue */
-- 
2.16.2



[PATCH] staging: pi433: add descriptions for mutex locks

2018-03-23 Thread Valentin Vidic
Removes TODO for tx_fifo_lock as tx_fifo is modified from
both pi433_tx_thread and pi433_write.

Fixes checkpatch warning:

  CHECK: struct mutex definition without comment

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..f6f106a3ff8e 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
 
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
-   struct mutextx_fifo_lock; // TODO: check, whether necessary 
or obsolete
+   struct mutextx_fifo_lock; /* serialize access to tx_fifo */
struct task_struct  *tx_task_struct;
wait_queue_head_t   tx_wait_queue;
u8  free_in_fifo;
@@ -100,7 +100,7 @@ struct pi433_device {
u32 rx_bytes_to_drop;
u32 rx_bytes_dropped;
unsigned intrx_position;
-   struct mutexrx_lock;
+   struct mutexrx_lock; /* serialize read requests */
wait_queue_head_t   rx_wait_queue;
 
/* fifo wait queue */
-- 
2.16.2



[PATCH] staging: pi433: cleanup local variable

2018-03-20 Thread Valentin Vidic
Rename temporary local variable and add required blank line.

Fixes checkpatch warning:

  WARNING: Missing a blank line after declarations

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/pi433_if.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 583b3803cf38..d1e0ddbc79ce 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -711,12 +711,13 @@ pi433_tx_thread(void *data)
while ((repetitions > 0) && (size > position)) {
if ((size - position) > device->free_in_fifo) {
/* msg to big for fifo - take a part */
-   int temp = device->free_in_fifo;
+   int write_size = device->free_in_fifo;
+
device->free_in_fifo = 0;
rf69_write_fifo(spi,
>buffer[position],
-   temp);
-   position += temp;
+   write_size);
+   position += write_size;
} else {
/* msg fits into fifo - take all */
device->free_in_fifo -= size;
-- 
2.16.2



[PATCH] staging: pi433: cleanup local variable

2018-03-20 Thread Valentin Vidic
Rename temporary local variable and add required blank line.

Fixes checkpatch warning:

  WARNING: Missing a blank line after declarations

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 583b3803cf38..d1e0ddbc79ce 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -711,12 +711,13 @@ pi433_tx_thread(void *data)
while ((repetitions > 0) && (size > position)) {
if ((size - position) > device->free_in_fifo) {
/* msg to big for fifo - take a part */
-   int temp = device->free_in_fifo;
+   int write_size = device->free_in_fifo;
+
device->free_in_fifo = 0;
rf69_write_fifo(spi,
>buffer[position],
-   temp);
-   position += temp;
+   write_size);
+   position += write_size;
} else {
/* msg fits into fifo - take all */
device->free_in_fifo -= size;
-- 
2.16.2



[PATCH 3/7] staging: pi433: fix CamelCase for syncSize variable

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/rf69.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index b2c54999b022..b57d3f4e9321 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -633,16 +633,16 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, 
enum fifo_fill_conditio
}
 }
 
-int rf69_set_sync_size(struct spi_device *spi, u8 syncSize)
+int rf69_set_sync_size(struct spi_device *spi, u8 sync_size)
 {
// check input value
-   if (syncSize > 0x07) {
+   if (sync_size > 0x07) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
// write value
-   return rf69_read_mod_write(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_SYNC_SIZE, (syncSize << 3));
+   return rf69_read_mod_write(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_SYNC_SIZE, (sync_size << 3));
 }
 
 int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8])
-- 
2.16.2



[PATCH 3/7] staging: pi433: fix CamelCase for syncSize variable

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index b2c54999b022..b57d3f4e9321 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -633,16 +633,16 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, 
enum fifo_fill_conditio
}
 }
 
-int rf69_set_sync_size(struct spi_device *spi, u8 syncSize)
+int rf69_set_sync_size(struct spi_device *spi, u8 sync_size)
 {
// check input value
-   if (syncSize > 0x07) {
+   if (sync_size > 0x07) {
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
}
 
// write value
-   return rf69_read_mod_write(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_SYNC_SIZE, (syncSize << 3));
+   return rf69_read_mod_write(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_SYNC_SIZE, (sync_size << 3));
 }
 
 int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8])
-- 
2.16.2



[PATCH 7/7] staging: pi433: fix CamelCase for dagc enum

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/Documentation/pi433.txt | 4 ++--
 drivers/staging/pi433/rf69.c  | 4 ++--
 drivers/staging/pi433/rf69_enum.h | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 3bb38644eb6e..d0b7000faafc 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -215,9 +215,9 @@ rf params:
Allowd values: 0...7
dagc;
operation mode of the digital automatic gain control
-   normalMode
+   normal_mode
improve
-   improve4LowModulationIndex
+   improve_for_low_modulation_index
 
  packet format:
enable_sync
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 0bc459e32f6b..5b0554823263 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -751,11 +751,11 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 
threshold)
 int rf69_set_dagc(struct spi_device *spi, enum dagc dagc)
 {
switch (dagc) {
-   case normalMode:
+   case normal_mode:
return rf69_write_reg(spi, REG_TESTDAGC, DAGC_NORMAL);
case improve:
return rf69_write_reg(spi, REG_TESTDAGC, 
DAGC_IMPROVED_LOWBETA0);
-   case improve4LowModulationIndex:
+   case improve_for_low_modulation_index:
return rf69_write_reg(spi, REG_TESTDAGC, 
DAGC_IMPROVED_LOWBETA1);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index eabaea99949d..493bd0025453 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -135,9 +135,9 @@ enum address_filtering {
 };
 
 enum dagc {
-   normalMode,
+   normal_mode,
improve,
-   improve4LowModulationIndex
+   improve_for_low_modulation_index
 };
 
 #endif
-- 
2.16.2



[PATCH 6/7] staging: pi433: fix CamelCase for lnaGain enum

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/Documentation/pi433.txt | 2 +-
 drivers/staging/pi433/pi433_if.h  | 2 +-
 drivers/staging/pi433/rf69.c  | 4 ++--
 drivers/staging/pi433/rf69.h  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 79bccc586869..3bb38644eb6e 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -196,7 +196,7 @@ rf params:
sets the electrical adoption of the antenna
fifty_ohm   - for antennas with an impedance of 50Ohm
two_hundred_ohm - for antennas with an impedance of 200Ohm
-   lnaGain
+   lna_gain
sets the gain of the low noise amp
automatic   - lna gain is determined by an agc
max - lna gain is set to maximum
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index be4a96055a97..b6e214c29ddf 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -117,7 +117,7 @@ struct pi433_rx_cfg {
__u8rssi_threshold;
enum threshold_decrement threshold_decrement;
enum antenna_impedance  antenna_impedance;
-   enum lnaGainlna_gain;
+   enum lna_gain   lna_gain;
enum mantisse   bw_mantisse;/* normal: 0x50 */
__u8bw_exponent;/* during AFC: 0x8b */
enum dagc   dagc;
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e3394094f6a1..0bc459e32f6b 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -399,9 +399,9 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum 
antenna_impedance an
}
 }
 
-int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
+int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain)
 {
-   switch (lnaGain) {
+   switch (lna_gain) {
case automatic:
return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, 
LNA_GAIN_AUTO);
case max:
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 4d6fc07f8255..b9f6850e3316 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -37,7 +37,7 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 
amplifier_mask);
 int rf69_set_output_power_level(struct spi_device *spi, u8 power_level);
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp);
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance 
antenna_impedance);
-int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain);
+int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain);
 int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
 int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse 
mantisse, u8 exponent);
 int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement threshold_decrement);
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 5ac3d33a3d0c..eabaea99949d 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -65,7 +65,7 @@ enum antenna_impedance {
two_hundred_ohm
 };
 
-enum lnaGain {
+enum lna_gain {
automatic,
max,
max_minus_6,
-- 
2.16.2



[PATCH 7/7] staging: pi433: fix CamelCase for dagc enum

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/Documentation/pi433.txt | 4 ++--
 drivers/staging/pi433/rf69.c  | 4 ++--
 drivers/staging/pi433/rf69_enum.h | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 3bb38644eb6e..d0b7000faafc 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -215,9 +215,9 @@ rf params:
Allowd values: 0...7
dagc;
operation mode of the digital automatic gain control
-   normalMode
+   normal_mode
improve
-   improve4LowModulationIndex
+   improve_for_low_modulation_index
 
  packet format:
enable_sync
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 0bc459e32f6b..5b0554823263 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -751,11 +751,11 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 
threshold)
 int rf69_set_dagc(struct spi_device *spi, enum dagc dagc)
 {
switch (dagc) {
-   case normalMode:
+   case normal_mode:
return rf69_write_reg(spi, REG_TESTDAGC, DAGC_NORMAL);
case improve:
return rf69_write_reg(spi, REG_TESTDAGC, 
DAGC_IMPROVED_LOWBETA0);
-   case improve4LowModulationIndex:
+   case improve_for_low_modulation_index:
return rf69_write_reg(spi, REG_TESTDAGC, 
DAGC_IMPROVED_LOWBETA1);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index eabaea99949d..493bd0025453 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -135,9 +135,9 @@ enum address_filtering {
 };
 
 enum dagc {
-   normalMode,
+   normal_mode,
improve,
-   improve4LowModulationIndex
+   improve_for_low_modulation_index
 };
 
 #endif
-- 
2.16.2



[PATCH 6/7] staging: pi433: fix CamelCase for lnaGain enum

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/Documentation/pi433.txt | 2 +-
 drivers/staging/pi433/pi433_if.h  | 2 +-
 drivers/staging/pi433/rf69.c  | 4 ++--
 drivers/staging/pi433/rf69.h  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 79bccc586869..3bb38644eb6e 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -196,7 +196,7 @@ rf params:
sets the electrical adoption of the antenna
fifty_ohm   - for antennas with an impedance of 50Ohm
two_hundred_ohm - for antennas with an impedance of 200Ohm
-   lnaGain
+   lna_gain
sets the gain of the low noise amp
automatic   - lna gain is determined by an agc
max - lna gain is set to maximum
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index be4a96055a97..b6e214c29ddf 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -117,7 +117,7 @@ struct pi433_rx_cfg {
__u8rssi_threshold;
enum threshold_decrement threshold_decrement;
enum antenna_impedance  antenna_impedance;
-   enum lnaGainlna_gain;
+   enum lna_gain   lna_gain;
enum mantisse   bw_mantisse;/* normal: 0x50 */
__u8bw_exponent;/* during AFC: 0x8b */
enum dagc   dagc;
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e3394094f6a1..0bc459e32f6b 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -399,9 +399,9 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum 
antenna_impedance an
}
 }
 
-int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
+int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain)
 {
-   switch (lnaGain) {
+   switch (lna_gain) {
case automatic:
return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, 
LNA_GAIN_AUTO);
case max:
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 4d6fc07f8255..b9f6850e3316 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -37,7 +37,7 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 
amplifier_mask);
 int rf69_set_output_power_level(struct spi_device *spi, u8 power_level);
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp);
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance 
antenna_impedance);
-int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain);
+int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain);
 int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
 int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse 
mantisse, u8 exponent);
 int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement threshold_decrement);
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 5ac3d33a3d0c..eabaea99949d 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -65,7 +65,7 @@ enum antenna_impedance {
two_hundred_ohm
 };
 
-enum lnaGain {
+enum lna_gain {
automatic,
max,
max_minus_6,
-- 
2.16.2



[PATCH 5/7] staging: pi433: fix CamelCase for DIONumber variable

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/rf69.c | 4 ++--
 drivers/staging/pi433/rf69.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e11c9cca447b..e3394094f6a1 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -501,14 +501,14 @@ int rf69_set_ook_threshold_dec(struct spi_device *spi, 
enum threshold_decrement
}
 }
 
-int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value)
+int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value)
 {
u8 mask;
u8 shift;
u8 dio_addr;
u8 dio_value;
 
-   switch (DIONumber) {
+   switch (dio_number) {
case 0:
mask = MASK_DIO0; shift = SHIFT_DIO0; dio_addr = 
REG_DIOMAPPING1;
break;
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index ee22a10c85c0..4d6fc07f8255 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -41,7 +41,7 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain 
lnaGain);
 int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
 int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse 
mantisse, u8 exponent);
 int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement threshold_decrement);
-int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value);
+int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value);
 bool rf69_get_flag(struct spi_device *spi, enum flag flag);
 int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length);
-- 
2.16.2



[PATCH 5/7] staging: pi433: fix CamelCase for DIONumber variable

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.c | 4 ++--
 drivers/staging/pi433/rf69.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e11c9cca447b..e3394094f6a1 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -501,14 +501,14 @@ int rf69_set_ook_threshold_dec(struct spi_device *spi, 
enum threshold_decrement
}
 }
 
-int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value)
+int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value)
 {
u8 mask;
u8 shift;
u8 dio_addr;
u8 dio_value;
 
-   switch (DIONumber) {
+   switch (dio_number) {
case 0:
mask = MASK_DIO0; shift = SHIFT_DIO0; dio_addr = 
REG_DIOMAPPING1;
break;
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index ee22a10c85c0..4d6fc07f8255 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -41,7 +41,7 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain 
lnaGain);
 int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
 int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse 
mantisse, u8 exponent);
 int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement threshold_decrement);
-int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value);
+int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value);
 bool rf69_get_flag(struct spi_device *spi, enum flag flag);
 int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length);
-- 
2.16.2



[PATCH 2/7] staging: pi433: fix CamelCase for preambleLength variable

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/rf69.c | 6 +++---
 drivers/staging/pi433/rf69.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e5c7e48a3b86..b2c54999b022 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -590,7 +590,7 @@ int rf69_set_rssi_threshold(struct spi_device *spi, u8 
threshold)
return rf69_write_reg(spi, REG_RSSITHRESH, threshold);
 }
 
-int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength)
+int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length)
 {
int retval;
u8 msb, lsb;
@@ -598,8 +598,8 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 
preambleLength)
/* no value check needed - u16 exactly matches register size */
 
/* calculate reg settings */
-   msb = (preambleLength & 0xff00) >> 8;
-   lsb = (preambleLength & 0xff);
+   msb = (preamble_length & 0xff00) >> 8;
+   lsb = (preamble_length & 0xff);
 
/* transmit to chip */
retval = rf69_write_reg(spi, REG_PREAMBLE_MSB, msb);
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index d83808a5dd86..78366f251084 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -44,7 +44,7 @@ int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement
 int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value);
 bool rf69_get_flag(struct spi_device *spi, enum flag flag);
 int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);
-int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength);
+int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length);
 int rf69_enable_sync(struct spi_device *spi);
 int rf69_disable_sync(struct spi_device *spi);
 int rf69_set_fifo_fill_condition(struct spi_device *spi, enum 
fifo_fill_condition fifo_fill_condition);
-- 
2.16.2



[PATCH 2/7] staging: pi433: fix CamelCase for preambleLength variable

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.c | 6 +++---
 drivers/staging/pi433/rf69.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e5c7e48a3b86..b2c54999b022 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -590,7 +590,7 @@ int rf69_set_rssi_threshold(struct spi_device *spi, u8 
threshold)
return rf69_write_reg(spi, REG_RSSITHRESH, threshold);
 }
 
-int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength)
+int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length)
 {
int retval;
u8 msb, lsb;
@@ -598,8 +598,8 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 
preambleLength)
/* no value check needed - u16 exactly matches register size */
 
/* calculate reg settings */
-   msb = (preambleLength & 0xff00) >> 8;
-   lsb = (preambleLength & 0xff);
+   msb = (preamble_length & 0xff00) >> 8;
+   lsb = (preamble_length & 0xff);
 
/* transmit to chip */
retval = rf69_write_reg(spi, REG_PREAMBLE_MSB, msb);
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index d83808a5dd86..78366f251084 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -44,7 +44,7 @@ int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement
 int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value);
 bool rf69_get_flag(struct spi_device *spi, enum flag flag);
 int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);
-int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength);
+int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length);
 int rf69_enable_sync(struct spi_device *spi);
 int rf69_disable_sync(struct spi_device *spi);
 int rf69_set_fifo_fill_condition(struct spi_device *spi, enum 
fifo_fill_condition fifo_fill_condition);
-- 
2.16.2



[PATCH 1/7] staging: pi433: fix CamelCase for GPIO functions

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/pi433_if.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 5c6a7224180a..583b3803cf38 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -997,7 +997,7 @@ static int pi433_release(struct inode *inode, struct file 
*filp)
 
 /*-*/
 
-static int setup_GPIOs(struct pi433_device *device)
+static int setup_gpio(struct pi433_device *device)
 {
charname[5];
int retval;
@@ -1059,7 +1059,7 @@ static int setup_GPIOs(struct pi433_device *device)
return 0;
 }
 
-static void free_GPIOs(struct pi433_device *device)
+static void free_gpio(struct pi433_device *device)
 {
int i;
 
@@ -1174,7 +1174,7 @@ static int pi433_probe(struct spi_device *spi)
mutex_init(>rx_lock);
 
/* setup GPIO (including irq_handler) for the different DIOs */
-   retval = setup_GPIOs(device);
+   retval = setup_gpio(device);
if (retval) {
dev_dbg(>dev, "setup of GPIOs failed");
goto GPIO_failed;
@@ -1261,7 +1261,7 @@ static int pi433_probe(struct spi_device *spi)
 device_create_failed:
pi433_free_minor(device);
 minor_failed:
-   free_GPIOs(device);
+   free_gpio(device);
 GPIO_failed:
kfree(device);
 
@@ -1273,7 +1273,7 @@ static int pi433_remove(struct spi_device *spi)
struct pi433_device *device = spi_get_drvdata(spi);
 
/* free GPIOs */
-   free_GPIOs(device);
+   free_gpio(device);
 
/* make sure ops on existing fds can abort cleanly */
device->spi = NULL;
-- 
2.16.2



[PATCH 1/7] staging: pi433: fix CamelCase for GPIO functions

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 5c6a7224180a..583b3803cf38 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -997,7 +997,7 @@ static int pi433_release(struct inode *inode, struct file 
*filp)
 
 /*-*/
 
-static int setup_GPIOs(struct pi433_device *device)
+static int setup_gpio(struct pi433_device *device)
 {
charname[5];
int retval;
@@ -1059,7 +1059,7 @@ static int setup_GPIOs(struct pi433_device *device)
return 0;
 }
 
-static void free_GPIOs(struct pi433_device *device)
+static void free_gpio(struct pi433_device *device)
 {
int i;
 
@@ -1174,7 +1174,7 @@ static int pi433_probe(struct spi_device *spi)
mutex_init(>rx_lock);
 
/* setup GPIO (including irq_handler) for the different DIOs */
-   retval = setup_GPIOs(device);
+   retval = setup_gpio(device);
if (retval) {
dev_dbg(>dev, "setup of GPIOs failed");
goto GPIO_failed;
@@ -1261,7 +1261,7 @@ static int pi433_probe(struct spi_device *spi)
 device_create_failed:
pi433_free_minor(device);
 minor_failed:
-   free_GPIOs(device);
+   free_gpio(device);
 GPIO_failed:
kfree(device);
 
@@ -1273,7 +1273,7 @@ static int pi433_remove(struct spi_device *spi)
struct pi433_device *device = spi_get_drvdata(spi);
 
/* free GPIOs */
-   free_GPIOs(device);
+   free_gpio(device);
 
/* make sure ops on existing fds can abort cleanly */
device->spi = NULL;
-- 
2.16.2



[PATCH 4/7] staging: pi433: fix CamelCase for bitRate variables

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/rf69.c | 16 
 drivers/staging/pi433/rf69.h |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index b57d3f4e9321..e11c9cca447b 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -201,26 +201,26 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
}
 }
 
-int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
+int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate)
 {
int retval;
-   u32 bitRate_min;
-   u32 bitRate_reg;
+   u32 bit_rate_min;
+   u32 bit_rate_reg;
u8 msb;
u8 lsb;
 
// check input value
-   bitRate_min = F_OSC / 8388608; // 8388608 = 2^23;
-   if (bitRate < bitRate_min) {
+   bit_rate_min = F_OSC / 8388608; // 8388608 = 2^23;
+   if (bit_rate < bit_rate_min) {
dev_dbg(>dev, "setBitRate: illegal input param");
return -EINVAL;
}
 
// calculate reg settings
-   bitRate_reg = (F_OSC / bitRate);
+   bit_rate_reg = (F_OSC / bit_rate);
 
-   msb = (bitRate_reg & 0xff00) >> 8;
-   lsb = (bitRate_reg & 0xff);
+   msb = (bit_rate_reg & 0xff00) >> 8;
+   lsb = (bit_rate_reg & 0xff);
 
// transmit to RF 69
retval = rf69_write_reg(spi, REG_BITRATE_MSB, msb);
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 78366f251084..ee22a10c85c0 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -29,7 +29,7 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation);
 int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping 
mod_shaping);
-int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate);
+int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate);
 int rf69_set_deviation(struct spi_device *spi, u32 deviation);
 int rf69_set_frequency(struct spi_device *spi, u32 frequency);
 int rf69_enable_amplifier(struct spi_device *spi, u8 amplifier_mask);
-- 
2.16.2



[PATCH 4/7] staging: pi433: fix CamelCase for bitRate variables

2018-03-14 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.c | 16 
 drivers/staging/pi433/rf69.h |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index b57d3f4e9321..e11c9cca447b 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -201,26 +201,26 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
}
 }
 
-int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
+int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate)
 {
int retval;
-   u32 bitRate_min;
-   u32 bitRate_reg;
+   u32 bit_rate_min;
+   u32 bit_rate_reg;
u8 msb;
u8 lsb;
 
// check input value
-   bitRate_min = F_OSC / 8388608; // 8388608 = 2^23;
-   if (bitRate < bitRate_min) {
+   bit_rate_min = F_OSC / 8388608; // 8388608 = 2^23;
+   if (bit_rate < bit_rate_min) {
dev_dbg(>dev, "setBitRate: illegal input param");
return -EINVAL;
}
 
// calculate reg settings
-   bitRate_reg = (F_OSC / bitRate);
+   bit_rate_reg = (F_OSC / bit_rate);
 
-   msb = (bitRate_reg & 0xff00) >> 8;
-   lsb = (bitRate_reg & 0xff);
+   msb = (bit_rate_reg & 0xff00) >> 8;
+   lsb = (bit_rate_reg & 0xff);
 
// transmit to RF 69
retval = rf69_write_reg(spi, REG_BITRATE_MSB, msb);
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 78366f251084..ee22a10c85c0 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -29,7 +29,7 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation);
 int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping 
mod_shaping);
-int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate);
+int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate);
 int rf69_set_deviation(struct spi_device *spi, u32 deviation);
 int rf69_set_frequency(struct spi_device *spi, u32 frequency);
 int rf69_enable_amplifier(struct spi_device *spi, u8 amplifier_mask);
-- 
2.16.2



[PATCH 2/6] staging: pi433: fix CamelCase for flag enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/pi433_if.c  |  4 ++--
 drivers/staging/pi433/rf69.c  | 18 +-
 drivers/staging/pi433/rf69_enum.h | 18 +-
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index b1cbec876857..57db806ff5af 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -443,7 +443,7 @@ pi433_receive(void *data)
return retval;
 
/* now check RSSI, if low wait for getting high (RSSI interrupt) */
-   while (!rf69_get_flag(dev->spi, rssiExceededThreshold)) {
+   while (!rf69_get_flag(dev->spi, rssi_exceeded_threshold)) {
/* allow tx to interrupt us while waiting for high RSSI */
dev->interrupt_rx_allowed = true;
wake_up_interruptible(>tx_wait_queue);
@@ -452,7 +452,7 @@ pi433_receive(void *data)
dev_dbg(dev->dev, "rx: going to wait for high RSSI level");
retval = wait_event_interruptible(dev->rx_wait_queue,
  rf69_get_flag(dev->spi,
-   
rssiExceededThreshold));
+   
rssi_exceeded_threshold));
if (retval) /* wait was interrupted */
goto abort;
dev->interrupt_rx_allowed = false;
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 54d8105b5812..fc4919711477 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -545,21 +545,21 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 
DIONumber, u8 value)
 bool rf69_get_flag(struct spi_device *spi, enum flag flag)
 {
switch (flag) {
-   case modeSwitchCompleted:
+   case mode_switch_completed:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_MODE_READY);
-   case readyToReceive:
+   case ready_to_receive:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_RX_READY);
-   case readyToSend:
+   case ready_to_send:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_TX_READY);
-   case pllLocked:
+   case pll_locked:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_PLL_LOCK);
-   case rssiExceededThreshold:
+   case rssi_exceeded_threshold:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_RSSI);
case timeout:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_TIMEOUT);
case automode:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_AUTOMODE);
-   case syncAddressMatch:
+   case sync_address_match:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH);
case fifo_full:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_FIFO_FULL);
@@ -571,13 +571,13 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag)
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_FIFO_LEVEL);
case fifo_overrun:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_FIFO_OVERRUN);
-   case packetSent:
+   case packet_sent:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_PACKET_SENT);
case payload_ready:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_PAYLOAD_READY);
-   case crcOk:
+   case crc_ok:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_CRC_OK);
-   case batteryLow:
+   case battery_low:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_LOW_BAT);
default: return false;
}
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 682b667bf342..81287ce6be35 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -94,23 +94,23 @@ enum threshold_decrement {
 };
 
 enum flag {
-   modeSwitchCompleted,
-   readyToReceive,
-   readyToSend,
-   pllLocked,
-   rssiExceededThreshold,
+   mode_switch_completed,
+   ready_to_receive,
+   ready_to_send,
+   pll_locked,
+   rssi_exceeded_threshold,
timeout,
automode,
-   syncAddressMatch,
+   sync_address_ma

[PATCH 2/6] staging: pi433: fix CamelCase for flag enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c  |  4 ++--
 drivers/staging/pi433/rf69.c  | 18 +-
 drivers/staging/pi433/rf69_enum.h | 18 +-
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index b1cbec876857..57db806ff5af 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -443,7 +443,7 @@ pi433_receive(void *data)
return retval;
 
/* now check RSSI, if low wait for getting high (RSSI interrupt) */
-   while (!rf69_get_flag(dev->spi, rssiExceededThreshold)) {
+   while (!rf69_get_flag(dev->spi, rssi_exceeded_threshold)) {
/* allow tx to interrupt us while waiting for high RSSI */
dev->interrupt_rx_allowed = true;
wake_up_interruptible(>tx_wait_queue);
@@ -452,7 +452,7 @@ pi433_receive(void *data)
dev_dbg(dev->dev, "rx: going to wait for high RSSI level");
retval = wait_event_interruptible(dev->rx_wait_queue,
  rf69_get_flag(dev->spi,
-   
rssiExceededThreshold));
+   
rssi_exceeded_threshold));
if (retval) /* wait was interrupted */
goto abort;
dev->interrupt_rx_allowed = false;
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 54d8105b5812..fc4919711477 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -545,21 +545,21 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 
DIONumber, u8 value)
 bool rf69_get_flag(struct spi_device *spi, enum flag flag)
 {
switch (flag) {
-   case modeSwitchCompleted:
+   case mode_switch_completed:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_MODE_READY);
-   case readyToReceive:
+   case ready_to_receive:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_RX_READY);
-   case readyToSend:
+   case ready_to_send:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_TX_READY);
-   case pllLocked:
+   case pll_locked:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_PLL_LOCK);
-   case rssiExceededThreshold:
+   case rssi_exceeded_threshold:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_RSSI);
case timeout:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_TIMEOUT);
case automode:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_AUTOMODE);
-   case syncAddressMatch:
+   case sync_address_match:
return (rf69_read_reg(spi, REG_IRQFLAGS1) & 
MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH);
case fifo_full:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_FIFO_FULL);
@@ -571,13 +571,13 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag)
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_FIFO_LEVEL);
case fifo_overrun:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_FIFO_OVERRUN);
-   case packetSent:
+   case packet_sent:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_PACKET_SENT);
case payload_ready:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_PAYLOAD_READY);
-   case crcOk:
+   case crc_ok:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_CRC_OK);
-   case batteryLow:
+   case battery_low:
return (rf69_read_reg(spi, REG_IRQFLAGS2) & 
MASK_IRQFLAGS2_LOW_BAT);
default: return false;
}
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 682b667bf342..81287ce6be35 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -94,23 +94,23 @@ enum threshold_decrement {
 };
 
 enum flag {
-   modeSwitchCompleted,
-   readyToReceive,
-   readyToSend,
-   pllLocked,
-   rssiExceededThreshold,
+   mode_switch_completed,
+   ready_to_receive,
+   ready_to_send,
+   pll_locked,
+   rssi_exceeded_threshold,
timeout,
automode,
-   syncAddressMatch,
+   sync_address_match,
fifo_full,
 // 

[PATCH 5/6] staging: pi433: fix CamelCase for Address variables

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/rf69.c | 8 
 drivers/staging/pi433/rf69.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index f419a3d4485b..c143ffc7596f 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -704,14 +704,14 @@ int rf69_set_payload_length(struct spi_device *spi, u8 
payload_length)
return rf69_write_reg(spi, REG_PAYLOAD_LENGTH, payload_length);
 }
 
-int rf69_set_node_address(struct spi_device *spi, u8 nodeAddress)
+int rf69_set_node_address(struct spi_device *spi, u8 node_address)
 {
-   return rf69_write_reg(spi, REG_NODEADRS, nodeAddress);
+   return rf69_write_reg(spi, REG_NODEADRS, node_address);
 }
 
-int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcastAddress)
+int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address)
 {
-   return rf69_write_reg(spi, REG_BROADCASTADRS, broadcastAddress);
+   return rf69_write_reg(spi, REG_BROADCASTADRS, broadcast_address);
 }
 
 int rf69_set_tx_start_condition(struct spi_device *spi, enum 
tx_start_condition tx_start_condition)
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 7b7932a553e8..677091319d7e 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -55,8 +55,8 @@ int rf69_enable_crc(struct spi_device *spi);
 int rf69_disable_crc(struct spi_device *spi);
 int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering);
 int rf69_set_payload_length(struct spi_device *spi, u8 payload_length);
-int rf69_set_node_address(struct spi_device *spi, u8 nodeAddress);
-int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcastAddress);
+int rf69_set_node_address(struct spi_device *spi, u8 node_address);
+int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address);
 int rf69_set_tx_start_condition(struct spi_device *spi, enum 
tx_start_condition tx_start_condition);
 int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_dagc(struct spi_device *spi, enum dagc dagc);
-- 
2.16.1



[PATCH 4/6] staging: pi433: fix CamelCase for address_filtering enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/Documentation/pi433.txt | 12 ++--
 drivers/staging/pi433/pi433_if.c  |  6 +++---
 drivers/staging/pi433/rf69.c  |  6 +++---
 drivers/staging/pi433/rf69_enum.h |  6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 3313dff3c37e..2e8835bf2c9a 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -232,12 +232,12 @@ rf params:
 amount of bytes that were requested by the read 
request.
Attention: should be used in combination with sync, only
enable_address_filtering;
-   filteringOff- no address filtering will take place
-   nodeAddress - all telegrams, not matching the node
- address will be internally discarded
-   nodeOrBroadcastAddress  - all telegrams, neither matching the
- node, nor the broadcast address will
- be internally discarded
+   filtering_off - no address filtering will take place
+   node_address  - all telegrams, not matching the node
+   address will be internally discarded
+   node_or_broadcast_address - all telegrams, neither matching the
+   node, nor the broadcast address will
+   be internally discarded
Attention: Sync option must be enabled in order to use this 
feature
enable_crc
optionOn- a crc will be calculated over the payload of
diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 730200597218..88da91d31e61 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -257,7 +257,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
payload_length = rx_cfg->fixed_message_length;
if (rx_cfg->enable_length_byte  == OPTION_ON)
payload_length++;
-   if (rx_cfg->enable_address_filtering != filteringOff)
+   if (rx_cfg->enable_address_filtering != filtering_off)
payload_length++;
ret = rf69_set_payload_length(dev->spi, payload_length);
if (ret < 0)
@@ -274,7 +274,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
if (ret < 0)
return ret;
}
-   if (rx_cfg->enable_address_filtering != filteringOff) {
+   if (rx_cfg->enable_address_filtering != filtering_off) {
ret = rf69_set_node_address(dev->spi, rx_cfg->node_address);
if (ret < 0)
return ret;
@@ -502,7 +502,7 @@ pi433_receive(void *data)
}
 
/* address byte enabled? */
-   if (dev->rx_cfg.enable_address_filtering != filteringOff) {
+   if (dev->rx_cfg.enable_address_filtering != filtering_off) {
u8 dummy;
 
bytes_total--;
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index a73a3d2c0685..f419a3d4485b 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -687,11 +687,11 @@ int rf69_disable_crc(struct spi_device *spi)
 int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering)
 {
switch (address_filtering) {
-   case filteringOff:
+   case filtering_off:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_OFF);
-   case nodeAddress:
+   case node_address:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODE);
-   case nodeOrBroadcastAddress:
+   case node_or_broadcast_address:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_ADDRESSFILTERING, 
PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index d82d2be88cbd..43990e74db85 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -129,9 +129,9 @@ enum tx_start_condition {
 };
 
 enum address_filtering {
-   filteringOff,
-   node

[PATCH 5/6] staging: pi433: fix CamelCase for Address variables

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/rf69.c | 8 
 drivers/staging/pi433/rf69.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index f419a3d4485b..c143ffc7596f 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -704,14 +704,14 @@ int rf69_set_payload_length(struct spi_device *spi, u8 
payload_length)
return rf69_write_reg(spi, REG_PAYLOAD_LENGTH, payload_length);
 }
 
-int rf69_set_node_address(struct spi_device *spi, u8 nodeAddress)
+int rf69_set_node_address(struct spi_device *spi, u8 node_address)
 {
-   return rf69_write_reg(spi, REG_NODEADRS, nodeAddress);
+   return rf69_write_reg(spi, REG_NODEADRS, node_address);
 }
 
-int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcastAddress)
+int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address)
 {
-   return rf69_write_reg(spi, REG_BROADCASTADRS, broadcastAddress);
+   return rf69_write_reg(spi, REG_BROADCASTADRS, broadcast_address);
 }
 
 int rf69_set_tx_start_condition(struct spi_device *spi, enum 
tx_start_condition tx_start_condition)
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 7b7932a553e8..677091319d7e 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -55,8 +55,8 @@ int rf69_enable_crc(struct spi_device *spi);
 int rf69_disable_crc(struct spi_device *spi);
 int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering);
 int rf69_set_payload_length(struct spi_device *spi, u8 payload_length);
-int rf69_set_node_address(struct spi_device *spi, u8 nodeAddress);
-int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcastAddress);
+int rf69_set_node_address(struct spi_device *spi, u8 node_address);
+int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address);
 int rf69_set_tx_start_condition(struct spi_device *spi, enum 
tx_start_condition tx_start_condition);
 int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_dagc(struct spi_device *spi, enum dagc dagc);
-- 
2.16.1



[PATCH 4/6] staging: pi433: fix CamelCase for address_filtering enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/Documentation/pi433.txt | 12 ++--
 drivers/staging/pi433/pi433_if.c  |  6 +++---
 drivers/staging/pi433/rf69.c  |  6 +++---
 drivers/staging/pi433/rf69_enum.h |  6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 3313dff3c37e..2e8835bf2c9a 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -232,12 +232,12 @@ rf params:
 amount of bytes that were requested by the read 
request.
Attention: should be used in combination with sync, only
enable_address_filtering;
-   filteringOff- no address filtering will take place
-   nodeAddress - all telegrams, not matching the node
- address will be internally discarded
-   nodeOrBroadcastAddress  - all telegrams, neither matching the
- node, nor the broadcast address will
- be internally discarded
+   filtering_off - no address filtering will take place
+   node_address  - all telegrams, not matching the node
+   address will be internally discarded
+   node_or_broadcast_address - all telegrams, neither matching the
+   node, nor the broadcast address will
+   be internally discarded
Attention: Sync option must be enabled in order to use this 
feature
enable_crc
optionOn- a crc will be calculated over the payload of
diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 730200597218..88da91d31e61 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -257,7 +257,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
payload_length = rx_cfg->fixed_message_length;
if (rx_cfg->enable_length_byte  == OPTION_ON)
payload_length++;
-   if (rx_cfg->enable_address_filtering != filteringOff)
+   if (rx_cfg->enable_address_filtering != filtering_off)
payload_length++;
ret = rf69_set_payload_length(dev->spi, payload_length);
if (ret < 0)
@@ -274,7 +274,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
if (ret < 0)
return ret;
}
-   if (rx_cfg->enable_address_filtering != filteringOff) {
+   if (rx_cfg->enable_address_filtering != filtering_off) {
ret = rf69_set_node_address(dev->spi, rx_cfg->node_address);
if (ret < 0)
return ret;
@@ -502,7 +502,7 @@ pi433_receive(void *data)
}
 
/* address byte enabled? */
-   if (dev->rx_cfg.enable_address_filtering != filteringOff) {
+   if (dev->rx_cfg.enable_address_filtering != filtering_off) {
u8 dummy;
 
bytes_total--;
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index a73a3d2c0685..f419a3d4485b 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -687,11 +687,11 @@ int rf69_disable_crc(struct spi_device *spi)
 int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering)
 {
switch (address_filtering) {
-   case filteringOff:
+   case filtering_off:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_OFF);
-   case nodeAddress:
+   case node_address:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_NODE);
-   case nodeOrBroadcastAddress:
+   case node_or_broadcast_address:
return rf69_read_mod_write(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_ADDRESSFILTERING, 
PACKETCONFIG1_ADDRESSFILTERING_NODEBROADCAST);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index d82d2be88cbd..43990e74db85 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -129,9 +129,9 @@ enum tx_start_condition {
 };
 
 enum address_filtering {
-   filteringOff,
-   nodeAddress,
-   nodeOrBroad

[PATCH 3/6] staging: pi433: fix CamelCase for afterSyncInterrupt

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/pi433_if.c  | 2 +-
 drivers/staging/pi433/rf69.c  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 57db806ff5af..730200597218 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -209,7 +209,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
return ret;
 
ret = rf69_set_fifo_fill_condition(dev->spi,
-  afterSyncInterrupt);
+  after_sync_interrupt);
if (ret < 0)
return ret;
} else {
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index fc4919711477..a73a3d2c0685 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -625,7 +625,7 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, 
enum fifo_fill_conditio
switch (fifo_fill_condition) {
case always:
return rf69_set_bit(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
-   case afterSyncInterrupt:
+   case after_sync_interrupt:
return rf69_clear_bit(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 81287ce6be35..d82d2be88cbd 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -114,7 +114,7 @@ enum flag {
 };
 
 enum fifo_fill_condition {
-   afterSyncInterrupt,
+   after_sync_interrupt,
always
 };
 
-- 
2.16.1



[PATCH 3/6] staging: pi433: fix CamelCase for afterSyncInterrupt

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/pi433_if.c  | 2 +-
 drivers/staging/pi433/rf69.c  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 57db806ff5af..730200597218 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -209,7 +209,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
return ret;
 
ret = rf69_set_fifo_fill_condition(dev->spi,
-  afterSyncInterrupt);
+  after_sync_interrupt);
if (ret < 0)
return ret;
} else {
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index fc4919711477..a73a3d2c0685 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -625,7 +625,7 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, 
enum fifo_fill_conditio
switch (fifo_fill_condition) {
case always:
return rf69_set_bit(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
-   case afterSyncInterrupt:
+   case after_sync_interrupt:
return rf69_clear_bit(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 81287ce6be35..d82d2be88cbd 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -114,7 +114,7 @@ enum flag {
 };
 
 enum fifo_fill_condition {
-   afterSyncInterrupt,
+   after_sync_interrupt,
always
 };
 
-- 
2.16.1



[PATCH 1/6 v2] staging: pi433: fix CamelCase for packetFormat enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
v2: order patches so they apply correctly

 drivers/staging/pi433/pi433_if.c  | 8 
 drivers/staging/pi433/rf69.c  | 8 
 drivers/staging/pi433/rf69.h  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index aad1debd34a2..b1cbec876857 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -222,11 +222,11 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
return ret;
}
if (rx_cfg->enable_length_byte == OPTION_ON) {
-   ret = rf69_set_packet_format(dev->spi, packetLengthVar);
+   ret = rf69_set_packet_format(dev->spi, packet_length_var);
if (ret < 0)
return ret;
} else {
-   ret = rf69_set_packet_format(dev->spi, packetLengthFix);
+   ret = rf69_set_packet_format(dev->spi, packet_length_fix);
if (ret < 0)
return ret;
}
@@ -337,11 +337,11 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
}
 
if (tx_cfg->enable_length_byte == OPTION_ON) {
-   ret = rf69_set_packet_format(dev->spi, packetLengthVar);
+   ret = rf69_set_packet_format(dev->spi, packet_length_var);
if (ret < 0)
return ret;
} else {
-   ret = rf69_set_packet_format(dev->spi, packetLengthFix);
+   ret = rf69_set_packet_format(dev->spi, packet_length_fix);
if (ret < 0)
return ret;
}
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index b2cea5f52eea..54d8105b5812 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -661,12 +661,12 @@ int rf69_set_sync_values(struct spi_device *spi, u8 
sync_values[8])
return retval;
 }
 
-int rf69_set_packet_format(struct spi_device *spi, enum packetFormat 
packetFormat)
+int rf69_set_packet_format(struct spi_device *spi, enum packet_format 
packet_format)
 {
-   switch (packetFormat) {
-   case packetLengthVar:
+   switch (packet_format) {
+   case packet_length_var:
return rf69_set_bit(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
-   case packetLengthFix:
+   case packet_length_fix:
return rf69_clear_bit(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index cf89b556cb00..7b7932a553e8 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -50,7 +50,7 @@ int rf69_disable_sync(struct spi_device *spi);
 int rf69_set_fifo_fill_condition(struct spi_device *spi, enum 
fifo_fill_condition fifo_fill_condition);
 int rf69_set_sync_size(struct spi_device *spi, u8 sync_size);
 int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8]);
-int rf69_set_packet_format(struct spi_device *spi, enum packetFormat 
packetFormat);
+int rf69_set_packet_format(struct spi_device *spi, enum packet_format 
packet_format);
 int rf69_enable_crc(struct spi_device *spi);
 int rf69_disable_crc(struct spi_device *spi);
 int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering);
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index cba3c5b3995c..682b667bf342 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -118,9 +118,9 @@ enum fifo_fill_condition {
always
 };
 
-enum packetFormat {
-   packetLengthFix,
-   packetLengthVar
+enum packet_format {
+   packet_length_fix,
+   packet_length_var
 };
 
 enum tx_start_condition {
-- 
2.16.1



[PATCH 6/6] staging: pi433: fix CamelCase for paRamp enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/Documentation/pi433.txt | 2 +-
 drivers/staging/pi433/pi433_if.h  | 2 +-
 drivers/staging/pi433/rf69.c  | 4 ++--
 drivers/staging/pi433/rf69.h  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 2e8835bf2c9a..79bccc586869 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -92,7 +92,7 @@ rf params:
shaping0_3  - gauss filter with BT 0.3 (FSK only)
shapingBR   - filter cut off at BR (OOK only)
shaping2BR  - filter cut off at 2*BR (OOK only)
-   paRamp (FSK only)
+   pa_ramp (FSK only)
ramp3400- amp ramps up in 3.4ms
ramp2000- amp ramps up in 2.0ms
ramp1000- amp ramps up in 1ms
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index b3fa4fe64c5c..be4a96055a97 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -67,7 +67,7 @@ struct pi433_tx_cfg {
enum modulation modulation;
enum mod_shapingmod_shaping;
 
-   enum paRamp pa_ramp;
+   enum pa_ramppa_ramp;
 
enum tx_start_condition tx_start_condition;
 
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index c143ffc7596f..e5c7e48a3b86 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -345,9 +345,9 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
power_level)
return rf69_read_mod_write(spi, REG_PALEVEL, MASK_PALEVEL_OUTPUT_POWER, 
power_level);
 }
 
-int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
+int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (paRamp) {
+   switch (pa_ramp) {
case ramp3400:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
case ramp2000:
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 677091319d7e..d83808a5dd86 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -35,7 +35,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency);
 int rf69_enable_amplifier(struct spi_device *spi, u8 amplifier_mask);
 int rf69_disable_amplifier(struct spi_device *spi, u8 amplifier_mask);
 int rf69_set_output_power_level(struct spi_device *spi, u8 power_level);
-int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp);
+int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp);
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance 
antenna_impedance);
 int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain);
 int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 43990e74db85..5ac3d33a3d0c 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -41,7 +41,7 @@ enum mod_shaping {
SHAPING_2BR
 };
 
-enum paRamp {
+enum pa_ramp {
ramp3400,
ramp2000,
ramp1000,
-- 
2.16.1



[PATCH 6/6] staging: pi433: fix CamelCase for paRamp enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
 drivers/staging/pi433/Documentation/pi433.txt | 2 +-
 drivers/staging/pi433/pi433_if.h  | 2 +-
 drivers/staging/pi433/rf69.c  | 4 ++--
 drivers/staging/pi433/rf69.h  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/pi433/Documentation/pi433.txt 
b/drivers/staging/pi433/Documentation/pi433.txt
index 2e8835bf2c9a..79bccc586869 100644
--- a/drivers/staging/pi433/Documentation/pi433.txt
+++ b/drivers/staging/pi433/Documentation/pi433.txt
@@ -92,7 +92,7 @@ rf params:
shaping0_3  - gauss filter with BT 0.3 (FSK only)
shapingBR   - filter cut off at BR (OOK only)
shaping2BR  - filter cut off at 2*BR (OOK only)
-   paRamp (FSK only)
+   pa_ramp (FSK only)
ramp3400- amp ramps up in 3.4ms
ramp2000- amp ramps up in 2.0ms
ramp1000- amp ramps up in 1ms
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index b3fa4fe64c5c..be4a96055a97 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -67,7 +67,7 @@ struct pi433_tx_cfg {
enum modulation modulation;
enum mod_shapingmod_shaping;
 
-   enum paRamp pa_ramp;
+   enum pa_ramppa_ramp;
 
enum tx_start_condition tx_start_condition;
 
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index c143ffc7596f..e5c7e48a3b86 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -345,9 +345,9 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
power_level)
return rf69_read_mod_write(spi, REG_PALEVEL, MASK_PALEVEL_OUTPUT_POWER, 
power_level);
 }
 
-int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
+int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp)
 {
-   switch (paRamp) {
+   switch (pa_ramp) {
case ramp3400:
return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
case ramp2000:
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 677091319d7e..d83808a5dd86 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -35,7 +35,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency);
 int rf69_enable_amplifier(struct spi_device *spi, u8 amplifier_mask);
 int rf69_disable_amplifier(struct spi_device *spi, u8 amplifier_mask);
 int rf69_set_output_power_level(struct spi_device *spi, u8 power_level);
-int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp);
+int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp);
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance 
antenna_impedance);
 int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain);
 int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 43990e74db85..5ac3d33a3d0c 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -41,7 +41,7 @@ enum mod_shaping {
SHAPING_2BR
 };
 
-enum paRamp {
+enum pa_ramp {
ramp3400,
ramp2000,
ramp1000,
-- 
2.16.1



[PATCH 1/6 v2] staging: pi433: fix CamelCase for packetFormat enum

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 
  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic 
---
v2: order patches so they apply correctly

 drivers/staging/pi433/pi433_if.c  | 8 
 drivers/staging/pi433/rf69.c  | 8 
 drivers/staging/pi433/rf69.h  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index aad1debd34a2..b1cbec876857 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -222,11 +222,11 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
return ret;
}
if (rx_cfg->enable_length_byte == OPTION_ON) {
-   ret = rf69_set_packet_format(dev->spi, packetLengthVar);
+   ret = rf69_set_packet_format(dev->spi, packet_length_var);
if (ret < 0)
return ret;
} else {
-   ret = rf69_set_packet_format(dev->spi, packetLengthFix);
+   ret = rf69_set_packet_format(dev->spi, packet_length_fix);
if (ret < 0)
return ret;
}
@@ -337,11 +337,11 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
}
 
if (tx_cfg->enable_length_byte == OPTION_ON) {
-   ret = rf69_set_packet_format(dev->spi, packetLengthVar);
+   ret = rf69_set_packet_format(dev->spi, packet_length_var);
if (ret < 0)
return ret;
} else {
-   ret = rf69_set_packet_format(dev->spi, packetLengthFix);
+   ret = rf69_set_packet_format(dev->spi, packet_length_fix);
if (ret < 0)
return ret;
}
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index b2cea5f52eea..54d8105b5812 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -661,12 +661,12 @@ int rf69_set_sync_values(struct spi_device *spi, u8 
sync_values[8])
return retval;
 }
 
-int rf69_set_packet_format(struct spi_device *spi, enum packetFormat 
packetFormat)
+int rf69_set_packet_format(struct spi_device *spi, enum packet_format 
packet_format)
 {
-   switch (packetFormat) {
-   case packetLengthVar:
+   switch (packet_format) {
+   case packet_length_var:
return rf69_set_bit(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
-   case packetLengthFix:
+   case packet_length_fix:
return rf69_clear_bit(spi, REG_PACKETCONFIG1, 
MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index cf89b556cb00..7b7932a553e8 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -50,7 +50,7 @@ int rf69_disable_sync(struct spi_device *spi);
 int rf69_set_fifo_fill_condition(struct spi_device *spi, enum 
fifo_fill_condition fifo_fill_condition);
 int rf69_set_sync_size(struct spi_device *spi, u8 sync_size);
 int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8]);
-int rf69_set_packet_format(struct spi_device *spi, enum packetFormat 
packetFormat);
+int rf69_set_packet_format(struct spi_device *spi, enum packet_format 
packet_format);
 int rf69_enable_crc(struct spi_device *spi);
 int rf69_disable_crc(struct spi_device *spi);
 int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering);
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index cba3c5b3995c..682b667bf342 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -118,9 +118,9 @@ enum fifo_fill_condition {
always
 };
 
-enum packetFormat {
-   packetLengthFix,
-   packetLengthVar
+enum packet_format {
+   packet_length_fix,
+   packet_length_var
 };
 
 enum tx_start_condition {
-- 
2.16.1



[PATCH] staging: pi433: fix CamelCase for afterSyncInterrupt

2018-03-04 Thread Valentin Vidic
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: 

Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr>
---
 drivers/staging/pi433/pi433_if.c  | 2 +-
 drivers/staging/pi433/rf69.c  | 2 +-
 drivers/staging/pi433/rf69_enum.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 57db806ff5af..730200597218 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -209,7 +209,7 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
return ret;
 
ret = rf69_set_fifo_fill_condition(dev->spi,
-  afterSyncInterrupt);
+  after_sync_interrupt);
if (ret < 0)
return ret;
} else {
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index fc4919711477..a73a3d2c0685 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -625,7 +625,7 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, 
enum fifo_fill_conditio
switch (fifo_fill_condition) {
case always:
return rf69_set_bit(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
-   case afterSyncInterrupt:
+   case after_sync_interrupt:
return rf69_clear_bit(spi, REG_SYNC_CONFIG, 
MASK_SYNC_CONFIG_FIFO_FILL_CONDITION);
default:
dev_dbg(>dev, "set: illegal input param");
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index 81287ce6be35..d82d2be88cbd 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -114,7 +114,7 @@ enum flag {
 };
 
 enum fifo_fill_condition {
-   afterSyncInterrupt,
+   after_sync_interrupt,
always
 };
 
-- 
2.16.1



  1   2   3   >