Commit 553d8a6e authored by Chintan Patel's avatar Chintan Patel Committed by Helge Deller
Browse files

staging: fbtft: Make FB_DEVICE dependency optional



fbtft provides sysfs interfaces for debugging and gamma configuration,
but these are not required for the core driver.

Drop the hard dependency on CONFIG_FB_DEVICE and make sysfs support
optional by using dev_of_fbinfo() at runtime. When FB_DEVICE is disabled,
sysfs operations are skipped while the code remains buildable and
type-checked.

Suggested-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Suggested-by: default avatarHelge Deller <deller@gmx.de>
Reviewed-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarChintan Patel <chintanlike@gmail.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent 39b65316
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2,11 +2,14 @@
menuconfig FB_TFT
	tristate "Support for small TFT LCD display modules"
	depends on FB && SPI
	depends on FB_DEVICE
	depends on BACKLIGHT_CLASS_DEVICE
	depends on GPIOLIB || COMPILE_TEST
	select FB_BACKLIGHT
	select FB_SYSMEM_HELPERS_DEFERRED
	help
	  Support for small TFT LCD display modules over SPI bus. FB_DEVICE
	  is not required, but if enabled, provides sysfs interface for debugging
	  and gamma curve configuration.

if FB_TFT

+16 −4
Original line number Diff line number Diff line
@@ -203,14 +203,26 @@ static struct device_attribute debug_device_attr =

void fbtft_sysfs_init(struct fbtft_par *par)
{
	device_create_file(par->info->dev, &debug_device_attr);
	struct device *dev;

	dev = dev_of_fbinfo(par->info);
	if (!dev)
		return;

	device_create_file(dev, &debug_device_attr);
	if (par->gamma.curves && par->fbtftops.set_gamma)
		device_create_file(par->info->dev, &gamma_device_attrs[0]);
		device_create_file(dev, &gamma_device_attrs[0]);
}

void fbtft_sysfs_exit(struct fbtft_par *par)
{
	device_remove_file(par->info->dev, &debug_device_attr);
	struct device *dev;

	dev = dev_of_fbinfo(par->info);
	if (!dev)
		return;

	device_remove_file(dev, &debug_device_attr);
	if (par->gamma.curves && par->fbtftops.set_gamma)
		device_remove_file(par->info->dev, &gamma_device_attrs[0]);
		device_remove_file(dev, &gamma_device_attrs[0]);
}