Skip to content

Commit 9e9f079

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
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>
1 parent 343fda9 commit 9e9f079

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

drivers/tty/serial/serial_mctrl_gpio.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl)
4848
int value_array[UART_GPIO_MAX];
4949
unsigned int count = 0;
5050

51-
if (IS_ERR_OR_NULL(gpios))
52-
return;
53-
5451
for (i = 0; i < UART_GPIO_MAX; i++)
5552
if (!IS_ERR_OR_NULL(gpios->gpio[i]) &&
5653
mctrl_gpios_desc[i].dir_out) {
@@ -65,26 +62,16 @@ EXPORT_SYMBOL_GPL(mctrl_gpio_set);
6562
struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
6663
enum mctrl_gpio_idx gidx)
6764
{
68-
if (!IS_ERR_OR_NULL(gpios) && !IS_ERR_OR_NULL(gpios->gpio[gidx]))
69-
return gpios->gpio[gidx];
70-
else
71-
return NULL;
65+
return gpios->gpio[gidx];
7266
}
7367
EXPORT_SYMBOL_GPL(mctrl_gpio_to_gpiod);
7468

7569
unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl)
7670
{
7771
enum mctrl_gpio_idx i;
7872

79-
/*
80-
* return it unchanged if the structure is not allocated
81-
*/
82-
if (IS_ERR_OR_NULL(gpios))
83-
return *mctrl;
84-
8573
for (i = 0; i < UART_GPIO_MAX; i++) {
86-
if (!IS_ERR_OR_NULL(gpios->gpio[i]) &&
87-
!mctrl_gpios_desc[i].dir_out) {
74+
if (gpios->gpio[i] && !mctrl_gpios_desc[i].dir_out) {
8875
if (gpiod_get_value(gpios->gpio[i]))
8976
*mctrl |= mctrl_gpios_desc[i].mctrl;
9077
else
@@ -138,9 +125,6 @@ void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios)
138125
{
139126
enum mctrl_gpio_idx i;
140127

141-
if (IS_ERR_OR_NULL(gpios))
142-
return;
143-
144128
for (i = 0; i < UART_GPIO_MAX; i++)
145129
if (!IS_ERR_OR_NULL(gpios->gpio[i]))
146130
devm_gpiod_put(dev, gpios->gpio[i]);

0 commit comments

Comments
 (0)