summaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-02-18 11:38:58 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-03-07 08:57:56 +0100
commit3bd69ad077a955b469baa90d938fd83510297335 (patch)
tree94d314d51fd295e6cb7de9f682582c29fdd50eed /drivers/clocksource
parentfe7855bb4f2d82ac4559c46c586c2f29e9f123e2 (diff)
downloadbarebox-3bd69ad077a955b469baa90d938fd83510297335.tar.gz
barebox-3bd69ad077a955b469baa90d938fd83510297335.tar.xz
driver: replace dev_request_mem_region with dev_request_mem_resource
dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/arm_smp_twd.c8
-rw-r--r--drivers/clocksource/bcm2835.c8
-rw-r--r--drivers/clocksource/clps711x.c8
-rw-r--r--drivers/clocksource/digic.c8
-rw-r--r--drivers/clocksource/mvebu.c8
-rw-r--r--drivers/clocksource/nomadik.c8
-rw-r--r--drivers/clocksource/orion.c8
-rw-r--r--drivers/clocksource/uemd.c8
8 files changed, 40 insertions, 24 deletions
diff --git a/drivers/clocksource/arm_smp_twd.c b/drivers/clocksource/arm_smp_twd.c
index c0296cdfd8..226150aa42 100644
--- a/drivers/clocksource/arm_smp_twd.c
+++ b/drivers/clocksource/arm_smp_twd.c
@@ -42,6 +42,7 @@ static struct clocksource smp_twd_clksrc = {
static int smp_twd_probe(struct device_d *dev)
{
+ struct resource *iores;
u32 tick_rate;
u32 val;
int ret;
@@ -61,9 +62,10 @@ static int smp_twd_probe(struct device_d *dev)
return ret;
}
- twd_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(twd_base))
- return PTR_ERR(twd_base);
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores))
+ return PTR_ERR(iores);
+ twd_base = IOMEM(iores->start);
tick_rate = clk_get_rate(twd_clk);
if (tick_rate > SMP_TWD_MAX_FREQ) {
diff --git a/drivers/clocksource/bcm2835.c b/drivers/clocksource/bcm2835.c
index 0cb8e57993..b5831d5f10 100644
--- a/drivers/clocksource/bcm2835.c
+++ b/drivers/clocksource/bcm2835.c
@@ -42,6 +42,7 @@ static struct clocksource bcm2835_stc = {
static int bcm2835_cs_probe(struct device_d *dev)
{
+ struct resource *iores;
static struct clk *stc_clk;
u32 rate;
int ret;
@@ -61,9 +62,10 @@ static int bcm2835_cs_probe(struct device_d *dev)
}
rate = clk_get_rate(stc_clk);
- stc_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(stc_base))
- return PTR_ERR(stc_base);
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores))
+ return PTR_ERR(iores);
+ stc_base = IOMEM(iores->start);
clocks_calc_mult_shift(&bcm2835_stc.mult, &bcm2835_stc.shift, rate, NSEC_PER_SEC, 60);
diff --git a/drivers/clocksource/clps711x.c b/drivers/clocksource/clps711x.c
index a49853f2b5..f6399e9300 100644
--- a/drivers/clocksource/clps711x.c
+++ b/drivers/clocksource/clps711x.c
@@ -29,6 +29,7 @@ static struct clocksource clps711x_cs = {
static int clps711x_cs_probe(struct device_d *dev)
{
+ struct resource *iores;
u32 rate;
struct clk *timer_clk;
@@ -37,11 +38,12 @@ static int clps711x_cs_probe(struct device_d *dev)
return PTR_ERR(timer_clk);
rate = clk_get_rate(timer_clk);
- clps711x_timer_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(clps711x_timer_base)) {
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores)) {
clk_put(timer_clk);
- return PTR_ERR(clps711x_timer_base);
+ return PTR_ERR(iores);
}
+ clps711x_timer_base = IOMEM(iores->start);
clocks_calc_mult_shift(&clps711x_cs.mult, &clps711x_cs.shift, rate,
NSEC_PER_SEC, 10);
diff --git a/drivers/clocksource/digic.c b/drivers/clocksource/digic.c
index 277bb02b63..1ecd839160 100644
--- a/drivers/clocksource/digic.c
+++ b/drivers/clocksource/digic.c
@@ -40,15 +40,17 @@ static struct clocksource digic_cs = {
static int digic_timer_probe(struct device_d *dev)
{
+ struct resource *iores;
/* use only one timer */
if (timer_base)
return -EBUSY;
- timer_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(timer_base)) {
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores)) {
dev_err(dev, "could not get memory region\n");
- return PTR_ERR(timer_base);
+ return PTR_ERR(iores);
}
+ timer_base = IOMEM(iores->start);
clocks_calc_mult_shift(&digic_cs.mult, &digic_cs.shift,
DIGIC_TIMER_CLOCK, NSEC_PER_SEC, 1);
diff --git a/drivers/clocksource/mvebu.c b/drivers/clocksource/mvebu.c
index 88db0b06c3..cf80571263 100644
--- a/drivers/clocksource/mvebu.c
+++ b/drivers/clocksource/mvebu.c
@@ -56,12 +56,14 @@ static struct clocksource cs = {
static int mvebu_timer_probe(struct device_d *dev)
{
+ struct resource *iores;
struct clk *clk;
u32 rate, div, val;
- timer_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(timer_base))
- return PTR_ERR(timer_base);
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores))
+ return PTR_ERR(iores);
+ timer_base = IOMEM(iores->start);
val = __raw_readl(timer_base + TIMER_CTRL_OFF);
val &= ~(TIMER0_25MHZ | TIMER0_DIV_MASK);
diff --git a/drivers/clocksource/nomadik.c b/drivers/clocksource/nomadik.c
index 48f4715c8f..9b20cbc946 100644
--- a/drivers/clocksource/nomadik.c
+++ b/drivers/clocksource/nomadik.c
@@ -94,6 +94,7 @@ static void nmdk_timer_reset(void)
static int nmdk_mtu_probe(struct device_d *dev)
{
+ struct resource *iores;
static struct clk *mtu_clk;
u32 rate;
int ret;
@@ -123,9 +124,10 @@ static int nmdk_mtu_probe(struct device_d *dev)
nmdk_cycle = (rate + 1000 / 2) / 1000;
/* Save global pointer to mtu, used by functions above */
- mtu_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(mtu_base))
- return PTR_ERR(mtu_base);
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores))
+ return PTR_ERR(iores);
+ mtu_base = IOMEM(iores->start);
/* Init the timer and register clocksource */
nmdk_timer_reset();
diff --git a/drivers/clocksource/orion.c b/drivers/clocksource/orion.c
index 2e40b49ee7..97008dabab 100644
--- a/drivers/clocksource/orion.c
+++ b/drivers/clocksource/orion.c
@@ -45,12 +45,14 @@ static struct clocksource clksrc = {
static int orion_timer_probe(struct device_d *dev)
{
+ struct resource *iores;
struct clk *tclk;
uint32_t val;
- timer_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(timer_base))
- return PTR_ERR(timer_base);
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores))
+ return PTR_ERR(iores);
+ timer_base = IOMEM(iores->start);
tclk = clk_get(dev, NULL);
diff --git a/drivers/clocksource/uemd.c b/drivers/clocksource/uemd.c
index d4291dd736..b80908f3b0 100644
--- a/drivers/clocksource/uemd.c
+++ b/drivers/clocksource/uemd.c
@@ -66,6 +66,7 @@ static struct clocksource uemd_cs = {
static int uemd_timer_probe(struct device_d *dev)
{
+ struct resource *iores;
int mode;
struct clk *timer_clk;
@@ -73,11 +74,12 @@ static int uemd_timer_probe(struct device_d *dev)
if (timer_base)
return -EBUSY;
- timer_base = dev_request_mem_region(dev, 0);
- if (IS_ERR(timer_base)) {
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores)) {
dev_err(dev, "could not get memory region\n");
- return PTR_ERR(timer_base);
+ return PTR_ERR(iores);
}
+ timer_base = IOMEM(iores->start);
timer_clk = clk_get(dev, NULL);
if (IS_ERR(timer_clk)) {