Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'backlight-next-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
"New Drivers:
- Add support for Kinetic KTD2801 Backlight

Fix-ups:
- Fix include lists; alphabetise, remove unused, explicitly add used
- Device Tree binding adaptions/conversions/creation
- Use dev_err_probe() to clean-up error paths
- Use/convert to new/better APIs/helpers/MACROs instead of hand-rolling implementations

Bug Fixes:
- Fix changes of NULL pointer dereference
- Remedy a bunch of logic errors
- Initialise (zero) Backlight properties data structures"

* tag 'backlight-next-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: (32 commits)
backlight: pandora_bl: Drop unneeded ENOMEM error message
backlight: lm3630a_bl: Simplify probe return on gpio request error
backlight: lm3630a_bl: Handle deferred probe
backlight: as3711_bl: Handle deferred probe
backlight: bd6107: Handle deferred probe
backlight: l4f00242t03: Simplify with dev_err_probe()
backlight: gpio: Simplify with dev_err_probe()
backlight: lp8788: Fully initialize backlight_properties during probe
backlight: lm3639: Fully initialize backlight_properties during probe
backlight: da9052: Fully initialize backlight_properties during probe
backlight: lm3630a: Use backlight_get_brightness helper in update_status
backlight: lm3630a: Don't set bl->props.brightness in get_brightness
backlight: lm3630a: Initialize backlight_properties on init
backlight: mp3309c: Fully initialize backlight_properties during probe
backlight: mp3309c: Utilise temporary variable for struct device
backlight: mp3309c: Use dev_err_probe() instead of dev_err()
backlight: mp3309c: Make use of device properties
dt-bindings: backlight: qcom-wled: Fix bouncing email addresses
backlight: hx8357: Utilise temporary variable for struct device
backlight: hx8357: Make use of dev_err_probe()
...

+461 -248
+46
Documentation/devicetree/bindings/leds/backlight/kinetic,ktd2801.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/leds/backlight/kinetic,ktd2801.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Kinetic Technologies KTD2801 one-wire backlight 8 + 9 + maintainers: 10 + - Duje Mihanović <duje.mihanovic@skole.hr> 11 + 12 + description: | 13 + The Kinetic Technologies KTD2801 is a LED backlight driver controlled 14 + by a single GPIO line. The driver can be controlled with a PWM signal 15 + or by pulsing the GPIO line to set the backlight level. This is called 16 + "ExpressWire". 17 + 18 + allOf: 19 + - $ref: common.yaml# 20 + 21 + properties: 22 + compatible: 23 + const: kinetic,ktd2801 24 + 25 + ctrl-gpios: 26 + maxItems: 1 27 + 28 + default-brightness: true 29 + max-brightness: true 30 + 31 + required: 32 + - compatible 33 + - ctrl-gpios 34 + 35 + additionalProperties: false 36 + 37 + examples: 38 + - | 39 + #include <dt-bindings/gpio/gpio.h> 40 + 41 + backlight { 42 + compatible = "kinetic,ktd2801"; 43 + ctrl-gpios = <&gpio 97 GPIO_ACTIVE_HIGH>; 44 + max-brightness = <210>; 45 + default-brightness = <100>; 46 + };
+2 -2
Documentation/devicetree/bindings/leds/backlight/qcom-wled.yaml
··· 7 7 title: Qualcomm Technologies, Inc. WLED driver 8 8 9 9 maintainers: 10 - - Bjorn Andersson <bjorn.andersson@linaro.org> 11 - - Kiran Gunda <kgunda@codeaurora.org> 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Kiran Gunda <quic_kgunda@quicinc.com> 12 12 13 13 description: | 14 14 WLED (White Light Emitting Diode) driver is used for controlling display
+13
MAINTAINERS
··· 8039 8039 T: git git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat.git 8040 8040 F: fs/exfat/ 8041 8041 8042 + EXPRESSWIRE PROTOCOL LIBRARY 8043 + M: Duje Mihanović <duje.mihanovic@skole.hr> 8044 + L: linux-leds@vger.kernel.org 8045 + S: Maintained 8046 + F: drivers/leds/leds-expresswire.c 8047 + F: include/linux/leds-expresswire.h 8048 + 8042 8049 EXT2 FILE SYSTEM 8043 8050 M: Jan Kara <jack@suse.com> 8044 8051 L: linux-ext4@vger.kernel.org ··· 12109 12102 S: Maintained 12110 12103 F: Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml 12111 12104 F: drivers/video/backlight/ktd253-backlight.c 12105 + 12106 + KTD2801 BACKLIGHT DRIVER 12107 + M: Duje Mihanović <duje.mihanovic@skole.hr> 12108 + S: Maintained 12109 + F: Documentation/devicetree/bindings/leds/backlight/kinetic,ktd2801.yaml 12110 + F: drivers/video/backlight/ktd2801-backlight.c 12112 12111 12113 12112 KTEST 12114 12113 M: Steven Rostedt <rostedt@goodmis.org>
+4
drivers/leds/Kconfig
··· 186 186 To compile this driver as a module, choose M here: the module 187 187 will be called leds-el15203000. 188 188 189 + config LEDS_EXPRESSWIRE 190 + bool 191 + depends on GPIOLIB 192 + 189 193 config LEDS_TURRIS_OMNIA 190 194 tristate "LED support for CZ.NIC's Turris Omnia" 191 195 depends on LEDS_CLASS_MULTICOLOR
+3
drivers/leds/Makefile
··· 91 91 obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o 92 92 obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o 93 93 94 + # Kinetic ExpressWire Protocol 95 + obj-$(CONFIG_LEDS_EXPRESSWIRE) += leds-expresswire.o 96 + 94 97 # LED SPI Drivers 95 98 obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o 96 99 obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
+2 -1
drivers/leds/flash/Kconfig
··· 23 23 config LEDS_KTD2692 24 24 tristate "LED support for Kinetic KTD2692 flash LED controller" 25 25 depends on OF 26 - depends on GPIOLIB || COMPILE_TEST 26 + depends on GPIOLIB 27 + select LEDS_EXPRESSWIRE 27 28 help 28 29 This option enables support for Kinetic KTD2692 LED flash connected 29 30 through ExpressWire interface.
+27 -89
drivers/leds/flash/leds-ktd2692.c
··· 6 6 * Ingi Kim <ingi2.kim@samsung.com> 7 7 */ 8 8 9 - #include <linux/delay.h> 10 9 #include <linux/err.h> 11 10 #include <linux/gpio/consumer.h> 11 + #include <linux/leds-expresswire.h> 12 12 #include <linux/led-class-flash.h> 13 13 #include <linux/module.h> 14 14 #include <linux/mutex.h> ··· 37 37 #define KTD2692_REG_FLASH_CURRENT_BASE 0x80 38 38 #define KTD2692_REG_MODE_BASE 0xA0 39 39 40 - /* Set bit coding time for expresswire interface */ 41 - #define KTD2692_TIME_RESET_US 700 42 - #define KTD2692_TIME_DATA_START_TIME_US 10 43 - #define KTD2692_TIME_HIGH_END_OF_DATA_US 350 44 - #define KTD2692_TIME_LOW_END_OF_DATA_US 10 45 - #define KTD2692_TIME_SHORT_BITSET_US 4 46 - #define KTD2692_TIME_LONG_BITSET_US 12 47 - 48 40 /* KTD2692 default length of name */ 49 41 #define KTD2692_NAME_LENGTH 20 50 - 51 - enum ktd2692_bitset { 52 - KTD2692_LOW = 0, 53 - KTD2692_HIGH, 54 - }; 55 42 56 43 /* Movie / Flash Mode Control */ 57 44 enum ktd2692_led_mode { ··· 58 71 enum led_brightness max_brightness; 59 72 }; 60 73 74 + const struct expresswire_timing ktd2692_timing = { 75 + .poweroff_us = 700, 76 + .data_start_us = 10, 77 + .end_of_data_low_us = 10, 78 + .end_of_data_high_us = 350, 79 + .short_bitset_us = 4, 80 + .long_bitset_us = 12 81 + }; 82 + 61 83 struct ktd2692_context { 84 + /* Common ExpressWire properties (ctrl GPIO and timing) */ 85 + struct expresswire_common_props props; 86 + 62 87 /* Related LED Flash class device */ 63 88 struct led_classdev_flash fled_cdev; 64 89 ··· 79 80 struct regulator *regulator; 80 81 81 82 struct gpio_desc *aux_gpio; 82 - struct gpio_desc *ctrl_gpio; 83 83 84 84 enum ktd2692_led_mode mode; 85 85 enum led_brightness torch_brightness; ··· 88 90 struct led_classdev_flash *fled_cdev) 89 91 { 90 92 return container_of(fled_cdev, struct ktd2692_context, fled_cdev); 91 - } 92 - 93 - static void ktd2692_expresswire_start(struct ktd2692_context *led) 94 - { 95 - gpiod_direction_output(led->ctrl_gpio, KTD2692_HIGH); 96 - udelay(KTD2692_TIME_DATA_START_TIME_US); 97 - } 98 - 99 - static void ktd2692_expresswire_reset(struct ktd2692_context *led) 100 - { 101 - gpiod_direction_output(led->ctrl_gpio, KTD2692_LOW); 102 - udelay(KTD2692_TIME_RESET_US); 103 - } 104 - 105 - static void ktd2692_expresswire_end(struct ktd2692_context *led) 106 - { 107 - gpiod_direction_output(led->ctrl_gpio, KTD2692_LOW); 108 - udelay(KTD2692_TIME_LOW_END_OF_DATA_US); 109 - gpiod_direction_output(led->ctrl_gpio, KTD2692_HIGH); 110 - udelay(KTD2692_TIME_HIGH_END_OF_DATA_US); 111 - } 112 - 113 - static void ktd2692_expresswire_set_bit(struct ktd2692_context *led, bool bit) 114 - { 115 - /* 116 - * The Low Bit(0) and High Bit(1) is based on a time detection 117 - * algorithm between time low and time high 118 - * Time_(L_LB) : Low time of the Low Bit(0) 119 - * Time_(H_LB) : High time of the LOW Bit(0) 120 - * Time_(L_HB) : Low time of the High Bit(1) 121 - * Time_(H_HB) : High time of the High Bit(1) 122 - * 123 - * It can be simplified to: 124 - * Low Bit(0) : 2 * Time_(H_LB) < Time_(L_LB) 125 - * High Bit(1) : 2 * Time_(L_HB) < Time_(H_HB) 126 - * HIGH ___ ____ _.. _________ ___ 127 - * |_________| |_.. |____| |__| 128 - * LOW <L_LB> <H_LB> <L_HB> <H_HB> 129 - * [ Low Bit (0) ] [ High Bit(1) ] 130 - */ 131 - if (bit) { 132 - gpiod_direction_output(led->ctrl_gpio, KTD2692_LOW); 133 - udelay(KTD2692_TIME_SHORT_BITSET_US); 134 - gpiod_direction_output(led->ctrl_gpio, KTD2692_HIGH); 135 - udelay(KTD2692_TIME_LONG_BITSET_US); 136 - } else { 137 - gpiod_direction_output(led->ctrl_gpio, KTD2692_LOW); 138 - udelay(KTD2692_TIME_LONG_BITSET_US); 139 - gpiod_direction_output(led->ctrl_gpio, KTD2692_HIGH); 140 - udelay(KTD2692_TIME_SHORT_BITSET_US); 141 - } 142 - } 143 - 144 - static void ktd2692_expresswire_write(struct ktd2692_context *led, u8 value) 145 - { 146 - int i; 147 - 148 - ktd2692_expresswire_start(led); 149 - for (i = 7; i >= 0; i--) 150 - ktd2692_expresswire_set_bit(led, value & BIT(i)); 151 - ktd2692_expresswire_end(led); 152 93 } 153 94 154 95 static int ktd2692_led_brightness_set(struct led_classdev *led_cdev, ··· 100 163 101 164 if (brightness == LED_OFF) { 102 165 led->mode = KTD2692_MODE_DISABLE; 103 - gpiod_direction_output(led->aux_gpio, KTD2692_LOW); 166 + gpiod_direction_output(led->aux_gpio, 0); 104 167 } else { 105 - ktd2692_expresswire_write(led, brightness | 168 + expresswire_write_u8(&led->props, brightness | 106 169 KTD2692_REG_MOVIE_CURRENT_BASE); 107 170 led->mode = KTD2692_MODE_MOVIE; 108 171 } 109 172 110 - ktd2692_expresswire_write(led, led->mode | KTD2692_REG_MODE_BASE); 173 + expresswire_write_u8(&led->props, led->mode | KTD2692_REG_MODE_BASE); 111 174 mutex_unlock(&led->lock); 112 175 113 176 return 0; ··· 124 187 125 188 if (state) { 126 189 flash_tm_reg = GET_TIMEOUT_OFFSET(timeout->val, timeout->step); 127 - ktd2692_expresswire_write(led, flash_tm_reg 190 + expresswire_write_u8(&led->props, flash_tm_reg 128 191 | KTD2692_REG_FLASH_TIMEOUT_BASE); 129 192 130 193 led->mode = KTD2692_MODE_FLASH; 131 - gpiod_direction_output(led->aux_gpio, KTD2692_HIGH); 194 + gpiod_direction_output(led->aux_gpio, 1); 132 195 } else { 133 196 led->mode = KTD2692_MODE_DISABLE; 134 - gpiod_direction_output(led->aux_gpio, KTD2692_LOW); 197 + gpiod_direction_output(led->aux_gpio, 0); 135 198 } 136 199 137 - ktd2692_expresswire_write(led, led->mode | KTD2692_REG_MODE_BASE); 200 + expresswire_write_u8(&led->props, led->mode | KTD2692_REG_MODE_BASE); 138 201 139 202 fled_cdev->led_cdev.brightness = LED_OFF; 140 203 led->mode = KTD2692_MODE_DISABLE; ··· 184 247 static void ktd2692_setup(struct ktd2692_context *led) 185 248 { 186 249 led->mode = KTD2692_MODE_DISABLE; 187 - ktd2692_expresswire_reset(led); 188 - gpiod_direction_output(led->aux_gpio, KTD2692_LOW); 250 + expresswire_power_off(&led->props); 251 + gpiod_direction_output(led->aux_gpio, 0); 189 252 190 - ktd2692_expresswire_write(led, (KTD2692_MM_MIN_CURR_THRESHOLD_SCALE - 1) 253 + expresswire_write_u8(&led->props, (KTD2692_MM_MIN_CURR_THRESHOLD_SCALE - 1) 191 254 | KTD2692_REG_MM_MIN_CURR_THRESHOLD_BASE); 192 - ktd2692_expresswire_write(led, KTD2692_FLASH_MODE_CURR_PERCENT(45) 255 + expresswire_write_u8(&led->props, KTD2692_FLASH_MODE_CURR_PERCENT(45) 193 256 | KTD2692_REG_FLASH_CURRENT_BASE); 194 257 } 195 258 ··· 214 277 if (!np) 215 278 return -ENXIO; 216 279 217 - led->ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_ASIS); 218 - ret = PTR_ERR_OR_ZERO(led->ctrl_gpio); 280 + led->props.ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_ASIS); 281 + ret = PTR_ERR_OR_ZERO(led->props.ctrl_gpio); 219 282 if (ret) 220 283 return dev_err_probe(dev, ret, "cannot get ctrl-gpios\n"); 221 284 ··· 349 412 350 413 module_platform_driver(ktd2692_driver); 351 414 415 + MODULE_IMPORT_NS(EXPRESSWIRE); 352 416 MODULE_AUTHOR("Ingi Kim <ingi2.kim@samsung.com>"); 353 417 MODULE_DESCRIPTION("Kinetic KTD2692 LED driver"); 354 418 MODULE_LICENSE("GPL v2");
+72
drivers/leds/leds-expresswire.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Shared library for Kinetic's ExpressWire protocol. 4 + * This protocol works by pulsing the ExpressWire IC's control GPIO. 5 + * ktd2692 and ktd2801 are known to use this protocol. 6 + */ 7 + 8 + #include <linux/bits.h> 9 + #include <linux/delay.h> 10 + #include <linux/export.h> 11 + #include <linux/gpio/consumer.h> 12 + #include <linux/types.h> 13 + 14 + #include <linux/leds-expresswire.h> 15 + 16 + void expresswire_power_off(struct expresswire_common_props *props) 17 + { 18 + gpiod_set_value_cansleep(props->ctrl_gpio, 0); 19 + usleep_range(props->timing.poweroff_us, props->timing.poweroff_us * 2); 20 + } 21 + EXPORT_SYMBOL_NS_GPL(expresswire_power_off, EXPRESSWIRE); 22 + 23 + void expresswire_enable(struct expresswire_common_props *props) 24 + { 25 + gpiod_set_value(props->ctrl_gpio, 1); 26 + udelay(props->timing.detect_delay_us); 27 + gpiod_set_value(props->ctrl_gpio, 0); 28 + udelay(props->timing.detect_us); 29 + gpiod_set_value(props->ctrl_gpio, 1); 30 + } 31 + EXPORT_SYMBOL_NS_GPL(expresswire_enable, EXPRESSWIRE); 32 + 33 + void expresswire_start(struct expresswire_common_props *props) 34 + { 35 + gpiod_set_value(props->ctrl_gpio, 1); 36 + udelay(props->timing.data_start_us); 37 + } 38 + EXPORT_SYMBOL_NS_GPL(expresswire_start, EXPRESSWIRE); 39 + 40 + void expresswire_end(struct expresswire_common_props *props) 41 + { 42 + gpiod_set_value(props->ctrl_gpio, 0); 43 + udelay(props->timing.end_of_data_low_us); 44 + gpiod_set_value(props->ctrl_gpio, 1); 45 + udelay(props->timing.end_of_data_high_us); 46 + } 47 + EXPORT_SYMBOL_NS_GPL(expresswire_end, EXPRESSWIRE); 48 + 49 + void expresswire_set_bit(struct expresswire_common_props *props, bool bit) 50 + { 51 + if (bit) { 52 + gpiod_set_value(props->ctrl_gpio, 0); 53 + udelay(props->timing.short_bitset_us); 54 + gpiod_set_value(props->ctrl_gpio, 1); 55 + udelay(props->timing.long_bitset_us); 56 + } else { 57 + gpiod_set_value(props->ctrl_gpio, 0); 58 + udelay(props->timing.long_bitset_us); 59 + gpiod_set_value(props->ctrl_gpio, 1); 60 + udelay(props->timing.short_bitset_us); 61 + } 62 + } 63 + EXPORT_SYMBOL_NS_GPL(expresswire_set_bit, EXPRESSWIRE); 64 + 65 + void expresswire_write_u8(struct expresswire_common_props *props, u8 val) 66 + { 67 + expresswire_start(props); 68 + for (int i = 7; i >= 0; i--) 69 + expresswire_set_bit(props, val & BIT(i)); 70 + expresswire_end(props); 71 + } 72 + EXPORT_SYMBOL_NS_GPL(expresswire_write_u8, EXPRESSWIRE);
+7
drivers/video/backlight/Kconfig
··· 183 183 which is a 1-wire GPIO-controlled backlight found in some mobile 184 184 phones. 185 185 186 + config BACKLIGHT_KTD2801 187 + tristate "Backlight Driver for Kinetic KTD2801" 188 + select LEDS_EXPRESSWIRE 189 + help 190 + Say Y to enable the backlight driver for the Kinetic KTD2801 1-wire 191 + GPIO-controlled backlight found in Samsung Galaxy Core Prime VE LTE. 192 + 186 193 config BACKLIGHT_KTZ8866 187 194 tristate "Backlight Driver for Kinetic KTZ8866" 188 195 depends on I2C
+1
drivers/video/backlight/Makefile
··· 34 34 obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o 35 35 obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO) += ipaq_micro_bl.o 36 36 obj-$(CONFIG_BACKLIGHT_KTD253) += ktd253-backlight.o 37 + obj-$(CONFIG_BACKLIGHT_KTD2801) += ktd2801-backlight.o 37 38 obj-$(CONFIG_BACKLIGHT_KTZ8866) += ktz8866.o 38 39 obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o 39 40 obj-$(CONFIG_BACKLIGHT_LM3630A) += lm3630a_bl.o
+2 -4
drivers/video/backlight/as3711_bl.c
··· 383 383 384 384 if (pdev->dev.parent->of_node) { 385 385 ret = as3711_backlight_parse_dt(&pdev->dev); 386 - if (ret < 0) { 387 - dev_err(&pdev->dev, "DT parsing failed: %d\n", ret); 388 - return ret; 389 - } 386 + if (ret < 0) 387 + return dev_err_probe(&pdev->dev, ret, "DT parsing failed\n"); 390 388 } 391 389 392 390 if (!pdata->su1_fb && !pdata->su2_fb) {
+3 -6
drivers/video/backlight/bd6107.c
··· 119 119 struct backlight_device *backlight; 120 120 struct backlight_properties props; 121 121 struct bd6107 *bd; 122 - int ret; 123 122 124 123 if (pdata == NULL) { 125 124 dev_err(&client->dev, "No platform data\n"); ··· 146 147 * the reset. 147 148 */ 148 149 bd->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); 149 - if (IS_ERR(bd->reset)) { 150 - dev_err(&client->dev, "unable to request reset GPIO\n"); 151 - ret = PTR_ERR(bd->reset); 152 - return ret; 153 - } 150 + if (IS_ERR(bd->reset)) 151 + return dev_err_probe(&client->dev, PTR_ERR(bd->reset), 152 + "unable to request reset GPIO\n"); 154 153 155 154 memset(&props, 0, sizeof(props)); 156 155 props.type = BACKLIGHT_RAW;
+1
drivers/video/backlight/da9052_bl.c
··· 117 117 wleds->led_reg = platform_get_device_id(pdev)->driver_data; 118 118 wleds->state = DA9052_WLEDS_OFF; 119 119 120 + memset(&props, 0, sizeof(struct backlight_properties)); 120 121 props.type = BACKLIGHT_RAW; 121 122 props.max_brightness = DA9052_MAX_BRIGHTNESS; 122 123
+3 -7
drivers/video/backlight/gpio_backlight.c
··· 64 64 def_value = device_property_read_bool(dev, "default-on"); 65 65 66 66 gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS); 67 - if (IS_ERR(gbl->gpiod)) { 68 - ret = PTR_ERR(gbl->gpiod); 69 - if (ret != -EPROBE_DEFER) 70 - dev_err(dev, 71 - "Error: The gpios parameter is missing or invalid.\n"); 72 - return ret; 73 - } 67 + if (IS_ERR(gbl->gpiod)) 68 + return dev_err_probe(dev, PTR_ERR(gbl->gpiod), 69 + "The gpios parameter is missing or invalid\n"); 74 70 75 71 memset(&props, 0, sizeof(props)); 76 72 props.type = BACKLIGHT_RAW;
+33 -34
drivers/video/backlight/hx8357.c
··· 8 8 #include <linux/delay.h> 9 9 #include <linux/gpio/consumer.h> 10 10 #include <linux/lcd.h> 11 + #include <linux/mod_devicetable.h> 11 12 #include <linux/module.h> 12 - #include <linux/of.h> 13 - #include <linux/of_device.h> 13 + #include <linux/property.h> 14 14 #include <linux/spi/spi.h> 15 15 16 16 #define HX8357_NUM_IM_PINS 3 ··· 564 564 .get_power = hx8357_get_power, 565 565 }; 566 566 567 - static const struct of_device_id hx8357_dt_ids[] = { 568 - { 569 - .compatible = "himax,hx8357", 570 - .data = hx8357_lcd_init, 571 - }, 572 - { 573 - .compatible = "himax,hx8369", 574 - .data = hx8369_lcd_init, 575 - }, 576 - {}, 577 - }; 578 - MODULE_DEVICE_TABLE(of, hx8357_dt_ids); 567 + typedef int (*hx8357_init_fn)(struct lcd_device *); 579 568 580 569 static int hx8357_probe(struct spi_device *spi) 581 570 { 582 571 struct device *dev = &spi->dev; 583 572 struct lcd_device *lcdev; 584 573 struct hx8357_data *lcd; 585 - const struct of_device_id *match; 574 + hx8357_init_fn init_fn; 586 575 int i, ret; 587 576 588 - lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL); 577 + lcd = devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL); 589 578 if (!lcd) 590 579 return -ENOMEM; 591 580 592 581 ret = spi_setup(spi); 593 - if (ret < 0) { 594 - dev_err(&spi->dev, "SPI setup failed.\n"); 595 - return ret; 596 - } 582 + if (ret < 0) 583 + return dev_err_probe(dev, ret, "SPI setup failed.\n"); 597 584 598 585 lcd->spi = spi; 599 586 600 - match = of_match_device(hx8357_dt_ids, &spi->dev); 601 - if (!match || !match->data) 587 + init_fn = device_get_match_data(dev); 588 + if (!init_fn) 602 589 return -EINVAL; 603 590 604 591 lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); ··· 596 609 lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW); 597 610 if (IS_ERR(lcd->im_pins)) 598 611 return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to request im GPIOs\n"); 599 - if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS) 600 - return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n"); 612 + if (lcd->im_pins) { 613 + if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS) 614 + return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n"); 601 615 602 - for (i = 0; i < HX8357_NUM_IM_PINS; i++) 603 - gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins"); 616 + for (i = 0; i < HX8357_NUM_IM_PINS; i++) 617 + gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins"); 618 + } 604 619 605 - lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd, 606 - &hx8357_ops); 620 + lcdev = devm_lcd_device_register(dev, "mxsfb", dev, lcd, &hx8357_ops); 607 621 if (IS_ERR(lcdev)) { 608 622 ret = PTR_ERR(lcdev); 609 623 return ret; ··· 613 625 614 626 hx8357_lcd_reset(lcdev); 615 627 616 - ret = ((int (*)(struct lcd_device *))match->data)(lcdev); 617 - if (ret) { 618 - dev_err(&spi->dev, "Couldn't initialize panel\n"); 619 - return ret; 620 - } 628 + ret = init_fn(lcdev); 629 + if (ret) 630 + return dev_err_probe(dev, ret, "Couldn't initialize panel\n"); 621 631 622 - dev_info(&spi->dev, "Panel probed\n"); 632 + dev_info(dev, "Panel probed\n"); 623 633 624 634 return 0; 625 635 } 636 + 637 + static const struct of_device_id hx8357_dt_ids[] = { 638 + { 639 + .compatible = "himax,hx8357", 640 + .data = hx8357_lcd_init, 641 + }, 642 + { 643 + .compatible = "himax,hx8369", 644 + .data = hx8369_lcd_init, 645 + }, 646 + {} 647 + }; 648 + MODULE_DEVICE_TABLE(of, hx8357_dt_ids); 626 649 627 650 static struct spi_driver hx8357_driver = { 628 651 .probe = hx8357_probe,
+128
drivers/video/backlight/ktd2801-backlight.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Datasheet: 4 + * https://www.kinet-ic.com/uploads/web/KTD2801/KTD2801-04b.pdf 5 + */ 6 + #include <linux/backlight.h> 7 + #include <linux/gpio/consumer.h> 8 + #include <linux/leds-expresswire.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/property.h> 11 + 12 + #define KTD2801_DEFAULT_BRIGHTNESS 100 13 + #define KTD2801_MAX_BRIGHTNESS 255 14 + 15 + /* These values have been extracted from Samsung's driver. */ 16 + static const struct expresswire_timing ktd2801_timing = { 17 + .poweroff_us = 2600, 18 + .detect_delay_us = 150, 19 + .detect_us = 270, 20 + .data_start_us = 5, 21 + .short_bitset_us = 5, 22 + .long_bitset_us = 15, 23 + .end_of_data_low_us = 10, 24 + .end_of_data_high_us = 350 25 + }; 26 + 27 + struct ktd2801_backlight { 28 + struct expresswire_common_props props; 29 + struct backlight_device *bd; 30 + bool was_on; 31 + }; 32 + 33 + static int ktd2801_update_status(struct backlight_device *bd) 34 + { 35 + struct ktd2801_backlight *ktd2801 = bl_get_data(bd); 36 + u8 brightness = (u8) backlight_get_brightness(bd); 37 + 38 + if (backlight_is_blank(bd)) { 39 + expresswire_power_off(&ktd2801->props); 40 + ktd2801->was_on = false; 41 + return 0; 42 + } 43 + 44 + if (!ktd2801->was_on) { 45 + expresswire_enable(&ktd2801->props); 46 + ktd2801->was_on = true; 47 + } 48 + 49 + expresswire_write_u8(&ktd2801->props, brightness); 50 + 51 + return 0; 52 + } 53 + 54 + static const struct backlight_ops ktd2801_backlight_ops = { 55 + .update_status = ktd2801_update_status, 56 + }; 57 + 58 + static int ktd2801_backlight_probe(struct platform_device *pdev) 59 + { 60 + struct device *dev = &pdev->dev; 61 + struct backlight_device *bd; 62 + struct ktd2801_backlight *ktd2801; 63 + u32 brightness, max_brightness; 64 + int ret; 65 + 66 + ktd2801 = devm_kzalloc(dev, sizeof(*ktd2801), GFP_KERNEL); 67 + if (!ktd2801) 68 + return -ENOMEM; 69 + ktd2801->was_on = true; 70 + ktd2801->props.timing = ktd2801_timing; 71 + 72 + ret = device_property_read_u32(dev, "max-brightness", &max_brightness); 73 + if (ret) 74 + max_brightness = KTD2801_MAX_BRIGHTNESS; 75 + if (max_brightness > KTD2801_MAX_BRIGHTNESS) { 76 + dev_err(dev, "illegal max brightness specified\n"); 77 + max_brightness = KTD2801_MAX_BRIGHTNESS; 78 + } 79 + 80 + ret = device_property_read_u32(dev, "default-brightness", &brightness); 81 + if (ret) 82 + brightness = KTD2801_DEFAULT_BRIGHTNESS; 83 + if (brightness > max_brightness) { 84 + dev_err(dev, "default brightness exceeds max\n"); 85 + brightness = max_brightness; 86 + } 87 + 88 + ktd2801->props.ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_OUT_HIGH); 89 + if (IS_ERR(ktd2801->props.ctrl_gpio)) 90 + return dev_err_probe(dev, PTR_ERR(ktd2801->props.ctrl_gpio), 91 + "failed to get backlight GPIO"); 92 + gpiod_set_consumer_name(ktd2801->props.ctrl_gpio, dev_name(dev)); 93 + 94 + bd = devm_backlight_device_register(dev, dev_name(dev), dev, ktd2801, 95 + &ktd2801_backlight_ops, NULL); 96 + if (IS_ERR(bd)) 97 + return dev_err_probe(dev, PTR_ERR(bd), 98 + "failed to register backlight"); 99 + 100 + bd->props.max_brightness = max_brightness; 101 + bd->props.brightness = brightness; 102 + 103 + ktd2801->bd = bd; 104 + platform_set_drvdata(pdev, bd); 105 + backlight_update_status(bd); 106 + 107 + return 0; 108 + } 109 + 110 + static const struct of_device_id ktd2801_of_match[] = { 111 + { .compatible = "kinetic,ktd2801" }, 112 + { } 113 + }; 114 + MODULE_DEVICE_TABLE(of, ktd2801_of_match); 115 + 116 + static struct platform_driver ktd2801_backlight_driver = { 117 + .driver = { 118 + .name = "ktd2801-backlight", 119 + .of_match_table = ktd2801_of_match, 120 + }, 121 + .probe = ktd2801_backlight_probe, 122 + }; 123 + module_platform_driver(ktd2801_backlight_driver); 124 + 125 + MODULE_IMPORT_NS(EXPRESSWIRE); 126 + MODULE_AUTHOR("Duje Mihanović <duje.mihanovic@skole.hr>"); 127 + MODULE_DESCRIPTION("Kinetic KTD2801 Backlight Driver"); 128 + MODULE_LICENSE("GPL");
+3 -3
drivers/video/backlight/ktz8866.c
··· 97 97 { 98 98 unsigned int val = 0; 99 99 100 - if (of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val)) 100 + if (!of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val)) 101 101 ktz8866_write(ktz, BL_EN, BIT(val) - 1); 102 102 else 103 103 /* Enable all 6 current sinks if the number of current sinks isn't specified. */ 104 104 ktz8866_write(ktz, BL_EN, BIT(6) - 1); 105 105 106 - if (of_property_read_u32(ktz->client->dev.of_node, "kinetic,current-ramp-delay-ms", &val)) { 106 + if (!of_property_read_u32(ktz->client->dev.of_node, "kinetic,current-ramp-delay-ms", &val)) { 107 107 if (val <= 128) 108 108 ktz8866_write(ktz, BL_CFG2, BIT(7) | (ilog2(val) << 3) | PWM_HYST); 109 109 else 110 110 ktz8866_write(ktz, BL_CFG2, BIT(7) | ((5 + val / 64) << 3) | PWM_HYST); 111 111 } 112 112 113 - if (of_property_read_u32(ktz->client->dev.of_node, "kinetic,led-enable-ramp-delay-ms", &val)) { 113 + if (!of_property_read_u32(ktz->client->dev.of_node, "kinetic,led-enable-ramp-delay-ms", &val)) { 114 114 if (val == 0) 115 115 ktz8866_write(ktz, BL_DIMMING, 0); 116 116 else {
+14 -20
drivers/video/backlight/l4f00242t03.c
··· 179 179 priv->spi = spi; 180 180 181 181 priv->reset = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); 182 - if (IS_ERR(priv->reset)) { 183 - dev_err(&spi->dev, 184 - "Unable to get the lcd l4f00242t03 reset gpio.\n"); 185 - return PTR_ERR(priv->reset); 186 - } 182 + if (IS_ERR(priv->reset)) 183 + return dev_err_probe(&spi->dev, PTR_ERR(priv->reset), 184 + "Unable to get the lcd l4f00242t03 reset gpio.\n"); 187 185 gpiod_set_consumer_name(priv->reset, "lcd l4f00242t03 reset"); 188 186 189 187 priv->enable = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW); 190 - if (IS_ERR(priv->enable)) { 191 - dev_err(&spi->dev, 192 - "Unable to get the lcd l4f00242t03 data en gpio.\n"); 193 - return PTR_ERR(priv->enable); 194 - } 188 + if (IS_ERR(priv->enable)) 189 + return dev_err_probe(&spi->dev, PTR_ERR(priv->enable), 190 + "Unable to get the lcd l4f00242t03 data en gpio.\n"); 195 191 gpiod_set_consumer_name(priv->enable, "lcd l4f00242t03 data enable"); 196 192 197 193 priv->io_reg = devm_regulator_get(&spi->dev, "vdd"); 198 - if (IS_ERR(priv->io_reg)) { 199 - dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", 200 - __func__); 201 - return PTR_ERR(priv->io_reg); 202 - } 194 + if (IS_ERR(priv->io_reg)) 195 + return dev_err_probe(&spi->dev, PTR_ERR(priv->io_reg), 196 + "%s: Unable to get the IO regulator\n", 197 + __func__); 203 198 204 199 priv->core_reg = devm_regulator_get(&spi->dev, "vcore"); 205 - if (IS_ERR(priv->core_reg)) { 206 - dev_err(&spi->dev, "%s: Unable to get the core regulator\n", 207 - __func__); 208 - return PTR_ERR(priv->core_reg); 209 - } 200 + if (IS_ERR(priv->core_reg)) 201 + return dev_err_probe(&spi->dev, PTR_ERR(priv->core_reg), 202 + "%s: Unable to get the core regulator\n", 203 + __func__); 210 204 211 205 priv->ld = devm_lcd_device_register(&spi->dev, "l4f00242t03", &spi->dev, 212 206 priv, &l4f_ops);
+18 -24
drivers/video/backlight/lm3630a_bl.c
··· 189 189 int ret; 190 190 struct lm3630a_chip *pchip = bl_get_data(bl); 191 191 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; 192 + int brightness = backlight_get_brightness(bl); 192 193 193 194 /* pwm control */ 194 195 if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) 195 - return lm3630a_pwm_ctrl(pchip, bl->props.brightness, 196 + return lm3630a_pwm_ctrl(pchip, brightness, 196 197 bl->props.max_brightness); 197 198 198 199 /* disable sleep */ ··· 202 201 goto out_i2c_err; 203 202 usleep_range(1000, 2000); 204 203 /* minimum brightness is 0x04 */ 205 - ret = lm3630a_write(pchip, REG_BRT_A, bl->props.brightness); 204 + ret = lm3630a_write(pchip, REG_BRT_A, brightness); 206 205 207 - if (backlight_is_blank(bl) || (backlight_get_brightness(bl) < 0x4)) 206 + if (brightness < 0x4) 208 207 /* turn the string off */ 209 208 ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDA_ENABLE, 0); 210 209 else ··· 234 233 if (rval < 0) 235 234 goto out_i2c_err; 236 235 brightness |= rval; 237 - goto out; 236 + return brightness; 238 237 } 239 238 240 239 /* disable sleep */ ··· 245 244 rval = lm3630a_read(pchip, REG_BRT_A); 246 245 if (rval < 0) 247 246 goto out_i2c_err; 248 - brightness = rval; 247 + return rval; 249 248 250 - out: 251 - bl->props.brightness = brightness; 252 - return bl->props.brightness; 253 249 out_i2c_err: 254 250 dev_err(pchip->dev, "i2c failed to access register\n"); 255 251 return 0; ··· 264 266 int ret; 265 267 struct lm3630a_chip *pchip = bl_get_data(bl); 266 268 enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; 269 + int brightness = backlight_get_brightness(bl); 267 270 268 271 /* pwm control */ 269 272 if ((pwm_ctrl & LM3630A_PWM_BANK_B) != 0) 270 - return lm3630a_pwm_ctrl(pchip, bl->props.brightness, 273 + return lm3630a_pwm_ctrl(pchip, brightness, 271 274 bl->props.max_brightness); 272 275 273 276 /* disable sleep */ ··· 277 278 goto out_i2c_err; 278 279 usleep_range(1000, 2000); 279 280 /* minimum brightness is 0x04 */ 280 - ret = lm3630a_write(pchip, REG_BRT_B, bl->props.brightness); 281 + ret = lm3630a_write(pchip, REG_BRT_B, brightness); 281 282 282 - if (backlight_is_blank(bl) || (backlight_get_brightness(bl) < 0x4)) 283 + if (brightness < 0x4) 283 284 /* turn the string off */ 284 285 ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDB_ENABLE, 0); 285 286 else ··· 309 310 if (rval < 0) 310 311 goto out_i2c_err; 311 312 brightness |= rval; 312 - goto out; 313 + return brightness; 313 314 } 314 315 315 316 /* disable sleep */ ··· 320 321 rval = lm3630a_read(pchip, REG_BRT_B); 321 322 if (rval < 0) 322 323 goto out_i2c_err; 323 - brightness = rval; 324 + return rval; 324 325 325 - out: 326 - bl->props.brightness = brightness; 327 - return bl->props.brightness; 328 326 out_i2c_err: 329 327 dev_err(pchip->dev, "i2c failed to access register\n"); 330 328 return 0; ··· 339 343 struct backlight_properties props; 340 344 const char *label; 341 345 346 + memset(&props, 0, sizeof(struct backlight_properties)); 342 347 props.type = BACKLIGHT_RAW; 343 348 if (pdata->leda_ctrl != LM3630A_LEDA_DISABLE) { 344 349 props.brightness = pdata->leda_init_brt; ··· 540 543 541 544 pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", 542 545 GPIOD_OUT_HIGH); 543 - if (IS_ERR(pchip->enable_gpio)) { 544 - rval = PTR_ERR(pchip->enable_gpio); 545 - return rval; 546 - } 546 + if (IS_ERR(pchip->enable_gpio)) 547 + return PTR_ERR(pchip->enable_gpio); 547 548 548 549 /* chip initialize */ 549 550 rval = lm3630a_chip_init(pchip); ··· 558 563 /* pwm */ 559 564 if (pdata->pwm_ctrl != LM3630A_PWM_DISABLE) { 560 565 pchip->pwmd = devm_pwm_get(pchip->dev, "lm3630a-pwm"); 561 - if (IS_ERR(pchip->pwmd)) { 562 - dev_err(&client->dev, "fail : get pwm device\n"); 563 - return PTR_ERR(pchip->pwmd); 564 - } 566 + if (IS_ERR(pchip->pwmd)) 567 + return dev_err_probe(&client->dev, PTR_ERR(pchip->pwmd), 568 + "fail : get pwm device\n"); 565 569 566 570 pwm_init_state(pchip->pwmd, &pchip->pwmd_state); 567 571 }
+1
drivers/video/backlight/lm3639_bl.c
··· 338 338 } 339 339 340 340 /* backlight */ 341 + memset(&props, 0, sizeof(struct backlight_properties)); 341 342 props.type = BACKLIGHT_RAW; 342 343 props.brightness = pdata->init_brt_led; 343 344 props.max_brightness = pdata->max_brt_led;
+1
drivers/video/backlight/lp8788_bl.c
··· 191 191 int init_brt; 192 192 char *name; 193 193 194 + memset(&props, 0, sizeof(struct backlight_properties)); 194 195 props.type = BACKLIGHT_PLATFORM; 195 196 props.max_brightness = MAX_BRIGHTNESS; 196 197
+38 -55
drivers/video/backlight/mp3309c.c
··· 15 15 #include <linux/delay.h> 16 16 #include <linux/gpio/consumer.h> 17 17 #include <linux/i2c.h> 18 + #include <linux/mod_devicetable.h> 19 + #include <linux/property.h> 18 20 #include <linux/pwm.h> 19 21 #include <linux/regmap.h> 20 22 ··· 133 131 chip->pdata->levels[brightness], 134 132 chip->pdata->levels[chip->pdata->max_brightness]); 135 133 pwmstate.enabled = true; 136 - ret = pwm_apply_state(chip->pwmd, &pwmstate); 134 + ret = pwm_apply_might_sleep(chip->pwmd, &pwmstate); 137 135 if (ret) 138 136 return ret; 139 137 ··· 201 199 .update_status = mp3309c_bl_update_status, 202 200 }; 203 201 204 - static int pm3309c_parse_dt_node(struct mp3309c_chip *chip, 205 - struct mp3309c_platform_data *pdata) 202 + static int mp3309c_parse_fwnode(struct mp3309c_chip *chip, 203 + struct mp3309c_platform_data *pdata) 206 204 { 207 - struct device_node *node = chip->dev->of_node; 208 - struct property *prop_pwms; 209 - struct property *prop_levels = NULL; 210 - int length = 0; 211 205 int ret, i; 212 206 unsigned int num_levels, tmp_value; 207 + struct device *dev = chip->dev; 213 208 214 - if (!node) { 215 - dev_err(chip->dev, "failed to get DT node\n"); 216 - return -ENODEV; 217 - } 209 + if (!dev_fwnode(dev)) 210 + return dev_err_probe(dev, -ENODEV, "failed to get firmware node\n"); 218 211 219 212 /* 220 213 * Dimming mode: the MP3309C provides two dimming control mode: ··· 221 224 * found in the backlight node, the mode switches to PWM mode. 222 225 */ 223 226 pdata->dimming_mode = DIMMING_ANALOG_I2C; 224 - prop_pwms = of_find_property(node, "pwms", &length); 225 - if (prop_pwms) { 226 - chip->pwmd = devm_pwm_get(chip->dev, NULL); 227 + if (device_property_present(dev, "pwms")) { 228 + chip->pwmd = devm_pwm_get(dev, NULL); 227 229 if (IS_ERR(chip->pwmd)) 228 - return dev_err_probe(chip->dev, PTR_ERR(chip->pwmd), 229 - "error getting pwm data\n"); 230 + return dev_err_probe(dev, PTR_ERR(chip->pwmd), "error getting pwm data\n"); 230 231 pdata->dimming_mode = DIMMING_PWM; 231 232 pwm_apply_args(chip->pwmd); 232 233 } ··· 242 247 num_levels = ANALOG_I2C_NUM_LEVELS; 243 248 244 249 /* Enable GPIO used in I2C dimming mode only */ 245 - chip->enable_gpio = devm_gpiod_get(chip->dev, "enable", 246 - GPIOD_OUT_HIGH); 250 + chip->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH); 247 251 if (IS_ERR(chip->enable_gpio)) 248 - return dev_err_probe(chip->dev, 249 - PTR_ERR(chip->enable_gpio), 252 + return dev_err_probe(dev, PTR_ERR(chip->enable_gpio), 250 253 "error getting enable gpio\n"); 251 254 } else { 252 255 /* 253 256 * PWM control mode: check for brightness level in DT 254 257 */ 255 - prop_levels = of_find_property(node, "brightness-levels", 256 - &length); 257 - if (prop_levels) { 258 + if (device_property_present(dev, "brightness-levels")) { 258 259 /* Read brightness levels from DT */ 259 - num_levels = length / sizeof(u32); 260 + num_levels = device_property_count_u32(dev, "brightness-levels"); 260 261 if (num_levels < 2) 261 262 return -EINVAL; 262 263 } else { ··· 262 271 } 263 272 264 273 /* Fill brightness levels array */ 265 - pdata->levels = devm_kcalloc(chip->dev, num_levels, 266 - sizeof(*pdata->levels), GFP_KERNEL); 274 + pdata->levels = devm_kcalloc(dev, num_levels, sizeof(*pdata->levels), GFP_KERNEL); 267 275 if (!pdata->levels) 268 276 return -ENOMEM; 269 - if (prop_levels) { 270 - ret = of_property_read_u32_array(node, "brightness-levels", 271 - pdata->levels, 272 - num_levels); 277 + if (device_property_present(dev, "brightness-levels")) { 278 + ret = device_property_read_u32_array(dev, "brightness-levels", 279 + pdata->levels, num_levels); 273 280 if (ret < 0) 274 281 return ret; 275 282 } else { ··· 277 288 278 289 pdata->max_brightness = num_levels - 1; 279 290 280 - ret = of_property_read_u32(node, "default-brightness", 281 - &pdata->default_brightness); 291 + ret = device_property_read_u32(dev, "default-brightness", &pdata->default_brightness); 282 292 if (ret) 283 293 pdata->default_brightness = pdata->max_brightness; 284 294 if (pdata->default_brightness > pdata->max_brightness) { 285 - dev_err(chip->dev, 286 - "default brightness exceeds max brightness\n"); 295 + dev_err_probe(dev, -ERANGE, "default brightness exceeds max brightness\n"); 287 296 pdata->default_brightness = pdata->max_brightness; 288 297 } 289 298 ··· 297 310 * If missing, the default value for OVP is 35.5V 298 311 */ 299 312 pdata->over_voltage_protection = REG_I2C_1_OVP1; 300 - if (!of_property_read_u32(node, "mps,overvoltage-protection-microvolt", 301 - &tmp_value)) { 313 + ret = device_property_read_u32(dev, "mps,overvoltage-protection-microvolt", &tmp_value); 314 + if (!ret) { 302 315 switch (tmp_value) { 303 316 case 13500000: 304 317 pdata->over_voltage_protection = 0x00; ··· 315 328 } 316 329 317 330 /* Synchronous (default) and non-synchronous mode */ 318 - pdata->sync_mode = true; 319 - if (of_property_read_bool(node, "mps,no-sync-mode")) 320 - pdata->sync_mode = false; 331 + pdata->sync_mode = !device_property_read_bool(dev, "mps,no-sync-mode"); 321 332 322 333 return 0; 323 334 } 324 335 325 336 static int mp3309c_probe(struct i2c_client *client) 326 337 { 327 - struct mp3309c_platform_data *pdata = dev_get_platdata(&client->dev); 338 + struct device *dev = &client->dev; 339 + struct mp3309c_platform_data *pdata = dev_get_platdata(dev); 328 340 struct mp3309c_chip *chip; 329 341 struct backlight_properties props; 330 342 struct pwm_state pwmstate; 331 343 int ret; 332 344 333 - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 334 - dev_err(&client->dev, "failed to check i2c functionality\n"); 335 - return -EOPNOTSUPP; 336 - } 345 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 346 + return dev_err_probe(dev, -EOPNOTSUPP, "failed to check i2c functionality\n"); 337 347 338 - chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); 348 + chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); 339 349 if (!chip) 340 350 return -ENOMEM; 341 351 342 - chip->dev = &client->dev; 352 + chip->dev = dev; 343 353 344 354 chip->regmap = devm_regmap_init_i2c(client, &mp3309c_regmap); 345 355 if (IS_ERR(chip->regmap)) 346 - return dev_err_probe(&client->dev, PTR_ERR(chip->regmap), 356 + return dev_err_probe(dev, PTR_ERR(chip->regmap), 347 357 "failed to allocate register map\n"); 348 358 349 359 i2c_set_clientdata(client, chip); 350 360 351 361 if (!pdata) { 352 - pdata = devm_kzalloc(chip->dev, sizeof(*pdata), GFP_KERNEL); 362 + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 353 363 if (!pdata) 354 364 return -ENOMEM; 355 365 356 - ret = pm3309c_parse_dt_node(chip, pdata); 366 + ret = mp3309c_parse_fwnode(chip, pdata); 357 367 if (ret) 358 368 return ret; 359 369 } 360 370 chip->pdata = pdata; 361 371 362 372 /* Backlight properties */ 373 + memset(&props, 0, sizeof(struct backlight_properties)); 363 374 props.brightness = pdata->default_brightness; 364 375 props.max_brightness = pdata->max_brightness; 365 376 props.scale = BACKLIGHT_SCALE_LINEAR; 366 377 props.type = BACKLIGHT_RAW; 367 378 props.power = FB_BLANK_UNBLANK; 368 379 props.fb_blank = FB_BLANK_UNBLANK; 369 - chip->bl = devm_backlight_device_register(chip->dev, "mp3309c", 370 - chip->dev, chip, 380 + chip->bl = devm_backlight_device_register(dev, "mp3309c", dev, chip, 371 381 &mp3309c_bl_ops, &props); 372 382 if (IS_ERR(chip->bl)) 373 - return dev_err_probe(chip->dev, PTR_ERR(chip->bl), 383 + return dev_err_probe(dev, PTR_ERR(chip->bl), 374 384 "error registering backlight device\n"); 375 385 376 386 /* In PWM dimming mode, enable pwm device */ ··· 377 393 chip->pdata->default_brightness, 378 394 chip->pdata->max_brightness); 379 395 pwmstate.enabled = true; 380 - ret = pwm_apply_state(chip->pwmd, &pwmstate); 396 + ret = pwm_apply_might_sleep(chip->pwmd, &pwmstate); 381 397 if (ret) 382 - return dev_err_probe(chip->dev, ret, 383 - "error setting pwm device\n"); 398 + return dev_err_probe(dev, ret, "error setting pwm device\n"); 384 399 } 385 400 386 401 chip->pdata->status = FIRST_POWER_ON;
+1 -3
drivers/video/backlight/pandora_bl.c
··· 114 114 u8 r; 115 115 116 116 priv = devm_kmalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 117 - if (!priv) { 118 - dev_err(&pdev->dev, "failed to allocate driver private data\n"); 117 + if (!priv) 119 118 return -ENOMEM; 120 - } 121 119 122 120 memset(&props, 0, sizeof(props)); 123 121 props.max_brightness = MAX_USER_VALUE;
+38
include/linux/leds-expresswire.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Shared library for Kinetic's ExpressWire protocol. 4 + * This protocol works by pulsing the ExpressWire IC's control GPIO. 5 + * ktd2692 and ktd2801 are known to use this protocol. 6 + */ 7 + 8 + #ifndef _LEDS_EXPRESSWIRE_H 9 + #define _LEDS_EXPRESSWIRE_H 10 + 11 + #include <linux/types.h> 12 + 13 + struct gpio_desc; 14 + 15 + struct expresswire_timing { 16 + unsigned long poweroff_us; 17 + unsigned long detect_delay_us; 18 + unsigned long detect_us; 19 + unsigned long data_start_us; 20 + unsigned long end_of_data_low_us; 21 + unsigned long end_of_data_high_us; 22 + unsigned long short_bitset_us; 23 + unsigned long long_bitset_us; 24 + }; 25 + 26 + struct expresswire_common_props { 27 + struct gpio_desc *ctrl_gpio; 28 + struct expresswire_timing timing; 29 + }; 30 + 31 + void expresswire_power_off(struct expresswire_common_props *props); 32 + void expresswire_enable(struct expresswire_common_props *props); 33 + void expresswire_start(struct expresswire_common_props *props); 34 + void expresswire_end(struct expresswire_common_props *props); 35 + void expresswire_set_bit(struct expresswire_common_props *props, bool bit); 36 + void expresswire_write_u8(struct expresswire_common_props *props, u8 val); 37 + 38 + #endif /* _LEDS_EXPRESSWIRE_H */