projects
/
deliverable
/
linux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sh-pfc: Use PTR_ERR_OR_ZERO() to simplify the code
[deliverable/linux.git]
/
drivers
/
pinctrl
/
sh-pfc
/
pinctrl.c
diff --git
a/drivers/pinctrl/sh-pfc/pinctrl.c
b/drivers/pinctrl/sh-pfc/pinctrl.c
index fdb445d68b9a08a67992c07f46750bfb33875fc6..e208ee04a9f45482044606bc509c70ec5170c4cb 100644
(file)
--- a/
drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/
drivers/pinctrl/sh-pfc/pinctrl.c
@@
-632,19
+632,21
@@
static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned _pin,
}
case PIN_CONFIG_POWER_SOURCE: {
}
case PIN_CONFIG_POWER_SOURCE: {
- int ret;
+ u32 pocctrl, val;
+ int bit;
- if (!pfc->info->ops || !pfc->info->ops->
get_io_voltage
)
+ if (!pfc->info->ops || !pfc->info->ops->
pin_to_pocctrl
)
return -ENOTSUPP;
return -ENOTSUPP;
+ bit = pfc->info->ops->pin_to_pocctrl(pfc, _pin, &pocctrl);
+ if (WARN(bit < 0, "invalid pin %#x", _pin))
+ return bit;
+
spin_lock_irqsave(&pfc->lock, flags);
spin_lock_irqsave(&pfc->lock, flags);
-
ret = pfc->info->ops->get_io_voltage(pfc, _pin
);
+
val = sh_pfc_read_reg(pfc, pocctrl, 32
);
spin_unlock_irqrestore(&pfc->lock, flags);
spin_unlock_irqrestore(&pfc->lock, flags);
- if (ret < 0)
- return ret;
-
- *config = ret;
+ *config = (val & BIT(bit)) ? 3300 : 1800;
break;
}
break;
}
@@
-696,20
+698,29
@@
static int sh_pfc_pinconf_set(struct pinctrl_dev *pctldev, unsigned _pin,
}
case PIN_CONFIG_POWER_SOURCE: {
}
case PIN_CONFIG_POWER_SOURCE: {
- unsigned int
arg =
-
pinconf_to_config_argument(configs[i])
;
- int
re
t;
+ unsigned int
mV = pinconf_to_config_argument(configs[i]);
+
u32 pocctrl, val
;
+ int
bi
t;
- if (!pfc->info->ops || !pfc->info->ops->
set_io_voltage
)
+ if (!pfc->info->ops || !pfc->info->ops->
pin_to_pocctrl
)
return -ENOTSUPP;
return -ENOTSUPP;
+ bit = pfc->info->ops->pin_to_pocctrl(pfc, _pin, &pocctrl);
+ if (WARN(bit < 0, "invalid pin %#x", _pin))
+ return bit;
+
+ if (mV != 1800 && mV != 3300)
+ return -EINVAL;
+
spin_lock_irqsave(&pfc->lock, flags);
spin_lock_irqsave(&pfc->lock, flags);
- ret = pfc->info->ops->set_io_voltage(pfc, _pin, arg);
+ val = sh_pfc_read_reg(pfc, pocctrl, 32);
+ if (mV == 3300)
+ val |= BIT(bit);
+ else
+ val &= ~BIT(bit);
+ sh_pfc_write_reg(pfc, pocctrl, 32, val);
spin_unlock_irqrestore(&pfc->lock, flags);
spin_unlock_irqrestore(&pfc->lock, flags);
- if (ret)
- return ret;
-
break;
}
break;
}
@@
-803,8
+814,5
@@
int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
pmx->pctl_desc.npins = pfc->info->nr_pins;
pmx->pctl = devm_pinctrl_register(pfc->dev, &pmx->pctl_desc, pmx);
pmx->pctl_desc.npins = pfc->info->nr_pins;
pmx->pctl = devm_pinctrl_register(pfc->dev, &pmx->pctl_desc, pmx);
- if (IS_ERR(pmx->pctl))
- return PTR_ERR(pmx->pctl);
-
- return 0;
+ return PTR_ERR_OR_ZERO(pmx->pctl);
}
}
This page took
0.027735 seconds
and
5
git commands to generate.