Use a helper function to choose which set_addr_win implementation to use, based on the value of the setaddrwin module parameter. Signed-off-by: Fabio Falzoi <fabio.falzoi84@xxxxxxxxx> --- drivers/staging/fbtft/flexfb.c | 47 +++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index 1b833f9..2a15da1 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -470,6 +470,31 @@ static int flexfb_set_platform_bus_func(struct fbtft_par *par, return 0; } +static int flexfb_set_addr_win_func(const struct device *dev, + struct fbtft_par *par) +{ + switch (setaddrwin) { + case 0: + /* use default */ + break; + case 1: + par->fbtftops.set_addr_win = flexfb_set_addr_win_1; + break; + case 2: + par->fbtftops.set_addr_win = flexfb_set_addr_win_2; + break; + case 3: + par->fbtftops.set_addr_win = set_addr_win_3; + break; + default: + dev_err(dev, "argument 'setaddrwin': unknown value %d.\n", + setaddrwin); + return -EINVAL; + } + + return 0; +} + static int flexfb_probe_common(struct spi_device *sdev, struct platform_device *pdev) { @@ -531,25 +556,9 @@ static int flexfb_probe_common(struct spi_device *sdev, if (ret) goto out_release; - /* set_addr_win function */ - switch (setaddrwin) { - case 0: - /* use default */ - break; - case 1: - par->fbtftops.set_addr_win = flexfb_set_addr_win_1; - break; - case 2: - par->fbtftops.set_addr_win = flexfb_set_addr_win_2; - break; - case 3: - par->fbtftops.set_addr_win = set_addr_win_3; - break; - default: - dev_err(dev, "argument 'setaddrwin': unknown value %d.\n", - setaddrwin); - return -EINVAL; - } + ret = flexfb_set_addr_win_func(dev, par); + if (ret) + goto out_release; if (!nobacklight) par->fbtftops.register_backlight = fbtft_register_backlight; -- 2.1.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel