Skip to content

Commit

Permalink
backlight: hx8357: Make use of device properties
Browse files Browse the repository at this point in the history
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Include mod_devicetable.h explicitly to replace the dropped of.h
which included mod_devicetable.h indirectly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240201144951.294215-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
  • Loading branch information
Andy Shevchenko authored and Lee Jones committed Mar 7, 2024
1 parent 601eedb commit 64a6335
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/video/backlight/hx8357.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/lcd.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/property.h>
#include <linux/spi/spi.h>

#define HX8357_NUM_IM_PINS 3
Expand Down Expand Up @@ -564,6 +564,8 @@ static struct lcd_ops hx8357_ops = {
.get_power = hx8357_get_power,
};

typedef int (*hx8357_init_fn)(struct lcd_device *);

static const struct of_device_id hx8357_dt_ids[] = {
{
.compatible = "himax,hx8357",
Expand All @@ -582,7 +584,7 @@ static int hx8357_probe(struct spi_device *spi)
struct device *dev = &spi->dev;
struct lcd_device *lcdev;
struct hx8357_data *lcd;
const struct of_device_id *match;
hx8357_init_fn init_fn;
int i, ret;

lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL);
Expand All @@ -597,8 +599,8 @@ static int hx8357_probe(struct spi_device *spi)

lcd->spi = spi;

match = of_match_device(hx8357_dt_ids, &spi->dev);
if (!match || !match->data)
init_fn = device_get_match_data(dev);
if (!init_fn)
return -EINVAL;

lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
Expand Down Expand Up @@ -627,7 +629,7 @@ static int hx8357_probe(struct spi_device *spi)

hx8357_lcd_reset(lcdev);

ret = ((int (*)(struct lcd_device *))match->data)(lcdev);
ret = init_fn(lcdev);
if (ret) {
dev_err(&spi->dev, "Couldn't initialize panel\n");
return ret;
Expand Down

0 comments on commit 64a6335

Please sign in to comment.