All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] usb: xhci: fix of some code/comment
@ 2022-02-16  6:59 Linyu Yuan
  2022-02-16  6:59 ` [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init() Linyu Yuan
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Linyu Yuan @ 2022-02-16  6:59 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Jack Pham, Linyu Yuan

Only samll change, no description here.

Linyu Yuan (5):
  usb: host: xhci: use ffs() in xhci_mem_init()
  usb: host: xhci: fix a comment typo in xhci_mem_init()
  usb: host: xhci: update hci_version operation in xhci_gen_setup()
  usb: host: xhci: add blank line in xhci_halt()
  usb: host: xhci: remove init to some ret/retval

 drivers/usb/host/xhci-mem.c |  9 ++-------
 drivers/usb/host/xhci.c     | 14 ++++++++------
 2 files changed, 10 insertions(+), 13 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
  2022-02-16  6:59 [PATCH 0/5] usb: xhci: fix of some code/comment Linyu Yuan
@ 2022-02-16  6:59 ` Linyu Yuan
  2022-02-16  9:41   ` Sergei Shtylyov
  2022-02-16  6:59 ` [PATCH 2/5] usb: host: xhci: fix a comment typo " Linyu Yuan
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Linyu Yuan @ 2022-02-16  6:59 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Jack Pham, Linyu Yuan

The for loop to find page size bit can be replaced with ffs().

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/host/xhci-mem.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 0e31206..3cbc7f2 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2395,12 +2395,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 	page_size = readl(&xhci->op_regs->page_size);
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"Supported page size register = 0x%x", page_size);
-	for (i = 0; i < 16; i++) {
-		if ((0x1 & page_size) != 0)
-			break;
-		page_size = page_size >> 1;
-	}
-	if (i < 16)
+	if ((i = ffs(page_size)) < 16)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"Supported page size of %iK", (1 << (i+12)) / 1024);
 	else
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/5] usb: host: xhci: fix a comment typo in xhci_mem_init()
  2022-02-16  6:59 [PATCH 0/5] usb: xhci: fix of some code/comment Linyu Yuan
  2022-02-16  6:59 ` [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init() Linyu Yuan
@ 2022-02-16  6:59 ` Linyu Yuan
  2022-02-16  6:59 ` [PATCH 3/5] usb: host: xhci: update hci_version operation in xhci_gen_setup() Linyu Yuan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Linyu Yuan @ 2022-02-16  6:59 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Jack Pham, Linyu Yuan

It should be Device Context, not doorbell.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/host/xhci-mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 3cbc7f2..a255fe5 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2420,7 +2420,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 	writel(val, &xhci->op_regs->config_reg);
 
 	/*
-	 * xHCI section 5.4.6 - doorbell array must be
+	 * xHCI section 5.4.6 - Device Context array must be
 	 * "physically contiguous and 64-byte (cache line) aligned".
 	 */
 	xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/5] usb: host: xhci: update hci_version operation in xhci_gen_setup()
  2022-02-16  6:59 [PATCH 0/5] usb: xhci: fix of some code/comment Linyu Yuan
  2022-02-16  6:59 ` [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init() Linyu Yuan
  2022-02-16  6:59 ` [PATCH 2/5] usb: host: xhci: fix a comment typo " Linyu Yuan
@ 2022-02-16  6:59 ` Linyu Yuan
  2022-02-16  6:59 ` [PATCH 4/5] usb: host: xhci: add blank line in xhci_halt() Linyu Yuan
  2022-02-16  6:59 ` [PATCH 5/5] usb: host: xhci: remove init to some ret/retval Linyu Yuan
  4 siblings, 0 replies; 12+ messages in thread
From: Linyu Yuan @ 2022-02-16  6:59 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Jack Pham, Linyu Yuan

There is no need to store temperary value in hcc_params.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/host/xhci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index dc357ca..857a9c6 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -5280,8 +5280,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
 	xhci->hcs_params1 = readl(&xhci->cap_regs->hcs_params1);
 	xhci->hcs_params2 = readl(&xhci->cap_regs->hcs_params2);
 	xhci->hcs_params3 = readl(&xhci->cap_regs->hcs_params3);
-	xhci->hcc_params = readl(&xhci->cap_regs->hc_capbase);
-	xhci->hci_version = HC_VERSION(xhci->hcc_params);
+	xhci->hci_version = HC_VERSION(readl(&xhci->cap_regs->hc_capbase));
 	xhci->hcc_params = readl(&xhci->cap_regs->hcc_params);
 	if (xhci->hci_version > 0x100)
 		xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/5] usb: host: xhci: add blank line in xhci_halt()
  2022-02-16  6:59 [PATCH 0/5] usb: xhci: fix of some code/comment Linyu Yuan
                   ` (2 preceding siblings ...)
  2022-02-16  6:59 ` [PATCH 3/5] usb: host: xhci: update hci_version operation in xhci_gen_setup() Linyu Yuan
@ 2022-02-16  6:59 ` Linyu Yuan
  2022-02-16  6:59 ` [PATCH 5/5] usb: host: xhci: remove init to some ret/retval Linyu Yuan
  4 siblings, 0 replies; 12+ messages in thread
From: Linyu Yuan @ 2022-02-16  6:59 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Jack Pham, Linyu Yuan

It is more readable to add blank lines.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/host/xhci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 857a9c6..8b6f1a7 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -110,6 +110,7 @@ void xhci_quiesce(struct xhci_hcd *xhci)
 int xhci_halt(struct xhci_hcd *xhci)
 {
 	int ret;
+
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Halt the HC");
 	xhci_quiesce(xhci);
 
@@ -119,8 +120,10 @@ int xhci_halt(struct xhci_hcd *xhci)
 		xhci_warn(xhci, "Host halt failed, %d\n", ret);
 		return ret;
 	}
+
 	xhci->xhc_state |= XHCI_STATE_HALTED;
 	xhci->cmd_ring_state = CMD_RING_STATE_STOPPED;
+
 	return ret;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/5] usb: host: xhci: remove init to some ret/retval
  2022-02-16  6:59 [PATCH 0/5] usb: xhci: fix of some code/comment Linyu Yuan
                   ` (3 preceding siblings ...)
  2022-02-16  6:59 ` [PATCH 4/5] usb: host: xhci: add blank line in xhci_halt() Linyu Yuan
@ 2022-02-16  6:59 ` Linyu Yuan
  4 siblings, 0 replies; 12+ messages in thread
From: Linyu Yuan @ 2022-02-16  6:59 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Jack Pham, Linyu Yuan

The ret/retval will be set when it used, no need to init at definition.

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/host/xhci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8b6f1a7..b37735e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -327,7 +327,7 @@ static int xhci_setup_msi(struct xhci_hcd *xhci)
  */
 static int xhci_setup_msix(struct xhci_hcd *xhci)
 {
-	int i, ret = 0;
+	int i, ret;
 	struct usb_hcd *hcd = xhci_to_hcd(xhci);
 	struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
 
@@ -581,7 +581,7 @@ static int xhci_all_ports_seen_u0(struct xhci_hcd *xhci)
 static int xhci_init(struct usb_hcd *hcd)
 {
 	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-	int retval = 0;
+	int retval;
 
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_init");
 	spin_lock_init(&xhci->lock);
@@ -3971,7 +3971,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)
 	struct xhci_command *command;
 	unsigned long flags;
 	u32 state;
-	int ret = 0;
+	int ret;
 
 	command = xhci_alloc_command(xhci, true, GFP_KERNEL);
 	if (!command)
@@ -4007,7 +4007,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)
 
 	xhci_free_command(xhci, command);
 
-	return ret;
+	return 0;
 }
 
 /*
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
  2022-02-16  6:59 ` [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init() Linyu Yuan
@ 2022-02-16  9:41   ` Sergei Shtylyov
  2022-02-16  9:47     ` Linyu Yuan (QUIC)
  0 siblings, 1 reply; 12+ messages in thread
From: Sergei Shtylyov @ 2022-02-16  9:41 UTC (permalink / raw)
  To: Linyu Yuan, Mathias Nyman, Greg Kroah-Hartman; +Cc: linux-usb, Jack Pham

Hello!

On 2/16/22 9:59 AM, Linyu Yuan wrote:

> The for loop to find page size bit can be replaced with ffs().
> 
> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
>  drivers/usb/host/xhci-mem.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 0e31206..3cbc7f2 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -2395,12 +2395,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
>  	page_size = readl(&xhci->op_regs->page_size);
>  	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
>  			"Supported page size register = 0x%x", page_size);
> -	for (i = 0; i < 16; i++) {
> -		if ((0x1 & page_size) != 0)
> -			break;
> -		page_size = page_size >> 1;
> -	}
> -	if (i < 16)
> +	if ((i = ffs(page_size)) < 16)

   Always run your patches thru scripts/checkpatch.pl -- in this case it will complain
of an assignment in the *if* expression...

[...]

MNR, Sergey

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
  2022-02-16  9:41   ` Sergei Shtylyov
@ 2022-02-16  9:47     ` Linyu Yuan (QUIC)
  2022-02-16  9:53       ` Sergei Shtylyov
  0 siblings, 1 reply; 12+ messages in thread
From: Linyu Yuan (QUIC) @ 2022-02-16  9:47 UTC (permalink / raw)
  To: Sergei Shtylyov, Linyu Yuan (QUIC), Mathias Nyman, Greg Kroah-Hartman
  Cc: linux-usb, Jack Pham (QUIC)

Thanks,
that's correct,  from my view, one line is good,

What's your suggestion ? two lines ?

-----Original Message-----
From: Sergei Shtylyov <sergei.shtylyov@gmail.com> 
Sent: Wednesday, February 16, 2022 5:42 PM
To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>; Mathias Nyman <mathias.nyman@intel.com>; Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org; Jack Pham (QUIC) <quic_jackp@quicinc.com>
Subject: Re: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()

Hello!

On 2/16/22 9:59 AM, Linyu Yuan wrote:

> The for loop to find page size bit can be replaced with ffs().
> 
> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
>  drivers/usb/host/xhci-mem.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 0e31206..3cbc7f2 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -2395,12 +2395,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
>  	page_size = readl(&xhci->op_regs->page_size);
>  	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
>  			"Supported page size register = 0x%x", page_size);
> -	for (i = 0; i < 16; i++) {
> -		if ((0x1 & page_size) != 0)
> -			break;
> -		page_size = page_size >> 1;
> -	}
> -	if (i < 16)
> +	if ((i = ffs(page_size)) < 16)

   Always run your patches thru scripts/checkpatch.pl -- in this case it will complain
of an assignment in the *if* expression...

[...]

MNR, Sergey

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
  2022-02-16  9:47     ` Linyu Yuan (QUIC)
@ 2022-02-16  9:53       ` Sergei Shtylyov
  2022-02-16  9:57         ` Linyu Yuan (QUIC)
  0 siblings, 1 reply; 12+ messages in thread
From: Sergei Shtylyov @ 2022-02-16  9:53 UTC (permalink / raw)
  To: Linyu Yuan (QUIC), Mathias Nyman, Greg Kroah-Hartman
  Cc: linux-usb, Jack Pham (QUIC)

On 2/16/22 12:47 PM, Linyu Yuan (QUIC) wrote:

> that's correct,  from my view, one line is good,
> 
> What's your suggestion ? two lines ?

   Yes, and it is not just my suggestion -- it's the kernel coding style.

[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
  2022-02-16  9:53       ` Sergei Shtylyov
@ 2022-02-16  9:57         ` Linyu Yuan (QUIC)
  2022-02-16 10:11           ` Sergei Shtylyov
  2022-02-16 10:34           ` Greg Kroah-Hartman
  0 siblings, 2 replies; 12+ messages in thread
From: Linyu Yuan (QUIC) @ 2022-02-16  9:57 UTC (permalink / raw)
  To: Sergei Shtylyov, Linyu Yuan (QUIC), Mathias Nyman, Greg Kroah-Hartman
  Cc: linux-usb, Jack Pham (QUIC)

> From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
> Sent: Wednesday, February 16, 2022 5:53 PM
> To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>; Mathias Nyman
> <mathias.nyman@intel.com>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>
> Cc: linux-usb@vger.kernel.org; Jack Pham (QUIC) <quic_jackp@quicinc.com>
> Subject: Re: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
> 
> On 2/16/22 12:47 PM, Linyu Yuan (QUIC) wrote:
> 
> > that's correct,  from my view, one line is good,
> >
> > What's your suggestion ? two lines ?
> 
>    Yes, and it is not just my suggestion -- it's the kernel coding style.
I think in linux, there are many code like this,

arch/m68k/sun3x/dvma.c:         if((pmd = pmd_alloc(&init_mm, pud, vaddr)) == NULL) {
...

Two lines here is not good.
> 
> [...]
> 
> MBR, Sergey

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
  2022-02-16  9:57         ` Linyu Yuan (QUIC)
@ 2022-02-16 10:11           ` Sergei Shtylyov
  2022-02-16 10:34           ` Greg Kroah-Hartman
  1 sibling, 0 replies; 12+ messages in thread
From: Sergei Shtylyov @ 2022-02-16 10:11 UTC (permalink / raw)
  To: Linyu Yuan (QUIC), Mathias Nyman, Greg Kroah-Hartman
  Cc: linux-usb, Jack Pham (QUIC)

On 2/16/22 12:57 PM, Linyu Yuan (QUIC) wrote:

[...]

>>> that's correct,  from my view, one line is good,
>>>
>>> What's your suggestion ? two lines ?
>>
>>    Yes, and it is not just my suggestion -- it's the kernel coding style.
> I think in linux, there are many code like this,
> 
> arch/m68k/sun3x/dvma.c:         if((pmd = pmd_alloc(&init_mm, pud, vaddr)) == NULL) {
> ...
> 
> Two lines here is not good.

   Why?! 8-)

>> [...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
  2022-02-16  9:57         ` Linyu Yuan (QUIC)
  2022-02-16 10:11           ` Sergei Shtylyov
@ 2022-02-16 10:34           ` Greg Kroah-Hartman
  1 sibling, 0 replies; 12+ messages in thread
From: Greg Kroah-Hartman @ 2022-02-16 10:34 UTC (permalink / raw)
  To: Linyu Yuan (QUIC)
  Cc: Sergei Shtylyov, Mathias Nyman, linux-usb, Jack Pham (QUIC)

On Wed, Feb 16, 2022 at 09:57:04AM +0000, Linyu Yuan (QUIC) wrote:
> > From: Sergei Shtylyov <sergei.shtylyov@gmail.com>
> > Sent: Wednesday, February 16, 2022 5:53 PM
> > To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>; Mathias Nyman
> > <mathias.nyman@intel.com>; Greg Kroah-Hartman
> > <gregkh@linuxfoundation.org>
> > Cc: linux-usb@vger.kernel.org; Jack Pham (QUIC) <quic_jackp@quicinc.com>
> > Subject: Re: [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init()
> > 
> > On 2/16/22 12:47 PM, Linyu Yuan (QUIC) wrote:
> > 
> > > that's correct,  from my view, one line is good,
> > >
> > > What's your suggestion ? two lines ?
> > 
> >    Yes, and it is not just my suggestion -- it's the kernel coding style.
> I think in linux, there are many code like this,
> 
> arch/m68k/sun3x/dvma.c:         if((pmd = pmd_alloc(&init_mm, pud, vaddr)) == NULL) {
> ...

That file pre-dates the use of the kernel coding style.  Please look at
modern code (i.e. written in the last 15 years.)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-02-16 10:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16  6:59 [PATCH 0/5] usb: xhci: fix of some code/comment Linyu Yuan
2022-02-16  6:59 ` [PATCH 1/5] usb: host: xhci: use ffs() in xhci_mem_init() Linyu Yuan
2022-02-16  9:41   ` Sergei Shtylyov
2022-02-16  9:47     ` Linyu Yuan (QUIC)
2022-02-16  9:53       ` Sergei Shtylyov
2022-02-16  9:57         ` Linyu Yuan (QUIC)
2022-02-16 10:11           ` Sergei Shtylyov
2022-02-16 10:34           ` Greg Kroah-Hartman
2022-02-16  6:59 ` [PATCH 2/5] usb: host: xhci: fix a comment typo " Linyu Yuan
2022-02-16  6:59 ` [PATCH 3/5] usb: host: xhci: update hci_version operation in xhci_gen_setup() Linyu Yuan
2022-02-16  6:59 ` [PATCH 4/5] usb: host: xhci: add blank line in xhci_halt() Linyu Yuan
2022-02-16  6:59 ` [PATCH 5/5] usb: host: xhci: remove init to some ret/retval Linyu Yuan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.