All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] SPARC/LEON: added support for selecting Timer Core and Timer within core
@ 2016-07-13 13:38 Dan Carpenter
  2016-11-24 12:19 ` Dan Carpenter
  2016-11-24 13:33 ` Daniel Hellstrom
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2016-07-13 13:38 UTC (permalink / raw)
  To: sparclinux

Hello Daniel Hellstrom,

The patch 2791c1a43900: "SPARC/LEON: added support for selecting
Timer Core and Timer within core" from Jan 4, 2011, leads to the
following static checker warning:

	arch/sparc/kernel/leon_kernel.c:368 leon_init_timers()
	warn: continue to end of do { ... } while(0) loop.

arch/sparc/kernel/leon_kernel.c
   350          /* Find GPTIMER Timer Registers base address otherwise bail out. */
   351          nnp = rootnp;

I think the intent was to jump back to here.

   352          do {
   353                  np = of_find_node_by_name(nnp, "GAISLER_GPTIMER");
   354                  if (!np) {
   355                          np = of_find_node_by_name(nnp, "01_011");
   356                          if (!np)
   357                                  goto bad;
   358                  }
   359  
   360                  ampopts = 0;
   361                  pp = of_find_property(np, "ampopts", &len);
   362                  if (pp) {
   363                          ampopts = *(int *)pp->value;
   364                          if (ampopts = 0) {
   365                                  /* Skip this instance, resource already
   366                                   * allocated by other OS */
   367                                  nnp = np;
   368                                  continue;

But the continue actually jumps down to the end of the loop like a break
would.

   369                          }
   370                  }
   371  
   372                  /* Select Timer-Instance on Timer Core. Default is zero */
   373                  leon3_gptimer_idx = ampopts & 0x7;
   374  
   375                  pp = of_find_property(np, "reg", &len);
   376                  if (pp)
   377                          leon3_gptimer_regs = *(struct leon3_gptimer_regs_map **)
   378                                                  pp->value;
   379                  pp = of_find_property(np, "interrupts", &len);
   380                  if (pp)
   381                          leon3_gptimer_irq = *(unsigned int *)pp->value;
   382          } while (0);
   383  

We jump to here instead.  Either way, it would probably be best to get
rid of the loop entirely and use a label and a goto.

   384          if (!(leon3_gptimer_regs && leon3_irqctrl_regs && leon3_gptimer_irq))
   385                  goto bad;

regards,
dan carpenter

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

* [bug report] SPARC/LEON: added support for selecting Timer Core and Timer within core
  2016-07-13 13:38 [bug report] SPARC/LEON: added support for selecting Timer Core and Timer within core Dan Carpenter
@ 2016-11-24 12:19 ` Dan Carpenter
  2016-11-24 13:33 ` Daniel Hellstrom
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2016-11-24 12:19 UTC (permalink / raw)
  To: sparclinux

Hello Daniel Hellstrom,

The patch 2791c1a43900: "SPARC/LEON: added support for selecting
Timer Core and Timer within core" from Jan 4, 2011, leads to the
following static checker warning:

	arch/sparc/kernel/leon_kernel.c:368 leon_init_timers()
	warn: continue to end of do { ... } while(0); loop

arch/sparc/kernel/leon_kernel.c
   350          /* Find GPTIMER Timer Registers base address otherwise bail out. */
   351          nnp = rootnp;
   352          do {
   353                  np = of_find_node_by_name(nnp, "GAISLER_GPTIMER");
   354                  if (!np) {
   355                          np = of_find_node_by_name(nnp, "01_011");
   356                          if (!np)
   357                                  goto bad;
   358                  }
   359  
   360                  ampopts = 0;
   361                  pp = of_find_property(np, "ampopts", &len);
   362                  if (pp) {
   363                          ampopts = *(int *)pp->value;
   364                          if (ampopts = 0) {
   365                                  /* Skip this instance, resource already
   366                                   * allocated by other OS */
   367                                  nnp = np;
   368                                  continue;

"continue" and "break" mean the same thing here.  Please use break, if
that's what was intended.

   369                          }
   370                  }
   371  
   372                  /* Select Timer-Instance on Timer Core. Default is zero */
   373                  leon3_gptimer_idx = ampopts & 0x7;
   374  
   375                  pp = of_find_property(np, "reg", &len);
   376                  if (pp)
   377                          leon3_gptimer_regs = *(struct leon3_gptimer_regs_map **)
   378                                                  pp->value;
   379                  pp = of_find_property(np, "interrupts", &len);
   380                  if (pp)
   381                          leon3_gptimer_irq = *(unsigned int *)pp->value;
   382          } while (0);

regards,
dan carpenter

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

* Re: [bug report] SPARC/LEON: added support for selecting Timer Core and Timer within core
  2016-07-13 13:38 [bug report] SPARC/LEON: added support for selecting Timer Core and Timer within core Dan Carpenter
  2016-11-24 12:19 ` Dan Carpenter
@ 2016-11-24 13:33 ` Daniel Hellstrom
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Hellstrom @ 2016-11-24 13:33 UTC (permalink / raw)
  To: sparclinux

Hello Dan,

Thanks for your email. By reading the code I think "break" was not the 
intension, rather to restart from "do {" the timer instance "ampopts" 
property is 0. The purpose was to scan for the next GPTIMER instance, 
therefore nnp is set to np.

Best Regards,

Daniel Hellstrom
Software Section Head
Cobham Gaisler
T : +46 (0) 31 775 8657
F : +46 (0) 31 421407
daniel.hellstrom@gaisler.com

Cobham Gaisler AB, Kungsgatan 12, SE-411 19, GÖTEBORG, Sweden.
+46 (0) 31 775 8650, www.cobham.com/gaisler

Please consider the environment before printing this email

This e-mail and any files transmitted with it ("E-mail") is intended solely for the addressee(s) and may contain confidential and/or legally privileged information. If you are not the addressee(s), any disclosure,
reproduction, copying, distribution or other use of the E-mail is prohibited. If you have received this E-mail in error, please delete it and notify the sender immediately via our switchboard or return e-mail.

Neither the company nor any subsidiary or affiliate or associated company nor any individual sending this Email accepts any liability in respect of the content (including errors and omissions) nor shall this e-mail be deemed to enter the company or any subsidiary or affiliate or associated company into a contract or to create any legally binding obligations unless expressly agreed to in writing under separate cover and timeliness of the E-mail which arise as a result of transmission. If verification is required, please request a hard copy version from the sender.

On 2016-11-24 13:19, Dan Carpenter wrote:
> Hello Daniel Hellstrom,
>
> The patch 2791c1a43900: "SPARC/LEON: added support for selecting
> Timer Core and Timer within core" from Jan 4, 2011, leads to the
> following static checker warning:
>
> 	arch/sparc/kernel/leon_kernel.c:368 leon_init_timers()
> 	warn: continue to end of do { ... } while(0); loop
>
> arch/sparc/kernel/leon_kernel.c
>     350          /* Find GPTIMER Timer Registers base address otherwise bail out. */
>     351          nnp = rootnp;
>     352          do {
>     353                  np = of_find_node_by_name(nnp, "GAISLER_GPTIMER");
>     354                  if (!np) {
>     355                          np = of_find_node_by_name(nnp, "01_011");
>     356                          if (!np)
>     357                                  goto bad;
>     358                  }
>     359
>     360                  ampopts = 0;
>     361                  pp = of_find_property(np, "ampopts", &len);
>     362                  if (pp) {
>     363                          ampopts = *(int *)pp->value;
>     364                          if (ampopts = 0) {
>     365                                  /* Skip this instance, resource already
>     366                                   * allocated by other OS */
>     367                                  nnp = np;
>     368                                  continue;
>
> "continue" and "break" mean the same thing here.  Please use break, if
> that's what was intended.
>
>     369                          }
>     370                  }
>     371
>     372                  /* Select Timer-Instance on Timer Core. Default is zero */
>     373                  leon3_gptimer_idx = ampopts & 0x7;
>     374
>     375                  pp = of_find_property(np, "reg", &len);
>     376                  if (pp)
>     377                          leon3_gptimer_regs = *(struct leon3_gptimer_regs_map **)
>     378                                                  pp->value;
>     379                  pp = of_find_property(np, "interrupts", &len);
>     380                  if (pp)
>     381                          leon3_gptimer_irq = *(unsigned int *)pp->value;
>     382          } while (0);
>
> regards,
> dan carpenter


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

end of thread, other threads:[~2016-11-24 13:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-13 13:38 [bug report] SPARC/LEON: added support for selecting Timer Core and Timer within core Dan Carpenter
2016-11-24 12:19 ` Dan Carpenter
2016-11-24 13:33 ` Daniel Hellstrom

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.