Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752773AbbF3GoQ (ORCPT ); Tue, 30 Jun 2015 02:44:16 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:32926 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752412AbbF3Gny (ORCPT ); Tue, 30 Jun 2015 02:43:54 -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 04/10] Staging: fbtft: Use a helper function to set write_register op Date: Tue, 30 Jun 2015 08:43:11 +0200 Message-Id: <1435646597-7612-5-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: 1933 Lines: 70 Use a helper function to set the correct write_register function, based on the width of the registers. Signed-off-by: Fabio Falzoi --- drivers/staging/fbtft/flexfb.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c index 25b394d..dae092a 100644 --- a/drivers/staging/fbtft/flexfb.c +++ b/drivers/staging/fbtft/flexfb.c @@ -363,6 +363,25 @@ static int flexfb_chip_init(const struct device *dev) return -EINVAL; } +static int flexfb_set_regwrite_func(const struct device *dev, + struct fbtft_par *par) +{ + switch (regwidth) { + case 8: + par->fbtftops.write_register = fbtft_write_reg8_bus8; + break; + case 16: + par->fbtftops.write_register = fbtft_write_reg16_bus8; + break; + default: + dev_err(dev, "argument 'regwidth': %d is not supported.\n", + regwidth); + return -EINVAL; + } + + return 0; +} + static int flexfb_probe_common(struct spi_device *sdev, struct platform_device *pdev) { @@ -413,20 +432,9 @@ static int flexfb_probe_common(struct spi_device *sdev, par->init_sequence = initp; par->fbtftops.init_display = fbtft_init_display; - /* registerwrite functions */ - switch (regwidth) { - case 8: - par->fbtftops.write_register = fbtft_write_reg8_bus8; - break; - case 16: - par->fbtftops.write_register = fbtft_write_reg16_bus8; - break; - default: - dev_err(dev, - "argument 'regwidth': %d is not supported.\n", - regwidth); - return -EINVAL; - } + ret = flexfb_set_regwrite_func(dev, par); + if (ret) + goto out_release; /* bus functions */ if (sdev) { -- 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/