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

Revert "[media] Add device tree support to adp1653 flash driver"

As requested by Sakari:

"The driver changes are still being reviewed.
It's been proposed that the max-microamp property be renamed."

So, as the DT bindings are not agreed upstream yet, let's revert
it.

Requested-by: Sakari Ailus <sakari.ailus@iki.fi>
This reverts commit b6100f10bdc2019a65297d2597c388de2f7dd653.

+9 -118
-37
Documentation/devicetree/bindings/media/i2c/adp1653.txt
··· 1 - * Analog Devices ADP1653 flash LED driver 2 - 3 - Required Properties: 4 - 5 - - compatible: Must contain be "adi,adp1653" 6 - 7 - - reg: I2C slave address 8 - 9 - - gpios: References to the GPIO that controls the power for the chip. 10 - 11 - There are two led outputs available - flash and indicator. One led is 12 - represented by one child node, nodes need to be named "flash" and "indicator". 13 - 14 - Required properties of the LED child node: 15 - - max-microamp : see Documentation/devicetree/bindings/leds/common.txt 16 - 17 - Required properties of the flash LED child node: 18 - 19 - - flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt 20 - - flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt 21 - 22 - Example: 23 - 24 - adp1653: led-controller@30 { 25 - compatible = "adi,adp1653"; 26 - reg = <0x30>; 27 - gpios = <&gpio3 24 GPIO_ACTIVE_HIGH>; /* 88 */ 28 - 29 - flash { 30 - flash-timeout-us = <500000>; 31 - flash-max-microamp = <320000>; 32 - max-microamp = <50000>; 33 - }; 34 - indicator { 35 - max-microamp = <17500>; 36 - }; 37 - };
+9 -81
drivers/media/i2c/adp1653.c
··· 8 8 * Contributors: 9 9 * Sakari Ailus <sakari.ailus@iki.fi> 10 10 * Tuukka Toivonen <tuukkat76@gmail.com> 11 - * Pavel Machek <pavel@ucw.cz> 12 11 * 13 12 * This program is free software; you can redistribute it and/or 14 13 * modify it under the terms of the GNU General Public License ··· 34 35 #include <linux/module.h> 35 36 #include <linux/i2c.h> 36 37 #include <linux/slab.h> 37 - #include <linux/of_gpio.h> 38 - #include <linux/gpio.h> 39 38 #include <media/adp1653.h> 40 39 #include <media/v4l2-device.h> 41 40 ··· 306 309 static int 307 310 __adp1653_set_power(struct adp1653_flash *flash, int on) 308 311 { 309 - int ret = 0; 312 + int ret; 310 313 311 - if (flash->platform_data->power) { 312 - ret = flash->platform_data->power(&flash->subdev, on); 313 - } else { 314 - gpio_set_value(flash->platform_data->power_gpio, on); 315 - if (on) 316 - /* Some delay is apparently required. */ 317 - udelay(20); 318 - } 319 - 314 + ret = flash->platform_data->power(&flash->subdev, on); 320 315 if (ret < 0) 321 316 return ret; 322 317 ··· 316 327 return 0; 317 328 318 329 ret = adp1653_init_device(flash); 319 - if (ret >= 0) 320 - return ret; 321 - 322 - if (flash->platform_data->power) 330 + if (ret < 0) 323 331 flash->platform_data->power(&flash->subdev, 0); 324 - else 325 - gpio_set_value(flash->platform_data->power_gpio, 0); 326 332 327 333 return ret; 328 334 } ··· 407 423 408 424 #endif /* CONFIG_PM */ 409 425 410 - static int adp1653_of_init(struct i2c_client *client, 411 - struct adp1653_flash *flash, 412 - struct device_node *node) 413 - { 414 - u32 val; 415 - struct adp1653_platform_data *pd; 416 - enum of_gpio_flags flags; 417 - int gpio; 418 - struct device_node *child; 419 - 420 - if (!node) 421 - return -EINVAL; 422 - 423 - pd = devm_kzalloc(&client->dev, sizeof(*pd), GFP_KERNEL); 424 - if (!pd) 425 - return -ENOMEM; 426 - flash->platform_data = pd; 427 - 428 - child = of_get_child_by_name(node, "flash"); 429 - if (!child) 430 - return -EINVAL; 431 - if (of_property_read_u32(child, "flash-timeout-microsec", &val)) 432 - return -EINVAL; 433 - 434 - pd->max_flash_timeout = val; 435 - if (of_property_read_u32(child, "flash-max-microamp", &val)) 436 - return -EINVAL; 437 - pd->max_flash_intensity = val/1000; 438 - 439 - if (of_property_read_u32(child, "max-microamp", &val)) 440 - return -EINVAL; 441 - pd->max_torch_intensity = val/1000; 442 - 443 - child = of_get_child_by_name(node, "indicator"); 444 - if (!child) 445 - return -EINVAL; 446 - if (of_property_read_u32(child, "max-microamp", &val)) 447 - return -EINVAL; 448 - pd->max_indicator_intensity = val; 449 - 450 - if (!of_find_property(node, "gpios", NULL)) { 451 - dev_err(&client->dev, "No gpio node\n"); 452 - return -EINVAL; 453 - } 454 - 455 - pd->power_gpio = of_get_gpio_flags(node, 0, &flags); 456 - if (pd->power_gpio < 0) { 457 - dev_err(&client->dev, "Error getting GPIO\n"); 458 - return -EINVAL; 459 - } 460 - 461 - return 0; 462 - } 463 - 464 - 465 426 static int adp1653_probe(struct i2c_client *client, 466 427 const struct i2c_device_id *devid) 467 428 { 468 429 struct adp1653_flash *flash; 469 430 int ret; 470 431 432 + /* we couldn't work without platform data */ 433 + if (client->dev.platform_data == NULL) 434 + return -ENODEV; 435 + 471 436 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); 472 437 if (flash == NULL) 473 438 return -ENOMEM; 474 439 475 440 flash->platform_data = client->dev.platform_data; 476 - if (!flash->platform_data) { 477 - ret = adp1653_of_init(client, flash, client->dev.of_node); 478 - if (ret) 479 - return ret; 480 - } 481 441 482 442 mutex_init(&flash->power_lock); 483 443 ··· 438 510 goto free_and_quit; 439 511 440 512 flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; 513 + 441 514 return 0; 442 515 443 516 free_and_quit: 444 - dev_err(&client->dev, "adp1653: failed to register device\n"); 445 517 v4l2_ctrl_handler_free(&flash->ctrls); 446 518 return ret; 447 519 } ··· 464 536 }; 465 537 MODULE_DEVICE_TABLE(i2c, adp1653_id_table); 466 538 467 - static const struct dev_pm_ops adp1653_pm_ops = { 539 + static struct dev_pm_ops adp1653_pm_ops = { 468 540 .suspend = adp1653_suspend, 469 541 .resume = adp1653_resume, 470 542 };