Re: [PATCH v2 3/3] staging: erofs: support IO read error injection

2019-03-24 Thread Chao Yu
On 2019/3/25 11:40, Gao Xiang wrote:
> Used to simulate disk IO read error for testing fatal
> error tolerance.
> 
> Here are the details,
> 1) use bio->bi_private to indicate super_block
>for non-compressed bios since some (mainly meta)
>pages can be of the corresponding bdev inode;
> 2) get super_block dynamically for compressed bios,
>therefore it could not inject bios full of staging
>pages, yet it doesn't affect the normal usage.
> 
> Signed-off-by: Gao Xiang 

Reviewed-by: Chao Yu 

Thanks,
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 2/3] staging: erofs: introduce erofs_page_is_managed()

2019-03-24 Thread Gao Xiang
1) In order to clean up unnecessary
   page->mapping == MNGD_MAPPING(sbi) wrapped by #ifdefs;

2) Needed by "staging: erofs: support IO read error injection".

Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
---
 drivers/staging/erofs/internal.h  |  7 +++
 drivers/staging/erofs/unzip_vle.c | 31 +--
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 1286b98ffd0a..a66c7d495c35 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -268,8 +268,15 @@ int erofs_try_to_free_cached_page(struct address_space 
*mapping,
  struct page *page);
 
 #define MNGD_MAPPING(sbi)  ((sbi)->managed_cache->i_mapping)
+static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
+struct page *page)
+{
+   return page->mapping == MNGD_MAPPING(sbi);
+}
 #else
 #define MNGD_MAPPING(sbi)  (NULL)
+static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
+struct page *page) { return false; }
 #endif
 
 #define DEFAULT_MAX_SYNC_DECOMPRESS_PAGES  3
diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index 45541be12972..8e720bb882c7 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -845,11 +845,9 @@ static void z_erofs_vle_unzip_kickoff(void *ptr, int bios)
 static inline void z_erofs_vle_read_endio(struct bio *bio)
 {
const blk_status_t err = bio->bi_status;
+   struct erofs_sb_info *sbi = NULL;
unsigned int i;
struct bio_vec *bvec;
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-   struct address_space *mc = NULL;
-#endif
struct bvec_iter_all iter_all;
 
bio_for_each_segment_all(bvec, bio, i, iter_all) {
@@ -859,20 +857,12 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)
DBG_BUGON(PageUptodate(page));
DBG_BUGON(!page->mapping);
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-   if (unlikely(!mc && !z_erofs_is_stagingpage(page))) {
-   struct inode *const inode = page->mapping->host;
-   struct super_block *const sb = inode->i_sb;
+   if (unlikely(!sbi && !z_erofs_is_stagingpage(page)))
+   sbi = EROFS_SB(page->mapping->host->i_sb);
 
-   mc = MNGD_MAPPING(EROFS_SB(sb));
-   }
-
-   /*
-* If mc has not gotten, it equals NULL,
-* however, page->mapping never be NULL if working properly.
-*/
-   cachemngd = (page->mapping == mc);
-#endif
+   /* sbi should already be gotten if the page is managed */
+   if (sbi)
+   cachemngd = erofs_page_is_managed(sbi, page);
 
if (unlikely(err))
SetPageError(page);
@@ -984,13 +974,11 @@ static int z_erofs_vle_unzip(struct super_block *sb,
DBG_BUGON(!page->mapping);
 
if (!z_erofs_is_stagingpage(page)) {
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-   if (page->mapping == MNGD_MAPPING(sbi)) {
+   if (erofs_page_is_managed(sbi, page)) {
if (unlikely(!PageUptodate(page)))
err = -EIO;
continue;
}
-#endif
 
/*
 * only if non-head page can be selected
@@ -1055,10 +1043,9 @@ static int z_erofs_vle_unzip(struct super_block *sb,
for (i = 0; i < clusterpages; ++i) {
page = compressed_pages[i];
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-   if (page->mapping == MNGD_MAPPING(sbi))
+   if (erofs_page_is_managed(sbi, page))
continue;
-#endif
+
/* recycle all individual staging pages */
(void)z_erofs_gather_if_stagingpage(page_pool, page);
 
-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/3] staging: erofs: fix error handling when failed to read compresssed data

2019-03-24 Thread Gao Xiang
Complete read error handling paths for all three kinds of
compressed pages:

 1) For cache-managed pages, PG_uptodate will be checked since
read_endio will unlock and SetPageUptodate for these pages;

 2) For inplaced pages, read_endio cannot SetPageUptodate directly
since it should be used to mark the final decompressed data,
PG_error will be set with page locked for IO error instead;

 3) For staging pages, PG_error is used, which is similar to
what we do for inplaced pages.

Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
Cc:  # 4.19+
Reviewed-by: Chao Yu 
Signed-off-by: Gao Xiang 
---

changelog v2:
 - [3/3] wrap bio->bi_private assignment into erofs_grab_bio()
   as suggested by Chao;

This series focus on fixing error handling when failed to read
compresssed data due to previous incomplete paths.

In addition, the last 2 patches add IO error fault injection
for reading paths, which I have used to test the first patch as well.

Thanks,
Gao Xiang

 drivers/staging/erofs/unzip_vle.c | 41 ++-
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/erofs/unzip_vle.c 
b/drivers/staging/erofs/unzip_vle.c
index bfd52ebd0403..45541be12972 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -973,6 +973,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
overlapped = false;
compressed_pages = grp->compressed_pages;
 
+   err = 0;
for (i = 0; i < clusterpages; ++i) {
unsigned int pagenr;
 
@@ -982,26 +983,39 @@ static int z_erofs_vle_unzip(struct super_block *sb,
DBG_BUGON(!page);
DBG_BUGON(!page->mapping);
 
-   if (z_erofs_is_stagingpage(page))
-   continue;
+   if (!z_erofs_is_stagingpage(page)) {
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
-   if (page->mapping == MNGD_MAPPING(sbi)) {
-   DBG_BUGON(!PageUptodate(page));
-   continue;
-   }
+   if (page->mapping == MNGD_MAPPING(sbi)) {
+   if (unlikely(!PageUptodate(page)))
+   err = -EIO;
+   continue;
+   }
 #endif
 
-   /* only non-head page could be reused as a compressed page */
-   pagenr = z_erofs_onlinepage_index(page);
+   /*
+* only if non-head page can be selected
+* for inplace decompression
+*/
+   pagenr = z_erofs_onlinepage_index(page);
 
-   DBG_BUGON(pagenr >= nr_pages);
-   DBG_BUGON(pages[pagenr]);
-   ++sparsemem_pages;
-   pages[pagenr] = page;
+   DBG_BUGON(pagenr >= nr_pages);
+   DBG_BUGON(pages[pagenr]);
+   ++sparsemem_pages;
+   pages[pagenr] = page;
+
+   overlapped = true;
+   }
 
-   overlapped = true;
+   /* PG_error needs checking for inplaced and staging pages */
+   if (unlikely(PageError(page))) {
+   DBG_BUGON(PageUptodate(page));
+   err = -EIO;
+   }
}
 
+   if (unlikely(err))
+   goto out;
+
llen = (nr_pages << PAGE_SHIFT) - work->pageofs;
 
if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) {
@@ -1195,6 +1209,7 @@ pickup_page_for_submission(struct z_erofs_vle_workgroup 
*grp,
if (page->mapping == mc) {
WRITE_ONCE(grp->compressed_pages[nr], page);
 
+   ClearPageError(page);
if (!PagePrivate(page)) {
/*
 * impossible to be !PagePrivate(page) for
-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 3/3] staging: erofs: support IO read error injection

2019-03-24 Thread Gao Xiang
Used to simulate disk IO read error for testing fatal
error tolerance.

Here are the details,
1) use bio->bi_private to indicate super_block
   for non-compressed bios since some (mainly meta)
   pages can be of the corresponding bdev inode;
2) get super_block dynamically for compressed bios,
   therefore it could not inject bios full of staging
   pages, yet it doesn't affect the normal usage.

Signed-off-by: Gao Xiang 
---
 .../staging/erofs/Documentation/filesystems/erofs.txt  |  1 +
 drivers/staging/erofs/data.c   | 18 --
 drivers/staging/erofs/internal.h   |  6 --
 drivers/staging/erofs/super.c  |  3 ++-
 drivers/staging/erofs/unzip_vle.c  | 14 +-
 5 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt 
b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
index 961ec4da7705..74cf84ac48a3 100644
--- a/drivers/staging/erofs/Documentation/filesystems/erofs.txt
+++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
@@ -60,6 +60,7 @@ fault_injection=%d Enable fault injection in all 
supported types with
specified injection rate. Supported injection type:
Type_NameType_Value
FAULT_KMALLOC0x1
+   FAULT_READ_IO0x2
 (no)user_xattr Setup Extended User Attributes. Note: xattr is enabled
by default if CONFIG_EROFS_FS_XATTR is selected.
 (no)aclSetup POSIX Access Control List. Note: acl is enabled
diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index 526e0dbea5b5..0714061ba888 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -17,11 +17,17 @@
 
 static inline void read_endio(struct bio *bio)
 {
+   struct super_block *const sb = bio->bi_private;
int i;
struct bio_vec *bvec;
-   const blk_status_t err = bio->bi_status;
+   blk_status_t err = bio->bi_status;
struct bvec_iter_all iter_all;
 
+   if (time_to_inject(EROFS_SB(sb), FAULT_READ_IO)) {
+   erofs_show_injection_info(FAULT_READ_IO);
+   err = BLK_STS_IOERR;
+   }
+
bio_for_each_segment_all(bvec, bio, i, iter_all) {
struct page *page = bvec->bv_page;
 
@@ -63,7 +69,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
if (!PageUptodate(page)) {
struct bio *bio;
 
-   bio = erofs_grab_bio(sb, blkaddr, 1, read_endio, nofail);
+   bio = erofs_grab_bio(sb, blkaddr, 1, sb, read_endio, nofail);
if (IS_ERR(bio)) {
DBG_BUGON(nofail);
err = PTR_ERR(bio);
@@ -188,7 +194,8 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
  unsigned int nblocks,
  bool ra)
 {
-   struct inode *inode = mapping->host;
+   struct inode *const inode = mapping->host;
+   struct super_block *const sb = inode->i_sb;
erofs_off_t current_block = (erofs_off_t)page->index;
int err;
 
@@ -280,9 +287,8 @@ static inline struct bio *erofs_read_raw_page(struct bio 
*bio,
if (nblocks > BIO_MAX_PAGES)
nblocks = BIO_MAX_PAGES;
 
-   bio = erofs_grab_bio(inode->i_sb,
-blknr, nblocks, read_endio, false);
-
+   bio = erofs_grab_bio(sb, blknr, nblocks, sb,
+read_endio, false);
if (IS_ERR(bio)) {
err = PTR_ERR(bio);
bio = NULL;
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index a66c7d495c35..c47778b3fabd 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -44,11 +44,12 @@
 
 enum {
FAULT_KMALLOC,
+   FAULT_READ_IO,
FAULT_MAX,
 };
 
 #ifdef CONFIG_EROFS_FAULT_INJECTION
-extern char *erofs_fault_name[FAULT_MAX];
+extern const char *erofs_fault_name[FAULT_MAX];
 #define IS_FAULT_SET(fi, type) ((fi)->inject_type & (1 << (type)))
 
 struct erofs_fault_info {
@@ -467,7 +468,7 @@ static inline int z_erofs_map_blocks_iter(struct inode 
*inode,
 /* data.c */
 static inline struct bio *
 erofs_grab_bio(struct super_block *sb,
-  erofs_blk_t blkaddr, unsigned int nr_pages,
+  erofs_blk_t blkaddr, unsigned int nr_pages, void *bi_private,
   bio_end_io_t endio, bool nofail)
 {
const gfp_t gfp = GFP_NOIO;
@@ -489,6 +490,7 @@ erofs_grab_bio(struct super_block *sb,
bio->bi_end_io = endio;
bio_set_dev(bio, sb->s_bdev);
bio->bi_iter.bi_sector = (sector_t)blkaddr << 

Re: [PATCH 1/3] staging: erofs: fix error handling when failed to read compresssed data

2019-03-24 Thread Gao Xiang
Hi Chao,

On 2019/3/25 10:05, Chao Yu wrote:
> On 2019/3/22 11:25, Gao Xiang wrote:
>> ping?
>>
>> Hi Chao,
>> could you take some time looking into this series?
> 
> Done, sorry for the delay.

It doesn't matter. It is helpful for our kernel upgrade
since it keeps up with the latest community code now ;)

Thanks for keeping on taking time on erofs. *thumb*

Thanks,
Gao Xiang

> 
> Thanks,
> 
>>
>> Thanks,
>> Gao Xiang
>>
>> On 2019/3/19 21:54, Gao Xiang wrote:
>>> Complete read error handling paths for all three kinds of
>>> compressed pages:
>>>
>>>  1) For cache-managed pages, PG_uptodate will be checked since
>>> read_endio will unlock and SetPageUptodate for these pages;
>>>
>>>  2) For inplaced pages, read_endio cannot SetPageUptodate directly
>>> since it should be used to mark the final decompressed data,
>>> PG_error will be set with page locked for IO error instead;
>>>
>>>  3) For staging pages, PG_error is used, which is similar to
>>> what we do for inplaced pages.
>>>
>>> Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
>>> Cc:  # 4.19+
>>> Signed-off-by: Gao Xiang 
>>> ---
>>>
>>> This series focus on fixing error handling when failed to read
>>> compresssed data due to previous incomplete paths.
>>>
>>> In addition, the last 2 patches add IO error fault injection
>>> for reading paths, which I have used to test the first patch as well.
>>>
>>> Thanks,
>>> Gao Xiang
>>>
>>>  drivers/staging/erofs/unzip_vle.c | 41 
>>> ++-
>>>  1 file changed, 28 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/staging/erofs/unzip_vle.c 
>>> b/drivers/staging/erofs/unzip_vle.c
>>> index 8715bc50e09c..3416d3f10324 100644
>>> --- a/drivers/staging/erofs/unzip_vle.c
>>> +++ b/drivers/staging/erofs/unzip_vle.c
>>> @@ -972,6 +972,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
>>> overlapped = false;
>>> compressed_pages = grp->compressed_pages;
>>>  
>>> +   err = 0;
>>> for (i = 0; i < clusterpages; ++i) {
>>> unsigned int pagenr;
>>>  
>>> @@ -981,26 +982,39 @@ static int z_erofs_vle_unzip(struct super_block *sb,
>>> DBG_BUGON(!page);
>>> DBG_BUGON(!page->mapping);
>>>  
>>> -   if (z_erofs_is_stagingpage(page))
>>> -   continue;
>>> +   if (!z_erofs_is_stagingpage(page)) {
>>>  #ifdef EROFS_FS_HAS_MANAGED_CACHE
>>> -   if (page->mapping == MNGD_MAPPING(sbi)) {
>>> -   DBG_BUGON(!PageUptodate(page));
>>> -   continue;
>>> -   }
>>> +   if (page->mapping == MNGD_MAPPING(sbi)) {
>>> +   if (unlikely(!PageUptodate(page)))
>>> +   err = -EIO;
>>> +   continue;
>>> +   }
>>>  #endif
>>>  
>>> -   /* only non-head page could be reused as a compressed page */
>>> -   pagenr = z_erofs_onlinepage_index(page);
>>> +   /*
>>> +* only if non-head page can be selected
>>> +* for inplace decompression
>>> +*/
>>> +   pagenr = z_erofs_onlinepage_index(page);
>>>  
>>> -   DBG_BUGON(pagenr >= nr_pages);
>>> -   DBG_BUGON(pages[pagenr]);
>>> -   ++sparsemem_pages;
>>> -   pages[pagenr] = page;
>>> +   DBG_BUGON(pagenr >= nr_pages);
>>> +   DBG_BUGON(pages[pagenr]);
>>> +   ++sparsemem_pages;
>>> +   pages[pagenr] = page;
>>> +
>>> +   overlapped = true;
>>> +   }
>>>  
>>> -   overlapped = true;
>>> +   /* PG_error needs checking for inplaced and staging pages */
>>> +   if (unlikely(PageError(page))) {
>>> +   DBG_BUGON(PageUptodate(page));
>>> +   err = -EIO;
>>> +   }
>>> }
>>>  
>>> +   if (unlikely(err))
>>> +   goto out;
>>> +
>>> llen = (nr_pages << PAGE_SHIFT) - work->pageofs;
>>>  
>>> if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) {
>>> @@ -1194,6 +1208,7 @@ pickup_page_for_submission(struct 
>>> z_erofs_vle_workgroup *grp,
>>> if (page->mapping == mc) {
>>> WRITE_ONCE(grp->compressed_pages[nr], page);
>>>  
>>> +   ClearPageError(page);
>>> if (!PagePrivate(page)) {
>>> /*
>>>  * impossible to be !PagePrivate(page) for
>>>
>> .
>>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: erofs: fix error handling when failed to read compresssed data

2019-03-24 Thread Chao Yu
On 2019/3/22 11:25, Gao Xiang wrote:
> ping?
> 
> Hi Chao,
> could you take some time looking into this series?

Done, sorry for the delay.

Thanks,

> 
> Thanks,
> Gao Xiang
> 
> On 2019/3/19 21:54, Gao Xiang wrote:
>> Complete read error handling paths for all three kinds of
>> compressed pages:
>>
>>  1) For cache-managed pages, PG_uptodate will be checked since
>> read_endio will unlock and SetPageUptodate for these pages;
>>
>>  2) For inplaced pages, read_endio cannot SetPageUptodate directly
>> since it should be used to mark the final decompressed data,
>> PG_error will be set with page locked for IO error instead;
>>
>>  3) For staging pages, PG_error is used, which is similar to
>> what we do for inplaced pages.
>>
>> Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
>> Cc:  # 4.19+
>> Signed-off-by: Gao Xiang 
>> ---
>>
>> This series focus on fixing error handling when failed to read
>> compresssed data due to previous incomplete paths.
>>
>> In addition, the last 2 patches add IO error fault injection
>> for reading paths, which I have used to test the first patch as well.
>>
>> Thanks,
>> Gao Xiang
>>
>>  drivers/staging/erofs/unzip_vle.c | 41 
>> ++-
>>  1 file changed, 28 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/staging/erofs/unzip_vle.c 
>> b/drivers/staging/erofs/unzip_vle.c
>> index 8715bc50e09c..3416d3f10324 100644
>> --- a/drivers/staging/erofs/unzip_vle.c
>> +++ b/drivers/staging/erofs/unzip_vle.c
>> @@ -972,6 +972,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
>>  overlapped = false;
>>  compressed_pages = grp->compressed_pages;
>>  
>> +err = 0;
>>  for (i = 0; i < clusterpages; ++i) {
>>  unsigned int pagenr;
>>  
>> @@ -981,26 +982,39 @@ static int z_erofs_vle_unzip(struct super_block *sb,
>>  DBG_BUGON(!page);
>>  DBG_BUGON(!page->mapping);
>>  
>> -if (z_erofs_is_stagingpage(page))
>> -continue;
>> +if (!z_erofs_is_stagingpage(page)) {
>>  #ifdef EROFS_FS_HAS_MANAGED_CACHE
>> -if (page->mapping == MNGD_MAPPING(sbi)) {
>> -DBG_BUGON(!PageUptodate(page));
>> -continue;
>> -}
>> +if (page->mapping == MNGD_MAPPING(sbi)) {
>> +if (unlikely(!PageUptodate(page)))
>> +err = -EIO;
>> +continue;
>> +}
>>  #endif
>>  
>> -/* only non-head page could be reused as a compressed page */
>> -pagenr = z_erofs_onlinepage_index(page);
>> +/*
>> + * only if non-head page can be selected
>> + * for inplace decompression
>> + */
>> +pagenr = z_erofs_onlinepage_index(page);
>>  
>> -DBG_BUGON(pagenr >= nr_pages);
>> -DBG_BUGON(pages[pagenr]);
>> -++sparsemem_pages;
>> -pages[pagenr] = page;
>> +DBG_BUGON(pagenr >= nr_pages);
>> +DBG_BUGON(pages[pagenr]);
>> +++sparsemem_pages;
>> +pages[pagenr] = page;
>> +
>> +overlapped = true;
>> +}
>>  
>> -overlapped = true;
>> +/* PG_error needs checking for inplaced and staging pages */
>> +if (unlikely(PageError(page))) {
>> +DBG_BUGON(PageUptodate(page));
>> +err = -EIO;
>> +}
>>  }
>>  
>> +if (unlikely(err))
>> +goto out;
>> +
>>  llen = (nr_pages << PAGE_SHIFT) - work->pageofs;
>>  
>>  if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) {
>> @@ -1194,6 +1208,7 @@ pickup_page_for_submission(struct 
>> z_erofs_vle_workgroup *grp,
>>  if (page->mapping == mc) {
>>  WRITE_ONCE(grp->compressed_pages[nr], page);
>>  
>> +ClearPageError(page);
>>  if (!PagePrivate(page)) {
>>  /*
>>   * impossible to be !PagePrivate(page) for
>>
> .
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: erofs: support IO read error injection

2019-03-24 Thread Gao Xiang
Hi Chao,

On 2019/3/25 9:47, Chao Yu wrote:
> On 2019/3/19 21:55, Gao Xiang wrote:
>> Used to simulate disk IO read error for testing fatal
>> error tolerance.
>>
>> Here are the details,
>> 1) use bio->bi_private to indicate super_block
>>for non-compressed bios since some (mainly meta)
>>pages can be of the corresponding bdev inode;
>> 2) get super_block dynamically for compressed bios,
>>therefore it could not inject bios full of staging
>>pages, yet it doesn't affect the normal usage.
>>
>> Signed-off-by: Gao Xiang 
>> ---
>>  drivers/staging/erofs/Documentation/filesystems/erofs.txt |  1 +
>>  drivers/staging/erofs/data.c  | 10 +-
>>  drivers/staging/erofs/internal.h  |  3 ++-
>>  drivers/staging/erofs/super.c |  3 ++-
>>  drivers/staging/erofs/unzip_vle.c | 10 --
>>  5 files changed, 22 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt 
>> b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
>> index 961ec4da7705..74cf84ac48a3 100644
>> --- a/drivers/staging/erofs/Documentation/filesystems/erofs.txt
>> +++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
>> @@ -60,6 +60,7 @@ fault_injection=%d Enable fault injection in all 
>> supported types with
>> specified injection rate. Supported injection type:
>> Type_NameType_Value
>> FAULT_KMALLOC0x1
>> +   FAULT_READ_IO0x2
>>  (no)user_xattr Setup Extended User Attributes. Note: xattr is 
>> enabled
>> by default if CONFIG_EROFS_FS_XATTR is selected.
>>  (no)aclSetup POSIX Access Control List. Note: acl is enabled
>> diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
>> index 526e0dbea5b5..16302ee54261 100644
>> --- a/drivers/staging/erofs/data.c
>> +++ b/drivers/staging/erofs/data.c
>> @@ -17,11 +17,17 @@
>>  
>>  static inline void read_endio(struct bio *bio)
>>  {
>> +struct super_block *const sb = bio->bi_private;
>>  int i;
>>  struct bio_vec *bvec;
>> -const blk_status_t err = bio->bi_status;
>> +blk_status_t err = bio->bi_status;
>>  struct bvec_iter_all iter_all;
>>  
>> +if (time_to_inject(EROFS_SB(sb), FAULT_READ_IO)) {
>> +erofs_show_injection_info(FAULT_READ_IO);
>> +err = BLK_STS_IOERR;
>> +}
>> +
>>  bio_for_each_segment_all(bvec, bio, i, iter_all) {
>>  struct page *page = bvec->bv_page;
>>  
>> @@ -69,6 +75,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
>>  err = PTR_ERR(bio);
>>  goto err_out;
>>  }
>> +bio->bi_private = sb;
> 
> Will it be better to initialize bio's field in erofs_grab_bio()?

Agreed and it will be fixed since bi_private field in erofs bios will be
initialized.

Thanks for the review :)

Thanks,
Gao Xiang

> 
>>  
>>  err = bio_add_page(bio, page, PAGE_SIZE, 0);
>>  if (unlikely(err != PAGE_SIZE)) {
>> @@ -288,6 +295,7 @@ static inline struct bio *erofs_read_raw_page(struct bio 
>> *bio,
>>  bio = NULL;
>>  goto err_out;
>>  }
>> +bio->bi_private = inode->i_sb;
> 
> Ditto.
> 
> Thanks,
> 
>>  }
>>  
>>  err = bio_add_page(bio, page, PAGE_SIZE, 0);
>> diff --git a/drivers/staging/erofs/internal.h 
>> b/drivers/staging/erofs/internal.h
>> index ba1d86f3470e..5d7addd9cff0 100644
>> --- a/drivers/staging/erofs/internal.h
>> +++ b/drivers/staging/erofs/internal.h
>> @@ -44,11 +44,12 @@
>>  
>>  enum {
>>  FAULT_KMALLOC,
>> +FAULT_READ_IO,
>>  FAULT_MAX,
>>  };
>>  
>>  #ifdef CONFIG_EROFS_FAULT_INJECTION
>> -extern char *erofs_fault_name[FAULT_MAX];
>> +extern const char *erofs_fault_name[FAULT_MAX];
>>  #define IS_FAULT_SET(fi, type) ((fi)->inject_type & (1 << (type)))
>>  
>>  struct erofs_fault_info {
>> diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
>> index 15c784fba879..ce025e6e4399 100644
>> --- a/drivers/staging/erofs/super.c
>> +++ b/drivers/staging/erofs/super.c
>> @@ -141,8 +141,9 @@ static int superblock_read(struct super_block *sb)
>>  }
>>  
>>  #ifdef CONFIG_EROFS_FAULT_INJECTION
>> -char *erofs_fault_name[FAULT_MAX] = {
>> +const char *erofs_fault_name[FAULT_MAX] = {
>>  [FAULT_KMALLOC] = "kmalloc",
>> +[FAULT_READ_IO] = "read IO error",
>>  };
>>  
>>  static void __erofs_build_fault_attr(struct erofs_sb_info *sbi,
>> diff --git a/drivers/staging/erofs/unzip_vle.c 
>> b/drivers/staging/erofs/unzip_vle.c
>> index d05fed4f8013..9fabdf596438 100644
>> --- a/drivers/staging/erofs/unzip_vle.c
>> +++ b/drivers/staging/erofs/unzip_vle.c
>> @@ -843,8 +843,8 @@ static void 

Re: [PATCH 3/3] staging: erofs: support IO read error injection

2019-03-24 Thread Chao Yu
On 2019/3/19 21:55, Gao Xiang wrote:
> Used to simulate disk IO read error for testing fatal
> error tolerance.
> 
> Here are the details,
> 1) use bio->bi_private to indicate super_block
>for non-compressed bios since some (mainly meta)
>pages can be of the corresponding bdev inode;
> 2) get super_block dynamically for compressed bios,
>therefore it could not inject bios full of staging
>pages, yet it doesn't affect the normal usage.
> 
> Signed-off-by: Gao Xiang 
> ---
>  drivers/staging/erofs/Documentation/filesystems/erofs.txt |  1 +
>  drivers/staging/erofs/data.c  | 10 +-
>  drivers/staging/erofs/internal.h  |  3 ++-
>  drivers/staging/erofs/super.c |  3 ++-
>  drivers/staging/erofs/unzip_vle.c | 10 --
>  5 files changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt 
> b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> index 961ec4da7705..74cf84ac48a3 100644
> --- a/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> +++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> @@ -60,6 +60,7 @@ fault_injection=%d Enable fault injection in all 
> supported types with
> specified injection rate. Supported injection type:
> Type_NameType_Value
> FAULT_KMALLOC0x1
> +   FAULT_READ_IO0x2
>  (no)user_xattr Setup Extended User Attributes. Note: xattr is enabled
> by default if CONFIG_EROFS_FS_XATTR is selected.
>  (no)aclSetup POSIX Access Control List. Note: acl is enabled
> diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
> index 526e0dbea5b5..16302ee54261 100644
> --- a/drivers/staging/erofs/data.c
> +++ b/drivers/staging/erofs/data.c
> @@ -17,11 +17,17 @@
>  
>  static inline void read_endio(struct bio *bio)
>  {
> + struct super_block *const sb = bio->bi_private;
>   int i;
>   struct bio_vec *bvec;
> - const blk_status_t err = bio->bi_status;
> + blk_status_t err = bio->bi_status;
>   struct bvec_iter_all iter_all;
>  
> + if (time_to_inject(EROFS_SB(sb), FAULT_READ_IO)) {
> + erofs_show_injection_info(FAULT_READ_IO);
> + err = BLK_STS_IOERR;
> + }
> +
>   bio_for_each_segment_all(bvec, bio, i, iter_all) {
>   struct page *page = bvec->bv_page;
>  
> @@ -69,6 +75,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
>   err = PTR_ERR(bio);
>   goto err_out;
>   }
> + bio->bi_private = sb;

Will it be better to initialize bio's field in erofs_grab_bio()?

>  
>   err = bio_add_page(bio, page, PAGE_SIZE, 0);
>   if (unlikely(err != PAGE_SIZE)) {
> @@ -288,6 +295,7 @@ static inline struct bio *erofs_read_raw_page(struct bio 
> *bio,
>   bio = NULL;
>   goto err_out;
>   }
> + bio->bi_private = inode->i_sb;

Ditto.

Thanks,

>   }
>  
>   err = bio_add_page(bio, page, PAGE_SIZE, 0);
> diff --git a/drivers/staging/erofs/internal.h 
> b/drivers/staging/erofs/internal.h
> index ba1d86f3470e..5d7addd9cff0 100644
> --- a/drivers/staging/erofs/internal.h
> +++ b/drivers/staging/erofs/internal.h
> @@ -44,11 +44,12 @@
>  
>  enum {
>   FAULT_KMALLOC,
> + FAULT_READ_IO,
>   FAULT_MAX,
>  };
>  
>  #ifdef CONFIG_EROFS_FAULT_INJECTION
> -extern char *erofs_fault_name[FAULT_MAX];
> +extern const char *erofs_fault_name[FAULT_MAX];
>  #define IS_FAULT_SET(fi, type) ((fi)->inject_type & (1 << (type)))
>  
>  struct erofs_fault_info {
> diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
> index 15c784fba879..ce025e6e4399 100644
> --- a/drivers/staging/erofs/super.c
> +++ b/drivers/staging/erofs/super.c
> @@ -141,8 +141,9 @@ static int superblock_read(struct super_block *sb)
>  }
>  
>  #ifdef CONFIG_EROFS_FAULT_INJECTION
> -char *erofs_fault_name[FAULT_MAX] = {
> +const char *erofs_fault_name[FAULT_MAX] = {
>   [FAULT_KMALLOC] = "kmalloc",
> + [FAULT_READ_IO] = "read IO error",
>  };
>  
>  static void __erofs_build_fault_attr(struct erofs_sb_info *sbi,
> diff --git a/drivers/staging/erofs/unzip_vle.c 
> b/drivers/staging/erofs/unzip_vle.c
> index d05fed4f8013..9fabdf596438 100644
> --- a/drivers/staging/erofs/unzip_vle.c
> +++ b/drivers/staging/erofs/unzip_vle.c
> @@ -843,8 +843,8 @@ static void z_erofs_vle_unzip_kickoff(void *ptr, int bios)
>  
>  static inline void z_erofs_vle_read_endio(struct bio *bio)
>  {
> - const blk_status_t err = bio->bi_status;
>   struct erofs_sb_info *sbi = NULL;
> + blk_status_t err = bio->bi_status;
>   unsigned int i;
>   struct 

Re: [PATCH 2/3] staging: erofs: introduce erofs_page_is_managed()

2019-03-24 Thread Chao Yu
On 2019/3/19 21:55, Gao Xiang wrote:
> 1) In order to clean up unnecessary
>page->mapping == MNGD_MAPPING(sbi) wrapped by #ifdefs;
> 
> 2) Needed by "staging: erofs: support IO read error injection".
> 
> Signed-off-by: Gao Xiang 

Reviewed-by: Chao Yu 

Thanks,
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/3] staging: erofs: fix error handling when failed to read compresssed data

2019-03-24 Thread Chao Yu
On 2019/3/19 21:54, Gao Xiang wrote:
> Complete read error handling paths for all three kinds of
> compressed pages:
> 
>  1) For cache-managed pages, PG_uptodate will be checked since
> read_endio will unlock and SetPageUptodate for these pages;
> 
>  2) For inplaced pages, read_endio cannot SetPageUptodate directly
> since it should be used to mark the final decompressed data,
> PG_error will be set with page locked for IO error instead;
> 
>  3) For staging pages, PG_error is used, which is similar to
> what we do for inplaced pages.
> 
> Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
> Cc:  # 4.19+
> Signed-off-by: Gao Xiang 

Reviewed-by: Chao Yu 

Thanks,
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 2/2] staging: iio: ad5933: move out of staging

2019-03-24 Thread Joe Perches
On Sun, 2019-03-24 at 16:38 +, Jonathan Cameron wrote:
> > diff --git a/drivers/iio/impedance-analyzer/ad5933.c 
> > b/drivers/iio/impedance-analyzer/ad5933.c

trivial note:

> > +static void ad5933_calc_out_ranges(struct ad5933_state *st)
> > +{
> > +   int i;
> > +   unsigned int normalized_3v3[4] = {1980, 198, 383, 970};

This could be static const which would make the code smaller.


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] vc04_services: vchiq_arm: fix a NULL pointer dereference

2019-03-24 Thread Kangjie Lu
When kzalloc fails, "platform_state->inited = 1" is a NULL pointer
dereference. The fix returns VCHIQ_ERROR in case it failed to
avoid NULL pointer dereference.

Signed-off-by: Kangjie Lu 
---
 .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c  | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index dd4898861b83..0f12fe617575 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -209,6 +209,8 @@ vchiq_platform_init_state(struct vchiq_state *state)
struct vchiq_2835_state *platform_state;
 
state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
+   if (!state->platform_state)
+   return VCHIQ_ERROR;
platform_state = (struct vchiq_2835_state *)state->platform_state;
 
platform_state->inited = 1;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] drivers/staging: fix styling of the comment related to SPDX-License-Identifier in vt6656/*.h

2019-03-24 Thread Greg Kroah-Hartman
On Sun, Mar 24, 2019 at 11:17:22PM +0530, ojaswin wrote:
> Fix checkpatch.pl styling error related to SPDX-License-Identifier comment 
> in vt6656/*.h
> 
> Signed-off-by: ojaswin 

We need a "real name" here, please see the kernel documentation about
this for the details.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ralink-gdma: ralink-gdma.c fixed line width

2019-03-24 Thread Dominik Adamski
Fix checkpatch issue:
line over 80 characters

Signed-off-by: Dominik Adamski 
---
 drivers/staging/ralink-gdma/ralink-gdma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c 
b/drivers/staging/ralink-gdma/ralink-gdma.c
index dfdc425557b6..97dd2ca2d261 100644
--- a/drivers/staging/ralink-gdma/ralink-gdma.c
+++ b/drivers/staging/ralink-gdma/ralink-gdma.c
@@ -740,7 +740,9 @@ static void gdma_dma_tasklet(unsigned long arg)
atomic_inc(_dev->cnt);
gdma_start_transfer(dma_dev, chan);
} else {
-   dev_dbg(dma_dev->ddev.dev, "chan %d no desc to 
issue\n", chan->id);
+   dev_dbg(dma_dev->ddev.dev,
+   "chan %d no desc to issue\n",
+   chan->id);
}
if (!dma_dev->chan_issued)
break;
-- 
2.19.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6655: Fix interrupt race condition on device start up.

2019-03-24 Thread Malcolm Priestley
It appears on some slower systems that the driver can find its way
out of the workqueue while the interrupt is disabled by continuous polling
by it.

Move MACvIntEnable to vnt_interrupt_work so that it is always enabled
on all routes out of vnt_interrupt_process.

Move MACvIntDisable so that the device doesn't keep polling the system
while the workqueue is being processed.

Signed-off-by: Malcolm Priestley 
CC: sta...@vger.kernel.org # v4.2+
---
 drivers/staging/vt6655/device_main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index b370985b58a1..83f1a1cf9182 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1033,8 +1033,6 @@ static void vnt_interrupt_process(struct vnt_private 
*priv)
return;
}
 
-   MACvIntDisable(priv->PortOffset);
-
spin_lock_irqsave(>lock, flags);
 
/* Read low level stats */
@@ -1122,8 +1120,6 @@ static void vnt_interrupt_process(struct vnt_private 
*priv)
}
 
spin_unlock_irqrestore(>lock, flags);
-
-   MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE);
 }
 
 static void vnt_interrupt_work(struct work_struct *work)
@@ -1133,6 +1129,8 @@ static void vnt_interrupt_work(struct work_struct *work)
 
if (priv->vif)
vnt_interrupt_process(priv);
+
+   MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE);
 }
 
 static irqreturn_t vnt_interrupt(int irq,  void *arg)
@@ -1142,6 +1140,8 @@ static irqreturn_t vnt_interrupt(int irq,  void *arg)
if (priv->vif)
schedule_work(>interrupt_work);
 
+   MACvIntDisable(priv->PortOffset);
+
return IRQ_HANDLED;
 }
 
-- 
2.20.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] drivers/staging: fix styling of the comment related to SPDX-License-Identifier in vt6656/*.h

2019-03-24 Thread ojaswin
Fix checkpatch.pl styling error related to SPDX-License-Identifier comment 
in vt6656/*.h

Signed-off-by: ojaswin 
---
 drivers/staging/vt6656/baseband.h | 2 +-
 drivers/staging/vt6656/card.h | 2 +-
 drivers/staging/vt6656/channel.h  | 2 +-
 drivers/staging/vt6656/desc.h | 2 +-
 drivers/staging/vt6656/device.h   | 2 +-
 drivers/staging/vt6656/dpc.h  | 2 +-
 drivers/staging/vt6656/firmware.h | 2 +-
 drivers/staging/vt6656/int.h  | 2 +-
 drivers/staging/vt6656/key.h  | 2 +-
 drivers/staging/vt6656/power.h| 2 +-
 drivers/staging/vt6656/rf.h   | 2 +-
 drivers/staging/vt6656/rxtx.h | 2 +-
 drivers/staging/vt6656/usbpipe.h  | 2 +-
 drivers/staging/vt6656/wcmd.h | 2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.h 
b/drivers/staging/vt6656/baseband.h
index a907e30..c3b8bbd 100644
--- a/drivers/staging/vt6656/baseband.h
+++ b/drivers/staging/vt6656/baseband.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h
index 0a91d9b..75cd340 100644
--- a/drivers/staging/vt6656/card.h
+++ b/drivers/staging/vt6656/card.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/channel.h b/drivers/staging/vt6656/channel.h
index 6d0d282..cca330f 100644
--- a/drivers/staging/vt6656/channel.h
+++ b/drivers/staging/vt6656/channel.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h
index ac45ebb..3a83a9e 100644
--- a/drivers/staging/vt6656/desc.h
+++ b/drivers/staging/vt6656/desc.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index a2feeb9..6074ced 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/dpc.h b/drivers/staging/vt6656/dpc.h
index ddd0cb7..e080add 100644
--- a/drivers/staging/vt6656/dpc.h
+++ b/drivers/staging/vt6656/dpc.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/firmware.h 
b/drivers/staging/vt6656/firmware.h
index f30ae90..161126f 100644
--- a/drivers/staging/vt6656/firmware.h
+++ b/drivers/staging/vt6656/firmware.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
index 1e6ff92..987c454e9 100644
--- a/drivers/staging/vt6656/int.h
+++ b/drivers/staging/vt6656/int.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/key.h b/drivers/staging/vt6656/key.h
index 1306ff4..918c07c 100644
--- a/drivers/staging/vt6656/key.h
+++ b/drivers/staging/vt6656/key.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/power.h b/drivers/staging/vt6656/power.h
index d5a3198..58755ae 100644
--- a/drivers/staging/vt6656/power.h
+++ b/drivers/staging/vt6656/power.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h
index f77866a..6103117 100644
--- a/drivers/staging/vt6656/rf.h
+++ b/drivers/staging/vt6656/rf.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h
index 44698f4..d528607 100644
--- a/drivers/staging/vt6656/rxtx.h
+++ b/drivers/staging/vt6656/rxtx.h
@@ -1,4 +1,4 @@

[PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro

2019-03-24 Thread Cristian Sicilia
Enclosing parameter with parenthesis due to avoid
possible precedence issue.

Signed-off-by: Cristian Sicilia 
---
 drivers/staging/iio/adc/ad7280a.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index 571535d..c2391f6 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -97,9 +97,10 @@
 #define AD7280A_NUM_CH (AD7280A_AUX_ADC_6 - \
AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)((d * AD7280A_CELLS_PER_DEV) + \
-c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \
+(c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)(((d) * AD7280A_CELLS_PER_DEV) + \
+(c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER 0
 #define AD7280A_DEVADDR_ALL0x1F
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation

2019-03-24 Thread Cristian Sicilia
Fix CamelCase naming.

Signed-off-by: Cristian Sicilia 
---
 drivers/staging/iio/adc/ad7280a.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index 4ff28f1..229dcad 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -917,8 +917,8 @@ static int ad7280_probe(struct spi_device *spi)
const struct ad7280_platform_data *pdata = dev_get_platdata(>dev);
struct ad7280_state *st;
int ret;
-   const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
-   const unsigned short nAVG[4] = {1, 2, 4, 8};
+   const unsigned short t_acq_ns[4] = {465, 1010, 1460, 1890};
+   const unsigned short n_avg[4] = {1, 2, 4, 8};
struct iio_dev *indio_dev;
 
indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
@@ -966,10 +966,9 @@ static int ad7280_probe(struct spi_device *spi)
 */
 
st->readback_delay_us =
-   ((tACQ_ns[pdata->acquisition_time & 0x3] + 695) *
-   (AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3]))
-   - tACQ_ns[pdata->acquisition_time & 0x3] +
-   st->slave_num * 250;
+   ((t_acq_ns[pdata->acquisition_time & 0x3] + 695) *
+(AD7280A_NUM_CH * n_avg[pdata->conversion_averaging & 0x3])) -
+   t_acq_ns[pdata->acquisition_time & 0x3] + st->slave_num * 250;
 
/* Convert to usecs */
st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format

2019-03-24 Thread Cristian Sicilia
Changed bool format to bitfield format to save space.

Signed-off-by: Cristian Sicilia 
---
 drivers/staging/iio/adc/ad7192.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h
index 7433a43..9c1d223 100644
--- a/drivers/staging/iio/adc/ad7192.h
+++ b/drivers/staging/iio/adc/ad7192.h
@@ -35,13 +35,13 @@ struct ad7192_platform_data {
u16 vref_mv;
u8  clock_source_sel;
u32 ext_clk_hz;
-   boolrefin2_en;
-   boolrej60_en;
-   boolsinc3_en;
-   boolchop_en;
-   boolbuf_en;
-   boolunipolar_en;
-   boolburnout_curr_en;
+   u8  refin2_en:1;
+   u8  rej60_en:1;
+   u8  sinc3_en:1;
+   u8  chop_en:1;
+   u8  buf_en:1;
+   u8  unipolar_en:1;
+   u8  burnout_curr_en:1;
 };
 
 #endif /* IIO_ADC_AD7192_H_ */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change

2019-03-24 Thread Cristian Sicilia
Some source refactoring, parameters alignment and camel case clearing.

Replacement of bool to bitfield in a struct, but not found
the population to check if it is done correctly.

Cristian Sicilia (5):
  staging: iio: adc: ad7280a: Tab alignment
  staging: iio: adc: ad7192: Converted bool to bitfield format
  staging: iio: adc: ad7280a: Avoid precedence issues in macro
  staging: iio: adc: ad7280a: Adding temp var to improve readability
  staging: iio: adc: ad7280a: Remove CamelCase notation

 drivers/staging/iio/adc/ad7192.h  |  14 ++---
 drivers/staging/iio/adc/ad7280a.c | 109 ++
 2 files changed, 59 insertions(+), 64 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability

2019-03-24 Thread Cristian Sicilia
Creating a temporary variable to improve readability

Signed-off-by: Cristian Sicilia 
---
 drivers/staging/iio/adc/ad7280a.c | 55 ++-
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index c2391f6..4ff28f1 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void 
*private)
for (i = 0; i < st->scan_cnt; i++) {
if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
if (((channels[i] >> 11) & 0xFFF) >=
-   st->cell_threshhigh)
-   iio_push_event(indio_dev,
-  IIO_EVENT_CODE(IIO_VOLTAGE,
-   1,
-   0,
-   IIO_EV_DIR_RISING,
-   IIO_EV_TYPE_THRESH,
-   0, 0, 0),
+   st->cell_threshhigh) {
+   u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+IIO_EV_DIR_RISING,
+IIO_EV_TYPE_THRESH,
+0, 0, 0);
+   iio_push_event(indio_dev, tmp,
   iio_get_time_ns(indio_dev));
-   else if (((channels[i] >> 11) & 0xFFF) <=
-   st->cell_threshlow)
-   iio_push_event(indio_dev,
-  IIO_EVENT_CODE(IIO_VOLTAGE,
-   1,
-   0,
-   IIO_EV_DIR_FALLING,
-   IIO_EV_TYPE_THRESH,
-   0, 0, 0),
+   } else if (((channels[i] >> 11) & 0xFFF) <=
+  st->cell_threshlow) {
+   u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+IIO_EV_DIR_FALLING,
+IIO_EV_TYPE_THRESH,
+0, 0, 0);
+   iio_push_event(indio_dev, tmp,
   iio_get_time_ns(indio_dev));
+   }
} else {
-   if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
-   iio_push_event(indio_dev,
-  IIO_UNMOD_EVENT_CODE(
-   IIO_TEMP,
-   0,
+   if (((channels[i] >> 11) & 0xFFF) >=
+   st->aux_threshhigh) {
+   u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
-   IIO_EV_DIR_RISING),
+   IIO_EV_DIR_RISING);
+   iio_push_event(indio_dev, tmp,
   iio_get_time_ns(indio_dev));
-   else if (((channels[i] >> 11) & 0xFFF) <=
-   st->aux_threshlow)
-   iio_push_event(indio_dev,
-  IIO_UNMOD_EVENT_CODE(
-   IIO_TEMP,
-   0,
+   } else if (((channels[i] >> 11) & 0xFFF) <=
+   st->aux_threshlow) {
+   u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH,
-   IIO_EV_DIR_FALLING),
+   IIO_EV_DIR_FALLING);
+   iio_push_event(indio_dev, tmp,
   iio_get_time_ns(indio_dev));
+   }
}
}
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment

2019-03-24 Thread Cristian Sicilia
Aligned some parameters.

Signed-off-by: Cristian Sicilia 
---
 drivers/staging/iio/adc/ad7280a.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index d9df126..571535d 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void 
*private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-   in_voltage-voltage_thresh_low_value,
-   0644,
-   ad7280_read_channel_config,
-   ad7280_write_channel_config,
-   AD7280A_CELL_UNDERVOLTAGE);
+in_voltage-voltage_thresh_low_value,
+0644,
+ad7280_read_channel_config,
+ad7280_write_channel_config,
+AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-   in_voltage-voltage_thresh_high_value,
-   0644,
-   ad7280_read_channel_config,
-   ad7280_write_channel_config,
-   AD7280A_CELL_OVERVOLTAGE);
+in_voltage-voltage_thresh_high_value,
+0644,
+ad7280_read_channel_config,
+ad7280_write_channel_config,
+AD7280A_CELL_OVERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
-   0644,
-   ad7280_read_channel_config,
-   ad7280_write_channel_config,
-   AD7280A_AUX_ADC_UNDERVOLTAGE);
+  0644,
+  ad7280_read_channel_config,
+  ad7280_write_channel_config,
+  AD7280A_AUX_ADC_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
-   0644,
-   ad7280_read_channel_config,
-   ad7280_write_channel_config,
-   AD7280A_AUX_ADC_OVERVOLTAGE);
+  0644,
+  ad7280_read_channel_config,
+  ad7280_write_channel_config,
+  AD7280A_AUX_ADC_OVERVOLTAGE);
 
 static struct attribute *ad7280_event_attributes[] = {
_dev_attr_in_thresh_low_value.dev_attr.attr,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8188eu: cleanup long line in odm.c

2019-03-24 Thread Michael Straube
Align a comment to clear a line over 80 characters
checkpatch warning.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/hal/odm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/hal/odm.c 
b/drivers/staging/rtl8188eu/hal/odm.c
index ba3c3e5a8216..95a8fc23e62c 100644
--- a/drivers/staging/rtl8188eu/hal/odm.c
+++ b/drivers/staging/rtl8188eu/hal/odm.c
@@ -107,7 +107,7 @@ u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = {
{0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /*  29, -14.5dB */
{0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /*  30, -15.0dB */
{0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /*  31, -15.5dB */
-   {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}/*  32, -16.0dB 
*/
+   {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}  /*  32, -16.0dB */
 };
 
 u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = {
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vc04_services: add missing __user annotations

2019-03-24 Thread Jasminko Dedic
This patch fixes the following sparse warnings by adding missing __user
annotations. It also cleans up two related unnecessary casts by reuseing
casts already made a few lines up. Remaining sparse warnings are of a
different type.

vchiq_arm.c:1606:14: warning: incorrect type in assignment (different address 
spaces)
vchiq_arm.c:1606:14:expected struct vchiq_queue_message *args
vchiq_arm.c:1606:14:got void [noderef]  *

vchiq_arm.c:1612:13: warning: incorrect type in argument 1 (different address 
spaces)
vchiq_arm.c:1612:13:expected void const volatile [noderef]  *
vchiq_arm.c:1612:13:got unsigned int *

vchiq_arm.c:1613:13: warning: incorrect type in argument 1 (different address 
spaces)
vchiq_arm.c:1613:13:expected void const volatile [noderef]  *
vchiq_arm.c:1613:13:got unsigned int *

vchiq_arm.c:1614:13: warning: incorrect type in argument 1 (different address 
spaces)
vchiq_arm.c:1614:13:expected void const volatile [noderef]  *
vchiq_arm.c:1614:13:got struct vchiq_element const [noderef]  **

vchiq_arm.c:1638:21: warning: incorrect type in argument 1 (different address 
spaces)
vchiq_arm.c:1638:21:expected void const volatile [noderef]  *
vchiq_arm.c:1638:21:got struct vchiq_element const [noderef]  **

Signed-off-by: Jasminko Dedic 
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 804daf83be35..1ca1c37a7e6e 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -1540,9 +1540,7 @@ vchiq_compat_ioctl_create_service(
if (!args)
return -EFAULT;
 
-   if (copy_from_user(,
-  (struct vchiq_create_service32 __user *)arg,
-  sizeof(args32)))
+   if (copy_from_user(, ptrargs32, sizeof(args32)))
return -EFAULT;
 
if (put_user(args32.params.fourcc, >params.fourcc) ||
@@ -1593,7 +1591,7 @@ vchiq_compat_ioctl_queue_message(struct file *file,
 unsigned int cmd,
 unsigned long arg)
 {
-   struct vchiq_queue_message *args;
+   struct vchiq_queue_message __user *args;
struct vchiq_element __user *elements;
struct vchiq_queue_message32 args32;
unsigned int count;
@@ -1662,17 +1660,15 @@ vchiq_compat_ioctl_queue_bulk(struct file *file,
 {
struct vchiq_queue_bulk_transfer __user *args;
struct vchiq_queue_bulk_transfer32 args32;
-   struct vchiq_queue_bulk_transfer32 *ptrargs32 =
-   (struct vchiq_queue_bulk_transfer32 *)arg;
+   struct vchiq_queue_bulk_transfer32 __user *ptrargs32 =
+   (struct vchiq_queue_bulk_transfer32 __user *)arg;
long ret;
 
args = compat_alloc_user_space(sizeof(*args));
if (!args)
return -EFAULT;
 
-   if (copy_from_user(,
-  (struct vchiq_queue_bulk_transfer32 __user *)arg,
-  sizeof(args32)))
+   if (copy_from_user(, ptrargs32, sizeof(args32)))
return -EFAULT;
 
if (put_user(args32.handle, >handle) ||
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 2/2] staging: iio: ad5933: move out of staging

2019-03-24 Thread Jonathan Cameron
On Thu, 21 Mar 2019 15:42:37 -0300
Marcelo Schmitt  wrote:

> Move ad5933 impedance-analyzer driver from staging to mainline. The
> ad5933 is a high precision impedance converter system solution that
> combines an on-board frequency generator with an analog-to-digital
> converter (ADC). This driver was designed to be compatible with both
> ad5933 and ad5934 chips.
> 
> Signed-off-by: Marcelo Schmitt 
Hi Marcelo,

The comments I made on v4 are still valid (I think) + I'd still like
to get more eyes on this.

Also keen to hear how you get on with testing it.

Now, it's not an absolute requirement to have tested it before moving
out of staging but it would definitely be great if you can!

Thanks,

Jonathan
> ---
>  drivers/iio/Kconfig   |   1 +
>  drivers/iio/Makefile  |   1 +
>  drivers/iio/impedance-analyzer/Kconfig|  18 +
>  drivers/iio/impedance-analyzer/Makefile   |   5 +
>  drivers/iio/impedance-analyzer/ad5933.c   | 811 ++
>  drivers/staging/iio/Kconfig   |   1 -
>  drivers/staging/iio/Makefile  |   1 -
>  .../staging/iio/impedance-analyzer/Kconfig|  18 -
>  .../staging/iio/impedance-analyzer/Makefile   |   5 -
>  .../staging/iio/impedance-analyzer/ad5933.c   | 811 --
>  10 files changed, 836 insertions(+), 836 deletions(-)
>  create mode 100644 drivers/iio/impedance-analyzer/Kconfig
>  create mode 100644 drivers/iio/impedance-analyzer/Makefile
>  create mode 100644 drivers/iio/impedance-analyzer/ad5933.c
>  delete mode 100644 drivers/staging/iio/impedance-analyzer/Kconfig
>  delete mode 100644 drivers/staging/iio/impedance-analyzer/Makefile
>  delete mode 100644 drivers/staging/iio/impedance-analyzer/ad5933.c
> 
> diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
> index 014006d1cbb6..db38e6fb62fe 100644
> --- a/drivers/iio/Kconfig
> +++ b/drivers/iio/Kconfig
> @@ -81,6 +81,7 @@ source "drivers/iio/frequency/Kconfig"
>  source "drivers/iio/gyro/Kconfig"
>  source "drivers/iio/health/Kconfig"
>  source "drivers/iio/humidity/Kconfig"
> +source "drivers/iio/impedance-analyzer/Kconfig"
>  source "drivers/iio/imu/Kconfig"
>  source "drivers/iio/light/Kconfig"
>  source "drivers/iio/magnetometer/Kconfig"
> diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
> index cb5993251381..fae55479356b 100644
> --- a/drivers/iio/Makefile
> +++ b/drivers/iio/Makefile
> @@ -27,6 +27,7 @@ obj-y += gyro/
>  obj-y += frequency/
>  obj-y += health/
>  obj-y += humidity/
> +obj-y += impedance-analyzer/
>  obj-y += imu/
>  obj-y += light/
>  obj-y += magnetometer/
> diff --git a/drivers/iio/impedance-analyzer/Kconfig 
> b/drivers/iio/impedance-analyzer/Kconfig
> new file mode 100644
> index ..b9a679cdd146
> --- /dev/null
> +++ b/drivers/iio/impedance-analyzer/Kconfig
> @@ -0,0 +1,18 @@
> +#
> +# Impedance Converter, Network Analyzer drivers
> +#
> +menu "Network Analyzer, Impedance Converters"
> +
> +config AD5933
> + tristate "Analog Devices AD5933, AD5934 driver"
> + depends on I2C
> + select IIO_BUFFER
> + select IIO_KFIFO_BUF
> + help
> +   Say yes here to build support for Analog Devices Impedance Converter,
> +   Network Analyzer, AD5933/4.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called ad5933.
> +
> +endmenu
> diff --git a/drivers/iio/impedance-analyzer/Makefile 
> b/drivers/iio/impedance-analyzer/Makefile
> new file mode 100644
> index ..7604d786583e
> --- /dev/null
> +++ b/drivers/iio/impedance-analyzer/Makefile
> @@ -0,0 +1,5 @@
> +#
> +# Makefile for Impedance Converter, Network Analyzer drivers
> +#
> +
> +obj-$(CONFIG_AD5933) += ad5933.o
> diff --git a/drivers/iio/impedance-analyzer/ad5933.c 
> b/drivers/iio/impedance-analyzer/ad5933.c
> new file mode 100644
> index ..2b0f8f899e3f
> --- /dev/null
> +++ b/drivers/iio/impedance-analyzer/ad5933.c
> @@ -0,0 +1,811 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * AD5933 AD5934 Impedance Converter, Network Analyzer
> + *
> + * Copyright 2011 Analog Devices Inc.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* AD5933/AD5934 Registers */
> +#define AD5933_REG_CONTROL_HB0x80/* R/W, 1 byte */
> +#define AD5933_REG_CONTROL_LB0x81/* R/W, 1 byte */
> +#define AD5933_REG_FREQ_START0x82/* R/W, 3 bytes */
> +#define AD5933_REG_FREQ_INC  0x85/* R/W, 3 bytes */
> +#define AD5933_REG_INC_NUM   0x88/* R/W, 2 bytes, 9 bit */
> +#define AD5933_REG_SETTLING_CYCLES   0x8A/* R/W, 2 bytes */
> +#define AD5933_REG_STATUS0x8F/* R, 1 byte */
> +#define AD5933_REG_TEMP_DATA 0x92/* R, 2 bytes*/
> +#define AD5933_REG_REAL_DATA 0x94/* R, 2 

Re: [PATCH v5 1/2] staging: iio: ad5933: change attributes to match ABI

2019-03-24 Thread Jonathan Cameron
On Thu, 21 Mar 2019 15:42:13 -0300
Marcelo Schmitt  wrote:

> Change device attributes' names to match ABI documentation. Names were
> chosen such that they tend to be similar to existing ABI so it should
> be easier to standardize them when necessary.
> 
> Signed-off-by: Marcelo Schmitt 
> ---
Change log here.

Anyhow, I looked back so fairly obviously what changed.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

>  .../staging/iio/impedance-analyzer/ad5933.c   | 24 +--
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c 
> b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index d75bdfbf93de..2b0f8f899e3f 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -315,12 +315,12 @@ static ssize_t ad5933_store_frequency(struct device 
> *dev,
>   return ret ? ret : len;
>  }
>  
> -static IIO_DEVICE_ATTR(out_voltage0_freq_start, 0644,
> +static IIO_DEVICE_ATTR(out_altvoltage0_frequency_start, 0644,
>   ad5933_show_frequency,
>   ad5933_store_frequency,
>   AD5933_REG_FREQ_START);
>  
> -static IIO_DEVICE_ATTR(out_voltage0_freq_increment, 0644,
> +static IIO_DEVICE_ATTR(out_altvoltage0_frequency_increment, 0644,
>   ad5933_show_frequency,
>   ad5933_store_frequency,
>   AD5933_REG_FREQ_INC);
> @@ -443,12 +443,12 @@ static ssize_t ad5933_store(struct device *dev,
>   return ret ? ret : len;
>  }
>  
> -static IIO_DEVICE_ATTR(out_voltage0_scale, 0644,
> +static IIO_DEVICE_ATTR(out_altvoltage0_raw, 0644,
>   ad5933_show,
>   ad5933_store,
>   AD5933_OUT_RANGE);
>  
> -static IIO_DEVICE_ATTR(out_voltage0_scale_available, 0444,
> +static IIO_DEVICE_ATTR(out_altvoltage0_scale_available, 0444,
>   ad5933_show,
>   NULL,
>   AD5933_OUT_RANGE_AVAIL);
> @@ -463,12 +463,12 @@ static IIO_DEVICE_ATTR(in_voltage0_scale_available, 
> 0444,
>   NULL,
>   AD5933_IN_PGA_GAIN_AVAIL);
>  
> -static IIO_DEVICE_ATTR(out_voltage0_freq_points, 0644,
> +static IIO_DEVICE_ATTR(out_altvoltage0_frequency_points, 0644,
>   ad5933_show,
>   ad5933_store,
>   AD5933_FREQ_POINTS);
>  
> -static IIO_DEVICE_ATTR(out_voltage0_settling_cycles, 0644,
> +static IIO_DEVICE_ATTR(out_altvoltage0_settling_cycles, 0644,
>   ad5933_show,
>   ad5933_store,
>   AD5933_OUT_SETTLING_CYCLES);
> @@ -480,12 +480,12 @@ static IIO_DEVICE_ATTR(out_voltage0_settling_cycles, 
> 0644,
>   * don't create dedicated sysfs channel attributes for out0 and in0.
>   */
>  static struct attribute *ad5933_attributes[] = {
> - _dev_attr_out_voltage0_scale.dev_attr.attr,
> - _dev_attr_out_voltage0_scale_available.dev_attr.attr,
> - _dev_attr_out_voltage0_freq_start.dev_attr.attr,
> - _dev_attr_out_voltage0_freq_increment.dev_attr.attr,
> - _dev_attr_out_voltage0_freq_points.dev_attr.attr,
> - _dev_attr_out_voltage0_settling_cycles.dev_attr.attr,
> + _dev_attr_out_altvoltage0_raw.dev_attr.attr,
> + _dev_attr_out_altvoltage0_scale_available.dev_attr.attr,
> + _dev_attr_out_altvoltage0_frequency_start.dev_attr.attr,
> + _dev_attr_out_altvoltage0_frequency_increment.dev_attr.attr,
> + _dev_attr_out_altvoltage0_frequency_points.dev_attr.attr,
> + _dev_attr_out_altvoltage0_settling_cycles.dev_attr.attr,
>   _dev_attr_in_voltage0_scale.dev_attr.attr,
>   _dev_attr_in_voltage0_scale_available.dev_attr.attr,
>   NULL

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format

2019-03-24 Thread Sicilia Cristian
On Sun, Mar 24, 2019 at 12:34:52PM +, Jonathan Cameron wrote:
> On Sat, 23 Mar 2019 20:21:39 +0100
> Cristian Sicilia  wrote:
> 
 > > Changed bool format to bitfield format to save space.
> > 
> > Signed-off-by: Cristian Sicilia 
> > 
> > ---
> > The strange thing is that this struct seems not populated
> > using a DTS binding function.
> Indeed and that should have definitely been a warning sign ;)
> We are looking at traditional platform data here (pre device
> tree) and generally we will want to drop it entirely for old
> drivers that we are looking to move out of staging.
> 
> I don't mind improving it prior to dropping (as it avoids
> setting bad precedence in the code base in the meantime) but
> one comment inline...
> 

Thanks for comment

> > ---
> >  drivers/staging/iio/adc/ad7192.h | 16 
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/adc/ad7192.h 
> > b/drivers/staging/iio/adc/ad7192.h
> > index 7433a43..87891ba 100644
> > --- a/drivers/staging/iio/adc/ad7192.h
> > +++ b/drivers/staging/iio/adc/ad7192.h
> > @@ -35,13 +35,13 @@ struct ad7192_platform_data {
> > u16 vref_mv;
> > u8  clock_source_sel;
> > u32 ext_clk_hz;
> > -   boolrefin2_en;
> > -   boolrej60_en;
> > -   boolsinc3_en;
> > -   boolchop_en;
> > -   boolbuf_en;
> > -   boolunipolar_en;
> > -   boolburnout_curr_en;
> > -};
> > +   u8  refin2_en:1;
> > +   u8  rej60_en:1;
> > +   u8  sinc3_en:1;
> > +   u8  chop_en:1;
> > +   u8  buf_en:1;
> > +   u8  unipolar_en:1;
> > +   u8  burnout_curr_en:1;
> > +} __attribute__((__packed__));
> Please don't use packed for anything without a very very good reason.
> it may result in data layouts that are much harder to read from.
> That obviously doesn't matter here as I doubt it's read in a fast path.

Ok, I remove it, thanks

> 
> >  
> >  #endif /* IIO_ADC_AD7192_H_ */
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/5] staging: iio: adc: Tab alignment

2019-03-24 Thread Cristian Sicilia
On Sun, Mar 24, 2019 at 12:35:52PM +, Jonathan Cameron wrote:
> On Sat, 23 Mar 2019 20:21:36 +0100
> Cristian Sicilia  wrote:
>
> > Aligned some parameters.
> >
> > Signed-off-by: Cristian Sicilia 
> > ---
> >  drivers/staging/iio/adc/ad7280a.c | 36 ++--
> >  1 file changed, 18 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/staging/iio/adc/ad7280a.c 
> > b/drivers/staging/iio/adc/ad7280a.c
> > index d9df126..55b5879 100644
> > --- a/drivers/staging/iio/adc/ad7280a.c
> > +++ b/drivers/staging/iio/adc/ad7280a.c
> > @@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void 
> > *private)
> >  }
> >
> >  static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
> > -   in_voltage-voltage_thresh_low_value,
> > -   0644,
> > -   ad7280_read_channel_config,
> > -   ad7280_write_channel_config,
> > -   AD7280A_CELL_UNDERVOLTAGE);
> > +in_voltage - voltage_thresh_low_value,
> Firstly, that isn't in your description and secondly you just
> broke the userspace ABI.  Take a very good look at what is happening here.

Yes sorry, it will badly stringify, I fix it


>
> > +0644,
> > +ad7280_read_channel_config,
> > +ad7280_write_channel_config,
> > +AD7280A_CELL_UNDERVOLTAGE);
> >
> >  static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
> > -   in_voltage-voltage_thresh_high_value,
> > -   0644,
> > -   ad7280_read_channel_config,
> > -   ad7280_write_channel_config,
> > -   AD7280A_CELL_OVERVOLTAGE);
> > +in_voltage - voltage_thresh_high_value,
> > +0644,
> > +ad7280_read_channel_config,
> > +ad7280_write_channel_config,
> > +AD7280A_CELL_OVERVOLTAGE);
> >
> >  static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
> > -   0644,
> > -   ad7280_read_channel_config,
> > -   ad7280_write_channel_config,
> > -   AD7280A_AUX_ADC_UNDERVOLTAGE);
> > +  0644,
> > +  ad7280_read_channel_config,
> > +  ad7280_write_channel_config,
> > +  AD7280A_AUX_ADC_UNDERVOLTAGE);
> >
> >  static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
> > -   0644,
> > -   ad7280_read_channel_config,
> > -   ad7280_write_channel_config,
> > -   AD7280A_AUX_ADC_OVERVOLTAGE);
> > +  0644,
> > +  ad7280_read_channel_config,
> > +  ad7280_write_channel_config,
> > +  AD7280A_AUX_ADC_OVERVOLTAGE);
> >
> >  static struct attribute *ad7280_event_attributes[] = {
> > _dev_attr_in_thresh_low_value.dev_attr.attr,
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Help on testing ad5933 driver

2019-03-24 Thread Jonathan Cameron
On Fri, 22 Mar 2019 22:34:21 +0200
Alexandru Ardelean  wrote:

> On Thu, Mar 21, 2019 at 9:39 PM Marcelo Schmitt
>  wrote:
> >
> > Hello, would anyone mind helping me test ad5933 driver on actual
> > hardware?  I went through this
> > (https://oslongjourney.github.io/linux-kernel/experiment-one-iio-dummy/)
> > tutorial so I was able to load iio_simple_dummy driver, create and
> > inspect some dummy devices.  Now, as Jonathan has asked me, I would like
> > to test ad5933 driver on an EVAL-AD5933 board which was donated to FLUSP
> > (https://flusp.ime.usp.br/).
> >
> > So far I've been hesitating to plug this device on my Debian distro
> > since this
> > (https://www.analog.com/media/en/technical-documentation/user-guides/UG-364.pdf)
> > user guide for Windows says not to connect it before driver
> > installation. Is there something that could harm the board if plugged
> > on a computer without a proper driver?
> >  
> 
> You should take into account that a lot of eval boards have their eval
> SW written for Windows.
> This is something of a legacy-thing, because most corporations have
> been running their computers (for work & dev & offices) on Windows.
> 
> So, you shouldn't take things ad-literam (to the letter) when reading
> stuff for Windows and when writing code for Linux.
> 
> > I also didn't understand the hardware configuration showed on this
> > (https://wiki.analog.com/resources/tools-software/linux-drivers/iio-impedance-analyzer/ad5933)
> > page.  
> 
> Hmm, that doc was written a while ago.
> The newer eval board doesn't look like the one in the wiki.
> 
> Also, since the eval SW was targeted for Windows, getting it to work
> for Linux (and IIO) implies some hacking/reverse-engineering.
> The reason for this (reverse-engineering) is because [traditionally]
> eval boards are meant to highlight characteristics of the chip, so if
> using Windows, this should be simple.
> 
> Unfortunately, the docs aren't helping in this case. So, in this case,
> I would get some volt-meter & oscilloscope to help.
> It looks to me that U2 is the AD5933 on the eval-board.
> Worst case, you can solder directly to the pins and link them to a
> Raspberry PI [on the I2C], power, ground, etc.
> But, you can take a look at the T1 to T8 (if I didn't miss anything)
> and connect to them, and see what each of them is for.
> Hopefully, one of those test-points is for I2C, in which case you can
> attach wires to them and connect them to a host.
> I did not find a good doc for them yet.

Circuit diagrams at the end of the datasheet for the eval board...

Definitely start with i2c, as SPI can be considerably more irritating
to get working (I've been on an off trying to deal with some reflections
on a similar dev board for weeks whereas i2c tends to be more resilient).

Hmm.. Normally there are some test points on the bus lines, but here there
don't seem to be.  I definitely would solder to the chip only as a last resort.
Here your best bet is the pads of R15 and R16. If that is no good
find someone with a hot air gun (electronics lap) and lift U4 (the rom
for the USB chip) as that will give some reasonable pads to solder to.

It's possible you'll need to cut tracks on the way out of the usb chip, but
you normally don't need to for i2c.

Using the existing USB power supply is probably a good plan, but make sure to
connect 0V between your host (raspberry pi or similar) and the dev board.

Annoyingly the datasheet is missing the normal art work for the PCB so we
can't actually tell you where any of these components is.  The photo's on
the website aren't too bad though.  I'd wonder if those two long tracks
(3,4 below the CLK socket) are the i2c traces. If they are then some
careful work may let you solder nicely onto the pair of vias at the left
hand end. 

https://www.analog.com/-/media/analog/en/evaluation-board-images/images/eval-ad5933ebztop-web.gif?h=500=1=2226724BDCF5C3ED7854F8C55C51BB9C595CEF3D

Note an oscilloscope is really useful when debugging your wiring so I'd
try and borrow one of those for when you first try to talk to it!

Feel free to ask for more advice if you need it.

Jonathan

> 
> But anyway, I would ask some HW guy to help here (because I'm a SW guy
> mostly),and get help on figuring out the eval board
> 
> >
> > Any advice will be greatly appreciated.
> > Thanks in advance,
> >
> > Marcelo  

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/2] staging: iio: ad7780: Add parentheses to macros

2019-03-24 Thread Jonathan Cameron
On Fri, 22 Mar 2019 00:15:28 +0300
Vladimir Petrigo  wrote:

> - Fix CHECK Macro argument 'wordsize' may be better as '(wordsize)' to avoid 
> precedence issues
> 
> Signed-off-by: Vladimir Petrigo 

Hi Vladimir,

This particular driver has recently moved out of staging and gained support
for some additional parts.  Still the particular issue was there still.

I applied your patch by hand to the moved driver and the additional case
of the same thing that was write next to this.

Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7780.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7780.c 
> b/drivers/staging/iio/adc/ad7780.c
> index c4a8578..010fb47 100644
> --- a/drivers/staging/iio/adc/ad7780.c
> +++ b/drivers/staging/iio/adc/ad7780.c
> @@ -142,7 +142,7 @@ static const struct ad_sigma_delta_info 
> ad7780_sigma_delta_info = {
>  };
>  
>  #define AD7780_CHANNEL(bits, wordsize) \
> - AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits)
> + AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, (wordsize) - (bits))
>  
>  static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
>   [ID_AD7170] = {

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/2] staging: iio: ad7280a: Add parentheses to macros

2019-03-24 Thread Jonathan Cameron
On Fri, 22 Mar 2019 00:15:27 +0300
Vladimir Petrigo  wrote:

> - Fix CHECK Macro argument 'c' may be better as '(c)' to avoid precedence 
> issues
> - Fix CHECK Macro argument 'd' may be better as '(d)' to avoid precedence 
> issues
> 
> Signed-off-by: Vladimir Petrigo 
Sorry, I ended up taking Cristian's patch for the same issue.

No particular reason other than which email I hit first!

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c 
> b/drivers/staging/iio/adc/ad7280a.c
> index d9df126..98cf876 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -97,9 +97,9 @@
>  #define AD7280A_NUM_CH   (AD7280A_AUX_ADC_6 - \
>   AD7280A_CELL_VOLTAGE_1 + 1)
>  
> -#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
> -#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)((d * AD7280A_CELLS_PER_DEV) + \
> -  c - AD7280A_CELLS_PER_DEV)
> +#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + 
> (c))
> +#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)(((d) * AD7280A_CELLS_PER_DEV) + 
> \
> +  (c) - AD7280A_CELLS_PER_DEV)
>  
>  #define AD7280A_DEVADDR_MASTER   0
>  #define AD7280A_DEVADDR_ALL  0x1F

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation

2019-03-24 Thread Jonathan Cameron
On Sat, 23 Mar 2019 20:21:49 +0100
Cristian Sicilia  wrote:

> Fix CamelCase naming.
> 
> Signed-off-by: Cristian Sicilia 
Applied.

Note that I added the part number to the titles of all these patches
so that people can readily see what they are actually changing.
Directory isn't very helpful when there can potentially be many 10s
of drivers in there (not true in this case, but still more than 1!)

Thanks,

Jonathan


> ---
>  drivers/staging/iio/adc/ad7280a.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c 
> b/drivers/staging/iio/adc/ad7280a.c
> index 5d848aa..c02454c 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -917,8 +917,8 @@ static int ad7280_probe(struct spi_device *spi)
>   const struct ad7280_platform_data *pdata = dev_get_platdata(>dev);
>   struct ad7280_state *st;
>   int ret;
> - const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
> - const unsigned short nAVG[4] = {1, 2, 4, 8};
> + const unsigned short t_acq_ns[4] = {465, 1010, 1460, 1890};
> + const unsigned short n_avg[4] = {1, 2, 4, 8};
>   struct iio_dev *indio_dev;
>  
>   indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
> @@ -966,10 +966,9 @@ static int ad7280_probe(struct spi_device *spi)
>*/
>  
>   st->readback_delay_us =
> - ((tACQ_ns[pdata->acquisition_time & 0x3] + 695) *
> - (AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3]))
> - - tACQ_ns[pdata->acquisition_time & 0x3] +
> - st->slave_num * 250;
> + ((t_acq_ns[pdata->acquisition_time & 0x3] + 695) *
> +  (AD7280A_NUM_CH * n_avg[pdata->conversion_averaging & 0x3])) -
> + t_acq_ns[pdata->acquisition_time & 0x3] + st->slave_num * 250;
>  
>   /* Convert to usecs */
>   st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000);

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: pi433: remove unnecessary calling rf69_set_mode()

2019-03-24 Thread Sidong Yang
Remove unnecessary rf69_set_mode() function call when rx is waiting for
a telegram. There is waste to call rf69_set_mode() twice for becoming
standby mode.

Signed-off-by: Sidong Yang 
---
 drivers/staging/pi433/pi433_if.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 53928af696a6..e822f87fc533 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -650,21 +650,19 @@ pi433_tx_thread(void *data)
disable_irq(device->irq_num[DIO0]);
device->tx_active = true;
 
+   /* clear fifo, set fifo threshold, set payload length */
+   retval = rf69_set_mode(spi, standby); /* this clears the fifo */
+   if (retval < 0)
+   return retval;
+
if (device->rx_active && !rx_interrupted) {
/*
 * rx is currently waiting for a telegram;
 * we need to set the radio module to standby
 */
-   retval = rf69_set_mode(device->spi, standby);
-   if (retval < 0)
-   return retval;
rx_interrupted = true;
}
 
-   /* clear fifo, set fifo threshold, set payload length */
-   retval = rf69_set_mode(spi, standby); /* this clears the fifo */
-   if (retval < 0)
-   return retval;
retval = rf69_set_fifo_threshold(spi, FIFO_THRESHOLD);
if (retval < 0)
return retval;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: pidfd design

2019-03-24 Thread Serge E. Hallyn
On Wed, Mar 20, 2019 at 12:29:31PM -0700, Daniel Colascione wrote:
> On Wed, Mar 20, 2019 at 11:52 AM Christian Brauner  
> wrote:
> > I really want to see Joel's pidfd_wait() patchset and have more people
> > review the actual code.
> 
> Sure. But it's also unpleasant to have people write code and then have
> to throw it away due to guessing incorrectly about unclear
> requirements.

No, it is not.  It is not unpleasant.  And it is useful.  It is the best way to
identify and resolve those incorrect guesses and unclear requirements.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/01] staging: vt6655: Modify comment style of SPDX License Identifier

2019-03-24 Thread grbesd1
From: Ganesh Biradar 

Fix the comment style of SPDX license identifier based on header file
type

Signed-off-by: Ganesh Biradar 
---
 drivers/staging/vt6655/channel.h| 2 +-
 drivers/staging/vt6655/desc.h   | 2 +-
 drivers/staging/vt6655/device.h | 2 +-
 drivers/staging/vt6655/device_cfg.h | 2 +-
 drivers/staging/vt6655/dpc.h| 2 +-
 drivers/staging/vt6655/key.h| 2 +-
 drivers/staging/vt6655/mac.h| 2 +-
 drivers/staging/vt6655/power.h  | 2 +-
 drivers/staging/vt6655/rf.h | 2 +-
 drivers/staging/vt6655/rxtx.h   | 2 +-
 drivers/staging/vt6655/srom.h   | 2 +-
 drivers/staging/vt6655/tmacro.h | 2 +-
 drivers/staging/vt6655/upc.h| 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vt6655/channel.h b/drivers/staging/vt6655/channel.h
index 53f623a4af65..0d2709607456 100644
--- a/drivers/staging/vt6655/channel.h
+++ b/drivers/staging/vt6655/channel.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h
index b4a0037b40c1..d4572847b08a 100644
--- a/drivers/staging/vt6655/desc.h
+++ b/drivers/staging/vt6655/desc.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h
index 2f9e9219e8c8..29f354ced563 100644
--- a/drivers/staging/vt6655/device.h
+++ b/drivers/staging/vt6655/device.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/device_cfg.h 
b/drivers/staging/vt6655/device_cfg.h
index 6b41c74f7c2a..04db6a8d3db3 100644
--- a/drivers/staging/vt6655/device_cfg.h
+++ b/drivers/staging/vt6655/device_cfg.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/dpc.h b/drivers/staging/vt6655/dpc.h
index 93af4220605f..eac67794cc49 100644
--- a/drivers/staging/vt6655/dpc.h
+++ b/drivers/staging/vt6655/dpc.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h
index 0942d8703f98..9347776fa3a5 100644
--- a/drivers/staging/vt6655/key.h
+++ b/drivers/staging/vt6655/key.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h
index b8ab09434773..8c8c26792343 100644
--- a/drivers/staging/vt6655/mac.h
+++ b/drivers/staging/vt6655/mac.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/power.h b/drivers/staging/vt6655/power.h
index 2ec40045fddb..d1736c1cbfa8 100644
--- a/drivers/staging/vt6655/power.h
+++ b/drivers/staging/vt6655/power.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h
index bfce5a89657d..042ac67a9709 100644
--- a/drivers/staging/vt6655/rf.h
+++ b/drivers/staging/vt6655/rf.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h
index 08db848613f0..464dd89078b2 100644
--- a/drivers/staging/vt6655/rxtx.h
+++ b/drivers/staging/vt6655/rxtx.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h
index 577f20dc4308..d8aad3ff5f46 100644
--- a/drivers/staging/vt6655/srom.h
+++ b/drivers/staging/vt6655/srom.h
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0+
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  * All rights reserved.
diff --git a/drivers/staging/vt6655/tmacro.h b/drivers/staging/vt6655/tmacro.h
index 

Re: [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability

2019-03-24 Thread Jonathan Cameron
On Sat, 23 Mar 2019 20:21:45 +0100
Cristian Sicilia  wrote:

> Creating a temporary variable to improve readability
> 
> Signed-off-by: Cristian Sicilia 

Indeed makes it a little more readable, so fair enough.

Applied

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 55 
> ++-
>  1 file changed, 25 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c 
> b/drivers/staging/iio/adc/ad7280a.c
> index d81a5bd..5d848aa 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void 
> *private)
>   for (i = 0; i < st->scan_cnt; i++) {
>   if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
>   if (((channels[i] >> 11) & 0xFFF) >=
> - st->cell_threshhigh)
> - iio_push_event(indio_dev,
> -IIO_EVENT_CODE(IIO_VOLTAGE,
> - 1,
> - 0,
> - IIO_EV_DIR_RISING,
> - IIO_EV_TYPE_THRESH,
> - 0, 0, 0),
> + st->cell_threshhigh) {
> + u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
> +  IIO_EV_DIR_RISING,
> +  IIO_EV_TYPE_THRESH,
> +  0, 0, 0);
> + iio_push_event(indio_dev, tmp,
>  iio_get_time_ns(indio_dev));
> - else if (((channels[i] >> 11) & 0xFFF) <=
> - st->cell_threshlow)
> - iio_push_event(indio_dev,
> -IIO_EVENT_CODE(IIO_VOLTAGE,
> - 1,
> - 0,
> - IIO_EV_DIR_FALLING,
> - IIO_EV_TYPE_THRESH,
> - 0, 0, 0),
> + } else if (((channels[i] >> 11) & 0xFFF) <=
> +st->cell_threshlow) {
> + u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
> +  IIO_EV_DIR_FALLING,
> +  IIO_EV_TYPE_THRESH,
> +  0, 0, 0);
> + iio_push_event(indio_dev, tmp,
>  iio_get_time_ns(indio_dev));
> + }
>   } else {
> - if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
> - iio_push_event(indio_dev,
> -IIO_UNMOD_EVENT_CODE(
> - IIO_TEMP,
> - 0,
> + if (((channels[i] >> 11) & 0xFFF) >=
> + st->aux_threshhigh) {
> + u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
>   IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_RISING),
> + IIO_EV_DIR_RISING);
> + iio_push_event(indio_dev, tmp,
>  iio_get_time_ns(indio_dev));
> - else if (((channels[i] >> 11) & 0xFFF) <=
> - st->aux_threshlow)
> - iio_push_event(indio_dev,
> -IIO_UNMOD_EVENT_CODE(
> - IIO_TEMP,
> - 0,
> + } else if (((channels[i] >> 11) & 0xFFF) <=
> + st->aux_threshlow) {
> + u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
>   IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_FALLING),
> + IIO_EV_DIR_FALLING);
> + iio_push_event(indio_dev, tmp,
>  iio_get_time_ns(indio_dev));
> + }
>   }
>   }
>  


Re: [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro

2019-03-24 Thread Jonathan Cameron
On Sat, 23 Mar 2019 20:21:42 +0100
Cristian Sicilia  wrote:

> Enclosing parameter with parenthesis due to avoid
> possible precedence issue.
> 
> Signed-off-by: Cristian Sicilia 
Applied to the togreg branch of iio.git which will get first
pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c 
> b/drivers/staging/iio/adc/ad7280a.c
> index 55b5879..d81a5bd 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -97,9 +97,10 @@
>  #define AD7280A_NUM_CH   (AD7280A_AUX_ADC_6 - \
>   AD7280A_CELL_VOLTAGE_1 + 1)
>  
> -#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
> -#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)((d * AD7280A_CELLS_PER_DEV) + \
> -  c - AD7280A_CELLS_PER_DEV)
> +#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + 
> \
> +  (c))
> +#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)(((d) * AD7280A_CELLS_PER_DEV) + 
> \
> +  (c) - AD7280A_CELLS_PER_DEV)
>  
>  #define AD7280A_DEVADDR_MASTER   0
>  #define AD7280A_DEVADDR_ALL  0x1F

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/5] staging: iio: adc: Tab alignment

2019-03-24 Thread Jonathan Cameron
On Sat, 23 Mar 2019 20:21:36 +0100
Cristian Sicilia  wrote:

> Aligned some parameters.
> 
> Signed-off-by: Cristian Sicilia 
> ---
>  drivers/staging/iio/adc/ad7280a.c | 36 ++--
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c 
> b/drivers/staging/iio/adc/ad7280a.c
> index d9df126..55b5879 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void 
> *private)
>  }
>  
>  static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
> - in_voltage-voltage_thresh_low_value,
> - 0644,
> - ad7280_read_channel_config,
> - ad7280_write_channel_config,
> - AD7280A_CELL_UNDERVOLTAGE);
> +  in_voltage - voltage_thresh_low_value,
Firstly, that isn't in your description and secondly you just
broke the userspace ABI.  Take a very good look at what is happening here.

> +  0644,
> +  ad7280_read_channel_config,
> +  ad7280_write_channel_config,
> +  AD7280A_CELL_UNDERVOLTAGE);
>  
>  static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
> - in_voltage-voltage_thresh_high_value,
> - 0644,
> - ad7280_read_channel_config,
> - ad7280_write_channel_config,
> - AD7280A_CELL_OVERVOLTAGE);
> +  in_voltage - voltage_thresh_high_value,
> +  0644,
> +  ad7280_read_channel_config,
> +  ad7280_write_channel_config,
> +  AD7280A_CELL_OVERVOLTAGE);
>  
>  static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
> - 0644,
> - ad7280_read_channel_config,
> - ad7280_write_channel_config,
> - AD7280A_AUX_ADC_UNDERVOLTAGE);
> +0644,
> +ad7280_read_channel_config,
> +ad7280_write_channel_config,
> +AD7280A_AUX_ADC_UNDERVOLTAGE);
>  
>  static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
> - 0644,
> - ad7280_read_channel_config,
> - ad7280_write_channel_config,
> - AD7280A_AUX_ADC_OVERVOLTAGE);
> +0644,
> +ad7280_read_channel_config,
> +ad7280_write_channel_config,
> +AD7280A_AUX_ADC_OVERVOLTAGE);
>  
>  static struct attribute *ad7280_event_attributes[] = {
>   _dev_attr_in_thresh_low_value.dev_attr.attr,

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format

2019-03-24 Thread Jonathan Cameron
On Sat, 23 Mar 2019 20:21:39 +0100
Cristian Sicilia  wrote:

> Changed bool format to bitfield format to save space.
> 
> Signed-off-by: Cristian Sicilia 
> 
> ---
> The strange thing is that this struct seems not populated
> using a DTS binding function.
Indeed and that should have definitely been a warning sign ;)
We are looking at traditional platform data here (pre device
tree) and generally we will want to drop it entirely for old
drivers that we are looking to move out of staging.

I don't mind improving it prior to dropping (as it avoids
setting bad precedence in the code base in the meantime) but
one comment inline...

> ---
>  drivers/staging/iio/adc/ad7192.h | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7192.h 
> b/drivers/staging/iio/adc/ad7192.h
> index 7433a43..87891ba 100644
> --- a/drivers/staging/iio/adc/ad7192.h
> +++ b/drivers/staging/iio/adc/ad7192.h
> @@ -35,13 +35,13 @@ struct ad7192_platform_data {
>   u16 vref_mv;
>   u8  clock_source_sel;
>   u32 ext_clk_hz;
> - boolrefin2_en;
> - boolrej60_en;
> - boolsinc3_en;
> - boolchop_en;
> - boolbuf_en;
> - boolunipolar_en;
> - boolburnout_curr_en;
> -};
> + u8  refin2_en:1;
> + u8  rej60_en:1;
> + u8  sinc3_en:1;
> + u8  chop_en:1;
> + u8  buf_en:1;
> + u8  unipolar_en:1;
> + u8  burnout_curr_en:1;
> +} __attribute__((__packed__));
Please don't use packed for anything without a very very good reason.
it may result in data layouts that are much harder to read from.
That obviously doesn't matter here as I doubt it's read in a fast path.

>  
>  #endif /* IIO_ADC_AD7192_H_ */

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC/PATCH] staging: olpc_dcon: Use WARN_ON instead of BUG_ON

2019-03-24 Thread Greg KH
On Sun, Mar 24, 2019 at 05:42:08PM +0530, Bharath Vedartham wrote:
> This is with respect to a checkpatch.pl CHECK: "Avoid crashing the
> kernel. Use WARN_ON instead of BUG_ON". But I maybe wrong here. Is a
> kernel crash desired if olpc_board_at_least(olpc_board(0xc2)) fails,
> will there be inconsistent results if execution continues?
> 
> Signed-off-by: Bharath Vedartham 
> ---
>  drivers/staging/olpc_dcon/olpc_dcon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
> b/drivers/staging/olpc_dcon/olpc_dcon.c
> index 6b714f7..900baab7 100644
> --- a/drivers/staging/olpc_dcon/olpc_dcon.c
> +++ b/drivers/staging/olpc_dcon/olpc_dcon.c
> @@ -138,7 +138,7 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int 
> is_powered_down)
>   }
>   if (x < 0) {
>   pr_err("unable to stabilize dcon's smbus, reasserting power and 
> praying.\n");
> - BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
> + WARN_ON(olpc_board_at_least(olpc_board(0xc2)));

Shouldn't you do something to handle this error, if it can actually
happen?  Don't just warn and keep on going, if this was all that was
needed to fix up these types of issues, we could do it all in one simple
search/replace step :)

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC/PATCH] staging: olpc_dcon: Use WARN_ON instead of BUG_ON

2019-03-24 Thread Bharath Vedartham
This is with respect to a checkpatch.pl CHECK: "Avoid crashing the
kernel. Use WARN_ON instead of BUG_ON". But I maybe wrong here. Is a
kernel crash desired if olpc_board_at_least(olpc_board(0xc2)) fails,
will there be inconsistent results if execution continues?

Signed-off-by: Bharath Vedartham 
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
b/drivers/staging/olpc_dcon/olpc_dcon.c
index 6b714f7..900baab7 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -138,7 +138,7 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int 
is_powered_down)
}
if (x < 0) {
pr_err("unable to stabilize dcon's smbus, reasserting power and 
praying.\n");
-   BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
+   WARN_ON(olpc_board_at_least(olpc_board(0xc2)));
pm = 0;
olpc_ec_cmd(EC_DCON_POWER_MODE, , 1, NULL, 0);
msleep(100);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ralink-gdma: Convert unsigned to unsigned int

2019-03-24 Thread Greg KH
On Sun, Mar 24, 2019 at 03:07:48PM +0530, Bharath Vedartham wrote:
> On Sun, Mar 24, 2019 at 09:58:42AM +0100, Greg KH wrote:
> > On Sat, Mar 23, 2019 at 05:04:44PM +0530, Bharath Vedartham wrote:
> > > Fix the checkpatch.pl warning: "Use unsigned int instead of unsigned".
> > > 
> > > Signed-off-by: Bharath Vedartham 
> > > ---
> > >  drivers/staging/ralink-gdma/ralink-gdma.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > This patch also does not apply at all :(
> 
> I have been working on linus's branch and not the staging branch. I
> thought that linus's branch would have the latest updates and would be
> the latest branch :( . Is it a problem if I use linus's branch for
> staging drivers?

Yes, if you want to do kernel development, you always need to work off
of the subsystem tree that you are wanting to contribute to, or off of
linux-next.  Development trees can often be 3 months ahead of Linus's
tree depending on the time of the merge window.

The tree should always be listed in the MAINTAINERS file for what one to
use.

hope this helps,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 01/11] staging: iio: ad7780: add gain & filter gpio support

2019-03-24 Thread Jonathan Cameron
On Sat, 16 Mar 2019 17:46:40 +
Jonathan Cameron  wrote:

> On Fri, 15 Mar 2019 23:12:27 -0300
> Renato Lui Geh  wrote:
> 
> > Previously, the AD7780 driver only supported gpio for the 'powerdown'
> > pin. This commit adds suppport for the 'gain' and 'filter' pin.
> > 
> > Signed-off-by: Renato Lui Geh 
> > Signed-off-by: Giuliano Belinassi 
> > Co-developed-by: Giuliano Belinassi   
> Something a little odd happened when trying to use git am on this,
> but patch was happy so I did it that way. Please give it a quick
> sanity check once I push the tree out incase we have a real problem.
> 
> Applied to the togreg branch of iio.git to be shortly pushed out
> as testing for the autobuilders to play with it.

Ah, we missed a 64 bit being divided below. Found by 0day.


> 
> Thanks,
> 
> Jonathan
> 
> > ---
> > Changes in v3:
> >  - Renamed ad7780_chip_info's filter to odr
> >  - Renamed ad778x_filter to ad778x_odr_avail
> >  - Changed vref variable from unsigned int to unsigned long long to avoid
> >overflow
> >  - Removed unnecessary AD_SD_CHANNEL macro
> > Changes in v4:
> >  - Removed useless macro
> >  - Added default case for switch to suppress warning
> >  - Removed chunks belonging to filter reading, adding these as a
> >patch for itself
> > Changes in v5:
> >  - ad778x_odr_avail moved to filter patch
> >  - Split gain reading to its own patch
> >  - Init GPIOs in a separate function
> > 
> >  drivers/staging/iio/adc/ad7780.c | 114 ++-
> >  1 file changed, 96 insertions(+), 18 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/adc/ad7780.c 
> > b/drivers/staging/iio/adc/ad7780.c
> > index c4a85789c2db..07e5e35c92a3 100644
> > --- a/drivers/staging/iio/adc/ad7780.c
> > +++ b/drivers/staging/iio/adc/ad7780.c
> > @@ -39,6 +39,9 @@
> >  #define AD7170_PATTERN (AD7780_PAT0 | AD7170_PAT2)
> >  #define AD7170_PATTERN_MASK(AD7780_PAT0 | AD7780_PAT1 | 
> > AD7170_PAT2)
> >  
> > +#define AD7780_GAIN_MIDPOINT   64
> > +#define AD7780_FILTER_MIDPOINT 13350
> > +
> >  struct ad7780_chip_info {
> > struct iio_chan_specchannel;
> > unsigned intpattern_mask;
> > @@ -50,7 +53,10 @@ struct ad7780_state {
> > const struct ad7780_chip_info   *chip_info;
> > struct regulator*reg;
> > struct gpio_desc*powerdown_gpio;
> > -   unsigned intgain;
> > +   struct gpio_desc*gain_gpio;
> > +   struct gpio_desc*filter_gpio;
> > +   unsigned intgain;
> > +   unsigned intint_vref_mv;
> >  
> > struct ad_sigma_delta sd;
> >  };
> > @@ -104,8 +110,10 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
> > voltage_uv = regulator_get_voltage(st->reg);
> > if (voltage_uv < 0)
> > return voltage_uv;
> > -   *val = (voltage_uv / 1000) * st->gain;
> > +   voltage_uv /= 1000;
> > +   *val = voltage_uv * st->gain;
> > *val2 = chan->scan_type.realbits - 1;
> > +   st->int_vref_mv = voltage_uv;
> > return IIO_VAL_FRACTIONAL_LOG2;
> > case IIO_CHAN_INFO_OFFSET:
> > *val = -(1 << (chan->scan_type.realbits - 1));
> > @@ -115,6 +123,50 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
> > return -EINVAL;
> >  }
> >  
> > +static int ad7780_write_raw(struct iio_dev *indio_dev,
> > +   struct iio_chan_spec const *chan,
> > +   int val,
> > +   int val2,
> > +   long m)
> > +{
> > +   struct ad7780_state *st = iio_priv(indio_dev);
> > +   const struct ad7780_chip_info *chip_info = st->chip_info;
> > +   unsigned long long vref;
> > +   unsigned int full_scale, gain;
> > +
> > +   if (!chip_info->is_ad778x)
> > +   return -EINVAL;
> > +
> > +   switch (m) {
> > +   case IIO_CHAN_INFO_SCALE:
> > +   if (val != 0)
> > +   return -EINVAL;
> > +
> > +   vref = st->int_vref_mv * 100LL;
> > +   full_scale = 1 << (chip_info->channel.scan_type.realbits - 1);
> > +   gain = DIV_ROUND_CLOSEST(vref, full_scale);

DIV_ROUND_CLOSEST_ULL needed as vref is long long.

I'll fix up.

Jonathan

> > +   gain = DIV_ROUND_CLOSEST(gain, val2);
> > +   st->gain = gain;
> > +   if (gain < AD7780_GAIN_MIDPOINT)
> > +   gain = 0;
> > +   else
> > +   gain = 1;
> > +   gpiod_set_value(st->gain_gpio, gain);
> > +   break;
> > +   case IIO_CHAN_INFO_SAMP_FREQ:
> > +   if (1000*val + val2/1000 < AD7780_FILTER_MIDPOINT)
> > +   val = 0;
> > +   else
> > +   val = 1;
> > +   gpiod_set_value(st->filter_gpio, val);
> > +   break;
> > +   default:
> > +   break;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >  static int ad7780_postprocess_sample(struct 

[PATCH] staging: ralink-gdma: Remove space after cast

2019-03-24 Thread Bharath Vedartham
This fixes the checkpatch.pl check: "No space is necessary after the
cast".

Signed-off-by: Bharath Vedartham 
---
 drivers/staging/ralink-gdma/ralink-gdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c 
b/drivers/staging/ralink-gdma/ralink-gdma.c
index dfdc425..04c551a 100644
--- a/drivers/staging/ralink-gdma/ralink-gdma.c
+++ b/drivers/staging/ralink-gdma/ralink-gdma.c
@@ -818,7 +818,7 @@ static int gdma_dma_probe(struct platform_device *pdev)
match = of_match_device(gdma_of_match_table, >dev);
if (!match)
return -EINVAL;
-   data = (struct gdma_data *) match->data;
+   data = (struct gdma_data *)match->data;
 
dma_dev = devm_kzalloc(>dev,
   struct_size(dma_dev, chan, data->chancnt),
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ralink-gdma: Convert unsigned to unsigned int

2019-03-24 Thread Bharath Vedartham
On Sun, Mar 24, 2019 at 09:58:42AM +0100, Greg KH wrote:
> On Sat, Mar 23, 2019 at 05:04:44PM +0530, Bharath Vedartham wrote:
> > Fix the checkpatch.pl warning: "Use unsigned int instead of unsigned".
> > 
> > Signed-off-by: Bharath Vedartham 
> > ---
> >  drivers/staging/ralink-gdma/ralink-gdma.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> This patch also does not apply at all :(
I have sent version 2 based of the latest staging branch.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: ralink-gdma: Change unsigned to unsigned int

2019-03-24 Thread Bharath Vedartham
This fixes the checkpatch.pl warning: "Prefer unsigned to unsigned int"

Signed-off-by: Bharath Vedartham 
---
Changes since v1
- Based this patch of the staging branch and not linus's branch
  unlike the last patch.
---
 drivers/staging/ralink-gdma/ralink-gdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c 
b/drivers/staging/ralink-gdma/ralink-gdma.c
index 04c551a..680ce02 100644
--- a/drivers/staging/ralink-gdma/ralink-gdma.c
+++ b/drivers/staging/ralink-gdma/ralink-gdma.c
@@ -164,7 +164,7 @@ static inline uint32_t gdma_dma_read(struct gdma_dma_dev 
*dma_dev,
 }
 
 static inline void gdma_dma_write(struct gdma_dma_dev *dma_dev,
- unsigned reg, uint32_t val)
+ unsigned int reg, uint32_t val)
 {
writel(val, dma_dev->base + reg);
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] staging: ralink-gdma: Use u32 over uint32_t

2019-03-24 Thread Bharath Vedartham
On Sun, Mar 24, 2019 at 09:58:33AM +0100, Greg KH wrote:
> On Sat, Mar 23, 2019 at 09:16:48PM +0530, Bharath Vedartham wrote:
> > Fixes the checkpatch.pl warning: "Prefer u32 over uint32_t"
> > 
> > Signed-off-by: Bharath Vedartham 
> > ---
> > Changes since v3
> > - Fixed allignment issues.
> > - Submitted a seperate patch to change unsigned
> > to unsigned int.
> > - One of the allignments crosses 80 characters in a line
> > but I feel that we may loose readability if we try to reduce
> > the characters in the line.
> > ---
> >  drivers/staging/ralink-gdma/ralink-gdma.c | 14 ++
> >  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> This patch does not apply to my staging-testing branch at all :(
Same case here :(. I have used linus's branch rather than the staging
branch. I have also noticed that this patch does not apply to the
staging branch as this checkpatch warning has already been  fixed in the
staging branch.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ralink-gdma: Convert unsigned to unsigned int

2019-03-24 Thread Bharath Vedartham
On Sun, Mar 24, 2019 at 09:58:42AM +0100, Greg KH wrote:
> On Sat, Mar 23, 2019 at 05:04:44PM +0530, Bharath Vedartham wrote:
> > Fix the checkpatch.pl warning: "Use unsigned int instead of unsigned".
> > 
> > Signed-off-by: Bharath Vedartham 
> > ---
> >  drivers/staging/ralink-gdma/ralink-gdma.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> This patch also does not apply at all :(

I have been working on linus's branch and not the staging branch. I
thought that linus's branch would have the latest updates and would be
the latest branch :( . Is it a problem if I use linus's branch for
staging drivers?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ralink-gdma: Convert unsigned to unsigned int

2019-03-24 Thread Greg KH
On Sat, Mar 23, 2019 at 05:04:44PM +0530, Bharath Vedartham wrote:
> Fix the checkpatch.pl warning: "Use unsigned int instead of unsigned".
> 
> Signed-off-by: Bharath Vedartham 
> ---
>  drivers/staging/ralink-gdma/ralink-gdma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

This patch also does not apply at all :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v4] staging: ralink-gdma: Use u32 over uint32_t

2019-03-24 Thread Greg KH
On Sat, Mar 23, 2019 at 09:16:48PM +0530, Bharath Vedartham wrote:
> Fixes the checkpatch.pl warning: "Prefer u32 over uint32_t"
> 
> Signed-off-by: Bharath Vedartham 
> ---
> Changes since v3
>   - Fixed allignment issues.
>   - Submitted a seperate patch to change unsigned
>   to unsigned int.
>   - One of the allignments crosses 80 characters in a line
>   but I feel that we may loose readability if we try to reduce
>   the characters in the line.
> ---
>  drivers/staging/ralink-gdma/ralink-gdma.c | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)

This patch does not apply to my staging-testing branch at all :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel