From patchwork Mon Apr 19 07:35:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave X-Patchwork-Id: 93428 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3J7a2Jh025324 for ; Mon, 19 Apr 2010 07:36:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752034Ab0DSHfx (ORCPT ); Mon, 19 Apr 2010 03:35:53 -0400 Received: from mail-ww0-f46.google.com ([74.125.82.46]:34085 "EHLO mail-ww0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752051Ab0DSHfw (ORCPT ); Mon, 19 Apr 2010 03:35:52 -0400 Received: by mail-ww0-f46.google.com with SMTP id 24so2319543wwb.19 for ; Mon, 19 Apr 2010 00:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:received:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=UEgzhpp58ROQ7h2EIzHJjbjwQQJUzjbxvDk0rsE96A8=; b=bfCTZeCoF2OFdn6S2TjyZms4Gs5D30XthwgWXinoWLvCdPr06NE18z8D/Hf9T09Y/J 4cwE+48fyX9X/qXrvq0Liae2d5QajSj8CA1f5ZWQ+5CW3u9XCVbeUj96ringtaPI49D7 Cbyjjuu9p5UssZYypnXxFmY/q0fUOx5Sgn3n8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=ZeG/C4dfVmGHHkF8K7vFMGXy08JgqSI5fEo4f0wQJ5evs4jNGDt8/dC7PUoTC9VnZm KNrK1IHc6UinLEhwWJkZ6B8LIj00QzDe250RLd7feC23Cy9msw48ezsVXiR6uLN1wSQC ZzYSqKm404yhryBXB6QlwTh8gLukz8tAtGvdY= Received: by 10.216.178.148 with SMTP id f20mr3796333wem.43.1271662551494; Mon, 19 Apr 2010 00:35:51 -0700 (PDT) Received: from borken (5e01228a.bb.sky.com [94.1.34.138]) by mx.google.com with ESMTPS id z3sm46485768wbs.22.2010.04.19.00.35.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 19 Apr 2010 00:35:51 -0700 (PDT) Received: by borken (sSMTP sendmail emulation); Mon, 19 Apr 2010 08:35:53 +0100 From: David Kilroy To: linux-wireless@vger.kernel.org Cc: orinoco-devel@lists.sourceforge.net, David Kilroy Subject: [RFC 3/5] orinoco: encapsulate driver locking Date: Mon, 19 Apr 2010 08:35:20 +0100 Message-Id: <1271662522-29119-4-git-send-email-kilroyd@googlemail.com> X-Mailer: git-send-email 1.6.4.4 In-Reply-To: <1271662522-29119-1-git-send-email-kilroyd@googlemail.com> References: <1271662522-29119-1-git-send-email-kilroyd@googlemail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 19 Apr 2010 07:36:44 +0000 (UTC) diff --git a/drivers/net/wireless/orinoco/hermes.c b/drivers/net/wireless/orinoco/hermes.c index a7df524..6448366 100644 --- a/drivers/net/wireless/orinoco/hermes.c +++ b/drivers/net/wireless/orinoco/hermes.c @@ -529,6 +529,26 @@ static int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, return err; } +void hermes_lock_irqsave(spinlock_t *lock, unsigned long *flags) +{ + spin_lock_irqsave(lock, *flags); +} + +void hermes_unlock_irqrestore(spinlock_t *lock, unsigned long *flags) +{ + spin_unlock_irqrestore(lock, *flags); +} + +void hermes_lock_irq(spinlock_t *lock) +{ + spin_lock_irq(lock); +} + +void hermes_unlock_irq(spinlock_t *lock) +{ + spin_unlock_irq(lock); +} + /* Hermes operations for local buses */ static const struct hermes_ops hermes_ops_local = { .init = hermes_init, @@ -538,5 +558,9 @@ static const struct hermes_ops hermes_ops_local = { .read_ltv = hermes_read_ltv, .write_ltv = hermes_write_ltv, .bap_pread = hermes_bap_pread, - .bap_pwrite = hermes_bap_pwrite + .bap_pwrite = hermes_bap_pwrite, + .lock_irqsave = hermes_lock_irqsave, + .unlock_irqrestore = hermes_unlock_irqrestore, + .lock_irq = hermes_lock_irq, + .unlock_irq = hermes_unlock_irq, }; diff --git a/drivers/net/wireless/orinoco/hermes.h b/drivers/net/wireless/orinoco/hermes.h index 18b268c..9e21ecd 100644 --- a/drivers/net/wireless/orinoco/hermes.h +++ b/drivers/net/wireless/orinoco/hermes.h @@ -393,6 +393,10 @@ struct hermes_ops { u16 id, u16 offset); int (*bap_pwrite)(struct hermes *hw, int bap, const void *buf, int len, u16 id, u16 offset); + void (*lock_irqsave)(spinlock_t *lock, unsigned long *flags); + void (*unlock_irqrestore)(spinlock_t *lock, unsigned long *flags); + void (*lock_irq)(spinlock_t *lock); + void (*unlock_irq)(spinlock_t *lock); }; /* Basic control structure */ diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c index 9dc458d..9485da2 100644 --- a/drivers/net/wireless/orinoco/main.c +++ b/drivers/net/wireless/orinoco/main.c @@ -282,13 +282,13 @@ int orinoco_stop(struct net_device *dev) /* We mustn't use orinoco_lock() here, because we need to be able to close the interface even if hw_unavailable is set (e.g. as we're released after a PC Card removal) */ - spin_lock_irq(&priv->lock); + orinoco_lock_irq(priv); priv->open = 0; err = __orinoco_down(priv); - spin_unlock_irq(&priv->lock); + orinoco_unlock_irq(priv); return err; } @@ -1742,7 +1742,7 @@ void orinoco_reset(struct work_struct *work) } /* This has to be called from user context */ - spin_lock_irq(&priv->lock); + orinoco_lock_irq(priv); priv->hw_unavailable--; @@ -1757,7 +1757,7 @@ void orinoco_reset(struct work_struct *work) dev->trans_start = jiffies; } - spin_unlock_irq(&priv->lock); + orinoco_unlock_irq(priv); return; disable: @@ -2074,9 +2074,9 @@ int orinoco_init(struct orinoco_private *priv) /* Make the hardware available, as long as it hasn't been * removed elsewhere (e.g. by PCMCIA hot unplug) */ - spin_lock_irq(&priv->lock); + orinoco_lock_irq(priv); priv->hw_unavailable--; - spin_unlock_irq(&priv->lock); + orinoco_unlock_irq(priv); dev_dbg(dev, "Ready\n"); diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h index f1901d6..80a1386 100644 --- a/drivers/net/wireless/orinoco/orinoco.h +++ b/drivers/net/wireless/orinoco/orinoco.h @@ -212,11 +212,11 @@ void orinoco_tx_timeout(struct net_device *dev); static inline int orinoco_lock(struct orinoco_private *priv, unsigned long *flags) { - spin_lock_irqsave(&priv->lock, *flags); + priv->hw.ops->lock_irqsave(&priv->lock, flags); if (priv->hw_unavailable) { DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n", priv->ndev); - spin_unlock_irqrestore(&priv->lock, *flags); + priv->hw.ops->unlock_irqrestore(&priv->lock, flags); return -EBUSY; } return 0; @@ -225,7 +225,17 @@ static inline int orinoco_lock(struct orinoco_private *priv, static inline void orinoco_unlock(struct orinoco_private *priv, unsigned long *flags) { - spin_unlock_irqrestore(&priv->lock, *flags); + priv->hw.ops->unlock_irqrestore(&priv->lock, flags); +} + +static inline void orinoco_lock_irq(struct orinoco_private *priv) +{ + priv->hw.ops->lock_irq(&priv->lock); +} + +static inline void orinoco_unlock_irq(struct orinoco_private *priv) +{ + priv->hw.ops->unlock_irq(&priv->lock); } /*** Navigate from net_device to orinoco_private ***/