Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753127AbbF3GpT (ORCPT ); Tue, 30 Jun 2015 02:45:19 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:32875 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752531AbbF3Gn5 (ORCPT ); Tue, 30 Jun 2015 02:43:57 -0400 From: Fabio Falzoi To: thomas.petazzoni@free-electrons.com, noralf@tronnes.org Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Fabio Falzoi Subject: [PATCH 06/10] Staging: fbtft: Use a helper function to set set_addr_win op Date: Tue, 30 Jun 2015 08:43:13 +0200 Message-Id: <1435646597-7612-7-git-send-email-fabio.falzoi84@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435646597-7612-1-git-send-email-fabio.falzoi84@gmail.com> References: <1435646597-7612-1-git-send-email-fabio.falzoi84@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2172 Lines: 81 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/