[PATCH v3 4/4] staging: exfat: add millisecond support
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 3/4] staging: exfat: drop unused field access_time_ms
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 2/4] staging: exfat: drop duplicate date_time_t struct
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 v2 3/3] staging: exfat: add millisecond support
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/3] staging: exfat: drop unused field access_time_ms
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/3] staging: exfat: cleanup spacing for operators
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 3/3] staging: exfat: use integer constants
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 v3 2/3] staging: exfat: cleanup spacing for casts
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] staging: exfat: add millisecond support
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
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
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
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
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
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
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
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: exfat: cleanup braces for if/else statements
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: exfat: cleanup blank line warnings
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: exfat: use BIT macro for defining sizes
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<http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: cleanup comments in rf69.h
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: add SPDX-License-Identifier tag
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3] staging: pi433: replace simple switch statements
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
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
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)
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2] staging: pi433: add mutex fixing concurrency issues.
On Thu, Jun 07, 2018 at 08:45:03AM -0400, Hugo Lefeuvre wrote: > After discussing this issue on the kernel newbies mailing list[0] we > came to the conclusion that it is very unlikely that pi433_release and > pi433_ioctl would ever run concurrently in this case. This is also > true for read/write. Unless one can find a situation where this might > happen, I think we should not add this potentially unnecessary lock. Yes, so we should than drop the TODO comment on this issue? -- Valentin ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: pi433: cleanup tx_fifo locking
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: use help in Kconfig description
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: cleanup tx_fifo locking
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: add descriptions for mutex locks
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: cleanup local variable
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/7] staging: pi433: fix CamelCase for bitRate variables
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/7] staging: pi433: fix CamelCase for DIONumber variable
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/7] staging: pi433: fix CamelCase for syncSize variable
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/7] staging: pi433: fix CamelCase for preambleLength variable
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/7] staging: pi433: fix CamelCase for lnaGain enum
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/7] staging: pi433: fix CamelCase for dagc enum
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/7] staging: pi433: fix CamelCase for GPIO functions
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/6] staging: pi433: fix CamelCase for paRamp enum
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/6] staging: pi433: fix CamelCase for flag enum
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 4/6] staging: pi433: fix CamelCase for address_filtering enum
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
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/6 v2] staging: pi433: fix CamelCase for packetFormat enum
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/6] staging: pi433: fix CamelCase for afterSyncInterrupt
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for paRamp enum
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for flag enum
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] staging: pi433: fix CamelCase for Address variables
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for afterSyncInterrupt
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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for address_filtering enum
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] staging: pi433: fix CamelCase for packetFormat enum
Fixes checkpatch warnings: CHECK: Avoid CamelCase: CHECK: Avoid CamelCase: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- 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 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for addressFiltering
Fixes checkpatch warning: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/pi433_if.c | 4 ++-- 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, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index e8ddc924bb04..aad1debd34a2 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -230,8 +230,8 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) if (ret < 0) return ret; } - ret = rf69_set_adressFiltering(dev->spi, - rx_cfg->enable_address_filtering); + ret = rf69_set_address_filtering(dev->spi, +rx_cfg->enable_address_filtering); if (ret < 0) return ret; diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index 22c1631d0bf0..b3fa4fe64c5c 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -125,7 +125,7 @@ struct pi433_rx_cfg { /* packet format */ enum option_on_off enable_sync; enum option_on_off enable_length_byte; /* should be used in combination with sync, only */ - enum addressFiltering enable_address_filtering; /* operational with sync, only */ + enum address_filtering enable_address_filtering; /* operational with sync, only */ enum option_on_off enable_crc; /* only operational, if sync on and fixed length or length byte is used */ __u8sync_length; diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 91c834059710..b2cea5f52eea 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -684,9 +684,9 @@ int rf69_disable_crc(struct spi_device *spi) return rf69_clear_bit(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_CRC_ON); } -int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addressFiltering) +int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering address_filtering) { - switch (addressFiltering) { + switch (address_filtering) { case filteringOff: return rf69_read_mod_write(spi, REG_PACKETCONFIG1, MASK_PACKETCONFIG1_ADDRESSFILTERING, PACKETCONFIG1_ADDRESSFILTERING_OFF); case nodeAddress: diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 21d7034e2c79..cf89b556cb00 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -53,7 +53,7 @@ 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_enable_crc(struct spi_device *spi); int rf69_disable_crc(struct spi_device *spi); -int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addressFiltering); +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); diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi433/rf69_enum.h index 478e3a4c4948..cba3c5b3995c 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -128,7 +128,7 @@ enum tx_start_condition { fifo_not_empty }; -enum addressFiltering { +enum address_filtering { filteringOff, nodeAddress, nodeOrBroadcastAddress -- 2.16.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for thresholdDecrement
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 61ba9700d7dc..3313dff3c37e 100644 --- a/drivers/staging/pi433/Documentation/pi433.txt +++ b/drivers/staging/pi433/Documentation/pi433.txt @@ -180,7 +180,7 @@ rf params: threshold value for the signal strength on the receiver input. If this value is exceeded, a reception cycle starts Allowed values: 0...255 - thresholdDecrement + threshold_decrement in order to adapt to different levels of singnal strength, over time the receiver gets more and more sensitive. This value determs, how fast the sensitivity increases. diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index 69847f978a69..22c1631d0bf0 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -115,7 +115,7 @@ struct pi433_rx_cfg { enum modulation modulation; __u8rssi_threshold; - enum thresholdDecrement threshold_decrement; + enum threshold_decrement threshold_decrement; enum antenna_impedance antenna_impedance; enum lnaGainlna_gain; enum mantisse bw_mantisse;/* normal: 0x50 */ diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 722d95a3777f..91c834059710 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -476,9 +476,9 @@ int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse mantisse return rf69_set_bandwidth_intern(spi, REG_AFCBW, mantisse, exponent); } -int rf69_set_ook_threshold_dec(struct spi_device *spi, enum thresholdDecrement thresholdDecrement) +int rf69_set_ook_threshold_dec(struct spi_device *spi, enum threshold_decrement threshold_decrement) { - switch (thresholdDecrement) { + switch (threshold_decrement) { case dec_every8th: return rf69_read_mod_write(spi, REG_OOKPEAK, MASK_OOKPEAK_THRESDEC, OOKPEAK_THRESHDEC_EVERY_8TH); case dec_every4th: diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 147d89390745..21d7034e2c79 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -40,7 +40,7 @@ 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_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 thresholdDecrement thresholdDecrement); +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); bool rf69_get_flag(struct spi_device *spi, enum flag flag); int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold); diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi433/rf69_enum.h index 196c95dfe327..478e3a4c4948 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -82,7 +82,7 @@ enum mantisse { mantisse24 }; -enum thresholdDecrement { +enum threshold_decrement { dec_every8th, dec_every4th, dec_every2nd, -- 2.16.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for txStartCondition
Fixes checkpatch warning: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- 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 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index c4e4ea086a24..69847f978a69 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -69,7 +69,7 @@ struct pi433_tx_cfg { enum paRamp pa_ramp; - enum txStartCondition tx_start_condition; + enum tx_start_condition tx_start_condition; __u16 repetitions; diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 42c2e1c6b386..722d95a3777f 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -714,9 +714,9 @@ int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcastAddress) return rf69_write_reg(spi, REG_BROADCASTADRS, broadcastAddress); } -int rf69_set_tx_start_condition(struct spi_device *spi, enum txStartCondition txStartCondition) +int rf69_set_tx_start_condition(struct spi_device *spi, enum tx_start_condition tx_start_condition) { - switch (txStartCondition) { + switch (tx_start_condition) { case fifo_level: return rf69_clear_bit(spi, REG_FIFO_THRESH, MASK_FIFO_THRESH_TXSTART); case fifo_not_empty: diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 2c0d130f7a03..147d89390745 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -57,7 +57,7 @@ int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addre 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_tx_start_condition(struct spi_device *spi, enum txStartCondition txStartCondition); +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); diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi433/rf69_enum.h index 5629af716e4f..196c95dfe327 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -123,7 +123,7 @@ enum packetFormat { packetLengthVar }; -enum txStartCondition { +enum tx_start_condition { fifo_level, fifo_not_empty }; -- 2.16.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/8] staging: pi433: fix CamelCase for newValue
Local variable storing the new value for bandwidth register so replace with bandwidth. Fixes checkpatch warnings: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 261ba1643f5a..ef56deccd0af 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -425,7 +425,7 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain) static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg, enum mantisse mantisse, u8 exponent) { - u8 newValue; + u8 bandwidth; // check value for mantisse and exponent if (exponent > 7) { @@ -441,29 +441,29 @@ static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg, } // read old value - newValue = rf69_read_reg(spi, reg); + bandwidth = rf69_read_reg(spi, reg); // "delete" mantisse and exponent = just keep the DCC setting - newValue = newValue & MASK_BW_DCC_FREQ; + bandwidth = bandwidth & MASK_BW_DCC_FREQ; // add new mantisse switch (mantisse) { case mantisse16: - newValue = newValue | BW_MANT_16; + bandwidth = bandwidth | BW_MANT_16; break; case mantisse20: - newValue = newValue | BW_MANT_20; + bandwidth = bandwidth | BW_MANT_20; break; case mantisse24: - newValue = newValue | BW_MANT_24; + bandwidth = bandwidth | BW_MANT_24; break; } // add new exponent - newValue = newValue | exponent; + bandwidth = bandwidth | exponent; // write back - return rf69_write_reg(spi, reg, newValue); + return rf69_write_reg(spi, reg, bandwidth); } int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 exponent) -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/8] staging: pi433: fix CamelCase for regValue
Local variable storing the new value for dio register so replace with dio_value. Update regaddr to dio_addr to match. Fixes checkpatch warnings: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index ef56deccd0af..42c2e1c6b386 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -505,27 +505,27 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) { u8 mask; u8 shift; - u8 regaddr; - u8 regValue; + u8 dio_addr; + u8 dio_value; switch (DIONumber) { case 0: - mask = MASK_DIO0; shift = SHIFT_DIO0; regaddr = REG_DIOMAPPING1; + mask = MASK_DIO0; shift = SHIFT_DIO0; dio_addr = REG_DIOMAPPING1; break; case 1: - mask = MASK_DIO1; shift = SHIFT_DIO1; regaddr = REG_DIOMAPPING1; + mask = MASK_DIO1; shift = SHIFT_DIO1; dio_addr = REG_DIOMAPPING1; break; case 2: - mask = MASK_DIO2; shift = SHIFT_DIO2; regaddr = REG_DIOMAPPING1; + mask = MASK_DIO2; shift = SHIFT_DIO2; dio_addr = REG_DIOMAPPING1; break; case 3: - mask = MASK_DIO3; shift = SHIFT_DIO3; regaddr = REG_DIOMAPPING1; + mask = MASK_DIO3; shift = SHIFT_DIO3; dio_addr = REG_DIOMAPPING1; break; case 4: - mask = MASK_DIO4; shift = SHIFT_DIO4; regaddr = REG_DIOMAPPING2; + mask = MASK_DIO4; shift = SHIFT_DIO4; dio_addr = REG_DIOMAPPING2; break; case 5: - mask = MASK_DIO5; shift = SHIFT_DIO5; regaddr = REG_DIOMAPPING2; + mask = MASK_DIO5; shift = SHIFT_DIO5; dio_addr = REG_DIOMAPPING2; break; default: dev_dbg(>dev, "set: illegal input param"); @@ -533,13 +533,13 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) } // read reg - regValue = rf69_read_reg(spi, regaddr); + dio_value = rf69_read_reg(spi, dio_addr); // delete old value - regValue = regValue & ~mask; + dio_value = dio_value & ~mask; // add new value - regValue = regValue | value << shift; + dio_value = dio_value | value << shift; // write back - return rf69_write_reg(spi, regaddr, regValue); + return rf69_write_reg(spi, dio_addr, dio_value); } bool rf69_get_flag(struct spi_device *spi, enum flag flag) -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/8] staging: pi433: fix CamelCase for Ohm identifiers
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/pi433_if.c | 2 +- drivers/staging/pi433/rf69.c | 4 ++-- drivers/staging/pi433/rf69_enum.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/pi433/Documentation/pi433.txt b/drivers/staging/pi433/Documentation/pi433.txt index 05f278180ca3..61ba9700d7dc 100644 --- a/drivers/staging/pi433/Documentation/pi433.txt +++ b/drivers/staging/pi433/Documentation/pi433.txt @@ -194,8 +194,8 @@ rf params: step_6_0db - increase in 6 db steps antenna_impedance sets the electrical adoption of the antenna - fiftyOhm- for antennas with an impedance of 50Ohm - twohundretOhm - for antennas with an impedance of 200Ohm + fifty_ohm - for antennas with an impedance of 50Ohm + two_hundred_ohm - for antennas with an impedance of 200Ohm lnaGain sets the gain of the low noise amp automatic - lna gain is determined by an agc diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index edcd7e798f99..14712e1bd5eb 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1183,7 +1183,7 @@ static int pi433_probe(struct spi_device *spi) retval = rf69_set_output_power_level(spi, 13); if (retval < 0) goto minor_failed; - retval = rf69_set_antenna_impedance(spi, fiftyOhm); + retval = rf69_set_antenna_impedance(spi, fifty_ohm); if (retval < 0) goto minor_failed; diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 34ea865e55de..c69e63ffe537 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -389,9 +389,9 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp) int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance antenna_impedance) { switch (antenna_impedance) { - case fiftyOhm: + case fifty_ohm: return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN); - case twohundretOhm: + case two_hundred_ohm: return rf69_set_bit(spi, REG_LNA, MASK_LNA_ZIN); 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 7d0da84e2a29..5629af716e4f 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -61,8 +61,8 @@ enum paRamp { }; enum antenna_impedance { - fiftyOhm, - twohundretOhm + fifty_ohm, + two_hundred_ohm }; enum lnaGain { -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/8] staging: pi433: fix CamelCase for currentValue
Local variable storing the value for modulation register so replace with modulation_reg. Fixes checkpatch warnings: 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 c69e63ffe537..261ba1643f5a 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -151,11 +151,11 @@ int rf69_set_modulation(struct spi_device *spi, enum modulation modulation) static enum modulation rf69_get_modulation(struct spi_device *spi) { - u8 currentValue; + u8 modulation_reg; - currentValue = rf69_read_reg(spi, REG_DATAMODUL); + modulation_reg = rf69_read_reg(spi, REG_DATAMODUL); - switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE) { + switch (modulation_reg & MASK_DATAMODUL_MODULATION_TYPE) { case DATAMODUL_MODULATION_TYPE_OOK: return OOK; case DATAMODUL_MODULATION_TYPE_FSK: -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/8] staging: pi433: fix CamelCase for antennaImpedance
Fixes checkpatch warnings: 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 7d9dc2244848..05f278180ca3 100644 --- a/drivers/staging/pi433/Documentation/pi433.txt +++ b/drivers/staging/pi433/Documentation/pi433.txt @@ -192,7 +192,7 @@ rf params: step_4_0db - increase in 4 db steps step_5_0db - increase in 5 db steps step_6_0db - increase in 6 db steps - antennaImpedance + antenna_impedance sets the electrical adoption of the antenna fiftyOhm- for antennas with an impedance of 50Ohm twohundretOhm - for antennas with an impedance of 200Ohm diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index 7314f69af198..c4e4ea086a24 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -116,7 +116,7 @@ struct pi433_rx_cfg { __u8rssi_threshold; enum thresholdDecrement threshold_decrement; - enum antennaImpedance antenna_impedance; + enum antenna_impedance antenna_impedance; enum lnaGainlna_gain; enum mantisse bw_mantisse;/* normal: 0x50 */ __u8bw_exponent;/* during AFC: 0x8b */ diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 096bf84e9034..34ea865e55de 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -386,9 +386,9 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp) } } -int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance) +int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance antenna_impedance) { - switch (antennaImpedance) { + switch (antenna_impedance) { case fiftyOhm: return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN); case twohundretOhm: diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index cd085f2efa79..2c0d130f7a03 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -36,7 +36,7 @@ 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_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance); +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); int rf69_set_bandwidth_during_afc(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 03440cfa957c..7d0da84e2a29 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -60,7 +60,7 @@ enum paRamp { ramp10 }; -enum antennaImpedance { +enum antenna_impedance { fiftyOhm, twohundretOhm }; -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/8] staging: pi433: fix CamelCase for powerLevel
Fixes checkpatch warnings: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69.c | 8 drivers/staging/pi433/rf69.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index d55ef95b723e..096bf84e9034 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -330,19 +330,19 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 amplifier_mask) return rf69_clear_bit(spi, REG_PALEVEL, amplifier_mask); } -int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel) +int rf69_set_output_power_level(struct spi_device *spi, u8 power_level) { // TODO: Dependency to PA0,1,2 setting - powerLevel += 18; + power_level += 18; // check input value - if (powerLevel > 0x1f) { + if (power_level > 0x1f) { dev_dbg(>dev, "set: illegal input param"); return -EINVAL; } // write value - return rf69_read_mod_write(spi, REG_PALEVEL, MASK_PALEVEL_OUTPUT_POWER, powerLevel); + 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) diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 4531b5d8c08b..cd085f2efa79 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -34,7 +34,7 @@ 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); int rf69_disable_amplifier(struct spi_device *spi, u8 amplifier_mask); -int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel); +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_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance); int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain); -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/8] staging: pi433: fix CamelCase for syncValues
Fixes checkpatch warnings: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69.c | 18 +- drivers/staging/pi433/rf69.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 7ccdff6ae213..d55ef95b723e 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -645,18 +645,18 @@ int rf69_set_sync_size(struct spi_device *spi, u8 syncSize) return rf69_read_mod_write(spi, REG_SYNC_CONFIG, MASK_SYNC_CONFIG_SYNC_SIZE, (syncSize << 3)); } -int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8]) +int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8]) { int retval = 0; - retval += rf69_write_reg(spi, REG_SYNCVALUE1, syncValues[0]); - retval += rf69_write_reg(spi, REG_SYNCVALUE2, syncValues[1]); - retval += rf69_write_reg(spi, REG_SYNCVALUE3, syncValues[2]); - retval += rf69_write_reg(spi, REG_SYNCVALUE4, syncValues[3]); - retval += rf69_write_reg(spi, REG_SYNCVALUE5, syncValues[4]); - retval += rf69_write_reg(spi, REG_SYNCVALUE6, syncValues[5]); - retval += rf69_write_reg(spi, REG_SYNCVALUE7, syncValues[6]); - retval += rf69_write_reg(spi, REG_SYNCVALUE8, syncValues[7]); + retval += rf69_write_reg(spi, REG_SYNCVALUE1, sync_values[0]); + retval += rf69_write_reg(spi, REG_SYNCVALUE2, sync_values[1]); + retval += rf69_write_reg(spi, REG_SYNCVALUE3, sync_values[2]); + retval += rf69_write_reg(spi, REG_SYNCVALUE4, sync_values[3]); + retval += rf69_write_reg(spi, REG_SYNCVALUE5, sync_values[4]); + retval += rf69_write_reg(spi, REG_SYNCVALUE6, sync_values[5]); + retval += rf69_write_reg(spi, REG_SYNCVALUE7, sync_values[6]); + retval += rf69_write_reg(spi, REG_SYNCVALUE8, sync_values[7]); return retval; } diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 09d221b8b6df..4531b5d8c08b 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -49,7 +49,7 @@ 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); int rf69_set_sync_size(struct spi_device *spi, u8 sync_size); -int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8]); +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_enable_crc(struct spi_device *spi); int rf69_disable_crc(struct spi_device *spi); -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: pi433: Cleanup codestyle, indent statements after case labels
On Sun, Dec 24, 2017 at 02:42:57PM +0100, Marcus Wolf wrote: > > int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) > > { > > switch (dagc) { > > - case normalMode: return rf69_write_reg(spi, > > REG_TESTDAGC, DAGC_NORMAL); > > - case improve:return rf69_write_reg(spi, > > REG_TESTDAGC, DAGC_IMPROVED_LOWBETA0); > > - case improve4LowModulationIndex: return rf69_write_reg(spi, > > REG_TESTDAGC, DAGC_IMPROVED_LOWBETA1); > > + case normalMode: > > + return rf69_write_reg(spi, REG_TESTDAGC, DAGC_NORMAL); > > + case improve: > > + return rf69_write_reg(spi, REG_TESTDAGC, > > DAGC_IMPROVED_LOWBETA0); > > + case improve4LowModulationIndex: > > + return rf69_write_reg(spi, REG_TESTDAGC, > > DAGC_IMPROVED_LOWBETA1); > > default: > > dev_dbg(>dev, "set: illegal input param"); > > return -EINVAL; > > > > Hi Michael, > > first of all thank you for your effort :-) > > For me, the readability is reduced with this patch. > > But that's just my opinion/favour... Would something like this be any better for these simple switch statements? int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) { int dagc_value; switch (dagc) { case normalMode: dagc_value = DAGC_NORMAL; case improve: dagc_value = DAGC_IMPROVED_LOWBETA0; ... default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; } return rf69_write_reg(spi, REG_TESTDAGC, dagc_value); } -- Valentin ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: pi433: align function parameters with open parenthesis
Fixes checkpatch warnings: CHECK: Alignment should match open parenthesis Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v2: add missing Signed-off-by 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 f56425ffbe90..edcd7e798f99 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -799,7 +799,7 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) static ssize_t pi433_write(struct file *filp, const char __user *buf, - size_t count, loff_t *f_pos) + size_t count, loff_t *f_pos) { struct pi433_instance *instance; struct pi433_device *device; @@ -870,17 +870,17 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) switch (cmd) { case PI433_IOC_RD_TX_CFG: if (copy_to_user(argp, >tx_cfg, - sizeof(struct pi433_tx_cfg))) +sizeof(struct pi433_tx_cfg))) return -EFAULT; break; case PI433_IOC_WR_TX_CFG: if (copy_from_user(>tx_cfg, argp, - sizeof(struct pi433_tx_cfg))) + sizeof(struct pi433_tx_cfg))) return -EFAULT; break; case PI433_IOC_RD_RX_CFG: if (copy_to_user(argp, >rx_cfg, - sizeof(struct pi433_rx_cfg))) +sizeof(struct pi433_rx_cfg))) return -EFAULT; break; case PI433_IOC_WR_RX_CFG: @@ -893,7 +893,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } if (copy_from_user(>rx_cfg, argp, - sizeof(struct pi433_rx_cfg))) { + sizeof(struct pi433_rx_cfg))) { mutex_unlock(>rx_lock); return -EFAULT; } -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: align function parameters with open parenthesis
Fixes checkpatch warnings: CHECK: Alignment should match open parenthesis --- 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 f56425ffbe90..edcd7e798f99 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -799,7 +799,7 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) static ssize_t pi433_write(struct file *filp, const char __user *buf, - size_t count, loff_t *f_pos) + size_t count, loff_t *f_pos) { struct pi433_instance *instance; struct pi433_device *device; @@ -870,17 +870,17 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) switch (cmd) { case PI433_IOC_RD_TX_CFG: if (copy_to_user(argp, >tx_cfg, - sizeof(struct pi433_tx_cfg))) +sizeof(struct pi433_tx_cfg))) return -EFAULT; break; case PI433_IOC_WR_TX_CFG: if (copy_from_user(>tx_cfg, argp, - sizeof(struct pi433_tx_cfg))) + sizeof(struct pi433_tx_cfg))) return -EFAULT; break; case PI433_IOC_RD_RX_CFG: if (copy_to_user(argp, >rx_cfg, - sizeof(struct pi433_rx_cfg))) +sizeof(struct pi433_rx_cfg))) return -EFAULT; break; case PI433_IOC_WR_RX_CFG: @@ -893,7 +893,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } if (copy_from_user(>rx_cfg, argp, - sizeof(struct pi433_rx_cfg))) { + sizeof(struct pi433_rx_cfg))) { mutex_unlock(>rx_lock); return -EFAULT; } -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: remove unnecessary parentheses
Fixes checkpatch warnings: CHECK: Unnecessary parentheses around 'mantisse != mantisse16' CHECK: Unnecessary parentheses around 'mantisse != mantisse20' CHECK: Unnecessary parentheses around 'mantisse != mantisse24' 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 bdd00f750765..a07fc6bc27f7 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -391,9 +391,9 @@ static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg, return -EINVAL; } - if ((mantisse != mantisse16) && - (mantisse != mantisse20) && - (mantisse != mantisse24)) { + if (mantisse != mantisse16 && + mantisse != mantisse20 && + mantisse != mantisse24) { dev_dbg(>dev, "set: illegal input param"); return -EINVAL; } -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: replace shifting with BIT macro
Fixes checkpatch warnings: CHECK: Prefer using the BIT macro Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/pi433_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 960249c600a5..f56425ffbe90 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -54,7 +54,7 @@ #include "pi433_if.h" #include "rf69.h" -#define N_PI433_MINORS (1U << MINORBITS) /*32*//* ... up to 256 */ +#define N_PI433_MINORS BIT(MINORBITS) /*32*/ /* ... up to 256 */ #define MAX_MSG_SIZE 900 /* min: FIFO_SIZE! */ #define MSG_FIFO_SIZE 65536 /* 65536 = 2^16 */ #define NUM_DIO2 -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for payload identifiers
Fixes checkpatch warnings: CHECK: Avoid CamelCase: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/pi433_if.c | 2 +- drivers/staging/pi433/rf69.c | 6 +++--- drivers/staging/pi433/rf69.h | 2 +- drivers/staging/pi433/rf69_enum.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 1d7c50c1ac23..4de003fe72e7 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -510,7 +510,7 @@ pi433_receive(void *data) /* get payload */ while (dev->rx_position < bytes_total) { - if (!rf69_get_flag(dev->spi, payloadReady)) { + if (!rf69_get_flag(dev->spi, payload_ready)) { retval = wait_event_interruptible(dev->fifo_wait_queue, dev->free_in_fifo < FIFO_SIZE); if (retval) /* wait was interrupted */ diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index d0bb94a22f2f..78b3f257ac06 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -509,7 +509,7 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag) case fifo_level_below_threshold: 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: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PACKET_SENT); - case payloadReady: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PAYLOAD_READY); + case payload_ready: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PAYLOAD_READY); case crcOk: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_CRC_OK); case batteryLow: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_LOW_BAT); default: return false; @@ -649,9 +649,9 @@ int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addre } } -int rf69_set_payload_length(struct spi_device *spi, u8 payloadLength) +int rf69_set_payload_length(struct spi_device *spi, u8 payload_length) { - return rf69_write_reg(spi, REG_PAYLOAD_LENGTH, payloadLength); + return rf69_write_reg(spi, REG_PAYLOAD_LENGTH, payload_length); } int rf69_set_node_address(struct spi_device *spi, u8 nodeAddress) diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index f8c015ab3ff3..8a48a188ef31 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -56,7 +56,7 @@ int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetForma int rf69_enable_crc(struct spi_device *spi); int rf69_disable_crc(struct spi_device *spi); int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addressFiltering); -int rf69_set_payload_length(struct spi_device *spi, u8 payloadLength); +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_tx_start_condition(struct spi_device *spi, enum txStartCondition txStartCondition); diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi433/rf69_enum.h index 77b97d173f87..03440cfa957c 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -108,7 +108,7 @@ enum flag { fifo_level_below_threshold, fifo_overrun, packetSent, - payloadReady, + payload_ready, crcOk, batteryLow }; -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for maxMinus variables
Fixes checkpatch warnings: 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/Documentation/pi433.txt | 10 +- drivers/staging/pi433/rf69.c | 14 +++--- drivers/staging/pi433/rf69_enum.h | 10 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/pi433/Documentation/pi433.txt b/drivers/staging/pi433/Documentation/pi433.txt index c082878be0b1..7d9dc2244848 100644 --- a/drivers/staging/pi433/Documentation/pi433.txt +++ b/drivers/staging/pi433/Documentation/pi433.txt @@ -200,11 +200,11 @@ rf params: sets the gain of the low noise amp automatic - lna gain is determined by an agc max - lna gain is set to maximum - maxMinus6 - lna gain is set to 6db below max - maxMinus12 - lna gain is set to 12db below max - maxMinus24 - lna gain is set to 24db below max - maxMinus36 - lna gain is set to 36db below max - maxMinus48 - lna gain is set to 48db below max + max_minus_6 - lna gain is set to 6db below max + max_minus_12- lna gain is set to 12db below max + max_minus_24- lna gain is set to 24db below max + max_minus_36- lna gain is set to 36db below max + max_minus_48- lna gain is set to 48db below max bw_mantisse sets the bandwidth of the channel filter - part one: mantisse. mantisse16 - mantisse is set to 16 diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 8bc09e10a582..d0bb94a22f2f 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -367,13 +367,13 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance ant int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain) { switch (lnaGain) { - case automatic: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_AUTO); - case max:return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX); - case maxMinus6: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_6); - case maxMinus12: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_12); - case maxMinus24: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_24); - case maxMinus36: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_36); - case maxMinus48: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_48); + case automatic:return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_AUTO); + case max: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX); + case max_minus_6: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_6); + case max_minus_12: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_12); + case max_minus_24: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_24); + case max_minus_36: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_36); + case max_minus_48: return rf69_read_mod_write(spi, REG_LNA, MASK_LNA_GAIN, LNA_GAIN_MAX_MINUS_48); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi433/rf69_enum.h index 86f1d2f94ab2..77b97d173f87 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -68,11 +68,11 @@ enum antennaImpedance { enum lnaGain { automatic, max, - maxMinus6, - maxMinus12, - maxMinus24, - maxMinus36, - maxMinus48, + max_minus_6, + max_minus_12, + max_minus_24, + max_minus_36, + max_minus_48, undefined }; -- 2.15.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for fifo variables
Fixes checkpatch warnings: 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/Documentation/pi433.txt | 4 +-- drivers/staging/pi433/rf69.c | 46 +-- drivers/staging/pi433/rf69.h | 2 +- drivers/staging/pi433/rf69_enum.h | 16 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/staging/pi433/Documentation/pi433.txt b/drivers/staging/pi433/Documentation/pi433.txt index f79e998112fd..c082878be0b1 100644 --- a/drivers/staging/pi433/Documentation/pi433.txt +++ b/drivers/staging/pi433/Documentation/pi433.txt @@ -110,9 +110,9 @@ rf params: ramp12 - amp ramps up in 12us ramp10 - amp ramps up in 10us tx_start_condition - fifoLevel - transmission starts, if fifo is filled to + fifo_level - transmission starts, if fifo is filled to threshold level - fifoNotEmpty- transmission starts, as soon as there is one + fifo_not_empty - transmission starts, as soon as there is one byte in internal fifo repetitions This gives the option, to send a telegram multiple times. Default: 1 diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index d777e31688ad..82b65832d39f 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -523,24 +523,24 @@ 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: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY); - case readyToReceive: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RX_READY); - case readyToSend: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TX_READY); - case pllLocked: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_PLL_LOCK); - case rssiExceededThreshold: 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:return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH); - case fifoFull:return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_FULL); -/* case fifoNotEmpty:return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); */ - case fifoEmpty: return !(rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY); - case fifoLevelBelowThreshold: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_LEVEL); - case fifoOverrun: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_OVERRUN); - case packetSent: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PACKET_SENT); - case payloadReady:return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PAYLOAD_READY); - case crcOk: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_CRC_OK); - case batteryLow: return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_LOW_BAT); - default: return false; + case modeSwitchCompleted:return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY); + case readyToReceive: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RX_READY); + case readyToSend:return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TX_READY); + case pllLocked: return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_PLL_LOCK); + case rssiExceededThreshold: 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: 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); +/* case fifo_not_empty:
[PATCH 3/6 v5] staging: pi433: replace unsigned with unsigned int
Fixes checkpatch warning: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v5: resend patchset based on comments drivers/staging/pi433/pi433_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 86709a7100ad..6e147cd351c7 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -78,7 +78,7 @@ struct pi433_device { struct device *dev; struct cdev *cdev; struct spi_device *spi; - unsignedusers; + unsigned intusers; /* irq related values */ struct gpio_desc*gpiod[NUM_DIO]; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/6 v5] staging: pi433: remove unused function
As it turns out rf69_get_lna_gain is not used at all. Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v5: resend patchset based on comments drivers/staging/pi433/rf69.c | 18 -- drivers/staging/pi433/rf69.h | 1 - 2 files changed, 19 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index d777e31688ad..f58b925bb1da 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -334,24 +334,6 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain) } } -enum lnaGain rf69_get_lna_gain(struct spi_device *spi) -{ - u8 currentValue; - - currentValue = rf69_read_reg(spi, REG_LNA); - - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define - case LNA_GAIN_AUTO: return automatic; - case LNA_GAIN_MAX: return max; - case LNA_GAIN_MAX_MINUS_6: return maxMinus6; - case LNA_GAIN_MAX_MINUS_12: return maxMinus12; - case LNA_GAIN_MAX_MINUS_24: return maxMinus24; - case LNA_GAIN_MAX_MINUS_36: return maxMinus36; - case LNA_GAIN_MAX_MINUS_48: return maxMinus48; - default:return undefined; - } -} - int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dcc_percent dcc_percent) { switch (dcc_percent) { diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 079acbd8a366..e90228a0ca29 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -39,7 +39,6 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel); int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp); int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance); int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain); -enum lnaGain rf69_get_lna_gain(struct spi_device *spi); int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dcc_percent dcc_percent); int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dcc_percent dcc_percent); int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum dcc_percent dcc_percent); -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/6 v5] staging: pi433: replace printk calls with dev_dbg
Fixes checkpatch warning: WARNING: printk() should include KERN_ facility level Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v5: resend patchset based on comments 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 287bfa4e270f..1aa83cb3f15a 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -721,7 +721,7 @@ pi433_tx_thread(void *data) retval = wait_event_interruptible(device->fifo_wait_queue, device->free_in_fifo > 0); if (retval) { - printk("ABORT\n"); + dev_dbg(device->dev, "ABORT\n"); goto abort; } } @@ -732,7 +732,7 @@ pi433_tx_thread(void *data) device->free_in_fifo == FIFO_SIZE || kthread_should_stop()); if (kthread_should_stop()) - printk("ABORT\n"); + dev_dbg(device->dev, "ABORT\n"); /* STOP_TRANSMISSION */ dev_dbg(device->dev, "thread: Packet sent. Set mode to stby."); -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/6 v5] staging: pi433: avoid logging ENOMEM messages
Fixes checkpatch warning: WARNING: Possible unnecessary 'out of memory' message Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v5: resend patchset based on comments drivers/staging/pi433/pi433_if.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 6e147cd351c7..287bfa4e270f 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -937,10 +937,8 @@ static int pi433_open(struct inode *inode, struct file *filp) if (!device->rx_buffer) { device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); - if (!device->rx_buffer) { - dev_dbg(device->dev, "open/ENOMEM\n"); + if (!device->rx_buffer) return -ENOMEM; - } } device->users++; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/6 v5] staging: pi433: cleanup local variable declaration
Fix variable naming and checkpatch warning: WARNING: Missing a blank line after declarations Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v5: resend patchset based on comments drivers/staging/pi433/pi433_if.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 02887988d2ea..86709a7100ad 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -699,13 +699,15 @@ pi433_tx_thread(void *data) repetitions = tx_cfg.repetitions; while ((repetitions > 0) && (size > position)) { if ((size - position) > device->free_in_fifo) { + int write_size; + /* msg to big for fifo - take a part */ - int temp = device->free_in_fifo; + write_size = device->free_in_fifo; device->free_in_fifo = 0; rf69_write_fifo(spi, [position], - temp); - position += temp; + write_size); + position += write_size; } else { /* msg fits into fifo - take all */ device->free_in_fifo -= size; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/8 v4] staging: pi433: remove unused function
As it turns out rf69_get_lna_gain is not used at all. Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v2: - drop change for SHIFT_DATAMODUL_MODULATION_TYPE - move shifting to the header file v3: - drop auto case - use CURRENT suffix - precompute define values v4: - drop the whole function since it is not called from anywhere drivers/staging/pi433/rf69.c | 18 -- drivers/staging/pi433/rf69.h | 1 - 2 files changed, 19 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f77ecd60f43a..2aae23a813a0 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -334,24 +334,6 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain) } } -enum lnaGain rf69_get_lna_gain(struct spi_device *spi) -{ - u8 currentValue; - - currentValue = rf69_read_reg(spi, REG_LNA); - - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define - case LNA_GAIN_AUTO: return automatic; - case LNA_GAIN_MAX: return max; - case LNA_GAIN_MAX_MINUS_6: return maxMinus6; - case LNA_GAIN_MAX_MINUS_12: return maxMinus12; - case LNA_GAIN_MAX_MINUS_24: return maxMinus24; - case LNA_GAIN_MAX_MINUS_36: return maxMinus36; - case LNA_GAIN_MAX_MINUS_48: return maxMinus48; - default:return undefined; - } -} - int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dccPercent dccPercent) { switch (dccPercent) { diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index e8803241b13b..e8640b0ee33b 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -39,7 +39,6 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel); int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp); int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance); int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain); -enum lnaGain rf69_get_lna_gain(struct spi_device *spi); int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dccPercent dccPercent); int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dccPercent dccPercent); int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum dccPercent dccPercent); -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: pi433: fix CamelCase for dccPercent variables
Fixes checkpatch warning: CHECK: Avoid CamelCase: Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69.c | 30 +++--- drivers/staging/pi433/rf69.h | 6 +++--- drivers/staging/pi433/rf69_enum.h | 18 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f77ecd60f43a..23787f32bc73 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -352,31 +352,31 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) } } -int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dccPercent dccPercent) -{ - switch (dccPercent) { - case dcc16Percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_16_PERCENT); - case dcc8Percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_8_PERCENT); - case dcc4Percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_4_PERCENT); - case dcc2Percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_2_PERCENT); - case dcc1Percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_1_PERCENT); - case dcc0_5Percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_0_5_PERCENT); - case dcc0_25Percent:return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_0_25_PERCENT); - case dcc0_125Percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_0_125_PERCENT); +int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dcc_percent dcc_percent) +{ + switch (dcc_percent) { + case dcc_16_percent:return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_16_PERCENT); + case dcc_8_percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_8_PERCENT); + case dcc_4_percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_4_PERCENT); + case dcc_2_percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_2_PERCENT); + case dcc_1_percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_1_PERCENT); + case dcc_0_5_percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_0_5_PERCENT); + case dcc_0_25_percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_0_25_PERCENT); + case dcc_0_125_percent: return rf69_read_mod_write(spi, reg, MASK_BW_DCC_FREQ, BW_DCC_0_125_PERCENT); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; } } -int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dccPercent dccPercent) +int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dcc_percent dcc_percent) { - return rf69_set_dc_cut_off_frequency_intern(spi, REG_RXBW, dccPercent); + return rf69_set_dc_cut_off_frequency_intern(spi, REG_RXBW, dcc_percent); } -int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum dccPercent dccPercent) +int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum dcc_percent dcc_percent) { - return rf69_set_dc_cut_off_frequency_intern(spi, REG_AFCBW, dccPercent); + return rf69_set_dc_cut_off_frequency_intern(spi, REG_AFCBW, dcc_percent); } static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg, diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index e8803241b13b..dfc1a863d78c 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -40,9 +40,9 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp); int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance); int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain); enum lnaGain rf69_get_lna_gain(struct spi_device *spi); -int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dccPercent dccPercent); -int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dccPercent dccPercent); -int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum dccPercent dccPercent); +int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dcc_percent dcc_percent); +int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dcc_percent dcc_percent); +int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum dcc_percent dcc_percent); 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_type(struct spi_device *spi, enum thresholdType thresholdType); diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi43
[PATCH 2/8 v3] staging: pi433: cleanup local variable declaration
Fix variable naming and checkpatch warning: WARNING: Missing a blank line after declarations Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v2: use a better variable name v3: keep the variable scope drivers/staging/pi433/pi433_if.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 02887988d2ea..86709a7100ad 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -699,13 +699,15 @@ pi433_tx_thread(void *data) repetitions = tx_cfg.repetitions; while ((repetitions > 0) && (size > position)) { if ((size - position) > device->free_in_fifo) { + int write_size; + /* msg to big for fifo - take a part */ - int temp = device->free_in_fifo; + write_size = device->free_in_fifo; device->free_in_fifo = 0; rf69_write_fifo(spi, [position], - temp); - position += temp; + write_size); + position += write_size; } else { /* msg fits into fifo - take all */ device->free_in_fifo -= size; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/8 v3] staging: pi433: use defines for shifting register values
Avoid shifting by magic numbers and use defines instead. Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v2: - drop change for SHIFT_DATAMODUL_MODULATION_TYPE - move shifting to the header file v3: - drop auto case - use CURRENT suffix - precompute define values drivers/staging/pi433/rf69.c | 15 +++ drivers/staging/pi433/rf69_registers.h | 6 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f77ecd60f43a..0889c65d5a31 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -340,14 +340,13 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) currentValue = rf69_read_reg(spi, REG_LNA); - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define - case LNA_GAIN_AUTO: return automatic; - case LNA_GAIN_MAX: return max; - case LNA_GAIN_MAX_MINUS_6: return maxMinus6; - case LNA_GAIN_MAX_MINUS_12: return maxMinus12; - case LNA_GAIN_MAX_MINUS_24: return maxMinus24; - case LNA_GAIN_MAX_MINUS_36: return maxMinus36; - case LNA_GAIN_MAX_MINUS_48: return maxMinus48; + switch (currentValue & MASK_LNA_CURRENT_GAIN) { + case LNA_GAIN_MAX_CURRENT: return max; + case LNA_GAIN_MAX_MINUS_6_CURRENT: return maxMinus6; + case LNA_GAIN_MAX_MINUS_12_CURRENT: return maxMinus12; + case LNA_GAIN_MAX_MINUS_24_CURRENT: return maxMinus24; + case LNA_GAIN_MAX_MINUS_36_CURRENT: return maxMinus36; + case LNA_GAIN_MAX_MINUS_48_CURRENT: return maxMinus48; default:return undefined; } } diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h index d23b8b668ef5..4a189c6a4ab3 100644 --- a/drivers/staging/pi433/rf69_registers.h +++ b/drivers/staging/pi433/rf69_registers.h @@ -246,6 +246,12 @@ #define LNA_GAIN_MAX_MINUS_36 0x05 #define LNA_GAIN_MAX_MINUS_48 0x06 +#define LNA_GAIN_MAX_CURRENT 0x08 +#define LNA_GAIN_MAX_MINUS_6_CURRENT 0x10 +#define LNA_GAIN_MAX_MINUS_12_CURRENT 0x18 +#define LNA_GAIN_MAX_MINUS_24_CURRENT 0x20 +#define LNA_GAIN_MAX_MINUS_36_CURRENT 0x28 +#define LNA_GAIN_MAX_MINUS_48_CURRENT 0x30 /* RegRxBw (0x19) and RegAfcBw (0x1A) */ #define MASK_BW_DCC_FREQ 0xE0 -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 6/8] staging: pi433: use defines for shifting register values
On Wed, Dec 13, 2017 at 05:32:28PM +0200, Marcus Wolf wrote: > Am 13.12.2017 um 16:21 schrieb Valentin Vidic: > > Avoid shifting by magic numbers and use defines instead: > > > >SHIFT_DATAMODUL_MODULATION_TYPE > >SHIFT_LNA_CURRENT_GAIN > > > > Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> > > --- > > drivers/staging/pi433/rf69.c | 4 ++-- > > drivers/staging/pi433/rf69_registers.h | 2 ++ > > 2 files changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c > > index b1e243e5bcac..8c4841c9d796 100644 > > --- a/drivers/staging/pi433/rf69.c > > +++ b/drivers/staging/pi433/rf69.c > > @@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device > > *spi) > > currentValue = rf69_read_reg(spi, REG_DATAMODUL); > > - switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> 3) { // TODO > > improvement: change 3 to define > > + switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> > > SHIFT_DATAMODUL_MODULATION_TYPE) { > > As mentioned by Dan, this change isn't needed any more, since we don't need > the shift right here, since the DATAMODUL_MODULATION_TYPE_OOK and > DATAMODUL_MODULATION_TYPE_FSK already contains the bits at the correct > position. Not sure why this TODO is still visible in staging-next? https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/staging/+/staging-next/drivers/staging/pi433/rf69.c#99 > Regarding my previous mail: I was wrong! This way is right!! > > BUT: I would prefer to have a solution, like it was done for the modulation > type: Do not shift anything here, but introduce new defines > (LNA_GAIN_AUTO_xyz...), that are used for the casees, having the bits set at > the right position, so theycan be used without shifting. > Be aware: The old defines must remain untouched, since they are needed for > an other function. Just sent a v2 of this patch, please review if this is what you had in mind for LNA_GAIN. -- Valentin ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/8 v2] staging: pi433: use defines for shifting register values
Avoid shifting by magic numbers and use defines instead. Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v2: - drop change for SHIFT_DATAMODUL_MODULATION_TYPE - move shifting to the header file drivers/staging/pi433/rf69.c | 16 drivers/staging/pi433/rf69_registers.h | 8 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f77ecd60f43a..ce259b4f0b0e 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -340,14 +340,14 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) currentValue = rf69_read_reg(spi, REG_LNA); - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define - case LNA_GAIN_AUTO: return automatic; - case LNA_GAIN_MAX: return max; - case LNA_GAIN_MAX_MINUS_6: return maxMinus6; - case LNA_GAIN_MAX_MINUS_12: return maxMinus12; - case LNA_GAIN_MAX_MINUS_24: return maxMinus24; - case LNA_GAIN_MAX_MINUS_36: return maxMinus36; - case LNA_GAIN_MAX_MINUS_48: return maxMinus48; + switch (currentValue & MASK_LNA_CURRENT_GAIN) { + case LNA_GAIN_AUTO_SHIFTED: return automatic; + case LNA_GAIN_MAX_SHIFTED: return max; + case LNA_GAIN_MAX_MINUS_6_SHIFTED: return maxMinus6; + case LNA_GAIN_MAX_MINUS_12_SHIFTED: return maxMinus12; + case LNA_GAIN_MAX_MINUS_24_SHIFTED: return maxMinus24; + case LNA_GAIN_MAX_MINUS_36_SHIFTED: return maxMinus36; + case LNA_GAIN_MAX_MINUS_48_SHIFTED: return maxMinus48; default:return undefined; } } diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h index d23b8b668ef5..6329bbf9e499 100644 --- a/drivers/staging/pi433/rf69_registers.h +++ b/drivers/staging/pi433/rf69_registers.h @@ -237,6 +237,7 @@ #define MASK_LNA_ZIN 0x80 #define MASK_LNA_CURRENT_GAIN 0x38 #define MASK_LNA_GAIN 0x07 +#define SHIFT_LNA_CURRENT_GAIN3 #define LNA_GAIN_AUTO 0x00 /* default */ #define LNA_GAIN_MAX 0x01 @@ -246,6 +247,13 @@ #define LNA_GAIN_MAX_MINUS_36 0x05 #define LNA_GAIN_MAX_MINUS_48 0x06 +#define LNA_GAIN_AUTO_SHIFTED (LNA_GAIN_AUTO << SHIFT_LNA_CURRENT_GAIN) +#define LNA_GAIN_MAX_SHIFTED (LNA_GAIN_MAX << SHIFT_LNA_CURRENT_GAIN) +#define LNA_GAIN_MAX_MINUS_6_SHIFTED (LNA_GAIN_MAX_MINUS_6 << SHIFT_LNA_CURRENT_GAIN) +#define LNA_GAIN_MAX_MINUS_12_SHIFTED (LNA_GAIN_MAX_MINUS_12 << SHIFT_LNA_CURRENT_GAIN) +#define LNA_GAIN_MAX_MINUS_24_SHIFTED (LNA_GAIN_MAX_MINUS_24 << SHIFT_LNA_CURRENT_GAIN) +#define LNA_GAIN_MAX_MINUS_36_SHIFTED (LNA_GAIN_MAX_MINUS_36 << SHIFT_LNA_CURRENT_GAIN) +#define LNA_GAIN_MAX_MINUS_48_SHIFTED (LNA_GAIN_MAX_MINUS_48 << SHIFT_LNA_CURRENT_GAIN) /* RegRxBw (0x19) and RegAfcBw (0x1A) */ #define MASK_BW_DCC_FREQ 0xE0 -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/8 v2] staging: pi433: move var declaration to function level
Fixes checkpatch warning: WARNING: Missing a blank line after declarations Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v2: use a better variable name 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 02887988d2ea..dfa771304d97 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -565,6 +565,7 @@ pi433_tx_thread(void *data) bool rx_interrupted = false; intposition, repetitions; intretval; + intwrite_size; while (1) { /* wait for fifo to be populated or for request to terminate*/ @@ -700,12 +701,12 @@ 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; + write_size = device->free_in_fifo; device->free_in_fifo = 0; rf69_write_fifo(spi, [position], - temp); - position += temp; + write_size); + position += write_size; } else { /* msg fits into fifo - take all */ device->free_in_fifo -= size; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 8/8] staging: pi433: replace printk calls with dev_dbg
On Wed, Dec 13, 2017 at 05:52:36PM +0300, Dan Carpenter wrote: > On Wed, Dec 13, 2017 at 03:21:56PM +0100, Valentin Vidic wrote: > > 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 9e558154a143..02a5ba019801 100644 > > --- a/drivers/staging/pi433/pi433_if.c > > +++ b/drivers/staging/pi433/pi433_if.c > > @@ -720,7 +720,7 @@ pi433_tx_thread(void *data) > > retval = > > wait_event_interruptible(device->fifo_wait_queue, > > device->free_in_fifo > > > 0); > > if (retval) { > > - printk("ABORT\n"); > > + dev_dbg(device->dev, "ABORT\n"); > > goto abort; > > Hm... The kernel.org version of this driver has never looked like this. > I wonder what you are working against... Patch was against staging-testing, in linux-next this printk looks like this: if (retval) { printk("ABORT\n"); goto abort; } -- Valentin ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/8] staging: pi433: avoid logging ENOMEM messages
Fixes checkpatch warning: WARNING: Possible unnecessary 'out of memory' message Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/pi433_if.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 8234473e1add..9e558154a143 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -936,10 +936,8 @@ static int pi433_open(struct inode *inode, struct file *filp) if (!device->rx_buffer) { device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); - if (!device->rx_buffer) { - dev_dbg(device->dev, "open/ENOMEM\n"); + if (!device->rx_buffer) return -ENOMEM; - } } device->users++; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/8] staging: pi433: move var declaration to function level
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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 02887988d2ea..07e5352ae5ad 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -565,6 +565,7 @@ pi433_tx_thread(void *data) bool rx_interrupted = false; intposition, repetitions; intretval; + inttemp; while (1) { /* wait for fifo to be populated or for request to terminate*/ @@ -700,7 +701,7 @@ 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; + temp = device->free_in_fifo; device->free_in_fifo = 0; rf69_write_fifo(spi, [position], -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 8/8] staging: pi433: replace printk calls with dev_dbg
Fixes checkpatch warning: WARNING: printk() should include KERN_ facility level 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 9e558154a143..02a5ba019801 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -720,7 +720,7 @@ pi433_tx_thread(void *data) retval = wait_event_interruptible(device->fifo_wait_queue, device->free_in_fifo > 0); if (retval) { - printk("ABORT\n"); + dev_dbg(device->dev, "ABORT\n"); goto abort; } } @@ -731,7 +731,7 @@ pi433_tx_thread(void *data) device->free_in_fifo == FIFO_SIZE || kthread_should_stop()); if (kthread_should_stop()) - printk("ABORT\n"); + dev_dbg(device->dev, "ABORT\n"); /* STOP_TRANSMISSION */ dev_dbg(device->dev, "thread: Packet sent. Set mode to stby."); -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/8] staging: pi433: add parentheses to mask and shift
Fixes checkpatch warning: WARNING: Possible precedence defect with mask then right shift - may need parentheses Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f77ecd60f43a..b1e243e5bcac 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi) currentValue = rf69_read_reg(spi, REG_DATAMODUL); - switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define + switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> 3) { // TODO improvement: change 3 to define case DATAMODUL_MODULATION_TYPE_OOK: return OOK; case DATAMODUL_MODULATION_TYPE_FSK: return FSK; default:return UNDEF; @@ -340,7 +340,7 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) currentValue = rf69_read_reg(spi, REG_LNA); - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define + switch ((currentValue & MASK_LNA_CURRENT_GAIN) >> 3) { // improvement: change 3 to define case LNA_GAIN_AUTO: return automatic; case LNA_GAIN_MAX: return max; case LNA_GAIN_MAX_MINUS_6: return maxMinus6; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/8] staging: pi433: use defines for shifting register values
Avoid shifting by magic numbers and use defines instead: SHIFT_DATAMODUL_MODULATION_TYPE SHIFT_LNA_CURRENT_GAIN Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69.c | 4 ++-- drivers/staging/pi433/rf69_registers.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index b1e243e5bcac..8c4841c9d796 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi) currentValue = rf69_read_reg(spi, REG_DATAMODUL); - switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> 3) { // TODO improvement: change 3 to define + switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> SHIFT_DATAMODUL_MODULATION_TYPE) { case DATAMODUL_MODULATION_TYPE_OOK: return OOK; case DATAMODUL_MODULATION_TYPE_FSK: return FSK; default:return UNDEF; @@ -340,7 +340,7 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) currentValue = rf69_read_reg(spi, REG_LNA); - switch ((currentValue & MASK_LNA_CURRENT_GAIN) >> 3) { // improvement: change 3 to define + switch ((currentValue & MASK_LNA_CURRENT_GAIN) >> SHIFT_LNA_CURRENT_GAIN) { case LNA_GAIN_AUTO: return automatic; case LNA_GAIN_MAX: return max; case LNA_GAIN_MAX_MINUS_6: return maxMinus6; diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h index 981b57d7cc0b..da12642cf249 100644 --- a/drivers/staging/pi433/rf69_registers.h +++ b/drivers/staging/pi433/rf69_registers.h @@ -124,6 +124,7 @@ #define MASK_DATAMODUL_MODE 0x06 #define MASK_DATAMODUL_MODULATION_TYPE0x18 #define MASK_DATAMODUL_MODULATION_SHAPE 0x03 +#define SHIFT_DATAMODUL_MODULATION_TYPE 3 #define DATAMODUL_MODE_PACKET 0x00 /* default */ #define DATAMODUL_MODE_CONTINUOUS 0x40 @@ -235,6 +236,7 @@ #define MASK_LNA_ZIN 0x80 #define MASK_LNA_CURRENT_GAIN 0x38 #define MASK_LNA_GAIN 0x07 +#define SHIFT_LNA_CURRENT_GAIN3 #define LNA_GAIN_AUTO 0x00 /* default */ #define LNA_GAIN_MAX 0x01 -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/8] staging: pi433: fix DATAMODUL_MODULATION_TYPE_OOK value
Reading from the spec, allowed values for modulation scheme after the shift are: 00 FSK 01 OOK 10 - 11 reserved Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/rf69_registers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h index 33fd91518bb0..981b57d7cc0b 100644 --- a/drivers/staging/pi433/rf69_registers.h +++ b/drivers/staging/pi433/rf69_registers.h @@ -130,7 +130,7 @@ #define DATAMODUL_MODE_CONTINUOUS_NOSYNC 0x60 #define DATAMODUL_MODULATION_TYPE_FSK 0x00 /* default */ -#define DATAMODUL_MODULATION_TYPE_OOK 0x08 +#define DATAMODUL_MODULATION_TYPE_OOK 0x01 #define DATAMODUL_MODULATION_SHAPE_NONE 0x00 /* default */ #define DATAMODUL_MODULATION_SHAPE_1_00x01 -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/8] staging: pi433: replace unsigned with unsigned int
Fixes checkpatch warning: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/pi433_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 07e5352ae5ad..8234473e1add 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -78,7 +78,7 @@ struct pi433_device { struct device *dev; struct cdev *cdev; struct spi_device *spi; - unsignedusers; + unsigned intusers; /* irq related values */ struct gpio_desc*gpiod[NUM_DIO]; -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/8] staging: pi433: collapse else block after return statement
Fixes checkpatch warning: WARNING: else is not generally useful after a break or return Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/pi433_if.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index b4e6094ad553..02887988d2ea 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -773,11 +773,11 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) if (device->rx_active) { mutex_unlock(>rx_lock); return -EAGAIN; - } else { - device->rx_active = true; - mutex_unlock(>rx_lock); } + device->rx_active = true; + mutex_unlock(>rx_lock); + /* start receiving */ /* will block until something was received*/ device->rx_buffer_size = size; @@ -1117,12 +1117,12 @@ static int pi433_probe(struct spi_device *spi) if (retval) { dev_dbg(>dev, "configuration of SPI interface failed!\n"); return retval; - } else { - dev_dbg(>dev, - "spi interface setup: mode 0x%2x, %d bits per word, %dhz max speed", - spi->mode, spi->bits_per_word, spi->max_speed_hz); } + dev_dbg(>dev, + "spi interface setup: mode 0x%2x, %d bits per word, %dhz max speed", + spi->mode, spi->bits_per_word, spi->max_speed_hz); + /* Ping the chip by reading the version register */ retval = spi_w8r8(spi, 0x10); if (retval < 0) -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 11/16 v2] staging: pi433: remove multiple blank lines
Fixes checkpatch warning for multiple blank lines in source. Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- v2: refresh patch for staging-testing drivers/staging/pi433/pi433_if.c | 11 --- drivers/staging/pi433/pi433_if.h | 8 drivers/staging/pi433/rf69.h | 2 -- drivers/staging/pi433/rf69_registers.h | 4 4 files changed, 25 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 1f3ba552689e..b4e6094ad553 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -54,7 +54,6 @@ #include "pi433_if.h" #include "rf69.h" - #define N_PI433_MINORS (1U << MINORBITS) /*32*//* ... up to 256 */ #define MAX_MSG_SIZE 900 /* min: FIFO_SIZE! */ #define MSG_FIFO_SIZE 65536 /* 65536 = 2^16 */ @@ -119,7 +118,6 @@ struct pi433_instance { struct pi433_tx_cfg tx_cfg; }; - /*-*/ /* GPIO interrupt handlers */ @@ -406,7 +404,6 @@ pi433_start_rx(struct pi433_device *dev) return 0; } - /*-*/ static int @@ -526,7 +523,6 @@ pi433_receive(void *data) else bytes_to_read = bytes_total - dev->rx_position; - /* access the fifo */ if (bytes_to_read > FIFO_SIZE - dev->free_in_fifo) bytes_to_read = FIFO_SIZE - dev->free_in_fifo; @@ -545,7 +541,6 @@ pi433_receive(void *data) dev->rx_position += bytes_to_read; } - /* rx done, wait was interrupted or error occurred */ abort: dev->interrupt_rx_allowed = true; @@ -737,7 +732,6 @@ pi433_tx_thread(void *data) if (kthread_should_stop()) printk("ABORT\n"); - /* STOP_TRANSMISSION */ dev_dbg(device->dev, "thread: Packet sent. Set mode to stby."); retval = rf69_set_mode(spi, standby); @@ -804,7 +798,6 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) return bytes_received; } - static ssize_t pi433_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) @@ -854,7 +847,6 @@ pi433_write(struct file *filp, const char __user *buf, return -EAGAIN; } - static long pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { @@ -992,7 +984,6 @@ static int pi433_release(struct inode *inode, struct file *filp) return 0; } - /*-*/ static int setup_GPIOs(struct pi433_device *device) @@ -1028,14 +1019,12 @@ static int setup_GPIOs(struct pi433_device *device) return retval; } - /* configure the pin */ gpiod_unexport(device->gpiod[i]); retval = gpiod_direction_input(device->gpiod[i]); if (retval) return retval; - /* configure irq */ device->irq_num[i] = gpiod_to_irq(device->gpiod[i]); if (device->irq_num[i] < 0) { diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index f67d3833c271..7314f69af198 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -32,9 +32,6 @@ #include #include "rf69_enum.h" -/*---*/ - - /*---*/ enum option_on_off { @@ -76,7 +73,6 @@ struct pi433_tx_cfg { __u16 repetitions; - /* packet format */ enum option_on_off enable_preamble; enum option_on_off enable_sync; @@ -92,7 +88,6 @@ struct pi433_tx_cfg { __u8address_byte; }; - /** * struct pi433_rx_config - describes the configuration of the radio module for sending * @frequency: @@ -127,8 +122,6 @@ struct pi433_rx_cfg { __u8bw_exponent;/* during AFC: 0x8b */ enum dagc dagc; - - /* packet format */ enum option_on_off enable_sync; enum option_on_off enable_length_byte; /* should be used in combination with sync, only */ @@ -144,7 +137,6 @@ struct pi433_rx_cfg { __u8broadcast_address; }; - #define PI433_IOC_MAGIC'r' #define PI433_IOC_RD_TX_CFG_IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, char[sizeof(struct pi433_tx_cfg)]) diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h i
[PATCH 08/16] staging: pi433: remove spaces before tabs
Fixes checkpatch warning for hidden spaces before tabs. Signed-off-by: Valentin Vidic <valentin.vi...@carnet.hr> --- drivers/staging/pi433/pi433_if.c | 2 +- drivers/staging/pi433/pi433_if.h | 4 ++-- drivers/staging/pi433/rf69.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 06b0188b1760..1e50d8f431f0 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) { - charname[5]; + charname[5]; int retval; int i; const irq_handler_t DIO_irq_handler[NUM_DIO] = { diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index c8697d144e2b..f67d3833c271 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -62,7 +62,7 @@ enum option_on_off { * * NOTE: struct layout is the same in 64bit and 32bit userspace. */ -#define PI433_TX_CFG_IOCTL_NR 0 +#define PI433_TX_CFG_IOCTL_NR 0 struct pi433_tx_cfg { __u32 frequency; __u16 bit_rate; @@ -111,7 +111,7 @@ struct pi433_tx_cfg { * * NOTE: struct layout is the same in 64bit and 32bit userspace. */ -#define PI433_RX_CFG_IOCTL_NR 1 +#define PI433_RX_CFG_IOCTL_NR 1 struct pi433_rx_cfg { __u32 frequency; __u16 bit_rate; diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index a6b201fcc071..8dae788972cc 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -29,7 +29,7 @@ #include "rf69_registers.h" #define F_OSC3200 /* in Hz */ -#define FIFO_SIZE 66 /* in byte */ +#define FIFO_SIZE 66 /* in byte */ /*-*/ -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 02/16] staging: pi433: add space after comma
Fixes checkpatch error for missing spaces. 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 9c1787ef14e3..155d486f6cb3 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -436,7 +436,7 @@ pi433_receive(void *data) dev->interrupt_rx_allowed = false; /* wait for any tx to finish */ - dev_dbg(dev->dev,"rx: going to wait for any tx to finish"); + dev_dbg(dev->dev, "rx: going to wait for any tx to finish"); retval = wait_event_interruptible(dev->rx_wait_queue, !dev->tx_active); if (retval) /* wait was interrupted */ { @@ -490,7 +490,7 @@ pi433_receive(void *data) goto abort; } bytes_total = dev->rx_cfg.fixed_message_length; - dev_dbg(dev->dev,"rx: msg len set to %d by fixed length", bytes_total); + dev_dbg(dev->dev, "rx: msg len set to %d by fixed length", bytes_total); } else { -- 2.15.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel