#define MMC_POWER_UNDEFINED_SUPPORTED
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
-/*
- * At this time the internal API for the set brightness was changed to the async
- * version, and one sync API was added to handle cases that need immediate
- * effect. Also, the led class flash and lock for sysfs access was introduced.
- */
-#define LED_HAVE_SET_SYNC
-#define LED_HAVE_FLASH
-#define LED_HAVE_LOCK
-#include <linux/led-class-flash.h>
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
-/*
- * New change in LED api, the set_sync operation was renamed to set_blocking and
- * the workqueue is now handle by core. So, only one set operation is need.
- */
-#undef LED_HAVE_SET_SYNC
-#define LED_HAVE_SET_BLOCKING
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
-/*
- * New helper functions for registering/unregistering flash led devices as v4l2
- * subdevices were added.
- */
-#define V4L2_HAVE_FLASH
-#include <media/v4l2-flash-led-class.h>
-#endif
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
/*
* Power supply get by name need to drop reference after call
#include <linux/kernel.h>
#include <linux/leds.h>
+#include <linux/led-class-flash.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/version.h>
+#include <media/v4l2-flash-led-class.h>
#include "greybus.h"
#include "greybus_protocols.h"
struct attribute **attrs;
struct attribute_group *attr_group;
const struct attribute_group **attr_groups;
-#ifndef LED_HAVE_SET_BLOCKING
- struct work_struct work_brightness_set;
-#endif
struct led_classdev *led;
-#ifdef LED_HAVE_FLASH
+#if IS_REACHABLE(CONFIG_LEDS_CLASS_FLASH)
struct led_classdev_flash fled;
struct led_flash_setting intensity_uA;
struct led_flash_setting timeout_us;
struct gb_channel *channels;
bool has_flash;
bool ready;
-#ifdef V4L2_HAVE_FLASH
+#if IS_REACHABLE(CONFIG_V4L2_FLASH_LED_CLASS)
struct v4l2_flash *v4l2_flash;
#endif
};
| GB_CHANNEL_MODE_INDICATOR));
}
-#ifdef LED_HAVE_FLASH
+#if IS_REACHABLE(CONFIG_LEDS_CLASS_FLASH)
static struct gb_channel *get_channel_from_cdev(struct led_classdev *cdev)
{
struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(cdev);
return __gb_lights_flash_intensity_set(channel, intensity);
}
-#else /* LED_HAVE_FLASH */
+#else
static struct gb_channel *get_channel_from_cdev(struct led_classdev *cdev)
{
return container_of(cdev, struct gb_channel, cled);
{
return 0;
}
-#endif /* !LED_HAVE_FLASH */
+#endif
static int gb_lights_color_set(struct gb_channel *channel, u32 color);
static int gb_lights_fade_set(struct gb_channel *channel);
-#ifdef LED_HAVE_LOCK
static void led_lock(struct led_classdev *cdev)
{
mutex_lock(&cdev->led_access);
{
mutex_unlock(&cdev->led_access);
}
-#else
-static void led_lock(struct led_classdev *cdev)
-{
-}
-
-static void led_unlock(struct led_classdev *cdev)
-{
-}
-#endif /* !LED_HAVE_LOCK */
#define gb_lights_fade_attr(__dir) \
static ssize_t fade_##__dir##_show(struct device *dev, \
return ret;
}
-#ifndef LED_HAVE_SET_BLOCKING
-static void gb_brightness_set_work(struct work_struct *work)
-{
- struct gb_channel *channel = container_of(work, struct gb_channel,
- work_brightness_set);
-
- __gb_lights_brightness_set(channel);
-}
-
-#ifdef LED_HAVE_SET_SYNC
-static int gb_brightness_set_sync(struct led_classdev *cdev,
- enum led_brightness value)
-{
- struct gb_channel *channel = get_channel_from_cdev(cdev);
-
- channel->led->brightness = value;
-
- return __gb_lights_brightness_set(channel);
-}
-#endif
-
-static void gb_brightness_set(struct led_classdev *cdev,
- enum led_brightness value)
-{
- struct gb_channel *channel = get_channel_from_cdev(cdev);
-
- if (channel->releasing)
- return;
-
- cdev->brightness = value;
- schedule_work(&channel->work_brightness_set);
-}
-#else /* LED_HAVE_SET_BLOCKING */
static int gb_brightness_set(struct led_classdev *cdev,
enum led_brightness value)
{
return __gb_lights_brightness_set(channel);
}
-#endif
static enum led_brightness gb_brightness_get(struct led_classdev *cdev)
struct led_classdev *cdev)
{
cdev->brightness_get = gb_brightness_get;
-#ifdef LED_HAVE_SET_SYNC
- cdev->brightness_set_sync = gb_brightness_set_sync;
-#endif
-#ifdef LED_HAVE_SET_BLOCKING
cdev->brightness_set_blocking = gb_brightness_set;
-#endif
-#ifndef LED_HAVE_SET_BLOCKING
- cdev->brightness_set = gb_brightness_set;
- INIT_WORK(&channel->work_brightness_set, gb_brightness_set_work);
-#endif
if (channel->flags & GB_LIGHT_CHANNEL_BLINK)
cdev->blink_set = gb_blink_set;
}
-#ifdef V4L2_HAVE_FLASH
+#if IS_REACHABLE(CONFIG_V4L2_FLASH_LED_CLASS)
/* V4L2 specific helpers */
static const struct v4l2_flash_ops v4l2_flash_ops;
}
#endif
-#ifdef LED_HAVE_FLASH
+#if IS_REACHABLE(CONFIG_LEDS_CLASS_FLASH)
/* Flash specific operations */
static int gb_lights_flash_intensity_set(struct led_classdev_flash *fcdev,
u32 brightness)
{
}
-#endif /* LED_HAVE_FLASH */
+#endif
static int __gb_lights_led_register(struct gb_channel *channel)
{
static void gb_lights_channel_free(struct gb_channel *channel)
{
-#ifndef LED_HAVE_SET_BLOCKING
- flush_work(&channel->work_brightness_set);
-#endif
kfree(channel->attrs);
kfree(channel->attr_group);
kfree(channel->attr_groups);