serial: mctrl-gpio: don't check for struct mctrl_gpios * to be invalid
Drivers using mctrl-gpio must not pass invalid values for struct mctrl_gpios *. All drivers were fixed in this regard and so some checks can go away or be simplified. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
343fda9548
commit
9e9f079c56
|
@ -48,9 +48,6 @@ void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl)
|
||||||
int value_array[UART_GPIO_MAX];
|
int value_array[UART_GPIO_MAX];
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
|
|
||||||
if (IS_ERR_OR_NULL(gpios))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < UART_GPIO_MAX; i++)
|
for (i = 0; i < UART_GPIO_MAX; i++)
|
||||||
if (!IS_ERR_OR_NULL(gpios->gpio[i]) &&
|
if (!IS_ERR_OR_NULL(gpios->gpio[i]) &&
|
||||||
mctrl_gpios_desc[i].dir_out) {
|
mctrl_gpios_desc[i].dir_out) {
|
||||||
|
@ -65,10 +62,7 @@ EXPORT_SYMBOL_GPL(mctrl_gpio_set);
|
||||||
struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
|
struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
|
||||||
enum mctrl_gpio_idx gidx)
|
enum mctrl_gpio_idx gidx)
|
||||||
{
|
{
|
||||||
if (!IS_ERR_OR_NULL(gpios) && !IS_ERR_OR_NULL(gpios->gpio[gidx]))
|
return gpios->gpio[gidx];
|
||||||
return gpios->gpio[gidx];
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mctrl_gpio_to_gpiod);
|
EXPORT_SYMBOL_GPL(mctrl_gpio_to_gpiod);
|
||||||
|
|
||||||
|
@ -76,15 +70,8 @@ unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl)
|
||||||
{
|
{
|
||||||
enum mctrl_gpio_idx i;
|
enum mctrl_gpio_idx i;
|
||||||
|
|
||||||
/*
|
|
||||||
* return it unchanged if the structure is not allocated
|
|
||||||
*/
|
|
||||||
if (IS_ERR_OR_NULL(gpios))
|
|
||||||
return *mctrl;
|
|
||||||
|
|
||||||
for (i = 0; i < UART_GPIO_MAX; i++) {
|
for (i = 0; i < UART_GPIO_MAX; i++) {
|
||||||
if (!IS_ERR_OR_NULL(gpios->gpio[i]) &&
|
if (gpios->gpio[i] && !mctrl_gpios_desc[i].dir_out) {
|
||||||
!mctrl_gpios_desc[i].dir_out) {
|
|
||||||
if (gpiod_get_value(gpios->gpio[i]))
|
if (gpiod_get_value(gpios->gpio[i]))
|
||||||
*mctrl |= mctrl_gpios_desc[i].mctrl;
|
*mctrl |= mctrl_gpios_desc[i].mctrl;
|
||||||
else
|
else
|
||||||
|
@ -138,9 +125,6 @@ void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios)
|
||||||
{
|
{
|
||||||
enum mctrl_gpio_idx i;
|
enum mctrl_gpio_idx i;
|
||||||
|
|
||||||
if (IS_ERR_OR_NULL(gpios))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < UART_GPIO_MAX; i++)
|
for (i = 0; i < UART_GPIO_MAX; i++)
|
||||||
if (!IS_ERR_OR_NULL(gpios->gpio[i]))
|
if (!IS_ERR_OR_NULL(gpios->gpio[i]))
|
||||||
devm_gpiod_put(dev, gpios->gpio[i]);
|
devm_gpiod_put(dev, gpios->gpio[i]);
|
||||||
|
|
Loading…
Reference in New Issue