lm3533: Remove the outdated drivers
Subsystems (5)
cover lm3533: Remove the outdated drivers
Driver is quite outdated from the Linux kernel internal APIs perspective. In particular GPIO code is using legacy calls, that started being replaced by a new API ca. 2014, i.e. ten years ago.
Andy Shevchenko (4):
backlight: lm3533_bl: Remove the driver
iio: light: lm3533-als: Remove the driver
leds: lm3533: Remove the driver
mfd: lm3533: Remove the driver
drivers/iio/light/Kconfig | 17 - drivers/iio/light/Makefile | 1 - drivers/iio/light/lm3533-als.c | 922 ---------------------------- drivers/leds/Kconfig | 13 - drivers/leds/Makefile | 1 - drivers/leds/leds-lm3533.c | 755 ----------------------- drivers/mfd/lm3533-core.c | 645 ------------------- drivers/video/backlight/Kconfig | 11 - drivers/video/backlight/Makefile | 1 - drivers/video/backlight/lm3533_bl.c | 399 ------------ include/linux/mfd/lm3533.h | 100 --- 11 files changed, 2865 deletions(-) delete mode 100644 drivers/iio/light/lm3533-als.c delete mode 100644 drivers/leds/leds-lm3533.c delete mode 100644 drivers/mfd/lm3533-core.c delete mode 100644 drivers/video/backlight/lm3533_bl.c delete mode 100644 include/linux/mfd/lm3533.h
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 1/4 backlight: lm3533_bl: Remove the driver
The driver has no in kernel users and requires a board file to be instantiated. Remove basically a dead code.
If ever needed, it can be reinstantiated and converted to one that uses firmware node interfaces.
--- drivers/video/backlight/Kconfig | 11 - drivers/video/backlight/Makefile | 1 - drivers/video/backlight/lm3533_bl.c | 399 ---------------------------- 3 files changed, 411 deletions(-) delete mode 100644 drivers/video/backlight/lm3533_bl.c
drivers/video/backlight/Kconfig +0 -11
@@ -198,17 +198,6 @@ config BACKLIGHT_KTZ8866 Say Y to enable the backlight driver for the Kinetic KTZ8866 found in Xiaomi Mi Pad 5 series. -config BACKLIGHT_LM3533 - tristate "Backlight Driver for LM3533" - depends on MFD_LM3533 - help - Say Y to enable the backlight driver for National Semiconductor / TI - LM3533 Lighting Power chips. - - The backlights can be controlled directly, through PWM input, or by - the ambient-light-sensor interface. The chip supports 256 brightness - levels. - config BACKLIGHT_LOCOMO tristate "Sharp LOCOMO LCD/Backlight Driver" depends on SHARP_LOCOMO
drivers/video/backlight/Makefile +0 -1
@@ -36,7 +36,6 @@ obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO) += ipaq_micro_bl.o obj-$(CONFIG_BACKLIGHT_KTD253) += ktd253-backlight.o obj-$(CONFIG_BACKLIGHT_KTD2801) += ktd2801-backlight.o obj-$(CONFIG_BACKLIGHT_KTZ8866) += ktz8866.o -obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o obj-$(CONFIG_BACKLIGHT_LM3630A) += lm3630a_bl.o obj-$(CONFIG_BACKLIGHT_LM3639) += lm3639_bl.o obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
drivers/video/backlight/lm3533_bl.c deleted +0 -399
399 lines not on this page · raw message
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 2/4 iio: light: lm3533-als: Remove the driver
In reply to Andy ShevchenkoThe driver has no in kernel users and requires a board file to be instantiated. Remove basically a dead code.
If ever needed, it can be reinstantiated and converted to one that uses firmware node interfaces.
--- drivers/iio/light/Kconfig | 17 - drivers/iio/light/Makefile | 1 - drivers/iio/light/lm3533-als.c | 922 --------------------------------- 3 files changed, 940 deletions(-) delete mode 100644 drivers/iio/light/lm3533-als.c
drivers/iio/light/Kconfig +0 -17
@@ -358,23 +358,6 @@ config RPR0521 To compile this driver as a module, choose M here: the module will be called rpr0521. -config SENSORS_LM3533 - tristate "LM3533 ambient light sensor" - depends on MFD_LM3533 - help - If you say yes here you get support for the ambient light sensor - interface on National Semiconductor / TI LM3533 Lighting Power - chips. - - The sensor interface can be used to control the LEDs and backlights - of the chip through defining five light zones and three sets of - corresponding output-current values. - - The driver provides raw and mean adc readings along with the current - light zone through sysfs. A threshold event can be generated on zone - changes. The ALS-control output values can be set per zone for the - three current output channels. - config LTR390 tristate "LTR-390UV-01 ambient light and UV sensor" depends on I2C
drivers/iio/light/Makefile +0 -1
@@ -31,7 +31,6 @@ obj-$(CONFIG_SENSORS_ISL29028) += isl29028.o obj-$(CONFIG_ISL29125) += isl29125.o obj-$(CONFIG_ISL76682) += isl76682.o obj-$(CONFIG_JSA1212) += jsa1212.o -obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_LTR390) += ltr390.o obj-$(CONFIG_LTR501) += ltr501.o obj-$(CONFIG_LTRF216A) += ltrf216a.o
drivers/iio/light/lm3533-als.c deleted +0 -922
922 lines not on this page · raw message
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Re: [PATCH v1 2/4] iio: light: lm3533-als: Remove the driver
Quoted 7 lines · On Fri, 31 May 2024 19:56:14 +0300 Andy Shevchenko…
The driver has no in kernel users and requires a board file to be instantiated. Remove basically a dead code.
If ever needed, it can be reinstantiated and converted to one that uses firmware node interfaces.
Signed-off-by Andy Shevchenko <[email protected]>
Given the header removal in patch 4, I assume these all need to go together via mfd.
Quoted 975 lines
--- drivers/iio/light/Kconfig | 17 - drivers/iio/light/Makefile | 1 - drivers/iio/light/lm3533-als.c | 922 --------------------------------- 3 files changed, 940 deletions(-) delete mode 100644 drivers/iio/light/lm3533-als.cdrivers/iio/light/Kconfig +0
-17@@ -358,23 +358,6 @@ config RPR0521 To compile this driver as a module, choose M here: the module will be called rpr0521. -config SENSORS_LM3533 - tristate "LM3533 ambient light sensor" - depends on MFD_LM3533 - help - If you say yes here you get support for the ambient light sensor - interface on National Semiconductor / TI LM3533 Lighting Power - chips. - - The sensor interface can be used to control the LEDs and backlights - of the chip through defining five light zones and three sets of - corresponding output-current values. - - The driver provides raw and mean adc readings along with the current - light zone through sysfs. A threshold event can be generated on zone - changes. The ALS-control output values can be set per zone for the - three current output channels. - config LTR390 tristate "LTR-390UV-01 ambient light and UV sensor" depends on I2Cdrivers/iio/light/Makefile +0
-1@@ -31,7 +31,6 @@ obj-$(CONFIG_SENSORS_ISL29028) += isl29028.o obj-$(CONFIG_ISL29125) += isl29125.o obj-$(CONFIG_ISL76682) += isl76682.o obj-$(CONFIG_JSA1212) += jsa1212.o -obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_LTR390) += ltr390.o obj-$(CONFIG_LTR501) += ltr501.o obj-$(CONFIG_LTRF216A) += ltrf216a.odrivers/iio/light/lm3533-als.c deleted +0
-922@@ -1,922 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* lm3533-als.c -- LM3533 Ambient Light Sensor driver -* -* Copyright (C) 2011-2012 Texas Instruments -* -* Author: Johan Hovold <[email protected]> -*/ - -#include <linux/atomic.h> -#include <linux/fs.h> -#include <linux/interrupt.h> -#include <linux/io.h> -#include <linux/iio/events.h> -#include <linux/iio/iio.h> -#include <linux/module.h> -#include <linux/mutex.h> -#include <linux/mfd/core.h> -#include <linux/platform_device.h> -#include <linux/slab.h> -#include <linux/uaccess.h> - -#include <linux/mfd/lm3533.h> - - -#define LM3533_ALS_RESISTOR_MIN 1 -#define LM3533_ALS_RESISTOR_MAX 127 -#define LM3533_ALS_CHANNEL_CURRENT_MAX 2 -#define LM3533_ALS_THRESH_MAX 3 -#define LM3533_ALS_ZONE_MAX 4 - -#define LM3533_REG_ALS_RESISTOR_SELECT 0x30 -#define LM3533_REG_ALS_CONF 0x31 -#define LM3533_REG_ALS_ZONE_INFO 0x34 -#define LM3533_REG_ALS_READ_ADC_RAW 0x37 -#define LM3533_REG_ALS_READ_ADC_AVERAGE 0x38 -#define LM3533_REG_ALS_BOUNDARY_BASE 0x50 -#define LM3533_REG_ALS_TARGET_BASE 0x60 - -#define LM3533_ALS_ENABLE_MASK 0x01 -#define LM3533_ALS_INPUT_MODE_MASK 0x02 -#define LM3533_ALS_INT_ENABLE_MASK 0x01 - -#define LM3533_ALS_ZONE_SHIFT 2 -#define LM3533_ALS_ZONE_MASK 0x1c - -#define LM3533_ALS_FLAG_INT_ENABLED 1 - - -struct lm3533_als { -struct lm3533 *lm3533; -struct platform_device *pdev; - -unsigned long flags; -int irq; - -atomic_t zone; -struct mutex thresh_mutex; -}; - - -static int lm3533_als_get_adc (struct iio_dev *indio_dev,bool average, -int *adc) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 reg; -u8 val; -int ret; - -if (average) - reg =LM3533_REG_ALS_READ_ADC_AVERAGE ; -else - reg =LM3533_REG_ALS_READ_ADC_RAW ; - - ret =lm3533_read (als->lm3533, reg, &val); -if (ret) { -dev_err (&indio_dev->dev,"failed to read adc\n" ); -return ret; - } - - *adc = val; - -return 0 ; -} - -static int _lm3533_als_get_zone (struct iio_dev *indio_dev,u8 *zone) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 val; -int ret; - - ret =lm3533_read (als->lm3533,LM3533_REG_ALS_ZONE_INFO , &val); -if (ret) { -dev_err (&indio_dev->dev,"failed to read zone\n" ); -return ret; - } - - val = (val &LM3533_ALS_ZONE_MASK ) >>LM3533_ALS_ZONE_SHIFT ; - *zone =min_t (u8, val,LM3533_ALS_ZONE_MAX ); - -return 0 ; -} - -static int lm3533_als_get_zone (struct iio_dev *indio_dev,u8 *zone) -{ -struct lm3533_als *als =iio_priv (indio_dev); -int ret; - -if (test_bit (LM3533_ALS_FLAG_INT_ENABLED , &als->flags)) { - *zone =atomic_read (&als->zone); - }else { - ret =_lm3533_als_get_zone (indio_dev, zone); -if (ret) -return ret; - } - -return 0 ; -} - -/* -* channel output channel 0..2 -* zone zone 0..4 -*/ -static inline u8 lm3533_als_get_target_reg (unsigned channel,unsigned zone) -{ -return LM3533_REG_ALS_TARGET_BASE +5 * channel + zone; -} - -static int lm3533_als_get_target (struct iio_dev *indio_dev,unsigned channel, -unsigned zone,u8 *val) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 reg; -int ret; - -if (channel >LM3533_ALS_CHANNEL_CURRENT_MAX ) -return -EINVAL ; - -if (zone >LM3533_ALS_ZONE_MAX ) -return -EINVAL ; - - reg =lm3533_als_get_target_reg (channel, zone); - ret =lm3533_read (als->lm3533, reg, val); -if (ret) -dev_err (&indio_dev->dev,"failed to get target current\n" ); - -return ret; -} - -static int lm3533_als_set_target (struct iio_dev *indio_dev,unsigned channel, -unsigned zone,u8 val) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 reg; -int ret; - -if (channel >LM3533_ALS_CHANNEL_CURRENT_MAX ) -return -EINVAL ; - -if (zone >LM3533_ALS_ZONE_MAX ) -return -EINVAL ; - - reg =lm3533_als_get_target_reg (channel, zone); - ret =lm3533_write (als->lm3533, reg, val); -if (ret) -dev_err (&indio_dev->dev,"failed to set target current\n" ); - -return ret; -} - -static int lm3533_als_get_current (struct iio_dev *indio_dev,unsigned channel, -int *val) -{ -u8 zone; -u8 target; -int ret; - - ret =lm3533_als_get_zone (indio_dev, &zone); -if (ret) -return ret; - - ret =lm3533_als_get_target (indio_dev, channel, zone, &target); -if (ret) -return ret; - - *val = target; - -return 0 ; -} - -static int lm3533_als_read_raw (struct iio_dev *indio_dev, -struct iio_chan_spec const *chan, -int *val,int *val2,long mask) -{ -int ret; - -switch (mask) { -case IIO_CHAN_INFO_RAW : -switch (chan->type) { -case IIO_LIGHT : - ret =lm3533_als_get_adc (indio_dev, false, val); -break ; -case IIO_CURRENT : - ret =lm3533_als_get_current (indio_dev, chan->channel, - val); -break ; -default : -return -EINVAL ; - } -break ; -case IIO_CHAN_INFO_AVERAGE_RAW : - ret =lm3533_als_get_adc (indio_dev, true, val); -break ; -default : -return -EINVAL ; - } - -if (ret) -return ret; - -return IIO_VAL_INT ; -} - -#define CHANNEL_CURRENT (_channel) \ - { \ - .type = IIO_CURRENT, \ - .channel = _channel, \ - .indexed = true, \ - .output = true, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - } - -static const struct iio_chan_spec lm3533_als_channels[] = { - { - .type =IIO_LIGHT , - .channel =0 , - .indexed = true, - .info_mask_separate =BIT (IIO_CHAN_INFO_AVERAGE_RAW ) | -BIT (IIO_CHAN_INFO_RAW ), - }, -CHANNEL_CURRENT (0 ), -CHANNEL_CURRENT (1 ), -CHANNEL_CURRENT (2 ), -}; - -static irqreturn_t lm3533_als_isr (int irq,void *dev_id) -{ - -struct iio_dev *indio_dev = dev_id; -struct lm3533_als *als =iio_priv (indio_dev); -u8 zone; -int ret; - -/* Clear interrupt by reading the ALS zone register. */ - ret =_lm3533_als_get_zone (indio_dev, &zone); -if (ret) - goto out; - -atomic_set (&als->zone, zone); - -iio_push_event (indio_dev, -IIO_UNMOD_EVENT_CODE (IIO_LIGHT , -0 , -IIO_EV_TYPE_THRESH , -IIO_EV_DIR_EITHER ), -iio_get_time_ns (indio_dev)); -out: -return IRQ_HANDLED ; -} - -static int lm3533_als_set_int_mode (struct iio_dev *indio_dev,int enable) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 mask =LM3533_ALS_INT_ENABLE_MASK ; -u8 val; -int ret; - -if (enable) - val = mask; -else - val =0 ; - - ret =lm3533_update (als->lm3533,LM3533_REG_ALS_ZONE_INFO , val, mask); -if (ret) { -dev_err (&indio_dev->dev,"failed to set int mode %d\n" , - enable); -return ret; - } - -return 0 ; -} - -static int lm3533_als_get_int_mode (struct iio_dev *indio_dev,int *enable) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 mask =LM3533_ALS_INT_ENABLE_MASK ; -u8 val; -int ret; - - ret =lm3533_read (als->lm3533,LM3533_REG_ALS_ZONE_INFO , &val); -if (ret) { -dev_err (&indio_dev->dev,"failed to get int mode\n" ); -return ret; - } - - *enable = !!(val & mask); - -return 0 ; -} - -static inline u8 lm3533_als_get_threshold_reg (unsigned nr,bool raising) -{ -u8 offset = !raising; - -return LM3533_REG_ALS_BOUNDARY_BASE +2 * nr + offset; -} - -static int lm3533_als_get_threshold (struct iio_dev *indio_dev,unsigned nr, -bool raising,u8 *val) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 reg; -int ret; - -if (nr >LM3533_ALS_THRESH_MAX ) -return -EINVAL ; - - reg =lm3533_als_get_threshold_reg (nr, raising); - ret =lm3533_read (als->lm3533, reg, val); -if (ret) -dev_err (&indio_dev->dev,"failed to get threshold\n" ); - -return ret; -} - -static int lm3533_als_set_threshold (struct iio_dev *indio_dev,unsigned nr, -bool raising,u8 val) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 val2; -u8 reg, reg2; -int ret; - -if (nr >LM3533_ALS_THRESH_MAX ) -return -EINVAL ; - - reg =lm3533_als_get_threshold_reg (nr, raising); - reg2 =lm3533_als_get_threshold_reg (nr, !raising); - -mutex_lock (&als->thresh_mutex); - ret =lm3533_read (als->lm3533, reg2, &val2); -if (ret) { -dev_err (&indio_dev->dev,"failed to get threshold\n" ); - goto out; - } -/* -* This device does not allow negative hysteresis (in fact, it uses -* whichever value is smaller as the lower bound) so we need to make -* sure that thresh_falling <= thresh_raising. -*/ -if ((raising && (val < val2)) || (!raising && (val > val2))) { - ret = -EINVAL ; - goto out; - } - - ret =lm3533_write (als->lm3533, reg, val); -if (ret) { -dev_err (&indio_dev->dev,"failed to set threshold\n" ); - goto out; - } -out: -mutex_unlock (&als->thresh_mutex); - -return ret; -} - -static int lm3533_als_get_hysteresis (struct iio_dev *indio_dev,unsigned nr, -u8 *val) -{ -struct lm3533_als *als =iio_priv (indio_dev); -u8 falling; -u8 raising; -int ret; - -if (nr >LM3533_ALS_THRESH_MAX ) -return -EINVAL ; - -mutex_lock (&als->thresh_mutex); - ret =lm3533_als_get_threshold (indio_dev, nr, false, &falling); -if (ret) - goto out; - ret =lm3533_als_get_threshold (indio_dev, nr, true, &raising); -if (ret) - goto out; - - *val = raising - falling; -out: -mutex_unlock (&als->thresh_mutex); - -return ret; -} - -static ssize_t show_thresh_either_en (struct device *dev, -struct device_attribute *attr, -char *buf) -{ -struct iio_dev *indio_dev =dev_to_iio_dev (dev); -struct lm3533_als *als =iio_priv (indio_dev); -int enable; -int ret; - -if (als->irq) { - ret =lm3533_als_get_int_mode (indio_dev, &enable); -if (ret) -return ret; - }else { - enable =0 ; - } - -return sysfs_emit (buf,"%u\n" , enable); -} - -static ssize_t store_thresh_either_en (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t len) -{ -struct iio_dev *indio_dev =dev_to_iio_dev (dev); -struct lm3533_als *als =iio_priv (indio_dev); -unsigned long enable; -bool int_enabled; -u8 zone; -int ret; - -if (!als->irq) -return -EBUSY ; - -if (kstrtoul (buf,0 , &enable)) -return -EINVAL ; - - int_enabled =test_bit (LM3533_ALS_FLAG_INT_ENABLED , &als->flags); - -if (enable && !int_enabled) { - ret =lm3533_als_get_zone (indio_dev, &zone); -if (ret) -return ret; - -atomic_set (&als->zone, zone); - -set_bit (LM3533_ALS_FLAG_INT_ENABLED , &als->flags); - } - - ret =lm3533_als_set_int_mode (indio_dev, enable); -if (ret) { -if (!int_enabled) -clear_bit (LM3533_ALS_FLAG_INT_ENABLED , &als->flags); - -return ret; - } - -if (!enable) -clear_bit (LM3533_ALS_FLAG_INT_ENABLED , &als->flags); - -return len; -} - -static ssize_t show_zone (struct device *dev, -struct device_attribute *attr,char *buf) -{ -struct iio_dev *indio_dev =dev_to_iio_dev (dev); -u8 zone; -int ret; - - ret =lm3533_als_get_zone (indio_dev, &zone); -if (ret) -return ret; - -return sysfs_emit (buf,"%u\n" , zone); -} - -enum lm3533_als_attribute_type { -LM3533_ATTR_TYPE_HYSTERESIS , -LM3533_ATTR_TYPE_TARGET , -LM3533_ATTR_TYPE_THRESH_FALLING , -LM3533_ATTR_TYPE_THRESH_RAISING , -}; - -struct lm3533_als_attribute { -struct device_attribute dev_attr; -enum lm3533_als_attribute_type type; -u8 val1; -u8 val2; -}; - -static inline struct lm3533_als_attribute * -to_lm3533_als_attr (struct device_attribute *attr) -{ - return container_of(attr, struct lm3533_als_attribute, dev_attr); -} - -static ssize_t show_als_attr (struct device *dev, -struct device_attribute *attr, -char *buf) -{ -struct iio_dev *indio_dev =dev_to_iio_dev (dev); -struct lm3533_als_attribute *als_attr =to_lm3533_als_attr (attr); -u8 val; -int ret; - -switch (als_attr->type) { -case LM3533_ATTR_TYPE_HYSTERESIS : - ret =lm3533_als_get_hysteresis (indio_dev, als_attr->val1, - &val); -break ; -case LM3533_ATTR_TYPE_TARGET : - ret =lm3533_als_get_target (indio_dev, als_attr->val1, - als_attr->val2, &val); -break ; -case LM3533_ATTR_TYPE_THRESH_FALLING : - ret =lm3533_als_get_threshold (indio_dev, als_attr->val1, - false, &val); -break ; -case LM3533_ATTR_TYPE_THRESH_RAISING : - ret =lm3533_als_get_threshold (indio_dev, als_attr->val1, - true, &val); -break ; -default : - ret = -ENXIO ; - } - -if (ret) -return ret; - -return sysfs_emit (buf,"%u\n" , val); -} - -static ssize_t store_als_attr (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t len) -{ -struct iio_dev *indio_dev =dev_to_iio_dev (dev); -struct lm3533_als_attribute *als_attr =to_lm3533_als_attr (attr); -u8 val; -int ret; - -if (kstrtou8 (buf,0 , &val)) -return -EINVAL ; - -switch (als_attr->type) { -case LM3533_ATTR_TYPE_TARGET : - ret =lm3533_als_set_target (indio_dev, als_attr->val1, - als_attr->val2, val); -break ; -case LM3533_ATTR_TYPE_THRESH_FALLING : - ret =lm3533_als_set_threshold (indio_dev, als_attr->val1, - false, val); -break ; -case LM3533_ATTR_TYPE_THRESH_RAISING : - ret =lm3533_als_set_threshold (indio_dev, als_attr->val1, - true, val); -break ; -default : - ret = -ENXIO ; - } - -if (ret) -return ret; - -return len; -} - -#define ALS_ATTR (_name, _mode, _show, _store, _type, _val1, _val2) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .type = _type, \ - .val1 = _val1, \ - .val2 = _val2 } - -#define LM3533_ALS_ATTR (_name, _mode, _show, _store, _type, _val1, _val2) \ - struct lm3533_als_attribute lm3533_als_attr_##_name = \ - ALS_ATTR(_name, _mode, _show, _store, _type, _val1, _val2) - -#define ALS_TARGET_ATTR_RW (_channel, _zone) \ - LM3533_ALS_ATTR(out_current##_channel##_current##_zone##_raw, \ - S_IRUGO | S_IWUSR, \ - show_als_attr, store_als_attr, \ - LM3533_ATTR_TYPE_TARGET, _channel, _zone) -/* -* ALS output current values (ALS mapper targets) -* -* out_current[0-2]_current[0-4]_raw 0-255 -*/ -static ALS_TARGET_ATTR_RW(0, 0); -static ALS_TARGET_ATTR_RW(0, 1); -static ALS_TARGET_ATTR_RW(0, 2); -static ALS_TARGET_ATTR_RW(0, 3); -static ALS_TARGET_ATTR_RW(0, 4); - -static ALS_TARGET_ATTR_RW(1, 0); -static ALS_TARGET_ATTR_RW(1, 1); -static ALS_TARGET_ATTR_RW(1, 2); -static ALS_TARGET_ATTR_RW(1, 3); -static ALS_TARGET_ATTR_RW(1, 4); - -static ALS_TARGET_ATTR_RW(2, 0); -static ALS_TARGET_ATTR_RW(2, 1); -static ALS_TARGET_ATTR_RW(2, 2); -static ALS_TARGET_ATTR_RW(2, 3); -static ALS_TARGET_ATTR_RW(2, 4); - -#define ALS_THRESH_FALLING_ATTR_RW(_nr) \ - LM3533_ALS_ATTR(in_illuminance0_thresh##_nr##_falling_value, \ - S_IRUGO | S_IWUSR, \ - show_als_attr, store_als_attr, \ - LM3533_ATTR_TYPE_THRESH_FALLING, _nr, 0) - -#define ALS_THRESH_RAISING_ATTR_RW(_nr) \ - LM3533_ALS_ATTR(in_illuminance0_thresh##_nr##_raising_value, \ - S_IRUGO | S_IWUSR, \ - show_als_attr, store_als_attr, \ - LM3533_ATTR_TYPE_THRESH_RAISING, _nr, 0) -/* - * ALS Zone thresholds (boundaries) - * - * in_illuminance0_thresh[0-3]_falling_value 0-255 - * in_illuminance0_thresh[0-3]_raising_value 0-255 - */ -static ALS_THRESH_FALLING_ATTR_RW(0); -static ALS_THRESH_FALLING_ATTR_RW(1); -static ALS_THRESH_FALLING_ATTR_RW(2); -static ALS_THRESH_FALLING_ATTR_RW(3); - -static ALS_THRESH_RAISING_ATTR_RW(0); -static ALS_THRESH_RAISING_ATTR_RW(1); -static ALS_THRESH_RAISING_ATTR_RW(2); -static ALS_THRESH_RAISING_ATTR_RW(3); - -#define ALS_HYSTERESIS_ATTR_RO(_nr) \ - LM3533_ALS_ATTR(in_illuminance0_thresh##_nr##_hysteresis, \ - S_IRUGO, show_als_attr, NULL, \ - LM3533_ATTR_TYPE_HYSTERESIS, _nr, 0) -/* - * ALS Zone threshold hysteresis - * - * threshY_hysteresis = threshY_raising - threshY_falling - * - * in_illuminance0_thresh[0-3]_hysteresis 0-255 - * in_illuminance0_thresh[0-3]_hysteresis 0-255 - */ -static ALS_HYSTERESIS_ATTR_RO(0); -static ALS_HYSTERESIS_ATTR_RO(1); -static ALS_HYSTERESIS_ATTR_RO(2); -static ALS_HYSTERESIS_ATTR_RO(3); - -#define ILLUMINANCE_ATTR_RO(_name) \ - DEVICE_ATTR(in_illuminance0_##_name, S_IRUGO, show_##_name, NULL) -#define ILLUMINANCE_ATTR_RW(_name) \ - DEVICE_ATTR(in_illuminance0_##_name, S_IRUGO | S_IWUSR, \ - show_##_name, store_##_name) -/* - * ALS Zone threshold-event enable - * - * in_illuminance0_thresh_either_en 0,1 - */ -static ILLUMINANCE_ATTR_RW(thresh_either_en); - -/* - * ALS Current Zone - * - * in_illuminance0_zone 0-4 - */ -static ILLUMINANCE_ATTR_RO(zone); - -static struct attribute *lm3533_als_event_attributes[] = { - &dev_attr_in_illuminance0_thresh_either_en.attr, - &lm3533_als_attr_in_illuminance0_thresh0_falling_value.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh0_hysteresis.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh0_raising_value.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh1_falling_value.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh1_hysteresis.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh1_raising_value.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh2_falling_value.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh2_hysteresis.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh2_raising_value.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh3_falling_value.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh3_hysteresis.dev_attr.attr, - &lm3533_als_attr_in_illuminance0_thresh3_raising_value.dev_attr.attr, - NULL -}; - -static const struct attribute_group lm3533_als_event_attribute_group = { - .attrs = lm3533_als_event_attributes -}; - -static struct attribute *lm3533_als_attributes[] = { - &dev_attr_in_illuminance0_zone.attr, - &lm3533_als_attr_out_current0_current0_raw.dev_attr.attr, - &lm3533_als_attr_out_current0_current1_raw.dev_attr.attr, - &lm3533_als_attr_out_current0_current2_raw.dev_attr.attr, - &lm3533_als_attr_out_current0_current3_raw.dev_attr.attr, - &lm3533_als_attr_out_current0_current4_raw.dev_attr.attr, - &lm3533_als_attr_out_current1_current0_raw.dev_attr.attr, - &lm3533_als_attr_out_current1_current1_raw.dev_attr.attr, - &lm3533_als_attr_out_current1_current2_raw.dev_attr.attr, - &lm3533_als_attr_out_current1_current3_raw.dev_attr.attr, - &lm3533_als_attr_out_current1_current4_raw.dev_attr.attr, - &lm3533_als_attr_out_current2_current0_raw.dev_attr.attr, - &lm3533_als_attr_out_current2_current1_raw.dev_attr.attr, - &lm3533_als_attr_out_current2_current2_raw.dev_attr.attr, - &lm3533_als_attr_out_current2_current3_raw.dev_attr.attr, - &lm3533_als_attr_out_current2_current4_raw.dev_attr.attr, - NULL -}; - -static const struct attribute_group lm3533_als_attribute_group = { - .attrs = lm3533_als_attributes -}; - -static int lm3533_als_set_input_mode(struct lm3533_als *als, bool pwm_mode) -{ - u8 mask = LM3533_ALS_INPUT_MODE_MASK; - u8 val; - int ret; - - if (pwm_mode) - val = mask; /* pwm input */ - else - val = 0; /* analog input */ - - ret = lm3533_update(als->lm3533, LM3533_REG_ALS_CONF, val, mask); - if (ret) { - dev_err(&als->pdev->dev, "failed to set input mode %d\n", - pwm_mode); -return ret; - } - -return 0 ; -} - -static int lm3533_als_set_resistor (struct lm3533_als *als,u8 val) -{ -int ret; - -if (val <LM3533_ALS_RESISTOR_MIN || val >LM3533_ALS_RESISTOR_MAX ) { -dev_err (&als->pdev->dev,"invalid resistor value\n" ); -return -EINVAL ; - } - - ret =lm3533_write (als->lm3533,LM3533_REG_ALS_RESISTOR_SELECT , val); -if (ret) { -dev_err (&als->pdev->dev,"failed to set resistor\n" ); -return ret; - } - -return 0 ; -} - -static int lm3533_als_setup (struct lm3533_als *als, -struct lm3533_als_platform_data *pdata) -{ -int ret; - - ret =lm3533_als_set_input_mode (als, pdata->pwm_mode); -if (ret) -return ret; - -/* ALS input is always high impedance in PWM-mode. */ -if (!pdata->pwm_mode) { - ret =lm3533_als_set_resistor (als, pdata->r_select); -if (ret) -return ret; - } - -return 0 ; -} - -static int lm3533_als_setup_irq (struct lm3533_als *als,void *dev) -{ -u8 mask =LM3533_ALS_INT_ENABLE_MASK ; -int ret; - -/* Make sure interrupts are disabled. */ - ret =lm3533_update (als->lm3533,LM3533_REG_ALS_ZONE_INFO ,0 , mask); -if (ret) { -dev_err (&als->pdev->dev,"failed to disable interrupts\n" ); -return ret; - } - - ret =request_threaded_irq (als->irq,NULL , lm3533_als_isr, -IRQF_TRIGGER_LOW |IRQF_ONESHOT , -dev_name (&als->pdev->dev), dev); -if (ret) { -dev_err (&als->pdev->dev,"failed to request irq %d\n" , - als->irq); -return ret; - } - -return 0 ; -} - -static int lm3533_als_enable (struct lm3533_als *als) -{ -u8 mask =LM3533_ALS_ENABLE_MASK ; -int ret; - - ret =lm3533_update (als->lm3533,LM3533_REG_ALS_CONF , mask, mask); -if (ret) -dev_err (&als->pdev->dev,"failed to enable ALS\n" ); - -return ret; -} - -static int lm3533_als_disable (struct lm3533_als *als) -{ -u8 mask =LM3533_ALS_ENABLE_MASK ; -int ret; - - ret =lm3533_update (als->lm3533,LM3533_REG_ALS_CONF ,0 , mask); -if (ret) -dev_err (&als->pdev->dev,"failed to disable ALS\n" ); - -return ret; -} - -static const struct iio_info lm3533_als_info = { - .attrs = &lm3533_als_attribute_group, - .event_attrs = &lm3533_als_event_attribute_group, - .read_raw = &lm3533_als_read_raw, -}; - -static int lm3533_als_probe (struct platform_device *pdev) -{ -struct lm3533 *lm3533; -struct lm3533_als_platform_data *pdata; -struct lm3533_als *als; -struct iio_dev *indio_dev; -int ret; - - lm3533 =dev_get_drvdata (pdev->dev.parent); -if (!lm3533) -return -EINVAL ; - - pdata = pdev->dev.platform_data; -if (!pdata) { -dev_err (&pdev->dev,"no platform data\n" ); -return -EINVAL ; - } - - indio_dev =devm_iio_device_alloc (&pdev->dev,sizeof (*als)); -if (!indio_dev) -return -ENOMEM ; - - indio_dev->info = &lm3533_als_info; - indio_dev->channels = lm3533_als_channels; - indio_dev->num_channels =ARRAY_SIZE (lm3533_als_channels); - indio_dev->name =dev_name (&pdev->dev); -iio_device_set_parent (indio_dev, pdev->dev.parent); - indio_dev->modes =INDIO_DIRECT_MODE ; - - als =iio_priv (indio_dev); - als->lm3533 = lm3533; - als->pdev = pdev; - als->irq = lm3533->irq; -atomic_set (&als->zone,0 ); -mutex_init (&als->thresh_mutex); - -platform_set_drvdata (pdev, indio_dev); - -if (als->irq) { - ret =lm3533_als_setup_irq (als, indio_dev); -if (ret) -return ret; - } - - ret =lm3533_als_setup (als, pdata); -if (ret) - goto err_free_irq; - - ret =lm3533_als_enable (als); -if (ret) - goto err_free_irq; - - ret =iio_device_register (indio_dev); -if (ret) { -dev_err (&pdev->dev,"failed to register ALS\n" ); - goto err_disable; - } - -return 0 ; - -err_disable: -lm3533_als_disable (als); -err_free_irq: -if (als->irq) -free_irq (als->irq, indio_dev); - -return ret; -} - -static void lm3533_als_remove (struct platform_device *pdev) -{ -struct iio_dev *indio_dev =platform_get_drvdata (pdev); -struct lm3533_als *als =iio_priv (indio_dev); - -lm3533_als_set_int_mode (indio_dev, false); -iio_device_unregister (indio_dev); -lm3533_als_disable (als); -if (als->irq) -free_irq (als->irq, indio_dev); -} - -static struct platform_driver lm3533_als_driver = { - .driver = { - .name ="lm3533-als" , - }, - .probe = lm3533_als_probe, - .remove_new = lm3533_als_remove, -}; -module_platform_driver (lm3533_als_driver); - -MODULE_AUTHOR ("Johan Hovold <[email protected]>" ); -MODULE_DESCRIPTION ("LM3533 Ambient Light Sensor driver" ); -MODULE_LICENSE ("GPL" ); -MODULE_ALIAS ("platform:lm3533-als" );
Re: [PATCH v1 2/4] iio: light: lm3533-als: Remove the driver
Quoted 6 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 31 May 2024 19:56:14 +0300 Andy Shevchenko…
The driver has no in kernel users and requires a board file to be instantiated. Remove basically a dead code.
Quoted 8 lines
Quoted 4 lines
If ever needed, it can be reinstantiated and converted to one that uses firmware node interfaces.
Signed-off-by Andy Shevchenko <[email protected]>Given the header removal in patch 4, I assume these all need to go together via mfd.
Acked-by Jonathan Cameron <[email protected]>
Thank you! We are waiting for Johan to tell what his plans about the driver. If it comes to removal, I add your tag to the new version of this mini-series.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 3/4 leds: lm3533: Remove the driver
In reply to Andy ShevchenkoThe driver has no in kernel users and requires a board file to be instantiated. Remove basically a dead code.
If ever needed, it can be reinstantiated and converted to one that uses firmware node interfaces.
--- drivers/leds/Kconfig | 13 - drivers/leds/Makefile | 1 - drivers/leds/leds-lm3533.c | 755 ------------------------------------- 3 files changed, 769 deletions(-) delete mode 100644 drivers/leds/leds-lm3533.c
drivers/leds/Kconfig +0 -13
@@ -229,19 +229,6 @@ config LEDS_LM3532 controlled manually or using PWM input or using ambient light automatically. -config LEDS_LM3533 - tristate "LED support for LM3533" - depends on LEDS_CLASS - depends on MFD_LM3533 - help - This option enables support for the LEDs on National Semiconductor / - TI LM3533 Lighting Power chips. - - The LEDs can be controlled directly, through PWM input, or by the - ambient-light-sensor interface. The chip supports - hardware-accelerated blinking with maximum on and off periods of 9.8 - and 77 seconds respectively. - config LEDS_LM3642 tristate "LED support for LM3642 Chip" depends on LEDS_CLASS && I2C
drivers/leds/Makefile +0 -1
@@ -38,7 +38,6 @@ obj-$(CONFIG_LEDS_IS31FL319X) += leds-is31fl319x.o obj-$(CONFIG_LEDS_IS31FL32XX) += leds-is31fl32xx.o obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o obj-$(CONFIG_LEDS_LM3532) += leds-lm3532.o -obj-$(CONFIG_LEDS_LM3533) += leds-lm3533.o obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o obj-$(CONFIG_LEDS_LM36274) += leds-lm36274.o obj-$(CONFIG_LEDS_LM3642) += leds-lm3642.o
drivers/leds/leds-lm3533.c deleted +0 -755
755 lines not on this page · raw message
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 4/4 mfd: lm3533: Remove the driver
In reply to Andy ShevchenkoThe driver has no in kernel users and requires a board file to be instantiated. Remove basically a dead code.
If ever needed, it can be reinstantiated and converted to one that uses firmware node interfaces.
--- drivers/mfd/lm3533-core.c | 645 ------------------------------------- include/linux/mfd/lm3533.h | 100 ------ 2 files changed, 745 deletions(-) delete mode 100644 drivers/mfd/lm3533-core.c delete mode 100644 include/linux/mfd/lm3533.h
drivers/mfd/lm3533-core.c deleted +0 -645
@@ -1,645 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* lm3533-core.c -- LM3533 Core -* -* Copyright (C) 2011-2012 Texas Instruments -* -* Author: Johan Hovold <[email protected]> -*/ - -#include <linux/module.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/err.h> -#include <linux/gpio.h> -#include <linux/i2c.h> -#include <linux/mfd/core.h> -#include <linux/regmap.h> -#include <linux/seq_file.h> -#include <linux/slab.h> -#include <linux/uaccess.h> - -#include <linux/mfd/lm3533.h> - - -#define LM3533_BOOST_OVP_MASK 0x06 -#define LM3533_BOOST_OVP_SHIFT 1 - -#define LM3533_BOOST_FREQ_MASK 0x01 -#define LM3533_BOOST_FREQ_SHIFT 0 - -#define LM3533_BL_ID_MASK 1 -#define LM3533_LED_ID_MASK 3 -#define LM3533_BL_ID_MAX 1 -#define LM3533_LED_ID_MAX 3 - -#define LM3533_HVLED_ID_MAX 2 -#define LM3533_LVLED_ID_MAX 5 - -#define LM3533_REG_OUTPUT_CONF1 0x10 -#define LM3533_REG_OUTPUT_CONF2 0x11 -#define LM3533_REG_BOOST_PWM 0x2c - -#define LM3533_REG_MAX 0xb2 - - -static struct mfd_cell lm3533_als_devs[] = { - { - .name ="lm3533-als" , - .id =-1 , - }, -}; - -static struct mfd_cell lm3533_bl_devs[] = { - { - .name ="lm3533-backlight" , - .id =0 , - }, - { - .name ="lm3533-backlight" , - .id =1 , - }, -}; - -static struct mfd_cell lm3533_led_devs[] = { - { - .name ="lm3533-leds" , - .id =0 , - }, - { - .name ="lm3533-leds" , - .id =1 , - }, - { - .name ="lm3533-leds" , - .id =2 , - }, - { - .name ="lm3533-leds" , - .id =3 , - }, -}; - -int lm3533_read (struct lm3533 *lm3533,u8 reg,u8 *val) -{ -int tmp; -int ret; - - ret =regmap_read (lm3533->regmap, reg, &tmp); -if (ret <0 ) { -dev_err (lm3533->dev,"failed to read register %02x: %d\n" , - reg, ret); -return ret; - } - - *val = tmp; - -dev_dbg (lm3533->dev,"read [%02x]: %02x\n" , reg, *val); - -return ret; -} -EXPORT_SYMBOL_GPL (lm3533_read); - -int lm3533_write (struct lm3533 *lm3533,u8 reg,u8 val) -{ -int ret; - -dev_dbg (lm3533->dev,"write [%02x]: %02x\n" , reg, val); - - ret =regmap_write (lm3533->regmap, reg, val); -if (ret <0 ) { -dev_err (lm3533->dev,"failed to write register %02x: %d\n" , - reg, ret); - } - -return ret; -} -EXPORT_SYMBOL_GPL (lm3533_write); - -int lm3533_update (struct lm3533 *lm3533,u8 reg,u8 val,u8 mask) -{ -int ret; - -dev_dbg (lm3533->dev,"update [%02x]: %02x/%02x\n" , reg, val, mask); - - ret =regmap_update_bits (lm3533->regmap, reg, mask, val); -if (ret <0 ) { -dev_err (lm3533->dev,"failed to update register %02x: %d\n" , - reg, ret); - } - -return ret; -} -EXPORT_SYMBOL_GPL (lm3533_update); - -static int lm3533_set_boost_freq (struct lm3533 *lm3533, -enum lm3533_boost_freq freq) -{ -int ret; - - ret =lm3533_update (lm3533,LM3533_REG_BOOST_PWM , - freq <<LM3533_BOOST_FREQ_SHIFT , -LM3533_BOOST_FREQ_MASK ); -if (ret) -dev_err (lm3533->dev,"failed to set boost frequency\n" ); - -return ret; -} - - -static int lm3533_set_boost_ovp (struct lm3533 *lm3533, -enum lm3533_boost_ovp ovp) -{ -int ret; - - ret =lm3533_update (lm3533,LM3533_REG_BOOST_PWM , - ovp <<LM3533_BOOST_OVP_SHIFT , -LM3533_BOOST_OVP_MASK ); -if (ret) -dev_err (lm3533->dev,"failed to set boost ovp\n" ); - -return ret; -} - -/* -* HVLED output config -- output hvled controlled by backlight bl -*/ -static int lm3533_set_hvled_config (struct lm3533 *lm3533,u8 hvled,u8 bl) -{ -u8 val; -u8 mask; -int shift; -int ret; - -if (hvled ==0 || hvled >LM3533_HVLED_ID_MAX ) -return -EINVAL ; - -if (bl >LM3533_BL_ID_MAX ) -return -EINVAL ; - - shift = hvled -1 ; - mask =LM3533_BL_ID_MASK << shift; - val = bl << shift; - - ret =lm3533_update (lm3533,LM3533_REG_OUTPUT_CONF1 , val, mask); -if (ret) -dev_err (lm3533->dev,"failed to set hvled config\n" ); - -return ret; -} - -/* -* LVLED output config -- output lvled controlled by LED led -*/ -static int lm3533_set_lvled_config (struct lm3533 *lm3533,u8 lvled,u8 led) -{ -u8 reg; -u8 val; -u8 mask; -int shift; -int ret; - -if (lvled ==0 || lvled >LM3533_LVLED_ID_MAX ) -return -EINVAL ; - -if (led >LM3533_LED_ID_MAX ) -return -EINVAL ; - -if (lvled <4 ) { - reg =LM3533_REG_OUTPUT_CONF1 ; - shift =2 * lvled; - }else { - reg =LM3533_REG_OUTPUT_CONF2 ; - shift =2 * (lvled -4 ); - } - - mask =LM3533_LED_ID_MASK << shift; - val = led << shift; - - ret =lm3533_update (lm3533, reg, val, mask); -if (ret) -dev_err (lm3533->dev,"failed to set lvled config\n" ); - -return ret; -} - -static void lm3533_enable (struct lm3533 *lm3533) -{ -if (gpio_is_valid (lm3533->gpio_hwen)) -gpio_set_value (lm3533->gpio_hwen,1 ); -} - -static void lm3533_disable (struct lm3533 *lm3533) -{ -if (gpio_is_valid (lm3533->gpio_hwen)) -gpio_set_value (lm3533->gpio_hwen,0 ); -} - -enum lm3533_attribute_type { -LM3533_ATTR_TYPE_BACKLIGHT , -LM3533_ATTR_TYPE_LED , -}; - -struct lm3533_device_attribute { -struct device_attribute dev_attr; -enum lm3533_attribute_type type; -union { -struct { -u8 id; - } output; - } u; -}; - -#define to_lm3533_dev_attr (_attr) \ - container_of(_attr, struct lm3533_device_attribute, dev_attr) - -static ssize_t show_output (struct device *dev, -struct device_attribute *attr,char *buf) -{ -struct lm3533 *lm3533 =dev_get_drvdata (dev); -struct lm3533_device_attribute *lattr =to_lm3533_dev_attr (attr); -int id = lattr->u.output.id; -u8 reg; -u8 val; -u8 mask; -int shift; -int ret; - -if (lattr->type ==LM3533_ATTR_TYPE_BACKLIGHT ) { - reg =LM3533_REG_OUTPUT_CONF1 ; - shift = id -1 ; - mask =LM3533_BL_ID_MASK << shift; - }else { -if (id <4 ) { - reg =LM3533_REG_OUTPUT_CONF1 ; - shift =2 * id; - }else { - reg =LM3533_REG_OUTPUT_CONF2 ; - shift =2 * (id -4 ); - } - mask =LM3533_LED_ID_MASK << shift; - } - - ret =lm3533_read (lm3533, reg, &val); -if (ret) -return ret; - - val = (val & mask) >> shift; - -return sysfs_emit (buf,"%u\n" , val); -} - -static ssize_t store_output (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t len) -{ -struct lm3533 *lm3533 =dev_get_drvdata (dev); -struct lm3533_device_attribute *lattr =to_lm3533_dev_attr (attr); -int id = lattr->u.output.id; -u8 val; -int ret; - -if (kstrtou8 (buf,0 , &val)) -return -EINVAL ; - -if (lattr->type ==LM3533_ATTR_TYPE_BACKLIGHT ) - ret =lm3533_set_hvled_config (lm3533, id, val); -else - ret =lm3533_set_lvled_config (lm3533, id, val); - -if (ret) -return ret; - -return len; -} - -#define LM3533_OUTPUT_ATTR (_name, _mode, _show, _store, _type, _id) \ - struct lm3533_device_attribute lm3533_dev_attr_##_name = \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .type = _type, \ - .u.output = { .id = _id }, } - -#define LM3533_OUTPUT_ATTR_RW (_name, _type, _id) \ - LM3533_OUTPUT_ATTR(output_##_name, S_IRUGO | S_IWUSR, \ - show_output, store_output, _type, _id) - -#define LM3533_OUTPUT_HVLED_ATTR_RW (_nr) \ - LM3533_OUTPUT_ATTR_RW(hvled##_nr, LM3533_ATTR_TYPE_BACKLIGHT, _nr) -#define LM3533_OUTPUT_LVLED_ATTR_RW (_nr) \ - LM3533_OUTPUT_ATTR_RW(lvled##_nr, LM3533_ATTR_TYPE_LED, _nr) -/* -* Output config: -* -* output_hvled<nr> 0-1 -* output_lvled<nr> 0-3 -*/ -static LM3533_OUTPUT_HVLED_ATTR_RW(1); -static LM3533_OUTPUT_HVLED_ATTR_RW(2); -static LM3533_OUTPUT_LVLED_ATTR_RW(1); -static LM3533_OUTPUT_LVLED_ATTR_RW(2); -static LM3533_OUTPUT_LVLED_ATTR_RW(3); -static LM3533_OUTPUT_LVLED_ATTR_RW(4); -static LM3533_OUTPUT_LVLED_ATTR_RW(5); - -static struct attribute *lm3533_attributes[] = { - &lm3533_dev_attr_output_hvled1.dev_attr.attr, - &lm3533_dev_attr_output_hvled2.dev_attr.attr, - &lm3533_dev_attr_output_lvled1.dev_attr.attr, - &lm3533_dev_attr_output_lvled2.dev_attr.attr, - &lm3533_dev_attr_output_lvled3.dev_attr.attr, - &lm3533_dev_attr_output_lvled4.dev_attr.attr, - &lm3533_dev_attr_output_lvled5.dev_attr.attr, -NULL , -}; - -#define to_dev_attr (_attr) \ - container_of(_attr, struct device_attribute, attr) - -static umode_t lm3533_attr_is_visible (struct kobject *kobj, -struct attribute *attr,int n) -{ -struct device *dev =kobj_to_dev (kobj); -struct lm3533 *lm3533 =dev_get_drvdata (dev); -struct device_attribute *dattr =to_dev_attr (attr); -struct lm3533_device_attribute *lattr =to_lm3533_dev_attr (dattr); -enum lm3533_attribute_type type = lattr->type; -umode_t mode = attr->mode; - -if (!lm3533->have_backlights && type ==LM3533_ATTR_TYPE_BACKLIGHT ) - mode =0 ; -else if (!lm3533->have_leds && type ==LM3533_ATTR_TYPE_LED ) - mode =0 ; - -return mode; -}; - -static struct attribute_group lm3533_attribute_group = { - .is_visible = lm3533_attr_is_visible, - .attrs = lm3533_attributes -}; - -static int lm3533_device_als_init (struct lm3533 *lm3533) -{ -struct lm3533_platform_data *pdata =dev_get_platdata (lm3533->dev); -int ret; - -if (!pdata->als) -return 0 ; - - lm3533_als_devs[0 ].platform_data = pdata->als; - lm3533_als_devs[0 ].pdata_size =sizeof (*pdata->als); - - ret =mfd_add_devices (lm3533->dev,0 , lm3533_als_devs,1 ,NULL , -0 ,NULL ); -if (ret) { -dev_err (lm3533->dev,"failed to add ALS device\n" ); -return ret; - } - - lm3533->have_als =1 ; - -return 0 ; -} - -static int lm3533_device_bl_init (struct lm3533 *lm3533) -{ -struct lm3533_platform_data *pdata =dev_get_platdata (lm3533->dev); -int i; -int ret; - -if (!pdata->backlights || pdata->num_backlights ==0 ) -return 0 ; - -if (pdata->num_backlights >ARRAY_SIZE (lm3533_bl_devs)) - pdata->num_backlights =ARRAY_SIZE (lm3533_bl_devs); - -for (i =0 ; i < pdata->num_backlights; ++i) { - lm3533_bl_devs[i].platform_data = &pdata->backlights[i]; - lm3533_bl_devs[i].pdata_size =sizeof (pdata->backlights[i]); - } - - ret =mfd_add_devices (lm3533->dev,0 , lm3533_bl_devs, - pdata->num_backlights,NULL ,0 ,NULL ); -if (ret) { -dev_err (lm3533->dev,"failed to add backlight devices\n" ); -return ret; - } - - lm3533->have_backlights =1 ; - -return 0 ; -} - -static int lm3533_device_led_init (struct lm3533 *lm3533) -{ -struct lm3533_platform_data *pdata =dev_get_platdata (lm3533->dev); -int i; -int ret; - -if (!pdata->leds || pdata->num_leds ==0 ) -return 0 ; - -if (pdata->num_leds >ARRAY_SIZE (lm3533_led_devs)) - pdata->num_leds =ARRAY_SIZE (lm3533_led_devs); - -for (i =0 ; i < pdata->num_leds; ++i) { - lm3533_led_devs[i].platform_data = &pdata->leds[i]; - lm3533_led_devs[i].pdata_size =sizeof (pdata->leds[i]); - } - - ret =mfd_add_devices (lm3533->dev,0 , lm3533_led_devs, - pdata->num_leds,NULL ,0 ,NULL ); -if (ret) { -dev_err (lm3533->dev,"failed to add LED devices\n" ); -return ret; - } - - lm3533->have_leds =1 ; - -return 0 ; -} - -static int lm3533_device_setup (struct lm3533 *lm3533, -struct lm3533_platform_data *pdata) -{ -int ret; - - ret =lm3533_set_boost_freq (lm3533, pdata->boost_freq); -if (ret) -return ret; - -return lm3533_set_boost_ovp (lm3533, pdata->boost_ovp); -} - -static int lm3533_device_init (struct lm3533 *lm3533) -{ -struct lm3533_platform_data *pdata =dev_get_platdata (lm3533->dev); -int ret; - -dev_dbg (lm3533->dev,"%s\n" , __func__); - -if (!pdata) { -dev_err (lm3533->dev,"no platform data\n" ); -return -EINVAL ; - } - - lm3533->gpio_hwen = pdata->gpio_hwen; - -if (gpio_is_valid (lm3533->gpio_hwen)) { - ret =devm_gpio_request_one (lm3533->dev, lm3533->gpio_hwen, -GPIOF_OUT_INIT_LOW ,"lm3533-hwen" ); -if (ret <0 ) { -dev_err (lm3533->dev, -"failed to request HWEN GPIO %d\n" , - lm3533->gpio_hwen); -return ret; - } - } - -lm3533_enable (lm3533); - - ret =lm3533_device_setup (lm3533, pdata); -if (ret) - goto err_disable; - -lm3533_device_als_init (lm3533); -lm3533_device_bl_init (lm3533); -lm3533_device_led_init (lm3533); - - ret =sysfs_create_group (&lm3533->dev->kobj, &lm3533_attribute_group); -if (ret <0 ) { -dev_err (lm3533->dev,"failed to create sysfs attributes\n" ); - goto err_unregister; - } - -return 0 ; - -err_unregister: -mfd_remove_devices (lm3533->dev); -err_disable: -lm3533_disable (lm3533); - -return ret; -} - -static void lm3533_device_exit (struct lm3533 *lm3533) -{ -dev_dbg (lm3533->dev,"%s\n" , __func__); - -sysfs_remove_group (&lm3533->dev->kobj, &lm3533_attribute_group); - -mfd_remove_devices (lm3533->dev); -lm3533_disable (lm3533); -} - -static bool lm3533_readable_register (struct device *dev,unsigned int reg) -{ -switch (reg) { - case 0x10 ... 0x2c: - case 0x30 ... 0x38: - case 0x40 ... 0x45: - case 0x50 ... 0x57: - case 0x60 ... 0x6e: - case 0x70 ... 0x75: - case 0x80 ... 0x85: - case 0x90 ... 0x95: - case 0xa0 ... 0xa5: - case 0xb0 ... 0xb2: -return true; -default : -return false; - } -} - -static bool lm3533_volatile_register (struct device *dev,unsigned int reg) -{ -switch (reg) { - case 0x34 ... 0x36: /* zone */ - case 0x37 ... 0x38: /* adc */ - case 0xb0 ... 0xb1: /* fault */ -return true; -default : -return false; - } -} - -static bool lm3533_precious_register (struct device *dev,unsigned int reg) -{ -switch (reg) { -case 0x34 :/* zone */ -return true; -default : -return false; - } -} - -static const struct regmap_config regmap_config = { - .reg_bits =8 , - .val_bits =8 , - .max_register =LM3533_REG_MAX , - .readable_reg = lm3533_readable_register, - .volatile_reg = lm3533_volatile_register, - .precious_reg = lm3533_precious_register, -}; - -static int lm3533_i2c_probe (struct i2c_client *i2c) -{ -struct lm3533 *lm3533; - -dev_dbg (&i2c->dev,"%s\n" , __func__); - - lm3533 =devm_kzalloc (&i2c->dev,sizeof (*lm3533),GFP_KERNEL ); -if (!lm3533) -return -ENOMEM ; - -i2c_set_clientdata (i2c, lm3533); - - lm3533->regmap =devm_regmap_init_i2c (i2c, ®map_config); -if (IS_ERR (lm3533->regmap)) -return PTR_ERR (lm3533->regmap); - - lm3533->dev = &i2c->dev; - lm3533->irq = i2c->irq; - -return lm3533_device_init (lm3533); -} - -static void lm3533_i2c_remove (struct i2c_client *i2c) -{ -struct lm3533 *lm3533 =i2c_get_clientdata (i2c); - -dev_dbg (&i2c->dev,"%s\n" , __func__); - -lm3533_device_exit (lm3533); -} - -static const struct i2c_device_id lm3533_i2c_ids[] = { - {"lm3533" ,0 }, - { }, -}; -MODULE_DEVICE_TABLE (i2c, lm3533_i2c_ids); - -static struct i2c_driver lm3533_i2c_driver = { - .driver = { - .name ="lm3533" , - }, - .id_table = lm3533_i2c_ids, - .probe = lm3533_i2c_probe, - .remove = lm3533_i2c_remove, -}; - -static int __init lm3533_i2c_init (void ) -{ -return i2c_add_driver (&lm3533_i2c_driver); -} -subsys_initcall (lm3533_i2c_init); - -static void __exit lm3533_i2c_exit(void) -{ -i2c_del_driver (&lm3533_i2c_driver); -} -module_exit (lm3533_i2c_exit); - -MODULE_AUTHOR ("Johan Hovold <[email protected]>" ); -MODULE_DESCRIPTION ("LM3533 Core" ); -MODULE_LICENSE ("GPL" );
include/linux/mfd/lm3533.h deleted +0 -100
100 lines not on this page · raw message
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
kernel test robot
build botRe: [PATCH v1 4/4] mfd: lm3533: Remove the driver
kernel test robot noticed the following build errors:
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on lee-backlight/for-backlight-fixes linus/master v6.10-rc1 next-20240531] [cannot apply to lee-backlight/for-backlight-next pavel-leds/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/backlight-lm3533_bl-Remove-the-driver/20240601-011153 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20240531170844.1595468-5-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 4/4] mfd: lm3533: Remove the driver config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20240601/[email protected]/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240601/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/mfd/lm3533-ctrlbank.c:13:10: fatal error: linux/mfd/lm3533.h: No such file or directory
13 | #include <linux/mfd/lm3533.h>
| ^~~~~~~~~~~~~~~~~~~~compilation terminated.
vim +13 drivers/mfd/lm3533-ctrlbank.c
16c5c023aac862 Johan Hovold 2012-05-03 1216c5c023aac862 Johan Hovold 2012-05-03 @13 #include <linux/mfd/lm3533.h> 16c5c023aac862 Johan Hovold 2012-05-03 1416c5c023aac862 Johan Hovold 2012-05-03 15
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v1 4/4] mfd: lm3533: Remove the driver
In reply to Andy Shevchenkokernel test robot noticed the following build errors:
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on lee-backlight/for-backlight-fixes linus/master v6.10-rc1 next-20240531] [cannot apply to lee-backlight/for-backlight-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/backlight-lm3533_bl-Remove-the-driver/20240601-011153 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20240531170844.1595468-5-andriy.shevchenko%40linux.intel.com patch subject: [PATCH v1 4/4] mfd: lm3533: Remove the driver config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20240601/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project bafda89a0944d947fc4b3b5663185e07a397ac30) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240601/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/mfd/lm3533-ctrlbank.c:13:10: fatal error: 'linux/mfd/lm3533.h' file not found
13 | #include <linux/mfd/lm3533.h>
| ^~~~~~~~~~~~~~~~~~~~1 error generated.
vim +13 drivers/mfd/lm3533-ctrlbank.c
16c5c023aac862 Johan Hovold 2012-05-03 1216c5c023aac862 Johan Hovold 2012-05-03 @13 #include <linux/mfd/lm3533.h> 16c5c023aac862 Johan Hovold 2012-05-03 1416c5c023aac862 Johan Hovold 2012-05-03 15
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Lee Jones
maintainerMaking sure Johan is aware of this with his new address.
Quoted 34 lines · Andy Shevchenko
Driver is quite outdated from the Linux kernel internal APIs perspective. In particular GPIO code is using legacy calls, that started being replaced by a new API ca. 2014, i.e. ten years ago.
Suggested-by Linus Walleij <[email protected]>Andy Shevchenko (4):
backlight:lm3533_bl: Remove the driver
iio: light: lm3533-als: Remove the driver
leds: lm3533: Remove the driver
mfd: lm3533: Remove the driverdrivers/iio/light/Kconfig | 17 - drivers/iio/light/Makefile | 1 - drivers/iio/light/lm3533-als.c | 922 ---------------------------- drivers/leds/Kconfig | 13 - drivers/leds/Makefile | 1 - drivers/leds/leds-lm3533.c | 755 ----------------------- drivers/mfd/lm3533-core.c | 645 ------------------- drivers/video/backlight/Kconfig | 11 - drivers/video/backlight/Makefile | 1 - drivers/video/backlight/lm3533_bl.c | 399 ------------ include/linux/mfd/lm3533.h | 100 --- 11 files changed, 2865 deletions(-) delete mode 100644 drivers/iio/light/lm3533-als.c delete mode 100644 drivers/leds/leds-lm3533.c delete mode 100644 drivers/mfd/lm3533-core.c delete mode 100644 drivers/video/backlight/lm3533_bl.c delete mode 100644 include/linux/mfd/lm3533.hSignature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Signature · 1 line
Lee Jones [李琼斯]
Quoted 1 line · Lee Jones
Making sure Johan is aware of this with his new address.
Right, in any case this is not the final version (a couple of leftovers). I have mentioned this series in the original thread.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Driver is quite outdated from the Linux kernel internal APIs perspective. In particular GPIO code is using legacy calls, that started being replaced by a new API ca. 2014, i.e. ten years ago.
Suggested-by Linus Walleij <[email protected]>drivers/mfd/lm3533-core.c | 645 -------------------
Oops, still leftovers: one file and Kconfig/Makefile updates... If needed I'll send a v2, but now I leave it to Lee and Johan to decide the destiny of the drivers.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Lee Jones
maintainerQuoted 6 lines · Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
Driver is quite outdated from the Linux kernel internal APIs perspective. In particular GPIO code is using legacy calls, that started being replaced by a new API ca. 2014, i.e. ten years ago.
Quoted 7 lines
Quoted 3 lines
Suggested-by Linus Walleij <[email protected]>drivers/mfd/lm3533-core.c | 645 -------------------Oops, still leftovers: one file and Kconfig/Makefile updates... If needed I'll send a v2, but now I leave it to Lee and Johan to decide the destiny of the drivers.
Let's not rush into it. Take your time.
Signature · 1 line
Lee Jones [李琼斯]
Quoted 9 lines · Lee Jones
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Driver is quite outdated from the Linux kernel internal APIs perspective. In particular GPIO code is using legacy calls, that started being replaced by a new API ca. 2014, i.e. ten years ago.
Suggested-by Linus Walleij <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
drivers/mfd/lm3533-core.c | 645 -------------------Oops, still leftovers: one file and Kconfig/Makefile updates... If needed I'll send a v2, but now I leave it to Lee and Johan to decide the destiny of the drivers.
Let's not rush into it. Take your time.
Exactly, excellente fin de semaine!
Signature · 2 lines
With Best Regards, Andy Shevchenko
+Cc: Johan (via kernel.org)
Quoted 13 lines · Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Driver is quite outdated from the Linux kernel internal APIs perspective. In particular GPIO code is using legacy calls, that started being replaced by a new API ca. 2014, i.e. ten years ago.
Suggested-by Linus Walleij <[email protected]>drivers/mfd/lm3533-core.c | 645 -------------------Oops, still leftovers: one file and Kconfig/Makefile updates... If needed I'll send a v2, but now I leave it to Lee and Johan to decide the destiny of the drivers.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 16 lines · Andy Shevchenko
+Cc: Johan (via kernel.org)
Quoted 13 lines · Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Driver is quite outdated from the Linux kernel internal APIs perspective. In particular GPIO code is using legacy calls, that started being replaced by a new API ca. 2014, i.e. ten years ago.
Suggested-by Linus Walleij <[email protected]>drivers/mfd/lm3533-core.c | 645 -------------------Oops, still leftovers: one file and Kconfig/Makefile updates... If needed I'll send a v2, but now I leave it to Lee and Johan to decide the destiny of the drivers.
I prefer to keep them as I just mentioned here:
https://lore.kernel.org/lkml/[email protected]/
Johan