[PATCH -next] mm, page_alloc: avoid page_to_pfn() in move_freepages()

2021-03-23 Thread Liu Shixin
From: Kefeng Wang 

The start_pfn and end_pfn are already available in move_freepages_block(),
there is no need to go back and forth between page and pfn in move_freepages
and move_freepages_block, and pfn_valid_within() should validate pfn first
before touching the page.

Signed-off-by: Kefeng Wang 
Signed-off-by: Liu Shixin 
---
 mm/page_alloc.c | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c53fe4fa10bf..ccfaa8158862 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2425,19 +2425,21 @@ static inline struct page 
*__rmqueue_cma_fallback(struct zone *zone,
  * boundary. If alignment is required, use move_freepages_block()
  */
 static int move_freepages(struct zone *zone,
- struct page *start_page, struct page *end_page,
+ unsigned long start_pfn, unsigned long end_pfn,
  int migratetype, int *num_movable)
 {
struct page *page;
+   unsigned long pfn;
unsigned int order;
int pages_moved = 0;
 
-   for (page = start_page; page <= end_page;) {
-   if (!pfn_valid_within(page_to_pfn(page))) {
-   page++;
+   for (pfn = start_pfn; pfn <= end_pfn;) {
+   if (!pfn_valid_within(pfn)) {
+   pfn++;
continue;
}
 
+   page = pfn_to_page(pfn);
if (!PageBuddy(page)) {
/*
 * We assume that pages that could be isolated for
@@ -2447,8 +2449,7 @@ static int move_freepages(struct zone *zone,
if (num_movable &&
(PageLRU(page) || __PageMovable(page)))
(*num_movable)++;
-
-   page++;
+   pfn++;
continue;
}
 
@@ -2458,7 +2459,7 @@ static int move_freepages(struct zone *zone,
 
order = buddy_order(page);
move_to_free_list(page, zone, order, migratetype);
-   page += 1 << order;
+   pfn += 1 << order;
pages_moved += 1 << order;
}
 
@@ -2468,25 +2469,22 @@ static int move_freepages(struct zone *zone,
 int move_freepages_block(struct zone *zone, struct page *page,
int migratetype, int *num_movable)
 {
-   unsigned long start_pfn, end_pfn;
-   struct page *start_page, *end_page;
+   unsigned long start_pfn, end_pfn, pfn;
 
if (num_movable)
*num_movable = 0;
 
-   start_pfn = page_to_pfn(page);
-   start_pfn = start_pfn & ~(pageblock_nr_pages-1);
-   start_page = pfn_to_page(start_pfn);
-   end_page = start_page + pageblock_nr_pages - 1;
+   pfn = page_to_pfn(page);
+   start_pfn = pfn & ~(pageblock_nr_pages - 1);
end_pfn = start_pfn + pageblock_nr_pages - 1;
 
/* Do not cross zone boundaries */
if (!zone_spans_pfn(zone, start_pfn))
-   start_page = page;
+   start_pfn = pfn;
if (!zone_spans_pfn(zone, end_pfn))
return 0;
 
-   return move_freepages(zone, start_page, end_page, migratetype,
+   return move_freepages(zone, start_pfn, end_pfn, migratetype,
num_movable);
 }
 
-- 
2.25.1



Re: [PATCH -next] mm, page_alloc: avoid page_to_pfn() in move_freepages()

2021-03-26 Thread Liu Shixin
Sorry to reply to you after a so long time and thanks for your advice. It 
does seem that your proposed change will make the code cleaner and more 
efficient.

I repeated move_freepages_block() 200 times on the VM and counted 
jiffies. The average value before and after the change was both about 12,000. I 
think it's probably because I'm using the Sparse Memory Model, so pfn_to_page() 
is not time-consuming.


On 2021/3/23 20:54, Matthew Wilcox wrote:
> On Tue, Mar 23, 2021 at 09:12:15PM +0800, Liu Shixin wrote:
>> From: Kefeng Wang 
>>
>> The start_pfn and end_pfn are already available in move_freepages_block(),
>> there is no need to go back and forth between page and pfn in move_freepages
>> and move_freepages_block, and pfn_valid_within() should validate pfn first
>> before touching the page.
> This looks good to me:
>
> Reviewed-by: Matthew Wilcox (Oracle) 
>
>>  static int move_freepages(struct zone *zone,
>> -  struct page *start_page, struct page *end_page,
>> +  unsigned long start_pfn, unsigned long end_pfn,
>>int migratetype, int *num_movable)
>>  {
>>  struct page *page;
>> +unsigned long pfn;
>>  unsigned int order;
>>  int pages_moved = 0;
>>  
>> -for (page = start_page; page <= end_page;) {
>> -if (!pfn_valid_within(page_to_pfn(page))) {
>> -page++;
>> +for (pfn = start_pfn; pfn <= end_pfn;) {
>> +if (!pfn_valid_within(pfn)) {
>> +pfn++;
>>  continue;
>>  }
>>  
>> +page = pfn_to_page(pfn);
> I wonder if this wouldn't be even better if we did:
>
>   struct page *start_page = pfn_to_page(start_pfn);
>
>   for (pfn = start_pfn; pfn <= end_pfn; pfn++) {
>   struct page *page = start_page + pfn - start_pfn;
>
>   if (!pfn_valid_within(pfn))
>   continue;
>
>> -
>> -page++;
>> +pfn++;
>>  continue;
> ... then we can drop the increment of pfn here
>
>>  }
>>  
>> @@ -2458,7 +2459,7 @@ static int move_freepages(struct zone *zone,
>>  
>>  order = buddy_order(page);
>>  move_to_free_list(page, zone, order, migratetype);
>> -page += 1 << order;
>> +pfn += 1 << order;
> ... and change this to pfn += (1 << order) - 1;
>
> Do you have any numbers to quantify the benefit of this change?
> .
>



Re: [PATCH] arm: 9016/2: Make symbol 'tmp_pmd_table' static

2021-03-28 Thread Liu Shixin
I'm sorry for making such a stupid mistake. There was only one patch committed 
before(5615f69bc209 "ARM: 9016/2: Initialize the mapping of KASan shadow 
memory"), and I used the same subject by mistake.

Thanks for your correction, I will revise the subject and resend it. How about 
using "arm: mm: kasan_init" in the subject?


On 2021/3/27 18:20, Russell King - ARM Linux admin wrote:
> Why do you have 9016/2 in the subject line? That's an identifier from
> the patch system which shouldn't be in the subject line.
>
> If you want to refer to something already committed, please do so via
> the sha1 git hash and quote the first line of the commit description
> within ("...") in the body of your commit description.
>
> Thanks.
>
> On Sat, Mar 27, 2021 at 04:30:18PM +0800, Shixin Liu wrote:
>> Symbol 'tmp_pmd_table' is not used outside of kasan_init.c and only used
>> when CONFIG_ARM_LPAE enabled. So marks it static and add it into 
>> CONFIG_ARM_LPAE.
>>
>> Signed-off-by: Shixin Liu 
>> ---
>>  arch/arm/mm/kasan_init.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mm/kasan_init.c b/arch/arm/mm/kasan_init.c
>> index 9c348042a724..3a06d3b51f97 100644
>> --- a/arch/arm/mm/kasan_init.c
>> +++ b/arch/arm/mm/kasan_init.c
>> @@ -27,7 +27,9 @@
>>  
>>  static pgd_t tmp_pgd_table[PTRS_PER_PGD] __initdata __aligned(PGD_SIZE);
>>  
>> -pmd_t tmp_pmd_table[PTRS_PER_PMD] __page_aligned_bss;
>> +#ifdef CONFIG_ARM_LPAE
>> +static pmd_t tmp_pmd_table[PTRS_PER_PMD] __page_aligned_bss;
>> +#endif
>>  
>>  static __init void *kasan_alloc_block(size_t size)
>>  {
>> -- 
>> 2.25.1
>>
>>



Re: [PATCH -next v2 1/2] mm/debug_vm_pgtable: Move {pmd/pud}_huge_tests out of CONFIG_TRANSPARENT_HUGEPAGE

2021-04-18 Thread Liu Shixin
Thanks for your advice. I will fix these patches and resend them as soon as 
possilble.


On 2021/4/19 11:30, Anshuman Khandual wrote:
>
> On 4/9/21 9:35 AM, Anshuman Khandual wrote:
>> On 4/6/21 10:18 AM, Shixin Liu wrote:
>>> v1->v2:
>>> Modified the commit message.
>> Please avoid change log in the commit message, it should be after '---'
>> below the SOB statement.
>>
>>> The functions {pmd/pud}_set_huge and {pmd/pud}_clear_huge ars not dependent 
>>> on THP.
>> typo^ 
>> s/ars/are
>>
>> Also there is a checkpatch.pl warning.
>>
>> WARNING: Possible unwrapped commit description (prefer a maximum 75 chars 
>> per line)
>> #10: 
>> The functions {pmd/pud}_set_huge and {pmd/pud}_clear_huge ars not dependent 
>> on THP.
>>
>> total: 0 errors, 1 warnings, 121 lines checked
>>
>> As I had mentioned in the earlier version, the commit message should be some
>> thing like ..
>>
>> 
>> The functions {pmd/pud}_set_huge and {pmd/pud}_clear_huge are not dependent
>> on THP. Hence move {pmd/pud}_huge_tests out of CONFIG_TRANSPARENT_HUGEPAGE.
>> 
>>
>>> Signed-off-by: Shixin Liu 
>>> ---
>>>  mm/debug_vm_pgtable.c | 91 +++
>>>  1 file changed, 39 insertions(+), 52 deletions(-)
>>>
>>> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
>>> index 05efe98a9ac2..d3cf178621d9 100644
>>> --- a/mm/debug_vm_pgtable.c
>>> +++ b/mm/debug_vm_pgtable.c
>>> @@ -242,29 +242,6 @@ static void __init pmd_leaf_tests(unsigned long pfn, 
>>> pgprot_t prot)
>>> WARN_ON(!pmd_leaf(pmd));
>>>  }
>>>  
>>> -#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
>>> -static void __init pmd_huge_tests(pmd_t *pmdp, unsigned long pfn, pgprot_t 
>>> prot)
>>> -{
>>> -   pmd_t pmd;
>>> -
>>> -   if (!arch_vmap_pmd_supported(prot))
>>> -   return;
>>> -
>>> -   pr_debug("Validating PMD huge\n");
>>> -   /*
>>> -* X86 defined pmd_set_huge() verifies that the given
>>> -* PMD is not a populated non-leaf entry.
>>> -*/
>>> -   WRITE_ONCE(*pmdp, __pmd(0));
>>> -   WARN_ON(!pmd_set_huge(pmdp, __pfn_to_phys(pfn), prot));
>>> -   WARN_ON(!pmd_clear_huge(pmdp));
>>> -   pmd = READ_ONCE(*pmdp);
>>> -   WARN_ON(!pmd_none(pmd));
>>> -}
>>> -#else /* CONFIG_HAVE_ARCH_HUGE_VMAP */
>>> -static void __init pmd_huge_tests(pmd_t *pmdp, unsigned long pfn, pgprot_t 
>>> prot) { }
>>> -#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
>>> -
>>>  static void __init pmd_savedwrite_tests(unsigned long pfn, pgprot_t prot)
>>>  {
>>> pmd_t pmd = pfn_pmd(pfn, prot);
>>> @@ -379,30 +356,6 @@ static void __init pud_leaf_tests(unsigned long pfn, 
>>> pgprot_t prot)
>>> pud = pud_mkhuge(pud);
>>> WARN_ON(!pud_leaf(pud));
>>>  }
>>> -
>>> -#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
>>> -static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t 
>>> prot)
>>> -{
>>> -   pud_t pud;
>>> -
>>> -   if (!arch_vmap_pud_supported(prot))
>>> -   return;
>>> -
>>> -   pr_debug("Validating PUD huge\n");
>>> -   /*
>>> -* X86 defined pud_set_huge() verifies that the given
>>> -* PUD is not a populated non-leaf entry.
>>> -*/
>>> -   WRITE_ONCE(*pudp, __pud(0));
>>> -   WARN_ON(!pud_set_huge(pudp, __pfn_to_phys(pfn), prot));
>>> -   WARN_ON(!pud_clear_huge(pudp));
>>> -   pud = READ_ONCE(*pudp);
>>> -   WARN_ON(!pud_none(pud));
>>> -}
>>> -#else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
>>> -static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t 
>>> prot) { }
>>> -#endif /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
>>> -
>>>  #else  /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */
>>>  static void __init pud_basic_tests(struct mm_struct *mm, unsigned long 
>>> pfn, int idx) { }
>>>  static void __init pud_advanced_tests(struct mm_struct *mm,
>>> @@ -412,9 +365,6 @@ static void __init pud_advanced_tests(struct mm_struct 
>>> *mm,
>>>  {
>>>  }
>>>  static void __init pud_leaf_tests(unsigned long pfn, pgprot_t prot) { }
>>> -static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t 
>>> prot)
>>> -{
>>> -}
>>>  #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */
>>>  #else  /* !CONFIG_TRANSPARENT_HUGEPAGE */
>>>  static void __init pmd_basic_tests(unsigned long pfn, int idx) { }
>>> @@ -433,14 +383,51 @@ static void __init pud_advanced_tests(struct 
>>> mm_struct *mm,
>>>  }
>>>  static void __init pmd_leaf_tests(unsigned long pfn, pgprot_t prot) { }
>>>  static void __init pud_leaf_tests(unsigned long pfn, pgprot_t prot) { }
>>> +static void __init pmd_savedwrite_tests(unsigned long pfn, pgprot_t prot) 
>>> { }
>>> +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
>>> +
>>> +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
>>>  static void __init pmd_huge_tests(pmd_t *pmdp, unsigned long pfn, pgprot_t 
>>> prot)
>>>  {
>>> +   pmd_t pmd;
>>> +
>>> +   if (!arch_vmap_pmd_supported(prot))
>>> +   return;
>>> +
>>> +   pr_debug("Validating PMD huge\n");
>>> +   /*
>>> +* X86 defined pmd_set_huge() verifies that the given
>>> +* PM

[PATCH -next v3 1/2] mm/debug_vm_pgtable: Move {pmd/pud}_huge_tests out of CONFIG_TRANSPARENT_HUGEPAGE

2021-04-18 Thread Liu Shixin
From: Shixin Liu 

The functions {pmd/pud}_set_huge and {pmd/pud}_clear_huge are not dependent
on THP. Hence move {pmd/pud}_huge_tests out of CONFIG_TRANSPARENT_HUGEPAGE.

Signed-off-by: Shixin Liu 
Reviewed-by: Anshuman Khandual 
---
v2->v3:
Modified the commit message and fix a checkpatch warning.
v1->v2:
Modified the commit message.

 mm/debug_vm_pgtable.c | 91 +++
 1 file changed, 39 insertions(+), 52 deletions(-)

diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index 05efe98a9ac2..d3cf178621d9 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -242,29 +242,6 @@ static void __init pmd_leaf_tests(unsigned long pfn, 
pgprot_t prot)
WARN_ON(!pmd_leaf(pmd));
 }
 
-#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
-static void __init pmd_huge_tests(pmd_t *pmdp, unsigned long pfn, pgprot_t 
prot)
-{
-   pmd_t pmd;
-
-   if (!arch_vmap_pmd_supported(prot))
-   return;
-
-   pr_debug("Validating PMD huge\n");
-   /*
-* X86 defined pmd_set_huge() verifies that the given
-* PMD is not a populated non-leaf entry.
-*/
-   WRITE_ONCE(*pmdp, __pmd(0));
-   WARN_ON(!pmd_set_huge(pmdp, __pfn_to_phys(pfn), prot));
-   WARN_ON(!pmd_clear_huge(pmdp));
-   pmd = READ_ONCE(*pmdp);
-   WARN_ON(!pmd_none(pmd));
-}
-#else /* CONFIG_HAVE_ARCH_HUGE_VMAP */
-static void __init pmd_huge_tests(pmd_t *pmdp, unsigned long pfn, pgprot_t 
prot) { }
-#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
-
 static void __init pmd_savedwrite_tests(unsigned long pfn, pgprot_t prot)
 {
pmd_t pmd = pfn_pmd(pfn, prot);
@@ -379,30 +356,6 @@ static void __init pud_leaf_tests(unsigned long pfn, 
pgprot_t prot)
pud = pud_mkhuge(pud);
WARN_ON(!pud_leaf(pud));
 }
-
-#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
-static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t 
prot)
-{
-   pud_t pud;
-
-   if (!arch_vmap_pud_supported(prot))
-   return;
-
-   pr_debug("Validating PUD huge\n");
-   /*
-* X86 defined pud_set_huge() verifies that the given
-* PUD is not a populated non-leaf entry.
-*/
-   WRITE_ONCE(*pudp, __pud(0));
-   WARN_ON(!pud_set_huge(pudp, __pfn_to_phys(pfn), prot));
-   WARN_ON(!pud_clear_huge(pudp));
-   pud = READ_ONCE(*pudp);
-   WARN_ON(!pud_none(pud));
-}
-#else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
-static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t 
prot) { }
-#endif /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
-
 #else  /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */
 static void __init pud_basic_tests(struct mm_struct *mm, unsigned long pfn, 
int idx) { }
 static void __init pud_advanced_tests(struct mm_struct *mm,
@@ -412,9 +365,6 @@ static void __init pud_advanced_tests(struct mm_struct *mm,
 {
 }
 static void __init pud_leaf_tests(unsigned long pfn, pgprot_t prot) { }
-static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t 
prot)
-{
-}
 #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */
 #else  /* !CONFIG_TRANSPARENT_HUGEPAGE */
 static void __init pmd_basic_tests(unsigned long pfn, int idx) { }
@@ -433,14 +383,51 @@ static void __init pud_advanced_tests(struct mm_struct 
*mm,
 }
 static void __init pmd_leaf_tests(unsigned long pfn, pgprot_t prot) { }
 static void __init pud_leaf_tests(unsigned long pfn, pgprot_t prot) { }
+static void __init pmd_savedwrite_tests(unsigned long pfn, pgprot_t prot) { }
+#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+
+#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
 static void __init pmd_huge_tests(pmd_t *pmdp, unsigned long pfn, pgprot_t 
prot)
 {
+   pmd_t pmd;
+
+   if (!arch_vmap_pmd_supported(prot))
+   return;
+
+   pr_debug("Validating PMD huge\n");
+   /*
+* X86 defined pmd_set_huge() verifies that the given
+* PMD is not a populated non-leaf entry.
+*/
+   WRITE_ONCE(*pmdp, __pmd(0));
+   WARN_ON(!pmd_set_huge(pmdp, __pfn_to_phys(pfn), prot));
+   WARN_ON(!pmd_clear_huge(pmdp));
+   pmd = READ_ONCE(*pmdp);
+   WARN_ON(!pmd_none(pmd));
 }
+
 static void __init pud_huge_tests(pud_t *pudp, unsigned long pfn, pgprot_t 
prot)
 {
+   pud_t pud;
+
+   if (!arch_vmap_pud_supported(prot))
+   return;
+
+   pr_debug("Validating PUD huge\n");
+   /*
+* X86 defined pud_set_huge() verifies that the given
+* PUD is not a populated non-leaf entry.
+*/
+   WRITE_ONCE(*pudp, __pud(0));
+   WARN_ON(!pud_set_huge(pudp, __pfn_to_phys(pfn), prot));
+   WARN_ON(!pud_clear_huge(pudp));
+   pud = READ_ONCE(*pudp);
+   WARN_ON(!pud_none(pud));
 }
-static void __init pmd_savedwrite_tests(unsigned long pfn, pgprot_t prot) { }
-#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+#else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
+static void __init pmd_huge_tests(pmd_t *pmdp, unsigned long pfn, pgprot_t 
prot) { }
+static void __init pud_huge_tests(pud_t *p

[PATCH -next v3 2/2] mm/debug_vm_pgtable: Remove redundant pfn_{pmd/pte}() and fix one comment mistake

2021-04-18 Thread Liu Shixin
From: Shixin Liu 

Remove redundant pfn_{pmd/pte}() in {pmd/pte}_advanced_tests()
and adjust pfn_pud() in pud_advanced_tests() to make it similar with
other two functions.
In addition, the branch condition should be CONFIG_TRANSPARENT_HUGEPAGE
instead of CONFIG_ARCH_HAS_PTE_DEVMAP.

Signed-off-by: Shixin Liu 
Reviewed-by: Anshuman Khandual 
---
v2->v3:
Modified the commit message.
v1->v2:
Remove redundant pfn_pte() and fold two patch to one.

 mm/debug_vm_pgtable.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index d3cf178621d9..e2f35db8ba69 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -91,7 +91,7 @@ static void __init pte_advanced_tests(struct mm_struct *mm,
  unsigned long pfn, unsigned long vaddr,
  pgprot_t prot)
 {
-   pte_t pte = pfn_pte(pfn, prot);
+   pte_t pte;
 
/*
 * Architectures optimize set_pte_at by avoiding TLB flush.
@@ -185,7 +185,7 @@ static void __init pmd_advanced_tests(struct mm_struct *mm,
  unsigned long pfn, unsigned long vaddr,
  pgprot_t prot, pgtable_t pgtable)
 {
-   pmd_t pmd = pfn_pmd(pfn, prot);
+   pmd_t pmd;
 
if (!has_transparent_hugepage())
return;
@@ -300,7 +300,7 @@ static void __init pud_advanced_tests(struct mm_struct *mm,
  unsigned long pfn, unsigned long vaddr,
  pgprot_t prot)
 {
-   pud_t pud = pfn_pud(pfn, prot);
+   pud_t pud;
 
if (!has_transparent_hugepage())
return;
@@ -309,6 +309,7 @@ static void __init pud_advanced_tests(struct mm_struct *mm,
/* Align the address wrt HPAGE_PUD_SIZE */
vaddr = (vaddr & HPAGE_PUD_MASK) + HPAGE_PUD_SIZE;
 
+   pud = pfn_pud(pfn, prot);
set_pud_at(mm, vaddr, pudp, pud);
pudp_set_wrprotect(mm, vaddr, pudp);
pud = READ_ONCE(*pudp);
@@ -742,12 +743,12 @@ static void __init pmd_swap_soft_dirty_tests(unsigned 
long pfn, pgprot_t prot)
WARN_ON(!pmd_swp_soft_dirty(pmd_swp_mksoft_dirty(pmd)));
WARN_ON(pmd_swp_soft_dirty(pmd_swp_clear_soft_dirty(pmd)));
 }
-#else  /* !CONFIG_ARCH_HAS_PTE_DEVMAP */
+#else  /* !CONFIG_TRANSPARENT_HUGEPAGE */
 static void __init pmd_soft_dirty_tests(unsigned long pfn, pgprot_t prot) { }
 static void __init pmd_swap_soft_dirty_tests(unsigned long pfn, pgprot_t prot)
 {
 }
-#endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */
+#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
 static void __init pte_swap_tests(unsigned long pfn, pgprot_t prot)
 {
-- 
2.25.1



[PATCH v3 -next] binder: simplify the return expression of binder_mmap

2020-09-28 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
v3: Add the change description.
v2: Get rid of the "ret" and "failure string" variables.
v1: Simplify the return expression.
---
 drivers/android/binder.c | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 37a505c41dec..49c0700816a5 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5180,9 +5180,7 @@ static const struct vm_operations_struct binder_vm_ops = {
 
 static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
 {
-   int ret;
struct binder_proc *proc = filp->private_data;
-   const char *failure_string;
 
if (proc->tsk != current->group_leader)
return -EINVAL;
@@ -5194,9 +5192,9 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
 (unsigned long)pgprot_val(vma->vm_page_prot));
 
if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
-   ret = -EPERM;
-   failure_string = "bad vm_flags";
-   goto err_bad_arg;
+   pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
+  proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", 
-EPERM);
+   return -EPERM;
}
vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
vma->vm_flags &= ~VM_MAYWRITE;
@@ -5204,15 +5202,7 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
vma->vm_ops = &binder_vm_ops;
vma->vm_private_data = proc;
 
-   ret = binder_alloc_mmap_handler(&proc->alloc, vma);
-   if (ret)
-   return ret;
-   return 0;
-
-err_bad_arg:
-   pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
-  proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
-   return ret;
+   return binder_alloc_mmap_handler(&proc->alloc, vma);
 }
 
 static int binder_open(struct inode *nodp, struct file *filp)
-- 
2.25.1



[PATCH] fs/binfmt_elf: free interpreter in load_elf_binary

2020-11-03 Thread Liu Shixin
The file interpreter is allocated in load_elf_binary, but not freed
in the case interp_elf_ex is NULL.
We add a new mark out_free_file for this case to free interpreter.

This memory leak is catched when kmemleak is enabled in kernel,
the report looks like below:

unreferenced object 0x8b6e9fd41400 (size 488):
  comm "service", pid 4095, jiffies 4300970844 (age 49.618s)
  hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
e0 08 be b9 6e 8b ff ff 00 13 04 b7 6e 8b ff ff  n...n...
  backtrace:
[<eacadaa2>] kmem_cache_alloc+0x164/0x320
[<90fb7bf2>] __alloc_file+0x2a/0x140
[<ff8fab86>] alloc_empty_file+0x4b/0x100
[<3ab9b00d>] path_openat+0x4a/0xe20
[<27e3a067>] do_filp_open+0xb9/0x150
[<0edebcac>] do_open_execat+0xa6/0x250
[<8845564e>] open_exec+0x31/0x60
[<e6e6e1ca>] load_elf_binary+0x1dd/0x1b60
[<4515d8f0>] do_execveat_common.isra.39+0xaa0/0x1000
[<2ca5e83f>] __x64_sys_execve+0x37/0x40
[<beb519e4>] do_syscall_64+0x56/0xa0
[<00009cf54d51>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

Signed-off-by: Liu Shixin 
---
 fs/binfmt_elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index fa50e8936f5f..e223d798e5d8 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -907,7 +907,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
interp_elf_ex = kmalloc(sizeof(*interp_elf_ex), GFP_KERNEL);
if (!interp_elf_ex) {
retval = -ENOMEM;
-   goto out_free_ph;
+   goto out_free_file;
}
 
/* Get the exec headers */
@@ -1316,6 +1316,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 out_free_dentry:
kfree(interp_elf_ex);
kfree(interp_elf_phdata);
+out_free_file:
allow_write_access(interpreter);
if (interpreter)
fput(interpreter);
-- 
2.25.1



[PATCH] fs/binfmt_elf: free interpreter in load_elf_binary

2020-11-04 Thread Liu Shixin
The file interpreter is allocated in load_elf_binary, but not freed
in the case interp_elf_ex is NULL.
Add a label “out_allow_write_access” so that the interpreter
will be appropriately released in this case.

This memory leak is catched when kmemleak is enabled in kernel,
the report looks like below:

unreferenced object 0x8b6e9fd41400 (size 488):
  comm "service", pid 4095, jiffies 4300970844 (age 49.618s)
  hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
e0 08 be b9 6e 8b ff ff 00 13 04 b7 6e 8b ff ff  n...n...
  backtrace:
[<eacadaa2>] kmem_cache_alloc+0x164/0x320
[<90fb7bf2>] __alloc_file+0x2a/0x140
[<ff8fab86>] alloc_empty_file+0x4b/0x100
[<3ab9b00d>] path_openat+0x4a/0xe20
[<27e3a067>] do_filp_open+0xb9/0x150
[<0edebcac>] do_open_execat+0xa6/0x250
[<8845564e>] open_exec+0x31/0x60
[<e6e6e1ca>] load_elf_binary+0x1dd/0x1b60
[<4515d8f0>] do_execveat_common.isra.39+0xaa0/0x1000
[<2ca5e83f>] __x64_sys_execve+0x37/0x40
[<beb519e4>] do_syscall_64+0x56/0xa0
[<9cf54d51>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: 0693ffebcfe5 ("fs/binfmt_elf.c: allocate less for static executable")
Signed-off-by: Liu Shixin 
---
 fs/binfmt_elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index fa50e8936f5f..28e75cb45b26 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -907,7 +907,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
interp_elf_ex = kmalloc(sizeof(*interp_elf_ex), GFP_KERNEL);
if (!interp_elf_ex) {
retval = -ENOMEM;
-   goto out_free_ph;
+   goto out_allow_write_access;
}
 
/* Get the exec headers */
@@ -1316,6 +1316,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 out_free_dentry:
kfree(interp_elf_ex);
kfree(interp_elf_phdata);
+out_allow_write_access:
allow_write_access(interpreter);
if (interpreter)
fput(interpreter);
-- 
2.25.1



[PATCH v2] fs/binfmt_elf: free interpreter in load_elf_binary

2020-11-04 Thread Liu Shixin
The file interpreter is allocated in load_elf_binary, but not freed
in the case interp_elf_ex is NULL.
Add a label “out_allow_write_access” so that the interpreter
will be appropriately released in this case.

This memory leak is catched when kmemleak is enabled in kernel,
the report looks like below:

unreferenced object 0x8b6e9fd41400 (size 488):
  comm "service", pid 4095, jiffies 4300970844 (age 49.618s)
  hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
e0 08 be b9 6e 8b ff ff 00 13 04 b7 6e 8b ff ff  n...n...
  backtrace:
[<eacadaa2>] kmem_cache_alloc+0x164/0x320
[<90fb7bf2>] __alloc_file+0x2a/0x140
[<ff8fab86>] alloc_empty_file+0x4b/0x100
[<3ab9b00d>] path_openat+0x4a/0xe20
[<27e3a067>] do_filp_open+0xb9/0x150
[<0edebcac>] do_open_execat+0xa6/0x250
[<8845564e>] open_exec+0x31/0x60
[<e6e6e1ca>] load_elf_binary+0x1dd/0x1b60
[<4515d8f0>] do_execveat_common.isra.39+0xaa0/0x1000
[<2ca5e83f>] __x64_sys_execve+0x37/0x40
[<beb519e4>] do_syscall_64+0x56/0xa0
[<9cf54d51>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: 0693ffebcfe5 ("fs/binfmt_elf.c: allocate less for static executable")
Signed-off-by: Liu Shixin 
---
 fs/binfmt_elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index fa50e8936f5f..28e75cb45b26 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -907,7 +907,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
interp_elf_ex = kmalloc(sizeof(*interp_elf_ex), GFP_KERNEL);
if (!interp_elf_ex) {
retval = -ENOMEM;
-   goto out_free_ph;
+   goto out_allow_write_access;
}
 
/* Get the exec headers */
@@ -1316,6 +1316,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 out_free_dentry:
kfree(interp_elf_ex);
kfree(interp_elf_phdata);
+out_allow_write_access:
allow_write_access(interpreter);
if (interpreter)
fput(interpreter);
-- 
2.25.1



[PATCH] i2c: mlxbf: Fix build error with CONFIG_ACPI disabled

2020-11-02 Thread Liu Shixin
drivers/i2c/busses/i2c-mlxbf.c: In function ‘mlxbf_i2c_acpi_probe’:
drivers/i2c/busses/i2c-mlxbf.c:2296:8: error: implicit declaration of function 
‘acpi_device_uid’; did you mean ‘cpu_device_up’? 
[-Werror=implicit-function-declaration]
  uid = acpi_device_uid(adev);
^~~
cpu_device_up

Signed-off-by: Liu Shixin 
---
 drivers/i2c/busses/i2c-mlxbf.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index ee59e0da082d..cd8a909431a9 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -2272,6 +2272,7 @@ static const struct acpi_device_id mlxbf_i2c_acpi_ids[] = 
{
 
 MODULE_DEVICE_TABLE(acpi, mlxbf_i2c_acpi_ids);
 
+#ifdef CONFIG_ACPI
 static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv 
*priv)
 {
const struct acpi_device_id *aid;
@@ -2305,6 +2306,12 @@ static int mlxbf_i2c_acpi_probe(struct device *dev, 
struct mlxbf_i2c_priv *priv)
 
return ret;
 }
+#else
+static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv 
*priv)
+{
+   return -ENODEV;
+}
+#endif
 
 static int mlxbf_i2c_of_probe(struct device *dev, struct mlxbf_i2c_priv *priv)
 {
-- 
2.25.1



[PATCH -next] mtd: rawnand: remove redundant dev_err call in cadence_nand_dt_probe

2020-09-20 Thread Liu Shixin
There is a error message within devm_ioremap_resource
already, so remove the dev_err call to avoid redundant
error message.

Signed-off-by: Liu Shixin 
---
 drivers/mtd/nand/raw/cadence-nand-controller.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/raw/cadence-nand-controller.c 
b/drivers/mtd/nand/raw/cadence-nand-controller.c
index db29e5e512df..b46786cd53e0 100644
--- a/drivers/mtd/nand/raw/cadence-nand-controller.c
+++ b/drivers/mtd/nand/raw/cadence-nand-controller.c
@@ -2980,18 +2980,14 @@ static int cadence_nand_dt_probe(struct platform_device 
*ofdev)
dev_info(cdns_ctrl->dev, "IRQ: nr %d\n", cdns_ctrl->irq);
 
cdns_ctrl->reg = devm_platform_ioremap_resource(ofdev, 0);
-   if (IS_ERR(cdns_ctrl->reg)) {
-   dev_err(&ofdev->dev, "devm_ioremap_resource res 0 failed\n");
+   if (IS_ERR(cdns_ctrl->reg))
return PTR_ERR(cdns_ctrl->reg);
-   }
 
res = platform_get_resource(ofdev, IORESOURCE_MEM, 1);
cdns_ctrl->io.dma = res->start;
cdns_ctrl->io.virt = devm_ioremap_resource(&ofdev->dev, res);
-   if (IS_ERR(cdns_ctrl->io.virt)) {
-   dev_err(cdns_ctrl->dev, "devm_ioremap_resource res 1 failed\n");
+   if (IS_ERR(cdns_ctrl->io.virt))
return PTR_ERR(cdns_ctrl->io.virt);
-   }
 
dt->clk = devm_clk_get(cdns_ctrl->dev, "nf_clk");
if (IS_ERR(dt->clk))
-- 
2.25.1



[PATCH -next] binder: simplify the return expression of binder_mmap

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/android/binder.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 37a505c41dec..1f929e0cf39f 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5204,10 +5204,7 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
vma->vm_ops = &binder_vm_ops;
vma->vm_private_data = proc;
 
-   ret = binder_alloc_mmap_handler(&proc->alloc, vma);
-   if (ret)
-   return ret;
-   return 0;
+   return binder_alloc_mmap_handler(&proc->alloc, vma);
 
 err_bad_arg:
pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
-- 
2.25.1



[PATCH -next] fpga: dfl: simplify the return expression of fme_perf_pmu_register

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/fpga/dfl-fme-perf.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
index 531266287eee..e881fbe6d838 100644
--- a/drivers/fpga/dfl-fme-perf.c
+++ b/drivers/fpga/dfl-fme-perf.c
@@ -906,7 +906,6 @@ static int fme_perf_pmu_register(struct platform_device 
*pdev,
 {
struct pmu *pmu = &priv->pmu;
char *name;
-   int ret;
 
spin_lock_init(&priv->fab_lock);
 
@@ -926,11 +925,7 @@ static int fme_perf_pmu_register(struct platform_device 
*pdev,
 
name = devm_kasprintf(priv->dev, GFP_KERNEL, "dfl_fme%d", pdev->id);
 
-   ret = perf_pmu_register(pmu, name, -1);
-   if (ret)
-   return ret;
-
-   return 0;
+   return perf_pmu_register(pmu, name, -1);
 }
 
 static void fme_perf_pmu_unregister(struct fme_perf_priv *priv)
-- 
2.25.1



[PATCH -next] media: media/pci: simplify the return expression of verify_window_lock

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/media/pci/bt8xx/bttv-driver.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index 8c61d292dec1..4f7eaec20dc3 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2058,7 +2058,6 @@ verify_window_lock(struct bttv_fh *fh, struct v4l2_window 
*win,
 {
enum v4l2_field field;
unsigned int width_mask;
-   int rc;
 
if (win->w.width < 48)
win->w.width = 48;
@@ -2111,13 +2110,10 @@ verify_window_lock(struct bttv_fh *fh, struct 
v4l2_window *win,
win->w.width -= win->w.left & ~width_mask;
win->w.left = (win->w.left - width_mask - 1) & width_mask;
 
-   rc = limit_scaled_size_lock(fh, &win->w.width, &win->w.height,
-  field, width_mask,
-  /* width_bias: round down */ 0,
-  adjust_size, adjust_crop);
-   if (0 != rc)
-   return rc;
-   return 0;
+   return limit_scaled_size_lock(fh, &win->w.width, &win->w.height,
+ field, width_mask,
+ /* width_bias: round down */ 0,
+ adjust_size, adjust_crop);
 }
 
 static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
-- 
2.25.1



[PATCH -next] tpm/st33zp24/i2c: simplify the return expression of st33zp24_i2c_remove

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/char/tpm/st33zp24/i2c.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/char/tpm/st33zp24/i2c.c b/drivers/char/tpm/st33zp24/i2c.c
index 7c617edff4ca..b180171e5678 100644
--- a/drivers/char/tpm/st33zp24/i2c.c
+++ b/drivers/char/tpm/st33zp24/i2c.c
@@ -267,13 +267,8 @@ static int st33zp24_i2c_probe(struct i2c_client *client,
 static int st33zp24_i2c_remove(struct i2c_client *client)
 {
struct tpm_chip *chip = i2c_get_clientdata(client);
-   int ret;
 
-   ret = st33zp24_remove(chip);
-   if (ret)
-   return ret;
-
-   return 0;
+   return st33zp24_remove(chip);
 }
 
 static const struct i2c_device_id st33zp24_i2c_id[] = {
-- 
2.25.1



[PATCH -next] Input: synaptics-rmi4 - simplify the return expression of rmi_driver_of_probe

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/input/rmi4/rmi_driver.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 258d5fe3d395..eec5d926da25 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -991,14 +991,8 @@ static int rmi_driver_remove(struct device *dev)
 static int rmi_driver_of_probe(struct device *dev,
struct rmi_device_platform_data *pdata)
 {
-   int retval;
-
-   retval = rmi_of_property_read_u32(dev, &pdata->reset_delay_ms,
+   return rmi_of_property_read_u32(dev, &pdata->reset_delay_ms,
"syna,reset-delay-ms", 1);
-   if (retval)
-   return retval;
-
-   return 0;
 }
 #else
 static inline int rmi_driver_of_probe(struct device *dev,
-- 
2.25.1



[PATCH -next] HID: intel-ish-hid: simplify the return expression of ishtp_hid_parse

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/hid/intel-ish-hid/ishtp-hid.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.c 
b/drivers/hid/intel-ish-hid/ishtp-hid.c
index b8aae69ad15d..edf5ae942508 100644
--- a/drivers/hid/intel-ish-hid/ishtp-hid.c
+++ b/drivers/hid/intel-ish-hid/ishtp-hid.c
@@ -22,14 +22,9 @@ static int ishtp_hid_parse(struct hid_device *hid)
 {
struct ishtp_hid_data *hid_data =  hid->driver_data;
struct ishtp_cl_data *client_data = hid_data->client_data;
-   int rv;
-
-   rv = hid_parse_report(hid, client_data->report_descr[hid_data->index],
- client_data->report_descr_size[hid_data->index]);
-   if (rv)
-   return  rv;
 
-   return 0;
+   return hid_parse_report(hid, client_data->report_descr[hid_data->index],
+   
client_data->report_descr_size[hid_data->index]);
 }
 
 /* Empty callbacks with success return code */
-- 
2.25.1



[PATCH -next] omapfb: simplify the return expression of sharp_ls_connect

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 .../fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c  | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git 
a/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c 
b/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c
index a3912fc8031f..602324c5c9f9 100644
--- a/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c
+++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-sharp-ls037v7dw01.c
@@ -59,16 +59,11 @@ static int sharp_ls_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
-   int r;
 
if (omapdss_device_is_connected(dssdev))
return 0;
 
-   r = in->ops.dpi->connect(in, dssdev);
-   if (r)
-   return r;
-
-   return 0;
+   return in->ops.dpi->connect(in, dssdev);
 }
 
 static void sharp_ls_disconnect(struct omap_dss_device *dssdev)
-- 
2.25.1



[PATCH -next] omapfb: simplify the return expression of tpo_td043_connect

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 .../fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c 
b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
index bb85b21f0724..afac1d9445aa 100644
--- a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
+++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
@@ -337,16 +337,11 @@ static int tpo_td043_connect(struct omap_dss_device 
*dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
-   int r;
 
if (omapdss_device_is_connected(dssdev))
return 0;
 
-   r = in->ops.dpi->connect(in, dssdev);
-   if (r)
-   return r;
-
-   return 0;
+   return in->ops.dpi->connect(in, dssdev);
 }
 
 static void tpo_td043_disconnect(struct omap_dss_device *dssdev)
-- 
2.25.1



[PATCH -next] crypto: cpt - simplify the return expression of cav_register_algs

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/crypto/cavium/cpt/cptvf_algs.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/crypto/cavium/cpt/cptvf_algs.c 
b/drivers/crypto/cavium/cpt/cptvf_algs.c
index 5af0dc2a8909..ce3b91c612f0 100644
--- a/drivers/crypto/cavium/cpt/cptvf_algs.c
+++ b/drivers/crypto/cavium/cpt/cptvf_algs.c
@@ -451,13 +451,7 @@ static struct skcipher_alg algs[] = { {
 
 static inline int cav_register_algs(void)
 {
-   int err = 0;
-
-   err = crypto_register_skciphers(algs, ARRAY_SIZE(algs));
-   if (err)
-   return err;
-
-   return 0;
+   return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
 }
 
 static inline void cav_unregister_algs(void)
-- 
2.25.1



[PATCH -next] drm/ast: simplify the return expression of ast_* function

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/gpu/drm/ast/ast_drv.c  | 7 +--
 drivers/gpu/drm/ast/ast_mode.c | 7 +--
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index f0b4af1c390a..a2a3f32260f9 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -160,15 +160,10 @@ static int ast_drm_thaw(struct drm_device *dev)
 
 static int ast_drm_resume(struct drm_device *dev)
 {
-   int ret;
-
if (pci_enable_device(dev->pdev))
return -EIO;
 
-   ret = ast_drm_thaw(dev);
-   if (ret)
-   return ret;
-   return 0;
+   return ast_drm_thaw(dev);
 }
 
 static int ast_pm_suspend(struct device *dev)
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 834a156e3a75..4dca4ff01d41 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -636,18 +636,13 @@ ast_cursor_plane_helper_prepare_fb(struct drm_plane 
*plane,
struct drm_framebuffer *fb = new_state->fb;
struct drm_crtc *crtc = new_state->crtc;
struct ast_private *ast;
-   int ret;
 
if (!crtc || !fb)
return 0;
 
ast = to_ast_private(plane->dev);
 
-   ret = ast_cursor_blit(ast, fb);
-   if (ret)
-   return ret;
-
-   return 0;
+   return ast_cursor_blit(ast, fb);
 }
 
 static int ast_cursor_plane_helper_atomic_check(struct drm_plane *plane,
-- 
2.25.1



[PATCH -next] snic: simplify the return expression of svnic_cq_alloc

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/snic/vnic_cq.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/scsi/snic/vnic_cq.c b/drivers/scsi/snic/vnic_cq.c
index 4c8e64e4fba6..3455dd7e73f4 100644
--- a/drivers/scsi/snic/vnic_cq.c
+++ b/drivers/scsi/snic/vnic_cq.c
@@ -31,8 +31,6 @@ void svnic_cq_free(struct vnic_cq *cq)
 int svnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq,
unsigned int index, unsigned int desc_count, unsigned int desc_size)
 {
-   int err;
-
cq->index = index;
cq->vdev = vdev;
 
@@ -43,11 +41,7 @@ int svnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq,
return -EINVAL;
}
 
-   err = svnic_dev_alloc_desc_ring(vdev, &cq->ring, desc_count, desc_size);
-   if (err)
-   return err;
-
-   return 0;
+   return svnic_dev_alloc_desc_ring(vdev, &cq->ring, desc_count, 
desc_size);
 }
 
 void svnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable,
-- 
2.25.1



[PATCH -next] media: venus: simplify the return expression of venus_sys_set_* function

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/media/platform/qcom/venus/hfi_venus.c | 28 +++
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c 
b/drivers/media/platform/qcom/venus/hfi_venus.c
index 4be4a75ddcb6..05ddb68023b8 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -772,34 +772,24 @@ static int venus_sys_set_debug(struct venus_hfi_device 
*hdev, u32 debug)
 {
struct hfi_sys_set_property_pkt *pkt;
u8 packet[IFACEQ_VAR_SMALL_PKT_SIZE];
-   int ret;
 
pkt = (struct hfi_sys_set_property_pkt *)packet;
 
pkt_sys_debug_config(pkt, HFI_DEBUG_MODE_QUEUE, debug);
 
-   ret = venus_iface_cmdq_write(hdev, pkt);
-   if (ret)
-   return ret;
-
-   return 0;
+   return venus_iface_cmdq_write(hdev, pkt);
 }
 
 static int venus_sys_set_coverage(struct venus_hfi_device *hdev, u32 mode)
 {
struct hfi_sys_set_property_pkt *pkt;
u8 packet[IFACEQ_VAR_SMALL_PKT_SIZE];
-   int ret;
 
pkt = (struct hfi_sys_set_property_pkt *)packet;
 
pkt_sys_coverage_config(pkt, mode);
 
-   ret = venus_iface_cmdq_write(hdev, pkt);
-   if (ret)
-   return ret;
-
-   return 0;
+   return venus_iface_cmdq_write(hdev, pkt);
 }
 
 static int venus_sys_set_idle_message(struct venus_hfi_device *hdev,
@@ -807,7 +797,6 @@ static int venus_sys_set_idle_message(struct 
venus_hfi_device *hdev,
 {
struct hfi_sys_set_property_pkt *pkt;
u8 packet[IFACEQ_VAR_SMALL_PKT_SIZE];
-   int ret;
 
if (!enable)
return 0;
@@ -816,11 +805,7 @@ static int venus_sys_set_idle_message(struct 
venus_hfi_device *hdev,
 
pkt_sys_idle_indicator(pkt, enable);
 
-   ret = venus_iface_cmdq_write(hdev, pkt);
-   if (ret)
-   return ret;
-
-   return 0;
+   return venus_iface_cmdq_write(hdev, pkt);
 }
 
 static int venus_sys_set_power_control(struct venus_hfi_device *hdev,
@@ -828,17 +813,12 @@ static int venus_sys_set_power_control(struct 
venus_hfi_device *hdev,
 {
struct hfi_sys_set_property_pkt *pkt;
u8 packet[IFACEQ_VAR_SMALL_PKT_SIZE];
-   int ret;
 
pkt = (struct hfi_sys_set_property_pkt *)packet;
 
pkt_sys_power_control(pkt, enable);
 
-   ret = venus_iface_cmdq_write(hdev, pkt);
-   if (ret)
-   return ret;
-
-   return 0;
+   return venus_iface_cmdq_write(hdev, pkt);
 }
 
 static int venus_get_queue_size(struct venus_hfi_device *hdev,
-- 
2.25.1



[PATCH -next] PCI: mobiveil: simplify the return expression of mobiveil_pcie_init_irq_domain

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/pci/controller/mobiveil/pcie-mobiveil-host.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c 
b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
index 3adec419a45b..a2632d02ce8f 100644
--- a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
+++ b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
@@ -480,7 +480,6 @@ static int mobiveil_pcie_init_irq_domain(struct 
mobiveil_pcie *pcie)
struct device *dev = &pcie->pdev->dev;
struct device_node *node = dev->of_node;
struct mobiveil_root_port *rp = &pcie->rp;
-   int ret;
 
/* setup INTx */
rp->intx_domain = irq_domain_add_linear(node, PCI_NUM_INTX,
@@ -494,11 +493,7 @@ static int mobiveil_pcie_init_irq_domain(struct 
mobiveil_pcie *pcie)
raw_spin_lock_init(&rp->intx_mask_lock);
 
/* setup MSI */
-   ret = mobiveil_allocate_msi_domains(pcie);
-   if (ret)
-   return ret;
-
-   return 0;
+   return mobiveil_allocate_msi_domains(pcie);
 }
 
 static int mobiveil_pcie_integrated_interrupt_init(struct mobiveil_pcie *pcie)
-- 
2.25.1



[PATCH -next] scsi: libsas: simplify the return expression of sas_discover_end_dev

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/libsas/sas_discover.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/scsi/libsas/sas_discover.c 
b/drivers/scsi/libsas/sas_discover.c
index d0f9e90e3279..161c9b387da7 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -278,13 +278,7 @@ static void sas_resume_devices(struct work_struct *work)
  */
 int sas_discover_end_dev(struct domain_device *dev)
 {
-   int res;
-
-   res = sas_notify_lldd_dev_found(dev);
-   if (res)
-   return res;
-
-   return 0;
+   return sas_notify_lldd_dev_found(dev);
 }
 
 /* -- Device registration and unregistration -- */
-- 
2.25.1



[PATCH -next] clk: mediatek: mt7629: simplify the return expression of mtk_infrasys_init

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/clk/mediatek/clk-mt7629.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt7629.c 
b/drivers/clk/mediatek/clk-mt7629.c
index b73bdf152836..a0ee079670c7 100644
--- a/drivers/clk/mediatek/clk-mt7629.c
+++ b/drivers/clk/mediatek/clk-mt7629.c
@@ -601,7 +601,6 @@ static int mtk_infrasys_init(struct platform_device *pdev)
 {
struct device_node *node = pdev->dev.of_node;
struct clk_onecell_data *clk_data;
-   int r;
 
clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
 
@@ -611,12 +610,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
mtk_clk_register_cpumuxes(node, infra_muxes, ARRAY_SIZE(infra_muxes),
  clk_data);
 
-   r = of_clk_add_provider(node, of_clk_src_onecell_get,
-   clk_data);
-   if (r)
-   return r;
-
-   return 0;
+   return of_clk_add_provider(node, of_clk_src_onecell_get,
+  clk_data);
 }
 
 static int mtk_pericfg_init(struct platform_device *pdev)
-- 
2.25.1



[PATCH -next] omapfb: simplify the return expression of panel_dpi_connect

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/video/fbdev/omap2/omapfb/displays/panel-dpi.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-dpi.c 
b/drivers/video/fbdev/omap2/omapfb/displays/panel-dpi.c
index 37c9f5bfaefe..ff3d1e8e1e7b 100644
--- a/drivers/video/fbdev/omap2/omapfb/displays/panel-dpi.c
+++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-dpi.c
@@ -37,16 +37,11 @@ static int panel_dpi_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
-   int r;
 
if (omapdss_device_is_connected(dssdev))
return 0;
 
-   r = in->ops.dpi->connect(in, dssdev);
-   if (r)
-   return r;
-
-   return 0;
+   return in->ops.dpi->connect(in, dssdev);
 }
 
 static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
-- 
2.25.1



[PATCH -next] clk: mediatek: mt6797: simplify the return expression of mtk_infrasys_init

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/clk/mediatek/clk-mt6797.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6797.c 
b/drivers/clk/mediatek/clk-mt6797.c
index f35389a11af1..428eb24ffec5 100644
--- a/drivers/clk/mediatek/clk-mt6797.c
+++ b/drivers/clk/mediatek/clk-mt6797.c
@@ -582,7 +582,7 @@ CLK_OF_DECLARE_DRIVER(mtk_infra, "mediatek,mt6797-infracfg",
 
 static int mtk_infrasys_init(struct platform_device *pdev)
 {
-   int r, i;
+   int i;
struct device_node *node = pdev->dev.of_node;
 
if (!infra_clk_data) {
@@ -599,11 +599,7 @@ static int mtk_infrasys_init(struct platform_device *pdev)
mtk_clk_register_factors(infra_fixed_divs, ARRAY_SIZE(infra_fixed_divs),
 infra_clk_data);
 
-   r = of_clk_add_provider(node, of_clk_src_onecell_get, infra_clk_data);
-   if (r)
-   return r;
-
-   return 0;
+   return of_clk_add_provider(node, of_clk_src_onecell_get, 
infra_clk_data);
 }
 
 #define MT6797_PLL_FMAX(3000UL * MHZ)
-- 
2.25.1



[PATCH -next] drm/amdgpu/gmc9: simplify the return expression of gmc_v9_0_suspend

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 5400cac02087..cb9e9e5afa5a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1683,14 +1683,9 @@ static int gmc_v9_0_hw_fini(void *handle)
 
 static int gmc_v9_0_suspend(void *handle)
 {
-   int r;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-   r = gmc_v9_0_hw_fini(adev);
-   if (r)
-   return r;
-
-   return 0;
+   return gmc_v9_0_hw_fini(adev);
 }
 
 static int gmc_v9_0_resume(void *handle)
-- 
2.25.1



[PATCH -next] interconnect: simplify the return expression of imx_icc_unregister

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/interconnect/imx/imx.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/interconnect/imx/imx.c b/drivers/interconnect/imx/imx.c
index ac420f86008e..40fa22a32a60 100644
--- a/drivers/interconnect/imx/imx.c
+++ b/drivers/interconnect/imx/imx.c
@@ -269,15 +269,10 @@ EXPORT_SYMBOL_GPL(imx_icc_register);
 int imx_icc_unregister(struct platform_device *pdev)
 {
struct icc_provider *provider = platform_get_drvdata(pdev);
-   int ret;
 
imx_icc_unregister_nodes(provider);
 
-   ret = icc_provider_del(provider);
-   if (ret)
-   return ret;
-
-   return 0;
+   return icc_provider_del(provider);
 }
 EXPORT_SYMBOL_GPL(imx_icc_unregister);
 
-- 
2.25.1



[PATCH -next] pinctrl: spear: simplify the return expression of spear310_pinctrl_probe

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/pinctrl/spear/pinctrl-spear310.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/pinctrl/spear/pinctrl-spear310.c 
b/drivers/pinctrl/spear/pinctrl-spear310.c
index 393b2b97d527..9d9facc4a6e4 100644
--- a/drivers/pinctrl/spear/pinctrl-spear310.c
+++ b/drivers/pinctrl/spear/pinctrl-spear310.c
@@ -379,8 +379,6 @@ static const struct of_device_id 
spear310_pinctrl_of_match[] = {
 
 static int spear310_pinctrl_probe(struct platform_device *pdev)
 {
-   int ret;
-
spear3xx_machdata.groups = spear310_pingroups;
spear3xx_machdata.ngroups = ARRAY_SIZE(spear310_pingroups);
spear3xx_machdata.functions = spear310_functions;
@@ -392,11 +390,7 @@ static int spear310_pinctrl_probe(struct platform_device 
*pdev)
 
spear3xx_machdata.modes_supported = false;
 
-   ret = spear_pinctrl_probe(pdev, &spear3xx_machdata);
-   if (ret)
-   return ret;
-
-   return 0;
+   return spear_pinctrl_probe(pdev, &spear3xx_machdata);
 }
 
 static struct platform_driver spear310_pinctrl_driver = {
-- 
2.25.1



[PATCH -next] rtc: rv8803: simplify the return expression of rv8803_nvram_write

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/rtc/rtc-rv8803.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index 93c3a6b627bd..c6d8e3425688 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -454,13 +454,7 @@ static int rv8803_ioctl(struct device *dev, unsigned int 
cmd, unsigned long arg)
 static int rv8803_nvram_write(void *priv, unsigned int offset, void *val,
  size_t bytes)
 {
-   int ret;
-
-   ret = rv8803_write_reg(priv, RV8803_RAM, *(u8 *)val);
-   if (ret)
-   return ret;
-
-   return 0;
+   return rv8803_write_reg(priv, RV8803_RAM, *(u8 *)val);
 }
 
 static int rv8803_nvram_read(void *priv, unsigned int offset,
-- 
2.25.1



[PATCH -next] sata, highbank: simplify the return expression of ahci_highbank_suspend

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/ata/sata_highbank.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
index ad3893c62572..64b2ef15ec19 100644
--- a/drivers/ata/sata_highbank.c
+++ b/drivers/ata/sata_highbank.c
@@ -571,7 +571,6 @@ static int ahci_highbank_suspend(struct device *dev)
struct ahci_host_priv *hpriv = host->private_data;
void __iomem *mmio = hpriv->mmio;
u32 ctl;
-   int rc;
 
if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
dev_err(dev, "firmware update required for suspend/resume\n");
@@ -588,11 +587,7 @@ static int ahci_highbank_suspend(struct device *dev)
writel(ctl, mmio + HOST_CTL);
readl(mmio + HOST_CTL); /* flush */
 
-   rc = ata_host_suspend(host, PMSG_SUSPEND);
-   if (rc)
-   return rc;
-
-   return 0;
+   return ata_host_suspend(host, PMSG_SUSPEND);
 }
 
 static int ahci_highbank_resume(struct device *dev)
-- 
2.25.1



[PATCH -next] media: anysee: simplify the return expression of anysee_ci_* function

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/media/usb/dvb-usb-v2/anysee.c | 21 +++--
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c 
b/drivers/media/usb/dvb-usb-v2/anysee.c
index 89a1b204b90c..aa45b5d263f6 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.c
+++ b/drivers/media/usb/dvb-usb-v2/anysee.c
@@ -1171,14 +1171,9 @@ static int anysee_ci_write_attribute_mem(struct 
dvb_ca_en50221 *ci, int slot,
int addr, u8 val)
 {
struct dvb_usb_device *d = ci->data;
-   int ret;
u8 buf[] = {CMD_CI, 0x03, 0x40 | addr >> 8, addr & 0xff, 0x00, 1, val};
 
-   ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
-   if (ret)
-   return ret;
-
-   return 0;
+   return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
 }
 
 static int anysee_ci_read_cam_control(struct dvb_ca_en50221 *ci, int slot,
@@ -1200,14 +1195,9 @@ static int anysee_ci_write_cam_control(struct 
dvb_ca_en50221 *ci, int slot,
u8 addr, u8 val)
 {
struct dvb_usb_device *d = ci->data;
-   int ret;
u8 buf[] = {CMD_CI, 0x05, 0x40, addr, 0x00, 1, val};
 
-   ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
-   if (ret)
-   return ret;
-
-   return 0;
+   return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
 }
 
 static int anysee_ci_slot_reset(struct dvb_ca_en50221 *ci, int slot)
@@ -1252,13 +1242,8 @@ static int anysee_ci_slot_shutdown(struct dvb_ca_en50221 
*ci, int slot)
 static int anysee_ci_slot_ts_enable(struct dvb_ca_en50221 *ci, int slot)
 {
struct dvb_usb_device *d = ci->data;
-   int ret;
 
-   ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 1), 0x02);
-   if (ret)
-   return ret;
-
-   return 0;
+   return anysee_wr_reg_mask(d, REG_IOD, (0 << 1), 0x02);
 }
 
 static int anysee_ci_poll_slot_status(struct dvb_ca_en50221 *ci, int slot,
-- 
2.25.1



[PATCH -next] drm/amd/pm: simplify the return expression of smu_hw_fini

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 5c4b74f964fc..3612841d40dc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -1214,7 +1214,6 @@ static int smu_hw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct smu_context *smu = &adev->smu;
-   int ret = 0;
 
if (amdgpu_sriov_vf(adev)&& !amdgpu_sriov_is_pp_one_vf(adev))
return 0;
@@ -1230,11 +1229,7 @@ static int smu_hw_fini(void *handle)
 
adev->pm.dpm_enabled = false;
 
-   ret = smu_smc_hw_cleanup(smu);
-   if (ret)
-   return ret;
-
-   return 0;
+   return smu_smc_hw_cleanup(smu);
 }
 
 int smu_reset(struct smu_context *smu)
-- 
2.25.1



[PATCH -next] mtd: onenand_base: simplify the return expression of onenand_transfer_auto_oob

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/mtd/nand/onenand/onenand_base.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/onenand/onenand_base.c 
b/drivers/mtd/nand/onenand/onenand_base.c
index ec18ade33262..188b8061e1f7 100644
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -1052,16 +1052,11 @@ static int onenand_transfer_auto_oob(struct mtd_info 
*mtd, uint8_t *buf, int col
int thislen)
 {
struct onenand_chip *this = mtd->priv;
-   int ret;
 
this->read_bufferram(mtd, ONENAND_SPARERAM, this->oob_buf, 0,
 mtd->oobsize);
-   ret = mtd_ooblayout_get_databytes(mtd, buf, this->oob_buf,
- column, thislen);
-   if (ret)
-   return ret;
-
-   return 0;
+   return mtd_ooblayout_get_databytes(mtd, buf, this->oob_buf,
+  column, thislen);
 }
 
 /**
-- 
2.25.1



[PATCH -next] [SCSI] fnic: simplify the return expression of vnic_wq_copy_alloc

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/fnic/vnic_wq_copy.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/scsi/fnic/vnic_wq_copy.c b/drivers/scsi/fnic/vnic_wq_copy.c
index 9eab7e7caf38..7b18635df7e6 100644
--- a/drivers/scsi/fnic/vnic_wq_copy.c
+++ b/drivers/scsi/fnic/vnic_wq_copy.c
@@ -79,8 +79,6 @@ int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct 
vnic_wq_copy *wq,
   unsigned int index, unsigned int desc_count,
   unsigned int desc_size)
 {
-   int err;
-
wq->index = index;
wq->vdev = vdev;
wq->to_use_index = wq->to_clean_index = 0;
@@ -92,11 +90,7 @@ int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct 
vnic_wq_copy *wq,
 
vnic_wq_copy_disable(wq);
 
-   err = vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size);
-   if (err)
-   return err;
-
-   return 0;
+   return vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size);
 }
 
 void vnic_wq_copy_init(struct vnic_wq_copy *wq, unsigned int cq_index,
-- 
2.25.1



Re: [PATCH -next] binder: simplify the return expression of binder_mmap

2020-09-21 Thread Liu Shixin
On 2020/9/21 16:08, Christian Brauner wrote:

> On Mon, Sep 21, 2020 at 04:24:23PM +0800, Liu Shixin wrote:
>> Simplify the return expression.
>>
>> Signed-off-by: Liu Shixin 
>> ---
> Why not is all I can really say. :) But if this is about simplifying you
> could get rid of the "ret" and "failure string" variables, and the goto
> in that function completely by doing sm like this (__completely
> untested__):

Thanks for your advice. I will modify and test it.

Regards,
Liu Shixin

>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index f936530a19b0..26f4dc81b008 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5182,9 +5182,7 @@ static const struct vm_operations_struct binder_vm_ops 
> = {
>
>  static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
>  {
> -   int ret;
> struct binder_proc *proc = filp->private_data;
> -   const char *failure_string;
>
> if (proc->tsk != current->group_leader)
> return -EINVAL;
> @@ -5196,9 +5194,9 @@ static int binder_mmap(struct file *filp, struct 
> vm_area_struct *vma)
>  (unsigned long)pgprot_val(vma->vm_page_prot));
>
> if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
> -   ret = -EPERM;
> -   failure_string = "bad vm_flags";
> -   goto err_bad_arg;
> +   pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
> +   proc->pid, vma->vm_start, vma->vm_end, "bad 
> vm_flags", -EPERM);
> +   return -EPERM;
> }
> vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
> vma->vm_flags &= ~VM_MAYWRITE;
> @@ -5206,15 +5204,7 @@ static int binder_mmap(struct file *filp, struct 
> vm_area_struct *vma)
> vma->vm_ops = &binder_vm_ops;
> vma->vm_private_data = proc;
>
> -   ret = binder_alloc_mmap_handler(&proc->alloc, vma);
> -   if (ret)
> -   return ret;
> -   return 0;
> -
> -err_bad_arg:
> -   pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
> -  proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
> -   return ret;
> +   return binder_alloc_mmap_handler(&proc->alloc, vma);
>  }
>
> Christian
> .
>



[PATCH -next] binder: simplify the return expression of binder_mmap

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/android/binder.c | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 37a505c41dec..49c0700816a5 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5180,9 +5180,7 @@ static const struct vm_operations_struct binder_vm_ops = {
 
 static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
 {
-   int ret;
struct binder_proc *proc = filp->private_data;
-   const char *failure_string;
 
if (proc->tsk != current->group_leader)
return -EINVAL;
@@ -5194,9 +5192,9 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
 (unsigned long)pgprot_val(vma->vm_page_prot));
 
if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
-   ret = -EPERM;
-   failure_string = "bad vm_flags";
-   goto err_bad_arg;
+   pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
+  proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", 
-EPERM);
+   return -EPERM;
}
vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
vma->vm_flags &= ~VM_MAYWRITE;
@@ -5204,15 +5202,7 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
vma->vm_ops = &binder_vm_ops;
vma->vm_private_data = proc;
 
-   ret = binder_alloc_mmap_handler(&proc->alloc, vma);
-   if (ret)
-   return ret;
-   return 0;
-
-err_bad_arg:
-   pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
-  proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
-   return ret;
+   return binder_alloc_mmap_handler(&proc->alloc, vma);
 }
 
 static int binder_open(struct inode *nodp, struct file *filp)
-- 
2.25.1



[PATCH -next] scsi: libsas: simplify the return expression of sas_discover_* functions

2020-09-21 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/libsas/sas_ata.c  | 8 +---
 drivers/scsi/libsas/sas_discover.c | 8 +---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index a4887985aad6..024e5a550759 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -726,19 +726,13 @@ void sas_resume_sata(struct asd_sas_port *port)
  */
 int sas_discover_sata(struct domain_device *dev)
 {
-   int res;
-
if (dev->dev_type == SAS_SATA_PM)
return -ENODEV;
 
dev->sata_dev.class = sas_get_ata_command_set(dev);
sas_fill_in_rphy(dev, dev->rphy);
 
-   res = sas_notify_lldd_dev_found(dev);
-   if (res)
-   return res;
-
-   return 0;
+   return sas_notify_lldd_dev_found(dev);
 }
 
 static void async_sas_ata_eh(void *data, async_cookie_t cookie)
diff --git a/drivers/scsi/libsas/sas_discover.c 
b/drivers/scsi/libsas/sas_discover.c
index d0f9e90e3279..161c9b387da7 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -278,13 +278,7 @@ static void sas_resume_devices(struct work_struct *work)
  */
 int sas_discover_end_dev(struct domain_device *dev)
 {
-   int res;
-
-   res = sas_notify_lldd_dev_found(dev);
-   if (res)
-   return res;
-
-   return 0;
+   return sas_notify_lldd_dev_found(dev);
 }
 
 /* -- Device registration and unregistration -- */
-- 
2.25.1



[PATCH -next] can: peak_usb: convert to use le32_add_cpu()

2020-09-13 Thread Liu Shixin
Convert cpu_to_le32(le32_to_cpu(E1) + E2) to use le32_add_cpu().

Signed-off-by: Liu Shixin 
---
 drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c 
b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index 1689ab387612..d8ebf35dea1c 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -186,7 +186,7 @@ static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, 
int id, ...)
 
len = pc - pm->rec_ptr;
if (len > 0) {
-   *pm->u.rec_cnt = cpu_to_le32(le32_to_cpu(*pm->u.rec_cnt) + 1);
+   le32_add_cpu(pm->u.rec_cnt, 1);
*pm->rec_ptr = id;
 
pm->rec_ptr = pc;
-- 
2.25.1



[PATCH -next] mt76: mt7915: convert to use le16_add_cpu()

2020-09-13 Thread Liu Shixin
Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu().

Signed-off-by: Liu Shixin 
---
 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c 
b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index ac8ec257da03..8f0b67d0e93e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -714,8 +714,8 @@ mt7915_mcu_add_nested_subtlv(struct sk_buff *skb, int 
sub_tag, int sub_len,
ptlv = skb_put(skb, sub_len);
memcpy(ptlv, &tlv, sizeof(tlv));
 
-   *sub_ntlv = cpu_to_le16(le16_to_cpu(*sub_ntlv) + 1);
-   *len = cpu_to_le16(le16_to_cpu(*len) + sub_len);
+   le16_add_cpu(sub_ntlv, 1);
+   le16_add_cpu(len, sub_len);
 
return ptlv;
 }
-- 
2.25.1



[PATCH -next] dh key: convert to use be32_add_cpu()

2020-09-13 Thread Liu Shixin
Convert cpu_to_be32(be32_to_cpu(E1) + E2) to use be32_add_cpu().

Signed-off-by: Liu Shixin 
---
 security/keys/dh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/keys/dh.c b/security/keys/dh.c
index 1abfa70ed6e1..2635cb8a4561 100644
--- a/security/keys/dh.c
+++ b/security/keys/dh.c
@@ -186,7 +186,7 @@ static int kdf_ctr(struct kdf_sdesc *sdesc, const u8 *src, 
unsigned int slen,
 
dlen -= h;
dst += h;
-   counter = cpu_to_be32(be32_to_cpu(counter) + 1);
+   be32_add_cpu(&counter, 1);
}
 
return 0;
-- 
2.25.1



[PATCH -next] soc/qman: convert to use be32_add_cpu()

2020-09-13 Thread Liu Shixin
Signed-off-by: Liu Shixin 
drivers/soc/fsl/qbman/qman_test_api.c---
 drivers/soc/fsl/qbman/qman_test_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/fsl/qbman/qman_test_api.c 
b/drivers/soc/fsl/qbman/qman_test_api.c
index 2895d062cf51..7066b2f1467c 100644
--- a/drivers/soc/fsl/qbman/qman_test_api.c
+++ b/drivers/soc/fsl/qbman/qman_test_api.c
@@ -86,7 +86,7 @@ static void fd_inc(struct qm_fd *fd)
len--;
qm_fd_set_param(fd, fmt, off, len);
 
-   fd->cmd = cpu_to_be32(be32_to_cpu(fd->cmd) + 1);
+   be32_add_cpu(&fd->cmd, 1);
 }
 
 /* The only part of the 'fd' we can't memcmp() is the ppid */
-- 
2.25.1



[PATCH -next] dm integrity: convert to use le64_add_cpu()

2020-09-13 Thread Liu Shixin
Convert cpu_to_le64(le64_to_cpu(E1) + E2) to use le64_add_cpu().

Signed-off-by: Liu Shixin 
---
 drivers/md/dm-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 3fc3757def55..cf9dadd55625 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -3696,7 +3696,7 @@ static int create_journal(struct dm_integrity_c *ic, char 
**error)
 retest_commit_id:
for (j = 0; j < i; j++) {
if (ic->commit_ids[j] == ic->commit_ids[i]) {
-   ic->commit_ids[i] = 
cpu_to_le64(le64_to_cpu(ic->commit_ids[i]) + 1);
+   le64_add_cpu(&ic->commit_ids[i], 1);
goto retest_commit_id;
}
}
-- 
2.25.1



[PATCH -next] crypto: atmel-aes - convert to use be32_add_cpu()

2020-09-13 Thread Liu Shixin
Convert cpu_to_be32(be32_to_cpu(E1) + E2) to use be32_add_cpu().

Signed-off-by: Liu Shixin 
---
 drivers/crypto/atmel-aes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c
index a6e14491e080..b1d286004295 100644
--- a/drivers/crypto/atmel-aes.c
+++ b/drivers/crypto/atmel-aes.c
@@ -1539,7 +1539,7 @@ static int atmel_aes_gcm_length(struct atmel_aes_dev *dd)
 
/* Write incr32(J0) into IV. */
j0_lsw = j0[3];
-   j0[3] = cpu_to_be32(be32_to_cpu(j0[3]) + 1);
+   be32_add_cpu(&j0[3], 1);
atmel_aes_write_block(dd, AES_IVR(0), j0);
j0[3] = j0_lsw;
 
-- 
2.25.1



[PATCH -next] extcon: axp288: use module_platform_driver to simplify the code

2020-09-13 Thread Liu Shixin
module_platform_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/extcon/extcon-axp288.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 525345367260..fdb31954cf2b 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -491,18 +491,7 @@ static struct platform_driver axp288_extcon_driver = {
.pm = &axp288_extcon_pm_ops,
},
 };
-
-static int __init axp288_extcon_init(void)
-{
-   return platform_driver_register(&axp288_extcon_driver);
-}
-module_init(axp288_extcon_init);
-
-static void __exit axp288_extcon_exit(void)
-{
-   platform_driver_unregister(&axp288_extcon_driver);
-}
-module_exit(axp288_extcon_exit);
+module_platform_driver(axp288_extcon_driver);
 
 MODULE_AUTHOR("Ramakrishna Pallala ");
 MODULE_AUTHOR("Hans de Goede ");
-- 
2.25.1



[PATCH -next] iio: adc: palmas_gpadc: use module_platform_driver to simplify the code

2020-09-13 Thread Liu Shixin
module_platform_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/iio/adc/palmas_gpadc.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
index 1ca6570be66a..889b88768b63 100644
--- a/drivers/iio/adc/palmas_gpadc.c
+++ b/drivers/iio/adc/palmas_gpadc.c
@@ -834,18 +834,7 @@ static struct platform_driver palmas_gpadc_driver = {
.of_match_table = of_palmas_gpadc_match_tbl,
},
 };
-
-static int __init palmas_gpadc_init(void)
-{
-   return platform_driver_register(&palmas_gpadc_driver);
-}
-module_init(palmas_gpadc_init);
-
-static void __exit palmas_gpadc_exit(void)
-{
-   platform_driver_unregister(&palmas_gpadc_driver);
-}
-module_exit(palmas_gpadc_exit);
+module_platform_driver(palmas_gpadc_driver);
 
 MODULE_DESCRIPTION("palmas GPADC driver");
 MODULE_AUTHOR("Pradeep Goudagunta");
-- 
2.25.1



[PATCH -next] pinctrl: sprd: use module_platform_driver to simplify the code

2020-09-13 Thread Liu Shixin
module_platform_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c 
b/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c
index 06c8671b40e7..d14f382f2392 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c
@@ -946,18 +946,7 @@ static struct platform_driver sprd_pinctrl_driver = {
.remove = sprd_pinctrl_remove,
.shutdown = sprd_pinctrl_shutdown,
 };
-
-static int sprd_pinctrl_init(void)
-{
-   return platform_driver_register(&sprd_pinctrl_driver);
-}
-module_init(sprd_pinctrl_init);
-
-static void sprd_pinctrl_exit(void)
-{
-   platform_driver_unregister(&sprd_pinctrl_driver);
-}
-module_exit(sprd_pinctrl_exit);
+module_platform_driver(sprd_pinctrl_driver);
 
 MODULE_DESCRIPTION("SPREADTRUM Pin Controller Driver");
 MODULE_AUTHOR("Baolin Wang ");
-- 
2.25.1



[PATCH -next] scsi: use module_platform_driver to simplify the code

2020-09-13 Thread Liu Shixin
module_platform_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/jazz_esp.c   | 14 +-
 drivers/scsi/mac_esp.c| 14 +-
 drivers/scsi/qlogicpti.c  | 14 +-
 drivers/scsi/sni_53c710.c | 14 +-
 drivers/scsi/sun3x_esp.c  | 14 +-
 drivers/scsi/sun_esp.c| 14 +-
 6 files changed, 6 insertions(+), 78 deletions(-)

diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c
index 7f683e42c798..f0ed6863cc70 100644
--- a/drivers/scsi/jazz_esp.c
+++ b/drivers/scsi/jazz_esp.c
@@ -201,21 +201,9 @@ static struct platform_driver esp_jazz_driver = {
.name   = "jazz_esp",
},
 };
-
-static int __init jazz_esp_init(void)
-{
-   return platform_driver_register(&esp_jazz_driver);
-}
-
-static void __exit jazz_esp_exit(void)
-{
-   platform_driver_unregister(&esp_jazz_driver);
-}
+module_platform_driver(esp_jazz_driver);
 
 MODULE_DESCRIPTION("JAZZ ESP SCSI driver");
 MODULE_AUTHOR("Thomas Bogendoerfer (tsbog...@alpha.franken.de)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-module_init(jazz_esp_init);
-module_exit(jazz_esp_exit);
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
index 1c78bc10c790..6d23ab5aee56 100644
--- a/drivers/scsi/mac_esp.c
+++ b/drivers/scsi/mac_esp.c
@@ -439,22 +439,10 @@ static struct platform_driver esp_mac_driver = {
.name   = DRV_MODULE_NAME,
},
 };
-
-static int __init mac_esp_init(void)
-{
-   return platform_driver_register(&esp_mac_driver);
-}
-
-static void __exit mac_esp_exit(void)
-{
-   platform_driver_unregister(&esp_mac_driver);
-}
+module_platform_driver(esp_mac_driver);
 
 MODULE_DESCRIPTION("Mac ESP SCSI driver");
 MODULE_AUTHOR("Finn Thain");
 MODULE_LICENSE("GPL v2");
 MODULE_VERSION(DRV_VERSION);
 MODULE_ALIAS("platform:" DRV_MODULE_NAME);
-
-module_init(mac_esp_init);
-module_exit(mac_esp_exit);
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 48ff7d88af86..d84e218d32cb 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1468,22 +1468,10 @@ static struct platform_driver qpti_sbus_driver = {
.probe  = qpti_sbus_probe,
.remove = qpti_sbus_remove,
 };
-
-static int __init qpti_init(void)
-{
-   return platform_driver_register(&qpti_sbus_driver);
-}
-
-static void __exit qpti_exit(void)
-{
-   platform_driver_unregister(&qpti_sbus_driver);
-}
+module_platform_driver(qpti_sbus_driver);
 
 MODULE_DESCRIPTION("QlogicISP SBUS driver");
 MODULE_AUTHOR("David S. Miller (da...@davemloft.net)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION("2.1");
 MODULE_FIRMWARE("qlogic/isp1000.bin");
-
-module_init(qpti_init);
-module_exit(qpti_exit);
diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 03d43f016397..9e2e196bc202 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -124,16 +124,4 @@ static struct platform_driver snirm710_driver = {
.name   = "snirm_53c710",
},
 };
-
-static int __init snirm710_init(void)
-{
-   return platform_driver_register(&snirm710_driver);
-}
-
-static void __exit snirm710_exit(void)
-{
-   platform_driver_unregister(&snirm710_driver);
-}
-
-module_init(snirm710_init);
-module_exit(snirm710_exit);
+module_platform_driver(snirm710_driver);
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
index f37df79e37e1..7de82f2c9757 100644
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -270,22 +270,10 @@ static struct platform_driver esp_sun3x_driver = {
.name   = "sun3x_esp",
},
 };
-
-static int __init sun3x_esp_init(void)
-{
-   return platform_driver_register(&esp_sun3x_driver);
-}
-
-static void __exit sun3x_esp_exit(void)
-{
-   platform_driver_unregister(&esp_sun3x_driver);
-}
+module_platform_driver(esp_sun3x_driver);
 
 MODULE_DESCRIPTION("Sun3x ESP SCSI driver");
 MODULE_AUTHOR("Thomas Bogendoerfer (tsbog...@alpha.franken.de)");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-module_init(sun3x_esp_init);
-module_exit(sun3x_esp_exit);
 MODULE_ALIAS("platform:sun3x_esp");
diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c
index 964130d2c8a6..5dc38d35745b 100644
--- a/drivers/scsi/sun_esp.c
+++ b/drivers/scsi/sun_esp.c
@@ -606,21 +606,9 @@ static struct platform_driver esp_sbus_driver = {
.probe  = esp_sbus_probe,
.remove = esp_sbus_remove,
 };
-
-static int __init sunesp_init(void)
-{
-   return platform_driver_register(&esp_sbus_driver);
-}
-
-static void __exit sunesp_exit(void)
-{
-   platform_driver_unregister(&esp_sbus_driver);
-}
+m

[PATCH -next] EDAC/aspeed: use module_platform_driver to simplify the code

2020-09-13 Thread Liu Shixin
module_platform_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/edac/aspeed_edac.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index fbec28dc661d..fde809efc520 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -388,23 +388,7 @@ static struct platform_driver aspeed_driver = {
.probe  = aspeed_probe,
.remove = aspeed_remove
 };
-
-
-static int __init aspeed_init(void)
-{
-   return platform_driver_register(&aspeed_driver);
-}
-
-
-static void __exit aspeed_exit(void)
-{
-   platform_driver_unregister(&aspeed_driver);
-}
-
-
-module_init(aspeed_init);
-module_exit(aspeed_exit);
-
+module_platform_driver(aspeed_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Stefan Schaeckeler ");
-- 
2.25.1



[PATCH -next] omapfb: connector-dvi: simplify the return expression of dvic_connect()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c 
b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c
index b4a1aefff766..2fa436475b40 100644
--- a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c
+++ b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c
@@ -51,16 +51,11 @@ static int dvic_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
-   int r;
 
if (omapdss_device_is_connected(dssdev))
return 0;
 
-   r = in->ops.dvi->connect(in, dssdev);
-   if (r)
-   return r;
-
-   return 0;
+   return in->ops.dvi->connect(in, dssdev);
 }
 
 static void dvic_disconnect(struct omap_dss_device *dssdev)
-- 
2.25.1



[PATCH -next] w1: ds2490: simplify the return expression of ds_reset()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/w1/masters/ds2490.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index e17c8f70dcd0..d42da8bde06c 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -464,8 +464,6 @@ static int ds_wait_status(struct ds_device *dev, struct 
ds_status *st)
 
 static int ds_reset(struct ds_device *dev)
 {
-   int err;
-
/* Other potentionally interesting flags for reset.
 *
 * COMM_NTF: Return result register feedback.  This could be used to
@@ -475,11 +473,7 @@ static int ds_reset(struct ds_device *dev)
 * COMM_SE which allows SPEED_NORMAL, SPEED_FLEXIBLE, SPEED_OVERDRIVE:
 * Select the data transfer rate.
 */
-   err = ds_send_control(dev, COMM_1_WIRE_RESET | COMM_IM, SPEED_NORMAL);
-   if (err)
-   return err;
-
-   return 0;
+   return ds_send_control(dev, COMM_1_WIRE_RESET | COMM_IM, SPEED_NORMAL);
 }
 
 #if 0
-- 
2.25.1



[PATCH -next] ata: pata_samsung_cf: simplify the return expression of pata_s3c_wait_after_reset()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/ata/pata_samsung_cf.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/ata/pata_samsung_cf.c b/drivers/ata/pata_samsung_cf.c
index 3da0e8e30286..5fd5c79e1543 100644
--- a/drivers/ata/pata_samsung_cf.c
+++ b/drivers/ata/pata_samsung_cf.c
@@ -340,19 +340,14 @@ static unsigned int pata_s3c_devchk(struct ata_port *ap,
 static int pata_s3c_wait_after_reset(struct ata_link *link,
unsigned long deadline)
 {
-   int rc;
-
ata_msleep(link->ap, ATA_WAIT_AFTER_RESET);
 
-   /* always check readiness of the master device */
-   rc = ata_sff_wait_ready(link, deadline);
-   /* -ENODEV means the odd clown forgot the D7 pulldown resistor
+   /*
+* always check readiness of the master device.
+* -ENODEV means the odd clown forgot the D7 pulldown resistor
 * and TF status is 0xff, bail out on it too.
 */
-   if (rc)
-   return rc;
-
-   return 0;
+   return ata_sff_wait_ready(link, deadline);
 }
 
 /*
-- 
2.25.1



[PATCH -next] firmware: arm_sdei: simplify the return expression of sdei_device_freeze()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/firmware/arm_sdei.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c
index b4b9ce97f415..5b4c8c51cb20 100644
--- a/drivers/firmware/arm_sdei.c
+++ b/drivers/firmware/arm_sdei.c
@@ -798,16 +798,10 @@ static int sdei_device_resume(struct device *dev)
  */
 static int sdei_device_freeze(struct device *dev)
 {
-   int err;
-
/* unregister private events */
cpuhp_remove_state(CPUHP_AP_ARM_SDEI_STARTING);
 
-   err = sdei_unregister_shared();
-   if (err)
-   return err;
-
-   return 0;
+   return sdei_unregister_shared();
 }
 
 static int sdei_device_thaw(struct device *dev)
-- 
2.25.1



[PATCH -next] drm/panel: simplify the return expression of rb070d30_panel_enable()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/gpu/drm/panel/panel-ronbo-rb070d30.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-ronbo-rb070d30.c 
b/drivers/gpu/drm/panel/panel-ronbo-rb070d30.c
index 535c8d1cca21..a3782830ae3c 100644
--- a/drivers/gpu/drm/panel/panel-ronbo-rb070d30.c
+++ b/drivers/gpu/drm/panel/panel-ronbo-rb070d30.c
@@ -75,13 +75,8 @@ static int rb070d30_panel_unprepare(struct drm_panel *panel)
 static int rb070d30_panel_enable(struct drm_panel *panel)
 {
struct rb070d30_panel *ctx = panel_to_rb070d30_panel(panel);
-   int ret;
 
-   ret = mipi_dsi_dcs_exit_sleep_mode(ctx->dsi);
-   if (ret)
-   return ret;
-
-   return 0;
+   return mipi_dsi_dcs_exit_sleep_mode(ctx->dsi);
 }
 
 static int rb070d30_panel_disable(struct drm_panel *panel)
-- 
2.25.1



[PATCH -next] usbip: simplify the return expression of usbip_core_init()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/usb/usbip/usbip_common.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index e4b96674c405..4ce6c6a45eb1 100644
--- a/drivers/usb/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
@@ -755,13 +755,7 @@ EXPORT_SYMBOL_GPL(usbip_recv_xbuff);
 
 static int __init usbip_core_init(void)
 {
-   int ret;
-
-   ret = usbip_init_eh();
-   if (ret)
-   return ret;
-
-   return 0;
+   return usbip_init_eh();
 }
 
 static void __exit usbip_core_exit(void)
-- 
2.25.1



[PATCH -next] Input: da9034-ts - simplify the return expression of da9034_touch_probe()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/input/touchscreen/da9034-ts.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/da9034-ts.c 
b/drivers/input/touchscreen/da9034-ts.c
index 2943f6a58388..dfb2604381d2 100644
--- a/drivers/input/touchscreen/da9034-ts.c
+++ b/drivers/input/touchscreen/da9034-ts.c
@@ -298,7 +298,6 @@ static int da9034_touch_probe(struct platform_device *pdev)
struct da9034_touch_pdata *pdata = dev_get_platdata(&pdev->dev);
struct da9034_touch *touch;
struct input_dev *input_dev;
-   int error;
 
touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch),
 GFP_KERNEL);
@@ -344,11 +343,7 @@ static int da9034_touch_probe(struct platform_device *pdev)
touch->input_dev = input_dev;
input_set_drvdata(input_dev, touch);
 
-   error = input_register_device(input_dev);
-   if (error)
-   return error;
-
-   return 0;
+   return input_register_device(input_dev);
 }
 
 static struct platform_driver da9034_touch_driver = {
-- 
2.25.1



[PATCH -next] dmaengine: mediatek: simplify the return expression of mtk_uart_apdma_runtime_resume()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/dma/mediatek/mtk-uart-apdma.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c 
b/drivers/dma/mediatek/mtk-uart-apdma.c
index 29f1223b285a..27c07350971d 100644
--- a/drivers/dma/mediatek/mtk-uart-apdma.c
+++ b/drivers/dma/mediatek/mtk-uart-apdma.c
@@ -624,14 +624,9 @@ static int mtk_uart_apdma_runtime_suspend(struct device 
*dev)
 
 static int mtk_uart_apdma_runtime_resume(struct device *dev)
 {
-   int ret;
struct mtk_uart_apdmadev *mtkd = dev_get_drvdata(dev);
 
-   ret = clk_prepare_enable(mtkd->clk);
-   if (ret)
-   return ret;
-
-   return 0;
+   return clk_prepare_enable(mtkd->clk);
 }
 #endif /* CONFIG_PM */
 
-- 
2.25.1



[PATCH -next] staging: greybus: simplify the return expression of gb_svc_add()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/greybus/svc.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/greybus/svc.c b/drivers/greybus/svc.c
index ce7740ef449b..dca251172cd2 100644
--- a/drivers/greybus/svc.c
+++ b/drivers/greybus/svc.c
@@ -1345,18 +1345,12 @@ struct gb_svc *gb_svc_create(struct gb_host_device *hd)
 
 int gb_svc_add(struct gb_svc *svc)
 {
-   int ret;
-
/*
 * The SVC protocol is currently driven by the SVC, so the SVC device
 * is added from the connection request handler when enough
 * information has been received.
 */
-   ret = gb_connection_enable(svc->connection);
-   if (ret)
-   return ret;
-
-   return 0;
+   return gb_connection_enable(svc->connection);
 }
 
 static void gb_svc_remove_modules(struct gb_svc *svc)
-- 
2.25.1



[PATCH -next] power: avs: qcom-cpr: simplify the return expression of cpr_disable()

2020-09-14 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/power/avs/qcom-cpr.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/power/avs/qcom-cpr.c b/drivers/power/avs/qcom-cpr.c
index bd7c3e48b386..b24cc77d1889 100644
--- a/drivers/power/avs/qcom-cpr.c
+++ b/drivers/power/avs/qcom-cpr.c
@@ -665,8 +665,6 @@ static int cpr_enable(struct cpr_drv *drv)
 
 static int cpr_disable(struct cpr_drv *drv)
 {
-   int ret;
-
mutex_lock(&drv->lock);
 
if (cpr_is_allowed(drv)) {
@@ -676,11 +674,7 @@ static int cpr_disable(struct cpr_drv *drv)
 
mutex_unlock(&drv->lock);
 
-   ret = regulator_disable(drv->vdd_apc);
-   if (ret)
-   return ret;
-
-   return 0;
+   return regulator_disable(drv->vdd_apc);
 }
 
 static int cpr_config(struct cpr_drv *drv)
-- 
2.25.1



[PATCH -next] eeprom: ee1004: use module_i2c_driver to simplify the code

2020-09-17 Thread Liu Shixin
Use the module_i2c_driver() macro to make the code smaller
and a bit simpler.

Signed-off-by: Liu Shixin 
---
 drivers/misc/eeprom/ee1004.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c
index b081c67416d7..252e15ba65e1 100644
--- a/drivers/misc/eeprom/ee1004.c
+++ b/drivers/misc/eeprom/ee1004.c
@@ -280,18 +280,7 @@ static struct i2c_driver ee1004_driver = {
.remove = ee1004_remove,
.id_table = ee1004_ids,
 };
-
-static int __init ee1004_init(void)
-{
-   return i2c_add_driver(&ee1004_driver);
-}
-module_init(ee1004_init);
-
-static void __exit ee1004_exit(void)
-{
-   i2c_del_driver(&ee1004_driver);
-}
-module_exit(ee1004_exit);
+module_i2c_driver(ee1004_driver);
 
 MODULE_DESCRIPTION("Driver for EE1004-compliant DDR4 SPD EEPROMs");
 MODULE_AUTHOR("Jean Delvare");
-- 
2.25.1



[PATCH -next] PCI: iproc: use module_bcma_driver to simplify the code

2020-09-17 Thread Liu Shixin
module_bcma_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/pci/controller/pcie-iproc-bcma.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/pci/controller/pcie-iproc-bcma.c 
b/drivers/pci/controller/pcie-iproc-bcma.c
index aa55b064f64d..56b8ee7bf330 100644
--- a/drivers/pci/controller/pcie-iproc-bcma.c
+++ b/drivers/pci/controller/pcie-iproc-bcma.c
@@ -94,18 +94,7 @@ static struct bcma_driver iproc_pcie_bcma_driver = {
.probe  = iproc_pcie_bcma_probe,
.remove = iproc_pcie_bcma_remove,
 };
-
-static int __init iproc_pcie_bcma_init(void)
-{
-   return bcma_driver_register(&iproc_pcie_bcma_driver);
-}
-module_init(iproc_pcie_bcma_init);
-
-static void __exit iproc_pcie_bcma_exit(void)
-{
-   bcma_driver_unregister(&iproc_pcie_bcma_driver);
-}
-module_exit(iproc_pcie_bcma_exit);
+module_bcma_driver(iproc_pcie_bcma_driver);
 
 MODULE_AUTHOR("Hauke Mehrtens");
 MODULE_DESCRIPTION("Broadcom iProc PCIe BCMA driver");
-- 
2.25.1



[PATCH -next] USB: bcma: use module_bcma_driver to simplify the code

2020-09-17 Thread Liu Shixin
module_bcma_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/usb/host/bcma-hcd.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
index b1b777f33521..337b425dd4b0 100644
--- a/drivers/usb/host/bcma-hcd.c
+++ b/drivers/usb/host/bcma-hcd.c
@@ -498,15 +498,4 @@ static struct bcma_driver bcma_hcd_driver = {
.suspend= bcma_hcd_suspend,
.resume = bcma_hcd_resume,
 };
-
-static int __init bcma_hcd_init(void)
-{
-   return bcma_driver_register(&bcma_hcd_driver);
-}
-module_init(bcma_hcd_init);
-
-static void __exit bcma_hcd_exit(void)
-{
-   bcma_driver_unregister(&bcma_hcd_driver);
-}
-module_exit(bcma_hcd_exit);
+module_bcma_driver(bcma_hcd_driver);
-- 
2.25.1



[PATCH -next] usb: appledisplay: use module_usb_driver to simplify the code

2020-09-17 Thread Liu Shixin
module_usb_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/usb/misc/appledisplay.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 36fed1a09666..c8098e9b432e 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -342,20 +342,8 @@ static struct usb_driver appledisplay_driver = {
.disconnect = appledisplay_disconnect,
.id_table   = appledisplay_table,
 };
-
-static int __init appledisplay_init(void)
-{
-   return usb_register(&appledisplay_driver);
-}
-
-static void __exit appledisplay_exit(void)
-{
-   usb_deregister(&appledisplay_driver);
-}
+module_usb_driver(appledisplay_driver);
 
 MODULE_AUTHOR("Michael Hanselmann");
 MODULE_DESCRIPTION("Apple Cinema Display driver");
 MODULE_LICENSE("GPL");
-
-module_init(appledisplay_init);
-module_exit(appledisplay_exit);
-- 
2.25.1



[PATCH -next] w1: ds28e17: use module_w1_family to simplify the code

2020-09-17 Thread Liu Shixin
module_w1_family() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Liu Shixin 
---
 drivers/w1/slaves/w1_ds28e17.c | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/w1/slaves/w1_ds28e17.c b/drivers/w1/slaves/w1_ds28e17.c
index 046ddda83df9..d165aa9d803f 100644
--- a/drivers/w1/slaves/w1_ds28e17.c
+++ b/drivers/w1/slaves/w1_ds28e17.c
@@ -751,19 +751,4 @@ static struct w1_family w1_family_19 = {
.fid = W1_FAMILY_DS28E17,
.fops = &w1_f19_fops,
 };
-
-
-/* Module init and remove functions. */
-static int __init w1_f19_init(void)
-{
-   return w1_register_family(&w1_family_19);
-}
-
-static void __exit w1_f19_fini(void)
-{
-   w1_unregister_family(&w1_family_19);
-}
-
-module_init(w1_f19_init);
-module_exit(w1_f19_fini);
-
+module_w1_family(w1_family_19);
-- 
2.25.1



Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters()

2020-09-17 Thread Liu Shixin
On 2020/9/18 1:33, Leon Romanovsky wrote:
> On Thu, Sep 17, 2020 at 02:24:51PM -0300, Jason Gunthorpe wrote:
>> On Thu, Sep 17, 2020 at 08:05:11PM +0300, Leon Romanovsky wrote:
>>> On Thu, Sep 17, 2020 at 09:38:06AM -0300, Jason Gunthorpe wrote:
>>>> On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote:
>>>>> On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote:
>>>>>> sizeof() when applied to a pointer typed expression should give the
>>>>>> size of the pointed data, even if the data is a pointer.
>>>>>>
>>>>>> Signed-off-by: Liu Shixin 
>>>> Needs a fixes line
>>>>
>>>>>>  if (!cnts->names)
>>>>>>  return -ENOMEM;
>>>>>>
>>>>>>  cnts->offsets = kcalloc(num_counters,
>>>>>> -sizeof(cnts->offsets), GFP_KERNEL);
>>>>>> +sizeof(*cnts->offsets), GFP_KERNEL);
>>>>> This is not.
>>>> Why not?
>>> cnts->offsets is array of pointers that we will set later.
>>> The "sizeof(*cnts->offsets)" will return the size of size_t, while we
>>> need to get "size_t *".
>> Then why isn't a pointer to size **?
>>
>> Something is rotten here
> No problem, I'll check.
I think cnts->offsets is an array pointer whose element is size_t rathen than 
pointer,
so the patch description does not correspond.
And I think it should be modified to sizeof(*cnts->offsets) with other 
description.
>
>> Jason
> .
>



[PATCH -next] leds: pca9532 - simplify the return expression of pca9532_remove

2020-09-19 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/leds/leds-pca9532.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 7d515d5e57bd..88d2edf285c2 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -545,13 +545,8 @@ static int pca9532_probe(struct i2c_client *client,
 static int pca9532_remove(struct i2c_client *client)
 {
struct pca9532_data *data = i2c_get_clientdata(client);
-   int err;
 
-   err = pca9532_destroy_devices(data, data->chip_info->num_leds);
-   if (err)
-   return err;
-
-   return 0;
+   return pca9532_destroy_devices(data, data->chip_info->num_leds);
 }
 
 module_i2c_driver(pca9532_driver);
-- 
2.25.1



[PATCH -next] drm/lima: simplify the return expression of lima_devfreq_target

2020-09-19 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/gpu/drm/lima/lima_devfreq.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/lima/lima_devfreq.c 
b/drivers/gpu/drm/lima/lima_devfreq.c
index bbe02817721b..5914442936ed 100644
--- a/drivers/gpu/drm/lima/lima_devfreq.c
+++ b/drivers/gpu/drm/lima/lima_devfreq.c
@@ -35,18 +35,13 @@ static int lima_devfreq_target(struct device *dev, unsigned 
long *freq,
   u32 flags)
 {
struct dev_pm_opp *opp;
-   int err;
 
opp = devfreq_recommended_opp(dev, freq, flags);
if (IS_ERR(opp))
return PTR_ERR(opp);
dev_pm_opp_put(opp);
 
-   err = dev_pm_opp_set_rate(dev, *freq);
-   if (err)
-   return err;
-
-   return 0;
+   return dev_pm_opp_set_rate(dev, *freq);
 }
 
 static void lima_devfreq_reset(struct lima_devfreq *devfreq)
-- 
2.25.1



[PATCH -next] drm/omap: dsi: simplify the return expression of dsi_init_pll_data

2020-09-19 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index eeccf40bae41..cac0d1993dab 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5015,7 +5015,6 @@ static int dsi_init_pll_data(struct dss_device *dss, 
struct dsi_data *dsi)
 {
struct dss_pll *pll = &dsi->pll;
struct clk *clk;
-   int r;
 
clk = devm_clk_get(dsi->dev, "sys_clk");
if (IS_ERR(clk)) {
@@ -5030,11 +5029,7 @@ static int dsi_init_pll_data(struct dss_device *dss, 
struct dsi_data *dsi)
pll->hw = dsi->data->pll_hw;
pll->ops = &dsi_pll_ops;
 
-   r = dss_pll_register(dss, pll);
-   if (r)
-   return r;
-
-   return 0;
+   return dss_pll_register(dss, pll);
 }
 
 /* 
-
-- 
2.25.1



[PATCH -next] mtd: vmu-flash: simplify the return expression of probe_maple_vmu

2020-09-19 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/mtd/maps/vmu-flash.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c
index 177bf134e189..588e82de581c 100644
--- a/drivers/mtd/maps/vmu-flash.c
+++ b/drivers/mtd/maps/vmu-flash.c
@@ -772,7 +772,6 @@ static void vmu_file_error(struct maple_device *mdev, void 
*recvbuf)
 
 static int probe_maple_vmu(struct device *dev)
 {
-   int error;
struct maple_device *mdev = to_maple_dev(dev);
struct maple_driver *mdrv = to_maple_driver(dev->driver);
 
@@ -780,11 +779,7 @@ static int probe_maple_vmu(struct device *dev)
mdev->fileerr_handler = vmu_file_error;
mdev->driver = mdrv;
 
-   error = vmu_connect(mdev);
-   if (error)
-   return error;
-
-   return 0;
+   return vmu_connect(mdev);
 }
 
 static int remove_maple_vmu(struct device *dev)
-- 
2.25.1



[PATCH -next] rtc: meson: simplify the return expression of meson_vrtc_probe

2020-09-19 Thread Liu Shixin
Simplify the return expression.

Signed-off-by: Liu Shixin 
---
 drivers/rtc/rtc-meson-vrtc.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-meson-vrtc.c b/drivers/rtc/rtc-meson-vrtc.c
index 89e5ba0dae69..e6bd0808a092 100644
--- a/drivers/rtc/rtc-meson-vrtc.c
+++ b/drivers/rtc/rtc-meson-vrtc.c
@@ -65,7 +65,6 @@ static const struct rtc_class_ops meson_vrtc_ops = {
 static int meson_vrtc_probe(struct platform_device *pdev)
 {
struct meson_vrtc_data *vrtc;
-   int ret;
 
vrtc = devm_kzalloc(&pdev->dev, sizeof(*vrtc), GFP_KERNEL);
if (!vrtc)
@@ -84,11 +83,7 @@ static int meson_vrtc_probe(struct platform_device *pdev)
return PTR_ERR(vrtc->rtc);
 
vrtc->rtc->ops = &meson_vrtc_ops;
-   ret = rtc_register_device(vrtc->rtc);
-   if (ret)
-   return ret;
-
-   return 0;
+   return rtc_register_device(vrtc->rtc);
 }
 
 static int __maybe_unused meson_vrtc_suspend(struct device *dev)
-- 
2.25.1



[PATCH -next] PCI: dwc: Remove set but not used variable

2020-09-16 Thread Liu Shixin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/pci/controller/dwc/pci-dra7xx.c: In function 
'dra7xx_pcie_establish_link':
drivers/pci/controller/dwc/pci-dra7xx.c:142:6: warning: unused variable 
'exp_cap_off'
[-Wunused-variable]

After 3af45d34d30c ("PCI: dwc: Centralize link gen setting"), variable 
'exp_cap_off'
is never used. Remove it to avoid build warning.

Signed-off-by: Liu Shixin 
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c 
b/drivers/pci/controller/dwc/pci-dra7xx.c
index 69cd43f74260..7bac7c54b2aa 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -139,7 +139,7 @@ static int dra7xx_pcie_establish_link(struct dw_pcie *pci)
struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
struct device *dev = pci->dev;
u32 reg;
-   u32 exp_cap_off = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
+   dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
 
if (dw_pcie_link_up(pci)) {
dev_err(dev, "link is already up\n");
-- 
2.25.1



[PATCH -next] dmaengine: sf-pdma: Remove set but not used variable "desc"

2020-09-16 Thread Liu Shixin
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/dma/sf-pdma/sf-pdma.c: In function 'sf_pdma_donebh_tasklet':
drivers/dma/sf-pdma/sf-pdma.c:287:23: warning: unused variable 'desc' 
[-Wunused-variable]

After commit 8f6b6d060602 ("dmaengine: sf-pdma: Fix an error that calls 
callback twice"),
variable 'desc' is never used. Remove it to avoid build warning.

Signed-off-by: Liu Shixin 
---
 drivers/dma/sf-pdma/sf-pdma.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/dma/sf-pdma/sf-pdma.c b/drivers/dma/sf-pdma/sf-pdma.c
index 754994087e5f..1e66c6990d81 100644
--- a/drivers/dma/sf-pdma/sf-pdma.c
+++ b/drivers/dma/sf-pdma/sf-pdma.c
@@ -284,7 +284,6 @@ static void sf_pdma_free_desc(struct virt_dma_desc *vdesc)
 static void sf_pdma_donebh_tasklet(unsigned long arg)
 {
struct sf_pdma_chan *chan = (struct sf_pdma_chan *)arg;
-   struct sf_pdma_desc *desc = chan->desc;
unsigned long flags;
 
spin_lock_irqsave(&chan->lock, flags);
-- 
2.25.1



[PATCH -next] mm/madvise: Remove set but not used variable 'zone'

2020-09-16 Thread Liu Shixin
Fixes gcc '-Wunused-but-set-variable' warning:

mm/madvise.c: In function 'madvise_inject_error':
mm/madvise.c:882:15: warning: unused variable 'zone' [-Wunused-variable]

After 4b63fdbe2b25 ("mm: remove the now-unnecessary mmget_still_valid()
hack"), variable 'zone' is never used. Remove it to avoid build warning.

Signed-off-by: Liu Shixin 
---
 mm/madvise.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 460e19d60ba3..94b9d17331b9 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -879,7 +879,6 @@ static long madvise_remove(struct vm_area_struct *vma,
 static int madvise_inject_error(int behavior,
unsigned long start, unsigned long end)
 {
-   struct zone *zone;
unsigned long size;
 
if (!capable(CAP_SYS_ADMIN))
-- 
2.25.1



[PATCH -next] PCI/IOV: use module_pci_driver to simplify the code

2020-09-17 Thread Liu Shixin
Use the module_pci_driver() macro to make the code simpler
by eliminating module_init and module_exit calls.

Signed-off-by: Liu Shixin 
---
 drivers/pci/pci-pf-stub.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/pci/pci-pf-stub.c b/drivers/pci/pci-pf-stub.c
index a0b2bd6c918a..45855a5e9fca 100644
--- a/drivers/pci/pci-pf-stub.c
+++ b/drivers/pci/pci-pf-stub.c
@@ -37,18 +37,6 @@ static struct pci_driver pf_stub_driver = {
.probe  = pci_pf_stub_probe,
.sriov_configure= pci_sriov_configure_simple,
 };
-
-static int __init pci_pf_stub_init(void)
-{
-   return pci_register_driver(&pf_stub_driver);
-}
-
-static void __exit pci_pf_stub_exit(void)
-{
-   pci_unregister_driver(&pf_stub_driver);
-}
-
-module_init(pci_pf_stub_init);
-module_exit(pci_pf_stub_exit);
+module_pci_driver(pf_stub_driver);
 
 MODULE_LICENSE("GPL");
-- 
2.25.1



[PATCH -next] scsi: initio: use module_pci_driver to simplify the code

2020-09-17 Thread Liu Shixin
Use the module_pci_driver() macro to make the code simpler
by eliminating module_init and module_exit calls.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/initio.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 1d39628ac947..ca16ef45d8dc 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2962,20 +2962,8 @@ static struct pci_driver initio_pci_driver = {
.probe  = initio_probe_one,
.remove = initio_remove_one,
 };
-
-static int __init initio_init_driver(void)
-{
-   return pci_register_driver(&initio_pci_driver);
-}
-
-static void __exit initio_exit_driver(void)
-{
-   pci_unregister_driver(&initio_pci_driver);
-}
+module_pci_driver(initio_pci_driver);
 
 MODULE_DESCRIPTION("Initio INI-9X00U/UW SCSI device driver");
 MODULE_AUTHOR("Initio Corporation");
 MODULE_LICENSE("GPL");
-
-module_init(initio_init_driver);
-module_exit(initio_exit_driver);
-- 
2.25.1



[PATCH -next] scsi: dc395x: use module_pci_driver to simplify the code

2020-09-17 Thread Liu Shixin
Use the module_pci_driver() macro to make the code simpler
by eliminating module_init and module_exit calls.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/dc395x.c | 25 +
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 0c251a3b99b7..fa16894d8758 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -4721,30 +4721,7 @@ static struct pci_driver dc395x_driver = {
.probe  = dc395x_init_one,
.remove = dc395x_remove_one,
 };
-
-
-/**
- * dc395x_module_init - Module initialization function
- *
- * Used by both module and built-in driver to initialise this driver.
- **/
-static int __init dc395x_module_init(void)
-{
-   return pci_register_driver(&dc395x_driver);
-}
-
-
-/**
- * dc395x_module_exit - Module cleanup function.
- **/
-static void __exit dc395x_module_exit(void)
-{
-   pci_unregister_driver(&dc395x_driver);
-}
-
-
-module_init(dc395x_module_init);
-module_exit(dc395x_module_exit);
+module_pci_driver(dc395x_driver);
 
 MODULE_AUTHOR("C.L. Huang / Erich Chen / Kurt Garloff");
 MODULE_DESCRIPTION("SCSI host adapter driver for Tekram TRM-S1040 based 
adapters: Tekram DC395 and DC315 series");
-- 
2.25.1



[PATCH -next] drivers/firmware/psci: fix type warning of sizeof in alloc_init_cpu_groups()

2020-09-17 Thread Liu Shixin
sizeof() when applied to a pointer typed expression should gives the
size of the pointed data, even if the data is a pointer.

Signed-off-by: Liu Shixin 
---
 drivers/firmware/psci/psci_checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/psci/psci_checker.c 
b/drivers/firmware/psci/psci_checker.c
index 9a369a2eda71..116eb465cdb4 100644
--- a/drivers/firmware/psci/psci_checker.c
+++ b/drivers/firmware/psci/psci_checker.c
@@ -155,7 +155,7 @@ static int alloc_init_cpu_groups(cpumask_var_t 
**pcpu_groups)
if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
return -ENOMEM;
 
-   cpu_groups = kcalloc(nb_available_cpus, sizeof(cpu_groups),
+   cpu_groups = kcalloc(nb_available_cpus, sizeof(*cpu_groups),
 GFP_KERNEL);
if (!cpu_groups) {
free_cpumask_var(tmp);
-- 
2.25.1



[PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters()

2020-09-17 Thread Liu Shixin
sizeof() when applied to a pointer typed expression should gives the
size of the pointed data, even if the data is a pointer.

Signed-off-by: Liu Shixin 
---
 drivers/infiniband/hw/mlx5/counters.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/counters.c 
b/drivers/infiniband/hw/mlx5/counters.c
index 145f3cb40ccb..aeeb14ecb3ee 100644
--- a/drivers/infiniband/hw/mlx5/counters.c
+++ b/drivers/infiniband/hw/mlx5/counters.c
@@ -456,12 +456,12 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev 
*dev,
cnts->num_ext_ppcnt_counters = ARRAY_SIZE(ext_ppcnt_cnts);
num_counters += ARRAY_SIZE(ext_ppcnt_cnts);
}
-   cnts->names = kcalloc(num_counters, sizeof(cnts->names), GFP_KERNEL);
+   cnts->names = kcalloc(num_counters, sizeof(*cnts->names), GFP_KERNEL);
if (!cnts->names)
return -ENOMEM;
 
cnts->offsets = kcalloc(num_counters,
-   sizeof(cnts->offsets), GFP_KERNEL);
+   sizeof(*cnts->offsets), GFP_KERNEL);
if (!cnts->offsets)
goto err_names;
 
-- 
2.25.1



[PATCH -next] tee: optee: fix type warning of sizeof in pool_op_alloc()

2020-09-17 Thread Liu Shixin
sizeof() when applied to a pointer typed expression should gives the
size of the pointed data, even if the data is a pointer.

Signed-off-by: Liu Shixin 
---
 drivers/tee/optee/shm_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c
index d767eebf30bd..9fdc667b5df0 100644
--- a/drivers/tee/optee/shm_pool.c
+++ b/drivers/tee/optee/shm_pool.c
@@ -31,7 +31,7 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm,
unsigned int nr_pages = 1 << order, i;
struct page **pages;
 
-   pages = kcalloc(nr_pages, sizeof(pages), GFP_KERNEL);
+   pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
if (!pages)
return -ENOMEM;
 
-- 
2.25.1



[PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters()

2020-09-17 Thread Liu Shixin
sizeof() when applied to a pointer typed expression should give the
size of the pointed data, even if the data is a pointer.

Signed-off-by: Liu Shixin 
---
 drivers/infiniband/hw/mlx5/counters.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/counters.c 
b/drivers/infiniband/hw/mlx5/counters.c
index 145f3cb40ccb..aeeb14ecb3ee 100644
--- a/drivers/infiniband/hw/mlx5/counters.c
+++ b/drivers/infiniband/hw/mlx5/counters.c
@@ -456,12 +456,12 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev 
*dev,
cnts->num_ext_ppcnt_counters = ARRAY_SIZE(ext_ppcnt_cnts);
num_counters += ARRAY_SIZE(ext_ppcnt_cnts);
}
-   cnts->names = kcalloc(num_counters, sizeof(cnts->names), GFP_KERNEL);
+   cnts->names = kcalloc(num_counters, sizeof(*cnts->names), GFP_KERNEL);
if (!cnts->names)
return -ENOMEM;
 
cnts->offsets = kcalloc(num_counters,
-   sizeof(cnts->offsets), GFP_KERNEL);
+   sizeof(*cnts->offsets), GFP_KERNEL);
if (!cnts->offsets)
goto err_names;
 
-- 
2.25.1



[PATCH -next v2] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters()

2020-09-17 Thread Liu Shixin
sizeof() when applied to a pointer typed expression should give the
size of the pointed data, even if the data is a pointer.

Signed-off-by: Liu Shixin 
---
 drivers/infiniband/hw/mlx5/counters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/counters.c 
b/drivers/infiniband/hw/mlx5/counters.c
index 8d77fea0eb48..6f8a8b558070 100644
--- a/drivers/infiniband/hw/mlx5/counters.c
+++ b/drivers/infiniband/hw/mlx5/counters.c
@@ -457,7 +457,7 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev *dev,
cnts->num_ext_ppcnt_counters = ARRAY_SIZE(ext_ppcnt_cnts);
num_counters += ARRAY_SIZE(ext_ppcnt_cnts);
}
-   cnts->names = kcalloc(num_counters, sizeof(cnts->names), GFP_KERNEL);
+   cnts->names = kcalloc(num_counters, sizeof(*cnts->names), GFP_KERNEL);
if (!cnts->names)
return -ENOMEM;
 
-- 
2.25.1



[PATCH -next] scsi: snic: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 drivers/scsi/snic/snic_debugfs.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/snic/snic_debugfs.c b/drivers/scsi/snic/snic_debugfs.c
index 2b349365592f..4471c4c8aafa 100644
--- a/drivers/scsi/snic/snic_debugfs.c
+++ b/drivers/scsi/snic/snic_debugfs.c
@@ -439,26 +439,14 @@ snic_trc_seq_show(struct seq_file *sfp, void *data)
return 0;
 }
 
-static const struct seq_operations snic_trc_seq_ops = {
+static const struct seq_operations snic_trc_sops = {
.start  = snic_trc_seq_start,
.next   = snic_trc_seq_next,
.stop   = snic_trc_seq_stop,
.show   = snic_trc_seq_show,
 };
 
-static int
-snic_trc_open(struct inode *inode, struct file *filp)
-{
-   return seq_open(filp, &snic_trc_seq_ops);
-}
-
-static const struct file_operations snic_trc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = snic_trc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(snic_trc);
 
 /*
  * snic_trc_debugfs_init : creates trace/tracing_enable files for trace
-- 
2.25.1



[PATCH -next] cxgb4vf: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 .../ethernet/chelsio/cxgb4vf/cxgb4vf_main.c   | 92 +++
 1 file changed, 11 insertions(+), 81 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index e2fe78e2e242..2820a0bb971b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2017,33 +2017,14 @@ static void mboxlog_stop(struct seq_file *seq, void *v)
 {
 }
 
-static const struct seq_operations mboxlog_seq_ops = {
+static const struct seq_operations mboxlog_sops = {
.start = mboxlog_start,
.next  = mboxlog_next,
.stop  = mboxlog_stop,
.show  = mboxlog_show
 };
 
-static int mboxlog_open(struct inode *inode, struct file *file)
-{
-   int res = seq_open(file, &mboxlog_seq_ops);
-
-   if (!res) {
-   struct seq_file *seq = file->private_data;
-
-   seq->private = inode->i_private;
-   }
-   return res;
-}
-
-static const struct file_operations mboxlog_fops = {
-   .owner   = THIS_MODULE,
-   .open= mboxlog_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-};
-
+DEFINE_SEQ_ATTRIBUTE(mboxlog);
 /*
  * Show SGE Queue Set information.  We display QPL Queues Sets per line.
  */
@@ -2171,31 +2152,14 @@ static void *sge_queue_next(struct seq_file *seq, void 
*v, loff_t *pos)
return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
 }
 
-static const struct seq_operations sge_qinfo_seq_ops = {
+static const struct seq_operations sge_qinfo_sops = {
.start = sge_queue_start,
.next  = sge_queue_next,
.stop  = sge_queue_stop,
.show  = sge_qinfo_show
 };
 
-static int sge_qinfo_open(struct inode *inode, struct file *file)
-{
-   int res = seq_open(file, &sge_qinfo_seq_ops);
-
-   if (!res) {
-   struct seq_file *seq = file->private_data;
-   seq->private = inode->i_private;
-   }
-   return res;
-}
-
-static const struct file_operations sge_qinfo_debugfs_fops = {
-   .owner   = THIS_MODULE,
-   .open= sge_qinfo_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(sge_qinfo);
 
 /*
  * Show SGE Queue Set statistics.  We display QPL Queues Sets per line.
@@ -2317,31 +2281,14 @@ static void *sge_qstats_next(struct seq_file *seq, void 
*v, loff_t *pos)
return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
 }
 
-static const struct seq_operations sge_qstats_seq_ops = {
+static const struct seq_operations sge_qstats_sops = {
.start = sge_qstats_start,
.next  = sge_qstats_next,
.stop  = sge_qstats_stop,
.show  = sge_qstats_show
 };
 
-static int sge_qstats_open(struct inode *inode, struct file *file)
-{
-   int res = seq_open(file, &sge_qstats_seq_ops);
-
-   if (res == 0) {
-   struct seq_file *seq = file->private_data;
-   seq->private = inode->i_private;
-   }
-   return res;
-}
-
-static const struct file_operations sge_qstats_proc_fops = {
-   .owner   = THIS_MODULE,
-   .open= sge_qstats_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(sge_qstats);
 
 /*
  * Show PCI-E SR-IOV Virtual Function Resource Limits.
@@ -2415,31 +2362,14 @@ static void interfaces_stop(struct seq_file *seq, void 
*v)
 {
 }
 
-static const struct seq_operations interfaces_seq_ops = {
+static const struct seq_operations interfaces_sops = {
.start = interfaces_start,
.next  = interfaces_next,
.stop  = interfaces_stop,
.show  = interfaces_show
 };
 
-static int interfaces_open(struct inode *inode, struct file *file)
-{
-   int res = seq_open(file, &interfaces_seq_ops);
-
-   if (res == 0) {
-   struct seq_file *seq = file->private_data;
-   seq->private = inode->i_private;
-   }
-   return res;
-}
-
-static const struct file_operations interfaces_proc_fops = {
-   .owner   = THIS_MODULE,
-   .open= interfaces_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(interfaces);
 
 /*
  * /sys/kernel/debugfs/cxgb4vf/ files list.
@@ -2452,10 +2382,10 @@ struct cxgb4vf_debugfs_entry {
 
 static struct cxgb4vf_debugfs_entry debugfs_files[] = {
{ "mboxlog",0444, &mboxlog_fops },
-   { "sge_qinfo",  0444, &sge_qinfo_debugfs_fops },
-   { "sge_qstats", 0444, &sge_qstats_proc_fops },
+   { "sge_qinfo",  0444, &sge_qinfo_fops },
+   { "sge_qstats", 0444, &sge_qstats_fops },

[PATCH -next] s390/diag: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 arch/s390/kernel/diag.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/arch/s390/kernel/diag.c b/arch/s390/kernel/diag.c
index ccba63aaeb47..b8b0cd7b008f 100644
--- a/arch/s390/kernel/diag.c
+++ b/arch/s390/kernel/diag.c
@@ -104,18 +104,7 @@ static const struct seq_operations show_diag_stat_sops = {
.show   = show_diag_stat,
 };
 
-static int show_diag_stat_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &show_diag_stat_sops);
-}
-
-static const struct file_operations show_diag_stat_fops = {
-   .open   = show_diag_stat_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
+DEFINE_SEQ_ATTRIBUTE(show_diag_stat);
 
 static int __init show_diag_stat_init(void)
 {
-- 
2.25.1



[PATCH -next] KVM: arm64: vgic-debug: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 arch/arm64/kvm/vgic/vgic-debug.c | 24 ++--
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
index b13a9e3f99dd..f38c40a76251 100644
--- a/arch/arm64/kvm/vgic/vgic-debug.c
+++ b/arch/arm64/kvm/vgic/vgic-debug.c
@@ -260,34 +260,14 @@ static int vgic_debug_show(struct seq_file *s, void *v)
return 0;
 }
 
-static const struct seq_operations vgic_debug_seq_ops = {
+static const struct seq_operations vgic_debug_sops = {
.start = vgic_debug_start,
.next  = vgic_debug_next,
.stop  = vgic_debug_stop,
.show  = vgic_debug_show
 };
 
-static int debug_open(struct inode *inode, struct file *file)
-{
-   int ret;
-   ret = seq_open(file, &vgic_debug_seq_ops);
-   if (!ret) {
-   struct seq_file *seq;
-   /* seq_open will have modified file->private_data */
-   seq = file->private_data;
-   seq->private = inode->i_private;
-   }
-
-   return ret;
-};
-
-static const struct file_operations vgic_debug_fops = {
-   .owner   = THIS_MODULE,
-   .open= debug_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(vgic_debug);
 
 void vgic_debug_init(struct kvm *kvm)
 {
-- 
2.25.1



[PATCH -next] crypto: qat - convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 drivers/crypto/qat/qat_common/adf_cfg.c   | 19 +
 .../qat/qat_common/adf_transport_debug.c  | 42 ++-
 2 files changed, 5 insertions(+), 56 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_cfg.c 
b/drivers/crypto/qat/qat_common/adf_cfg.c
index ac462796cefc..22ae32838113 100644
--- a/drivers/crypto/qat/qat_common/adf_cfg.c
+++ b/drivers/crypto/qat/qat_common/adf_cfg.c
@@ -52,24 +52,7 @@ static const struct seq_operations qat_dev_cfg_sops = {
.show = qat_dev_cfg_show
 };
 
-static int qat_dev_cfg_open(struct inode *inode, struct file *file)
-{
-   int ret = seq_open(file, &qat_dev_cfg_sops);
-
-   if (!ret) {
-   struct seq_file *seq_f = file->private_data;
-
-   seq_f->private = inode->i_private;
-   }
-   return ret;
-}
-
-static const struct file_operations qat_dev_cfg_fops = {
-   .open = qat_dev_cfg_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(qat_dev_cfg);
 
 /**
  * adf_cfg_dev_add() - Create an acceleration device configuration table.
diff --git a/drivers/crypto/qat/qat_common/adf_transport_debug.c 
b/drivers/crypto/qat/qat_common/adf_transport_debug.c
index 2a2eccbf56ec..dac25ba47260 100644
--- a/drivers/crypto/qat/qat_common/adf_transport_debug.c
+++ b/drivers/crypto/qat/qat_common/adf_transport_debug.c
@@ -77,31 +77,14 @@ static void adf_ring_stop(struct seq_file *sfile, void *v)
mutex_unlock(&ring_read_lock);
 }
 
-static const struct seq_operations adf_ring_sops = {
+static const struct seq_operations adf_ring_debug_sops = {
.start = adf_ring_start,
.next = adf_ring_next,
.stop = adf_ring_stop,
.show = adf_ring_show
 };
 
-static int adf_ring_open(struct inode *inode, struct file *file)
-{
-   int ret = seq_open(file, &adf_ring_sops);
-
-   if (!ret) {
-   struct seq_file *seq_f = file->private_data;
-
-   seq_f->private = inode->i_private;
-   }
-   return ret;
-}
-
-static const struct file_operations adf_ring_debug_fops = {
-   .open = adf_ring_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(adf_ring_debug);
 
 int adf_ring_debugfs_add(struct adf_etr_ring_data *ring, const char *name)
 {
@@ -188,31 +171,14 @@ static void adf_bank_stop(struct seq_file *sfile, void *v)
mutex_unlock(&bank_read_lock);
 }
 
-static const struct seq_operations adf_bank_sops = {
+static const struct seq_operations adf_bank_debug_sops = {
.start = adf_bank_start,
.next = adf_bank_next,
.stop = adf_bank_stop,
.show = adf_bank_show
 };
 
-static int adf_bank_open(struct inode *inode, struct file *file)
-{
-   int ret = seq_open(file, &adf_bank_sops);
-
-   if (!ret) {
-   struct seq_file *seq_f = file->private_data;
-
-   seq_f->private = inode->i_private;
-   }
-   return ret;
-}
-
-static const struct file_operations adf_bank_debug_fops = {
-   .open = adf_bank_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(adf_bank_debug);
 
 int adf_bank_debugfs_add(struct adf_etr_bank_data *bank)
 {
-- 
2.25.1



[PATCH -next] ath5k: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 drivers/net/wireless/ath/ath5k/debug.c | 25 +++--
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/debug.c 
b/drivers/net/wireless/ath/ath5k/debug.c
index 2eaba1ccab20..4b41160e5d38 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -161,33 +161,14 @@ static int reg_show(struct seq_file *seq, void *p)
return 0;
 }
 
-static const struct seq_operations register_seq_ops = {
+static const struct seq_operations registers_sops = {
.start = reg_start,
.next  = reg_next,
.stop  = reg_stop,
.show  = reg_show
 };
 
-static int open_file_registers(struct inode *inode, struct file *file)
-{
-   struct seq_file *s;
-   int res;
-   res = seq_open(file, ®ister_seq_ops);
-   if (res == 0) {
-   s = file->private_data;
-   s->private = inode->i_private;
-   }
-   return res;
-}
-
-static const struct file_operations fops_registers = {
-   .open = open_file_registers,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-   .owner = THIS_MODULE,
-};
-
+DEFINE_SEQ_ATTRIBUTE(registers);
 
 /* debugfs: beacons */
 
@@ -1005,7 +986,7 @@ ath5k_debug_init_device(struct ath5k_hw *ah)
return;
 
debugfs_create_file("debug", 0600, phydir, ah, &fops_debug);
-   debugfs_create_file("registers", 0400, phydir, ah, &fops_registers);
+   debugfs_create_file("registers", 0400, phydir, ah, ®isters_fops);
debugfs_create_file("beacon", 0600, phydir, ah, &fops_beacon);
debugfs_create_file("reset", 0200, phydir, ah, &fops_reset);
debugfs_create_file("antenna", 0600, phydir, ah, &fops_antenna);
-- 
2.25.1



[PATCH -next] gfs2: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 fs/gfs2/glock.c | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index f13b136654ca..15c5c26f6ae7 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -2415,7 +2415,7 @@ static const struct seq_operations gfs2_glstats_seq_ops = 
{
.show  = gfs2_glstats_seq_show,
 };
 
-static const struct seq_operations gfs2_sbstats_seq_ops = {
+static const struct seq_operations gfs2_sbstats_sops = {
.start = gfs2_sbstats_seq_start,
.next  = gfs2_sbstats_seq_next,
.stop  = gfs2_sbstats_seq_stop,
@@ -2468,16 +2468,6 @@ static int gfs2_glstats_open(struct inode *inode, struct 
file *file)
return __gfs2_glocks_open(inode, file, &gfs2_glstats_seq_ops);
 }
 
-static int gfs2_sbstats_open(struct inode *inode, struct file *file)
-{
-   int ret = seq_open(file, &gfs2_sbstats_seq_ops);
-   if (ret == 0) {
-   struct seq_file *seq = file->private_data;
-   seq->private = inode->i_private;  /* sdp */
-   }
-   return ret;
-}
-
 static const struct file_operations gfs2_glocks_fops = {
.owner   = THIS_MODULE,
.open= gfs2_glocks_open,
@@ -2494,13 +2484,7 @@ static const struct file_operations gfs2_glstats_fops = {
.release = gfs2_glocks_release,
 };
 
-static const struct file_operations gfs2_sbstats_fops = {
-   .owner   = THIS_MODULE,
-   .open= gfs2_sbstats_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(gfs2_sbstats);
 
 void gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
 {
-- 
2.25.1



[PATCH -next] media: saa7164: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 drivers/media/pci/saa7164/saa7164-core.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/media/pci/saa7164/saa7164-core.c 
b/drivers/media/pci/saa7164/saa7164-core.c
index 6c08b77bfd47..f3a4e575a782 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1139,32 +1139,21 @@ static int saa7164_seq_show(struct seq_file *m, void *v)
return 0;
 }
 
-static const struct seq_operations saa7164_seq_ops = {
+static const struct seq_operations saa7164_sops = {
.start = saa7164_seq_start,
.next = saa7164_seq_next,
.stop = saa7164_seq_stop,
.show = saa7164_seq_show,
 };
 
-static int saa7164_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &saa7164_seq_ops);
-}
-
-static const struct file_operations saa7164_operations = {
-   .owner  = THIS_MODULE,
-   .open   = saa7164_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(saa7164);
 
 static struct dentry *saa7614_dentry;
 
 static void __init saa7164_debugfs_create(void)
 {
saa7614_dentry = debugfs_create_file("saa7164", 0444, NULL, NULL,
-&saa7164_operations);
+&saa7164_fops);
 }
 
 static void __exit saa7164_debugfs_remove(void)
-- 
2.25.1



[PATCH -next] pwm: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 drivers/pwm/core.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 276e939a5684..1f16f5365d3c 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -1327,30 +1327,19 @@ static int pwm_seq_show(struct seq_file *s, void *v)
return 0;
 }
 
-static const struct seq_operations pwm_seq_ops = {
+static const struct seq_operations pwm_debugfs_sops = {
.start = pwm_seq_start,
.next = pwm_seq_next,
.stop = pwm_seq_stop,
.show = pwm_seq_show,
 };
 
-static int pwm_seq_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &pwm_seq_ops);
-}
-
-static const struct file_operations pwm_debugfs_ops = {
-   .owner = THIS_MODULE,
-   .open = pwm_seq_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(pwm_debugfs);
 
 static int __init pwm_debugfs_init(void)
 {
debugfs_create_file("pwm", S_IFREG | S_IRUGO, NULL, NULL,
-   &pwm_debugfs_ops);
+   &pwm_debugfs_fops);
 
return 0;
 }
-- 
2.25.1



[PATCH -next] PCI: tegra: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 drivers/pci/controller/pci-tegra.c | 28 +++-
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/controller/pci-tegra.c 
b/drivers/pci/controller/pci-tegra.c
index c1d34353c29b..556c30a718f0 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -2564,36 +2564,14 @@ static int tegra_pcie_ports_seq_show(struct seq_file 
*s, void *v)
return 0;
 }
 
-static const struct seq_operations tegra_pcie_ports_seq_ops = {
+static const struct seq_operations tegra_pcie_ports_sops = {
.start = tegra_pcie_ports_seq_start,
.next = tegra_pcie_ports_seq_next,
.stop = tegra_pcie_ports_seq_stop,
.show = tegra_pcie_ports_seq_show,
 };
 
-static int tegra_pcie_ports_open(struct inode *inode, struct file *file)
-{
-   struct tegra_pcie *pcie = inode->i_private;
-   struct seq_file *s;
-   int err;
-
-   err = seq_open(file, &tegra_pcie_ports_seq_ops);
-   if (err)
-   return err;
-
-   s = file->private_data;
-   s->private = pcie;
-
-   return 0;
-}
-
-static const struct file_operations tegra_pcie_ports_ops = {
-   .owner = THIS_MODULE,
-   .open = tegra_pcie_ports_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(tegra_pcie_ports);
 
 static void tegra_pcie_debugfs_exit(struct tegra_pcie *pcie)
 {
@@ -2610,7 +2588,7 @@ static int tegra_pcie_debugfs_init(struct tegra_pcie 
*pcie)
return -ENOMEM;
 
file = debugfs_create_file("ports", S_IFREG | S_IRUGO, pcie->debugfs,
-  pcie, &tegra_pcie_ports_ops);
+  pcie, &tegra_pcie_ports_fops);
if (!file)
goto remove;
 
-- 
2.25.1



[PATCH -next] error-injection: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 lib/error-inject.c | 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/lib/error-inject.c b/lib/error-inject.c
index aa63751c916f..a93103488fdd 100644
--- a/lib/error-inject.c
+++ b/lib/error-inject.c
@@ -194,24 +194,14 @@ static int ei_seq_show(struct seq_file *m, void *v)
return 0;
 }
 
-static const struct seq_operations ei_seq_ops = {
+static const struct seq_operations ei_sops = {
.start = ei_seq_start,
.next  = ei_seq_next,
.stop  = ei_seq_stop,
.show  = ei_seq_show,
 };
 
-static int ei_open(struct inode *inode, struct file *filp)
-{
-   return seq_open(filp, &ei_seq_ops);
-}
-
-static const struct file_operations debugfs_ei_ops = {
-   .open   = ei_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(ei);
 
 static int __init ei_debugfs_init(void)
 {
@@ -221,7 +211,7 @@ static int __init ei_debugfs_init(void)
if (!dir)
return -ENOMEM;
 
-   file = debugfs_create_file("list", 0444, dir, NULL, &debugfs_ei_ops);
+   file = debugfs_create_file("list", 0444, dir, NULL, &ei_fops);
if (!file) {
debugfs_remove(dir);
return -ENOMEM;
-- 
2.25.1



[PATCH -next] infiniband: ipoib: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 drivers/infiniband/ulp/ipoib/ipoib_fs.c | 50 ++---
 1 file changed, 4 insertions(+), 46 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c 
b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
index 64c19f6fa931..12ba7a0fe0b5 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
@@ -124,35 +124,14 @@ static int ipoib_mcg_seq_show(struct seq_file *file, void 
*iter_ptr)
return 0;
 }
 
-static const struct seq_operations ipoib_mcg_seq_ops = {
+static const struct seq_operations ipoib_mcg_sops = {
.start = ipoib_mcg_seq_start,
.next  = ipoib_mcg_seq_next,
.stop  = ipoib_mcg_seq_stop,
.show  = ipoib_mcg_seq_show,
 };
 
-static int ipoib_mcg_open(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq;
-   int ret;
-
-   ret = seq_open(file, &ipoib_mcg_seq_ops);
-   if (ret)
-   return ret;
-
-   seq = file->private_data;
-   seq->private = inode->i_private;
-
-   return 0;
-}
-
-static const struct file_operations ipoib_mcg_fops = {
-   .owner   = THIS_MODULE,
-   .open= ipoib_mcg_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(ipoib_mcg);
 
 static void *ipoib_path_seq_start(struct seq_file *file, loff_t *pos)
 {
@@ -229,35 +208,14 @@ static int ipoib_path_seq_show(struct seq_file *file, 
void *iter_ptr)
return 0;
 }
 
-static const struct seq_operations ipoib_path_seq_ops = {
+static const struct seq_operations ipoib_path_sops = {
.start = ipoib_path_seq_start,
.next  = ipoib_path_seq_next,
.stop  = ipoib_path_seq_stop,
.show  = ipoib_path_seq_show,
 };
 
-static int ipoib_path_open(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq;
-   int ret;
-
-   ret = seq_open(file, &ipoib_path_seq_ops);
-   if (ret)
-   return ret;
-
-   seq = file->private_data;
-   seq->private = inode->i_private;
-
-   return 0;
-}
-
-static const struct file_operations ipoib_path_fops = {
-   .owner   = THIS_MODULE,
-   .open= ipoib_path_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(ipoib_path);
 
 void ipoib_create_debug_files(struct net_device *dev)
 {
-- 
2.25.1



[PATCH -next] powerpc/pseries: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 arch/powerpc/platforms/pseries/hvCall_inst.c | 23 +++-
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hvCall_inst.c 
b/arch/powerpc/platforms/pseries/hvCall_inst.c
index c40c62ec432e..2c59b4986ea5 100644
--- a/arch/powerpc/platforms/pseries/hvCall_inst.c
+++ b/arch/powerpc/platforms/pseries/hvCall_inst.c
@@ -70,31 +70,14 @@ static int hc_show(struct seq_file *m, void *p)
return 0;
 }
 
-static const struct seq_operations hcall_inst_seq_ops = {
+static const struct seq_operations hcall_inst_sops = {
 .start = hc_start,
 .next  = hc_next,
 .stop  = hc_stop,
 .show  = hc_show
 };
 
-static int hcall_inst_seq_open(struct inode *inode, struct file *file)
-{
-   int rc;
-   struct seq_file *seq;
-
-   rc = seq_open(file, &hcall_inst_seq_ops);
-   seq = file->private_data;
-   seq->private = file_inode(file)->i_private;
-
-   return rc;
-}
-
-static const struct file_operations hcall_inst_seq_fops = {
-   .open = hcall_inst_seq_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(hcall_inst);
 
 #defineHCALL_ROOT_DIR  "hcall_inst"
 #define CPU_NAME_BUF_SIZE  32
@@ -149,7 +132,7 @@ static int __init hcall_inst_init(void)
snprintf(cpu_name_buf, CPU_NAME_BUF_SIZE, "cpu%d", cpu);
debugfs_create_file(cpu_name_buf, 0444, hcall_root,
per_cpu(hcall_stats, cpu),
-   &hcall_inst_seq_fops);
+   &hcall_inst_fops);
}
 
return 0;
-- 
2.25.1



[PATCH -next] dlm: convert to use DEFINE_SEQ_ATTRIBUTE macro

2020-09-15 Thread Liu Shixin
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin 
---
 fs/dlm/debug_fs.c | 104 --
 1 file changed, 8 insertions(+), 96 deletions(-)

diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index d6bbccb0ed15..c4d1860b9e41 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -571,126 +571,38 @@ static void table_seq_stop(struct seq_file *seq, void 
*iter_ptr)
}
 }
 
-static const struct seq_operations format1_seq_ops = {
+static const struct seq_operations format1_sops = {
.start = table_seq_start,
.next  = table_seq_next,
.stop  = table_seq_stop,
.show  = table_seq_show,
 };
 
-static const struct seq_operations format2_seq_ops = {
+static const struct seq_operations format2_sops = {
.start = table_seq_start,
.next  = table_seq_next,
.stop  = table_seq_stop,
.show  = table_seq_show,
 };
 
-static const struct seq_operations format3_seq_ops = {
+static const struct seq_operations format3_sops = {
.start = table_seq_start,
.next  = table_seq_next,
.stop  = table_seq_stop,
.show  = table_seq_show,
 };
 
-static const struct seq_operations format4_seq_ops = {
+static const struct seq_operations format4_sops = {
.start = table_seq_start,
.next  = table_seq_next,
.stop  = table_seq_stop,
.show  = table_seq_show,
 };
 
-static const struct file_operations format1_fops;
-static const struct file_operations format2_fops;
-static const struct file_operations format3_fops;
-static const struct file_operations format4_fops;
-
-static int table_open1(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq;
-   int ret;
-
-   ret = seq_open(file, &format1_seq_ops);
-   if (ret)
-   return ret;
-
-   seq = file->private_data;
-   seq->private = inode->i_private; /* the dlm_ls */
-   return 0;
-}
-
-static int table_open2(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq;
-   int ret;
-
-   ret = seq_open(file, &format2_seq_ops);
-   if (ret)
-   return ret;
-
-   seq = file->private_data;
-   seq->private = inode->i_private; /* the dlm_ls */
-   return 0;
-}
-
-static int table_open3(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq;
-   int ret;
-
-   ret = seq_open(file, &format3_seq_ops);
-   if (ret)
-   return ret;
-
-   seq = file->private_data;
-   seq->private = inode->i_private; /* the dlm_ls */
-   return 0;
-}
-
-static int table_open4(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq;
-   int ret;
-
-   ret = seq_open(file, &format4_seq_ops);
-   if (ret)
-   return ret;
-
-   seq = file->private_data;
-   seq->private = inode->i_private; /* the dlm_ls */
-   return 0;
-}
-
-static const struct file_operations format1_fops = {
-   .owner   = THIS_MODULE,
-   .open= table_open1,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
-
-static const struct file_operations format2_fops = {
-   .owner   = THIS_MODULE,
-   .open= table_open2,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
-
-static const struct file_operations format3_fops = {
-   .owner   = THIS_MODULE,
-   .open= table_open3,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
-
-static const struct file_operations format4_fops = {
-   .owner   = THIS_MODULE,
-   .open= table_open4,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(format1);
+DEFINE_SEQ_ATTRIBUTE(format2);
+DEFINE_SEQ_ATTRIBUTE(format3);
+DEFINE_SEQ_ATTRIBUTE(format4);
 
 /*
  * dump lkb's on the ls_waiters list
-- 
2.25.1