Browse Source

CRIS: Check if pointer is set before using it

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Jesper Nilsson 15 years ago
parent
commit
243ba2fa46
1 changed files with 12 additions and 8 deletions
  1. 12 8
      arch/cris/include/arch-v32/arch/io.h

+ 12 - 8
arch/cris/include/arch-v32/arch/io.h

@@ -46,10 +46,12 @@ static inline void crisv32_io_set(struct crisv32_iopin *iopin, int val)
 	unsigned long flags;
 	spin_lock_irqsave(&iopin->port->lock, flags);
 
-	if (val)
-		*iopin->port->data |= iopin->bit;
-	else
-		*iopin->port->data &= ~iopin->bit;
+	if (iopin->port->data) {
+		if (val)
+			*iopin->port->data |= iopin->bit;
+		else
+			*iopin->port->data &= ~iopin->bit;
+	}
 
 	spin_unlock_irqrestore(&iopin->port->lock, flags);
 }
@@ -60,10 +62,12 @@ static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
 	unsigned long flags;
 	spin_lock_irqsave(&iopin->port->lock, flags);
 
-	if (dir == crisv32_io_dir_in)
-		*iopin->port->oe &= ~iopin->bit;
-	else
-		*iopin->port->oe |= iopin->bit;
+	if (iopin->port->oe) {
+		if (dir == crisv32_io_dir_in)
+			*iopin->port->oe &= ~iopin->bit;
+		else
+			*iopin->port->oe |= iopin->bit;
+	}
 
 	spin_unlock_irqrestore(&iopin->port->lock, flags);
 }