Commit a7ec7e40 authored by Alessandro Rubini's avatar Alessandro Rubini

wr_nic: use_count only if WR_IS_SWITCH

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c4675c82
......@@ -30,9 +30,11 @@ static int wrn_remove(struct platform_device *pdev)
struct wrn_dev *wrn = pdev->dev.platform_data;
int i;
spin_lock(&wrn->lock);
--wrn->use_count; /* Hmmm... looks like overkill... */
spin_unlock(&wrn->lock);
if (WR_IS_SWITCH) {
spin_lock(&wrn->lock);
--wrn->use_count; /* Hmmm... looks like overkill... */
spin_unlock(&wrn->lock);
}
/* First of all, stop any transmission */
writel(0, &wrn->regs->CR);
......@@ -104,13 +106,15 @@ static int __devinit wrn_probe(struct platform_device *pdev)
static irq_handler_t irq_handlers[] = WRN_IRQ_HANDLERS;
/* No need to lock_irq: we only protect count and continue unlocked */
spin_lock(&wrn->lock);
if (++wrn->use_count != 1) {
--wrn->use_count;
if (WR_IS_SWITCH) {
spin_lock(&wrn->lock);
if (++wrn->use_count != 1) {
--wrn->use_count;
spin_unlock(&wrn->lock);
return -EBUSY;
}
spin_unlock(&wrn->lock);
return -EBUSY;
}
spin_unlock(&wrn->lock);
/* Map our resource list and instantiate the shortcut pointers */
if ( (err = __wrn_map_resources(pdev)) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment