mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux1394-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] firewire: fw-ohci: untangle a mixed unsigned/signed expression
Date: Tue, 11 Mar 2008 02:16:08 +0100 (CET)	[thread overview]
Message-ID: <tkrat.3e10d02dc42cb944@s5r6.in-berlin.de> (raw)
In-Reply-To: <tkrat.ebca3f78fa768606@s5r6.in-berlin.de>

My old C textbook says that the result of casting an unsigned to signed
is undefined if the former's value can't be represented in the latter's
type.  Maybe that book is too old...?

Anyway, this change makes it more explicit what is going on, i.e. that
p.ack is meant to become negative on some occasions.  (p.ack is an int.)
fw-ohci.s does actually not change due to 1st and 2nd hunk of this patch
(with gcc 4.1.2 i686 -O2).

The 3rd hunk makes an expression more readable.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---

applies after patch "firewire: debug AT, AR, and selfID-complete events"

 drivers/firewire/fw-ohci.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Index: linux/drivers/firewire/fw-ohci.c
===================================================================
--- linux.orig/drivers/firewire/fw-ohci.c
+++ linux/drivers/firewire/fw-ohci.c
@@ -421,6 +421,7 @@ static __le32 *handle_ar_packet(struct a
 	struct fw_ohci *ohci = ctx->ohci;
 	struct fw_packet p;
 	u32 status, length, tcode;
+	int evt;
 
 	p.header[0] = cond_le32_to_cpu(buffer[0]);
 	p.header[1] = cond_le32_to_cpu(buffer[1]);
@@ -464,13 +465,14 @@ static __le32 *handle_ar_packet(struct a
 	length = (p.header_length + p.payload_length + 3) / 4;
 	status = cond_le32_to_cpu(buffer[length]);
 
-	p.ack        = ((status >> 16) & 0x1f) - 16;
+	evt          = (status >> 16) & 0x1f;
+	p.ack        = evt - 16;
 	p.speed      = (status >> 21) & 0x7;
 	p.timestamp  = status & 0xffff;
 	p.generation = ohci->request_generation;
 
 	if (unlikely(param_debug & OHCI_PARAM_DEBUG_AT_AR))
-		debug_ar_at_event('R', p.speed, p.header, status >> 16 & 0x1f);
+		debug_ar_at_event('R', p.speed, p.header, evt);
 
 	/*
 	 * The OHCI bus reset handler synthesizes a phy packet with
@@ -482,7 +484,7 @@ static __le32 *handle_ar_packet(struct a
 	 * request.
 	 */
 
-	if (p.ack + 16 == 0x09)
+	if (evt == OHCI1394_evt_bus_reset)
 		ohci->request_generation = (p.header[2] >> 16) & 0xff;
 	else if (ctx == &ohci->ar_request_ctx)
 		fw_core_handle_request(&ohci->card, &p);

-- 
Stefan Richter
-=====-==--- --== -=-==
http://arcgraph.de/sr/



  reply	other threads:[~2008-03-11  1:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-09 20:49 [PATCH] firewire: debug AT, AR, and selfID-complete events Stefan Richter
2008-03-10  4:47 ` Jarod Wilson
2008-03-10 22:28   ` [PATCH update] " Stefan Richter
2008-03-11  1:16     ` Stefan Richter [this message]
2008-03-12  9:15     ` Stefan Richter
2008-03-12 14:34       ` Jarod Wilson
2008-03-12 16:01         ` Stefan Richter
2008-03-15  1:57           ` Jarod Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tkrat.3e10d02dc42cb944@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome