Message ID | 20200429082631.925461-1-linus.walleij@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | backlight: lms283gf05: Convert to GPIO descriptors | expand |
On Wed, Apr 29, 2020 at 10:26:31AM +0200, Linus Walleij wrote: > This converts the lms283gf05 backlight driver to use GPIO > descriptors and switches the single PXA Palm Z2 device > over to defining these. > > Since the platform data was only used to convey GPIO > information we can delete the platform data header. > > Notice that we define the proper active low semantics in > the board file GPIO descriptor table (active low) and > assert the reset line by bringing it to "1" (asserted). > > Cc: Marek Vasut <marex@denx.de> > Cc: Daniel Mack <daniel@zonque.org> > Cc: Haojian Zhuang <haojian.zhuang@gmail.com> > Cc: Robert Jarzmik <robert.jarzmik@free.fr> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > Marek: I saw this was written by you, are you regularly > testing the Z2 device? > --- > arch/arm/mach-pxa/z2.c | 12 ++++++--- > drivers/video/backlight/lms283gf05.c | 39 +++++++++++----------------- > include/linux/spi/lms283gf05.h | 16 ------------ > 3 files changed, 23 insertions(+), 44 deletions(-) > delete mode 100644 include/linux/spi/lms283gf05.h > > diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c > index 0e45685bcc1c..71a26b8b7d3f 100644 > --- a/drivers/video/backlight/lms283gf05.c > +++ b/drivers/video/backlight/lms283gf05.c > @@ -150,18 +147,12 @@ static struct lcd_ops lms_ops = { > static int lms283gf05_probe(struct spi_device *spi) > { > struct lms283gf05_state *st; > - struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); > struct lcd_device *ld; > int ret = 0; > > - if (pdata != NULL) { > - ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio, > - GPIOF_DIR_OUT | (!pdata->reset_inverted ? > - GPIOF_INIT_HIGH : GPIOF_INIT_LOW), > - "LMS283GF05 RESET"); > - if (ret) > - return ret; > - } > + st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); Isn't this a change of behaviour w.r.t. to the initial state of the pin? To be honest I suspect it is harmless because we launch into the reset sequence shortly after anyway. More that that I think I prefer it this way since it is better aligned with the behaviour of lms283gf05_power_set(). However if it is an intentional change of behaviour then it would be good to spell that out in the description for the benefit of future archaeologists. Daniel. > + if (st->reset) > + gpiod_set_consumer_name(st->reset, "LMS283GF05 RESET"); > > st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), > GFP_KERNEL); _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Wed, Apr 29, 2020 at 1:33 PM Daniel Thompson <daniel.thompson@linaro.org> wrote: > On Wed, Apr 29, 2020 at 10:26:31AM +0200, Linus Walleij wrote: > > - if (pdata != NULL) { > > - ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio, > > - GPIOF_DIR_OUT | (!pdata->reset_inverted ? > > - GPIOF_INIT_HIGH : GPIOF_INIT_LOW), > > - "LMS283GF05 RESET"); > > - if (ret) > > - return ret; > > - } > > + st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); > > Isn't this a change of behaviour w.r.t. to the initial state of the pin? Yeah you're right. The original author intended reset to be de-asserted here so it should be GPIOD_OUT_LOW. > To be honest I suspect it is harmless because we launch into the reset > sequence shortly after anyway. More that that I think I prefer it this > way since it is better aligned with the behaviour of > lms283gf05_power_set(). > > However if it is an intentional change of behaviour then it would be > good to spell that out in the description for the benefit of future > archaeologists. Hm I'd rather not change semantics actually, you never know. I'll switch it back. If we decide to change it I'd use GPIOD_ASIS and not touch the hardware here. Yours, Linus Walleij _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Linus, I love your patch! Perhaps something to improve: [auto build test WARNING on backlight/for-backlight-next] [also build test WARNING on arm-soc/for-next spi/for-next tegra-drm/drm/tegra/for-next v5.7-rc3 next-20200428] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982] url: https://github.com/0day-ci/linux/commits/Linus-Walleij/backlight-lms283gf05-Convert-to-GPIO-descriptors/20200429-181222 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git for-backlight-next config: c6x-allyesconfig (attached as .config) compiler: c6x-elf-gcc (GCC) 9.3.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=c6x If you fix the issue, kindly add following tag as appropriate Reported-by: kbuild test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/video/backlight/lms283gf05.c: In function 'lms283gf05_probe': drivers/video/backlight/lms283gf05.c:151:6: warning: unused variable 'ret' [-Wunused-variable] 151 | int ret = 0; | ^~~ >> drivers/video/backlight/lms283gf05.c:153:12: warning: 'st' is used uninitialized in this function [-Wuninitialized] 153 | st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/st +153 drivers/video/backlight/lms283gf05.c 146 147 static int lms283gf05_probe(struct spi_device *spi) 148 { 149 struct lms283gf05_state *st; 150 struct lcd_device *ld; > 151 int ret = 0; 152 > 153 st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); 154 if (st->reset) 155 gpiod_set_consumer_name(st->reset, "LMS283GF05 RESET"); 156 157 st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), 158 GFP_KERNEL); 159 if (st == NULL) 160 return -ENOMEM; 161 162 ld = devm_lcd_device_register(&spi->dev, "lms283gf05", &spi->dev, st, 163 &lms_ops); 164 if (IS_ERR(ld)) 165 return PTR_ERR(ld); 166 167 st->spi = spi; 168 st->ld = ld; 169 170 spi_set_drvdata(spi, st); 171 172 /* kick in the LCD */ 173 if (st->reset) 174 lms283gf05_reset(st->reset); 175 lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); 176 177 return 0; 178 } 179 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c index 21fd76bb09cd..89eb5243c85f 100644 --- a/arch/arm/mach-pxa/z2.c +++ b/arch/arm/mach-pxa/z2.c @@ -20,7 +20,6 @@ #include <linux/spi/spi.h> #include <linux/spi/pxa2xx_spi.h> #include <linux/spi/libertas_spi.h> -#include <linux/spi/lms283gf05.h> #include <linux/power_supply.h> #include <linux/mtd/physmap.h> #include <linux/gpio.h> @@ -578,8 +577,13 @@ static struct pxa2xx_spi_chip lms283_chip_info = { .gpio_cs = GPIO88_ZIPITZ2_LCD_CS, }; -static const struct lms283gf05_pdata lms283_pdata = { - .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET, +static struct gpiod_lookup_table lms283_gpio_table = { + .dev_id = "spi2.0", /* SPI bus 2 chip select 0 */ + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO19_ZIPITZ2_LCD_RESET, + "reset", GPIO_ACTIVE_LOW), + { }, + }, }; static struct spi_board_info spi_board_info[] __initdata = { @@ -595,7 +599,6 @@ static struct spi_board_info spi_board_info[] __initdata = { { .modalias = "lms283gf05", .controller_data = &lms283_chip_info, - .platform_data = &lms283_pdata, .max_speed_hz = 400000, .bus_num = 2, .chip_select = 0, @@ -615,6 +618,7 @@ static void __init z2_spi_init(void) { pxa2xx_set_spi_info(1, &pxa_ssp1_master_info); pxa2xx_set_spi_info(2, &pxa_ssp2_master_info); + gpiod_add_lookup_table(&lms283_gpio_table); spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); } #else diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c index 0e45685bcc1c..71a26b8b7d3f 100644 --- a/drivers/video/backlight/lms283gf05.c +++ b/drivers/video/backlight/lms283gf05.c @@ -9,16 +9,16 @@ #include <linux/kernel.h> #include <linux/delay.h> #include <linux/slab.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/lcd.h> #include <linux/spi/spi.h> -#include <linux/spi/lms283gf05.h> #include <linux/module.h> struct lms283gf05_state { struct spi_device *spi; struct lcd_device *ld; + struct gpio_desc *reset; }; struct lms283gf05_seq { @@ -90,13 +90,13 @@ static const struct lms283gf05_seq disp_pdwnseq[] = { }; -static void lms283gf05_reset(unsigned long gpio, bool inverted) +static void lms283gf05_reset(struct gpio_desc *gpiod) { - gpio_set_value(gpio, !inverted); + gpiod_set_value(gpiod, 0); /* De-asserted */ mdelay(100); - gpio_set_value(gpio, inverted); + gpiod_set_value(gpiod, 1); /* Asserted */ mdelay(20); - gpio_set_value(gpio, !inverted); + gpiod_set_value(gpiod, 0); /* De-asserted */ mdelay(20); } @@ -125,18 +125,15 @@ static int lms283gf05_power_set(struct lcd_device *ld, int power) { struct lms283gf05_state *st = lcd_get_data(ld); struct spi_device *spi = st->spi; - struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); if (power <= FB_BLANK_NORMAL) { - if (pdata) - lms283gf05_reset(pdata->reset_gpio, - pdata->reset_inverted); + if (st->reset) + lms283gf05_reset(st->reset); lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); } else { lms283gf05_toggle(spi, disp_pdwnseq, ARRAY_SIZE(disp_pdwnseq)); - if (pdata) - gpio_set_value(pdata->reset_gpio, - pdata->reset_inverted); + if (st->reset) + gpiod_set_value(st->reset, 1); /* Asserted */ } return 0; @@ -150,18 +147,12 @@ static struct lcd_ops lms_ops = { static int lms283gf05_probe(struct spi_device *spi) { struct lms283gf05_state *st; - struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); struct lcd_device *ld; int ret = 0; - if (pdata != NULL) { - ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio, - GPIOF_DIR_OUT | (!pdata->reset_inverted ? - GPIOF_INIT_HIGH : GPIOF_INIT_LOW), - "LMS283GF05 RESET"); - if (ret) - return ret; - } + st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); + if (st->reset) + gpiod_set_consumer_name(st->reset, "LMS283GF05 RESET"); st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), GFP_KERNEL); @@ -179,8 +170,8 @@ static int lms283gf05_probe(struct spi_device *spi) spi_set_drvdata(spi, st); /* kick in the LCD */ - if (pdata) - lms283gf05_reset(pdata->reset_gpio, pdata->reset_inverted); + if (st->reset) + lms283gf05_reset(st->reset); lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); return 0; diff --git a/include/linux/spi/lms283gf05.h b/include/linux/spi/lms283gf05.h deleted file mode 100644 index f237b2d062e9..000000000000 --- a/include/linux/spi/lms283gf05.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * lms283gf05.h - Platform glue for Samsung LMS283GF05 LCD - * - * Copyright (C) 2009 Marek Vasut <marek.vasut@gmail.com> -*/ - -#ifndef _INCLUDE_LINUX_SPI_LMS283GF05_H_ -#define _INCLUDE_LINUX_SPI_LMS283GF05_H_ - -struct lms283gf05_pdata { - unsigned long reset_gpio; - bool reset_inverted; -}; - -#endif /* _INCLUDE_LINUX_SPI_LMS283GF05_H_ */
This converts the lms283gf05 backlight driver to use GPIO descriptors and switches the single PXA Palm Z2 device over to defining these. Since the platform data was only used to convey GPIO information we can delete the platform data header. Notice that we define the proper active low semantics in the board file GPIO descriptor table (active low) and assert the reset line by bringing it to "1" (asserted). Cc: Marek Vasut <marex@denx.de> Cc: Daniel Mack <daniel@zonque.org> Cc: Haojian Zhuang <haojian.zhuang@gmail.com> Cc: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- Marek: I saw this was written by you, are you regularly testing the Z2 device? --- arch/arm/mach-pxa/z2.c | 12 ++++++--- drivers/video/backlight/lms283gf05.c | 39 +++++++++++----------------- include/linux/spi/lms283gf05.h | 16 ------------ 3 files changed, 23 insertions(+), 44 deletions(-) delete mode 100644 include/linux/spi/lms283gf05.h -- 2.25.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel