Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198519
b: refs/heads/master
c: 1f1f584
h: refs/heads/master
i:
  198517: b533e93
  198515: 7cd7997
  198511: 42815a1
v: v3
  • Loading branch information
Ben Dooks committed May 20, 2010
1 parent 5605759 commit a55eb9a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 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: 6a399547242df3b12f13d637a95f63eaa82f9385
refs/heads/master: 1f1f584c9a1dd234041573d2d1c42620b3966607
26 changes: 20 additions & 6 deletions trunk/arch/arm/plat-samsung/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct adc_device {
struct s3c_adc_client *cur;
struct s3c_adc_client *ts_pend;
void __iomem *regs;
spinlock_t lock;

unsigned int prescale;

Expand All @@ -74,7 +75,7 @@ struct adc_device {

static struct adc_device *adc_dev;

static LIST_HEAD(adc_pending);
static LIST_HEAD(adc_pending); /* protected by adc_device.lock */

#define adc_dbg(_adc, msg...) dev_dbg(&(_adc)->pdev->dev, msg)

Expand Down Expand Up @@ -145,7 +146,7 @@ int s3c_adc_start(struct s3c_adc_client *client,
if (client->is_ts && adc->ts_pend)
return -EAGAIN;

local_irq_save(flags);
spin_lock_irqsave(&adc->lock, flags);

client->channel = channel;
client->nr_samples = nr_samples;
Expand All @@ -157,7 +158,8 @@ int s3c_adc_start(struct s3c_adc_client *client,

if (!adc->cur)
s3c_adc_try(adc);
local_irq_restore(flags);

spin_unlock_irqrestore(&adc->lock, flags);

return 0;
}
Expand Down Expand Up @@ -237,6 +239,10 @@ EXPORT_SYMBOL_GPL(s3c_adc_register);

void s3c_adc_release(struct s3c_adc_client *client)
{
unsigned long flags;

spin_lock_irqsave(&adc_dev->lock, flags);

/* We should really check that nothing is in progress. */
if (adc_dev->cur == client)
adc_dev->cur = NULL;
Expand All @@ -255,6 +261,8 @@ void s3c_adc_release(struct s3c_adc_client *client)

if (adc_dev->cur == NULL)
s3c_adc_try(adc_dev);

spin_unlock_irqrestore(&adc_dev->lock, flags);
kfree(client);
}
EXPORT_SYMBOL_GPL(s3c_adc_release);
Expand All @@ -264,7 +272,6 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
struct adc_device *adc = pw;
struct s3c_adc_client *client = adc->cur;
enum s3c_cpu_type cpu = platform_get_device_id(adc->pdev)->driver_data;
unsigned long flags;
unsigned data0, data1;

if (!client) {
Expand Down Expand Up @@ -296,12 +303,12 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
client->select_cb(client, 1);
s3c_adc_convert(adc);
} else {
local_irq_save(flags);
spin_lock(&adc->lock);
(client->select_cb)(client, 0);
adc->cur = NULL;

s3c_adc_try(adc);
local_irq_restore(flags);
spin_unlock(&adc->lock);
}

exit:
Expand All @@ -326,6 +333,8 @@ static int s3c_adc_probe(struct platform_device *pdev)
return -ENOMEM;
}

spin_lock_init(&adc->lock);

adc->pdev = pdev;
adc->prescale = S3C2410_ADCCON_PRSCVL(49);

Expand Down Expand Up @@ -407,13 +416,17 @@ static int __devexit s3c_adc_remove(struct platform_device *pdev)
static int s3c_adc_suspend(struct platform_device *pdev, pm_message_t state)
{
struct adc_device *adc = platform_get_drvdata(pdev);
unsigned long flags;
u32 con;

spin_lock_irqsave(&adc->lock, flags);

con = readl(adc->regs + S3C2410_ADCCON);
con |= S3C2410_ADCCON_STDBM;
writel(con, adc->regs + S3C2410_ADCCON);

disable_irq(adc->irq);
spin_unlock_irqrestore(&adc->lock, flags);
clk_disable(adc->clk);

return 0;
Expand All @@ -422,6 +435,7 @@ static int s3c_adc_suspend(struct platform_device *pdev, pm_message_t state)
static int s3c_adc_resume(struct platform_device *pdev)
{
struct adc_device *adc = platform_get_drvdata(pdev);
unsigned long flags;

clk_enable(adc->clk);
enable_irq(adc->irq);
Expand Down

0 comments on commit a55eb9a

Please sign in to comment.