Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53404
b: refs/heads/master
c: 9575499
h: refs/heads/master
v: v3
  • Loading branch information
Helge Deller authored and Dmitry Torokhov committed Mar 16, 2007
1 parent 5360ebd commit 20a0421
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5a90e5bca96696f1daa0bb0a9db299eb40241ada
refs/heads/master: 9575499dfebc0f0fbbf122223f02e9e92630661d
2 changes: 2 additions & 0 deletions trunk/drivers/input/serio/hil_mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,9 @@ static int hilse_donode(hil_mlc *mlc)
break;

case HILSE_CTS:
write_lock_irqsave(&mlc->lock, flags);
nextidx = mlc->cts(mlc) ? node->bad : node->good;
write_unlock_irqrestore(&mlc->lock, flags);
break;

default:
Expand Down
22 changes: 14 additions & 8 deletions trunk/drivers/input/serio/hp_sdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ EXPORT_SYMBOL(hp_sdc_release_timer_irq);
EXPORT_SYMBOL(hp_sdc_release_hil_irq);
EXPORT_SYMBOL(hp_sdc_release_cooked_irq);

EXPORT_SYMBOL(__hp_sdc_enqueue_transaction);
EXPORT_SYMBOL(hp_sdc_enqueue_transaction);
EXPORT_SYMBOL(hp_sdc_dequeue_transaction);

Expand Down Expand Up @@ -593,18 +594,15 @@ unsigned long hp_sdc_put(void)
}

/******* Functions called in either user or kernel context ****/
int hp_sdc_enqueue_transaction(hp_sdc_transaction *this)
int __hp_sdc_enqueue_transaction(hp_sdc_transaction *this)
{
unsigned long flags;
int i;

if (this == NULL) {
tasklet_schedule(&hp_sdc.task);
BUG();
return -EINVAL;
}

write_lock_irqsave(&hp_sdc.lock, flags);

/* Can't have same transaction on queue twice */
for (i = 0; i < HP_SDC_QUEUE_LEN; i++)
if (hp_sdc.tq[i] == this)
Expand All @@ -617,21 +615,29 @@ int hp_sdc_enqueue_transaction(hp_sdc_transaction *this)
for (i = 0; i < HP_SDC_QUEUE_LEN; i++)
if (hp_sdc.tq[i] == NULL) {
hp_sdc.tq[i] = this;
write_unlock_irqrestore(&hp_sdc.lock, flags);
tasklet_schedule(&hp_sdc.task);
return 0;
}

write_unlock_irqrestore(&hp_sdc.lock, flags);
printk(KERN_WARNING PREFIX "No free slot to add transaction.\n");
return -EBUSY;

fail:
write_unlock_irqrestore(&hp_sdc.lock,flags);
printk(KERN_WARNING PREFIX "Transaction add failed: transaction already queued?\n");
return -EINVAL;
}

int hp_sdc_enqueue_transaction(hp_sdc_transaction *this) {
unsigned long flags;
int ret;

write_lock_irqsave(&hp_sdc.lock, flags);
ret = __hp_sdc_enqueue_transaction(this);
write_unlock_irqrestore(&hp_sdc.lock,flags);

return ret;
}

int hp_sdc_dequeue_transaction(hp_sdc_transaction *this)
{
unsigned long flags;
Expand Down
19 changes: 2 additions & 17 deletions trunk/drivers/input/serio/hp_sdc_mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,11 @@ static void hp_sdc_mlc_isr (int irq, void *dev_id,

static int hp_sdc_mlc_in(hil_mlc *mlc, suseconds_t timeout)
{
unsigned long flags;
struct hp_sdc_mlc_priv_s *priv;
int rc = 2;

priv = mlc->priv;

write_lock_irqsave(&mlc->lock, flags);

/* Try to down the semaphore */
if (down_trylock(&mlc->isem)) {
struct timeval tv;
Expand Down Expand Up @@ -178,21 +175,16 @@ static int hp_sdc_mlc_in(hil_mlc *mlc, suseconds_t timeout)
wasup:
up(&mlc->isem);
rc = 0;
goto done;
done:
write_unlock_irqrestore(&mlc->lock, flags);
return rc;
}

static int hp_sdc_mlc_cts(hil_mlc *mlc)
{
struct hp_sdc_mlc_priv_s *priv;
unsigned long flags;

priv = mlc->priv;

write_lock_irqsave(&mlc->lock, flags);

/* Try to down the semaphores -- they should be up. */
BUG_ON(down_trylock(&mlc->isem));
BUG_ON(down_trylock(&mlc->osem));
Expand Down Expand Up @@ -221,26 +213,21 @@ static int hp_sdc_mlc_cts(hil_mlc *mlc)
priv->tseq[2] = 1;
priv->tseq[3] = 0;
priv->tseq[4] = 0;
hp_sdc_enqueue_transaction(&priv->trans);
__hp_sdc_enqueue_transaction(&priv->trans);
busy:
write_unlock_irqrestore(&mlc->lock, flags);
return 1;
done:
priv->trans.act.semaphore = &mlc->osem;
up(&mlc->csem);
write_unlock_irqrestore(&mlc->lock, flags);
return 0;
}

static void hp_sdc_mlc_out(hil_mlc *mlc)
{
struct hp_sdc_mlc_priv_s *priv;
unsigned long flags;

priv = mlc->priv;

write_lock_irqsave(&mlc->lock, flags);

/* Try to down the semaphore -- it should be up. */
BUG_ON(down_trylock(&mlc->osem));

Expand All @@ -250,7 +237,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc)
do_data:
if (priv->emtestmode) {
up(&mlc->osem);
goto done;
return;
}
/* Shouldn't be sending commands when loop may be busy */
BUG_ON(down_trylock(&mlc->csem));
Expand Down Expand Up @@ -313,8 +300,6 @@ static void hp_sdc_mlc_out(hil_mlc *mlc)
}
enqueue:
hp_sdc_enqueue_transaction(&priv->trans);
done:
write_unlock_irqrestore(&mlc->lock, flags);
}

static int __init hp_sdc_mlc_init(void)
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/hp_sdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typedef struct {
struct semaphore *semaphore; /* Semaphore to sleep on. */
} act;
} hp_sdc_transaction;
int __hp_sdc_enqueue_transaction(hp_sdc_transaction *this);
int hp_sdc_enqueue_transaction(hp_sdc_transaction *this);
int hp_sdc_dequeue_transaction(hp_sdc_transaction *this);

Expand Down

0 comments on commit 20a0421

Please sign in to comment.