EDP: remove old system EDP framework (max8831 backlight driver)
Timo Alho [Tue, 31 Dec 2013 08:50:30 +0000 (10:50 +0200)]
Revised system edp software framework has been put in place. This
patch removes old system edp client code from max8831 backlight
driver.

Bug 1431977

Change-Id: I4d107f7d26759c009a28e4b6617bd8126950a022
Signed-off-by: Timo Alho <talho@nvidia.com>
Reviewed-on: http://git-master/r/350985
Reviewed-by: Vineel Kumar Reddy Kovvuri <vineelkumarr@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

drivers/video/backlight/max8831_bl.c
include/linux/max8831_backlight.h

index b2fe554..f5c2809 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/mfd/max8831.h>
 #include <linux/max8831_backlight.h>
 #include <linux/regulator/consumer.h>
-#include <linux/edp.h>
 #include <linux/platform_device.h>
 
 struct max8831_backlight_data {
@@ -40,8 +39,6 @@ struct max8831_backlight_data {
 
        int (*notify)(struct device *dev, int brightness);
        bool (*is_powered)(void);
-       struct edp_client *max8831_edp_client;
-       int *edp_brightness_states;
 };
 
 static int max8831_backlight_set(struct backlight_device *bl, int brightness)
@@ -77,47 +74,6 @@ static int max8831_backlight_set(struct backlight_device *bl, int brightness)
        return 0;
 }
 
-static int max8831_backlight_set_with_edp(struct backlight_device *bl,
-       int brightness)
-{
-       struct max8831_backlight_data *data = bl_get_data(bl);
-       struct device *dev = data->max8831_dev;
-       unsigned int approved_state;
-       int unsigned approved_brightness;
-       int ret;
-       unsigned int edp_state;
-       unsigned int edp_brightness;
-       unsigned int i;
-
-       if (data->max8831_edp_client) {
-               for (i = 0; i < MAX8831_EDP_NUM_STATES; i++) {
-                       edp_brightness = data->edp_brightness_states[i];
-                       if (brightness > edp_brightness) {
-                               /* Choose the next higher EDP state */
-                               if (i)
-                                       i--;
-                               break;
-                       } else if (brightness == edp_brightness)
-                               break;
-               }
-               edp_state = i;
-               ret = edp_update_client_request(data->max8831_edp_client,
-                       edp_state, &approved_state);
-               if (ret) {
-                       dev_err(dev, "E state transition failed\n");
-                       return ret;
-               }
-
-               approved_brightness =
-                       data->edp_brightness_states[approved_state];
-               if (brightness > approved_brightness)
-                       brightness = approved_brightness;
-       }
-
-       max8831_backlight_set(bl, brightness);
-       return 0;
-}
-
 static int max8831_backlight_update_status(struct backlight_device *bl)
 {
        struct max8831_backlight_data *data = bl_get_data(bl);
@@ -134,15 +90,7 @@ static int max8831_backlight_update_status(struct backlight_device *bl)
        if (data->notify)
                brightness = data->notify(data->max8831_dev, brightness);
 
-       return max8831_backlight_set_with_edp(bl, brightness);
-}
-
-static void max8831_backlight_edpcb(unsigned int new_state, void *priv_data)
-{
-       struct backlight_device *bl_device = (struct backlight_device *) priv_data;
-       struct max8831_backlight_data *data = bl_get_data(bl_device);
-       max8831_backlight_set(bl_device,
-                       data->edp_brightness_states[new_state]);
+       return max8831_backlight_set(bl, brightness);
 }
 
 static int max8831_backlight_get_brightness(struct backlight_device *bl)
@@ -162,9 +110,6 @@ static int max8831_bl_probe(struct platform_device *pdev)
        struct backlight_device *bl;
        struct backlight_properties props;
        struct platform_max8831_backlight_data *pData = pdev->dev.platform_data;
-       struct edp_manager *battery_manager = NULL;
-       int ret;
-
 
        data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
        if (data == NULL)
@@ -175,7 +120,6 @@ static int max8831_bl_probe(struct platform_device *pdev)
        data->id = pdev->id;
        data->notify = pData->notify;
        data->is_powered = pData->is_powered;
-       data->edp_brightness_states = pData->edp_brightness;
        data->regulator = regulator_get(data->max8831_dev,
                        "vin");
        if (IS_ERR(data->regulator)) {
@@ -195,50 +139,6 @@ static int max8831_bl_probe(struct platform_device *pdev)
                return PTR_ERR(bl);
        }
 
-       data->max8831_edp_client = devm_kzalloc(&pdev->dev,
-                                       sizeof(struct edp_client), GFP_KERNEL);
-       if (IS_ERR_OR_NULL(data->max8831_edp_client)) {
-               dev_err(&pdev->dev, "could not allocate edp client\n");
-               return PTR_ERR(data->max8831_edp_client);
-       }
-
-       strncpy(data->max8831_edp_client->name, "backlight", EDP_NAME_LEN - 1);
-       data->max8831_edp_client->name[EDP_NAME_LEN - 1] = '\0';
-       data->max8831_edp_client->states = pData->edp_states;
-       data->max8831_edp_client->num_states = MAX8831_EDP_NUM_STATES;
-       data->max8831_edp_client->e0_index = MAX8831_EDP_ZERO;
-       data->max8831_edp_client->private_data = bl;
-       data->max8831_edp_client->priority = EDP_MAX_PRIO + 2;
-       data->max8831_edp_client->throttle = max8831_backlight_edpcb;
-       data->max8831_edp_client->notify_promotion = max8831_backlight_edpcb;
-
-       battery_manager = edp_get_manager("battery");
-       if (!battery_manager) {
-               dev_err(&pdev->dev, "unable to get edp manager\n");
-       } else {
-               ret = edp_register_client(battery_manager,
-                                       data->max8831_edp_client);
-               if (ret) {
-                       dev_err(&pdev->dev, "unable to register edp client\n");
-               } else {
-                       ret = edp_update_client_request(
-                                       data->max8831_edp_client,
-                                               MAX8831_EDP_ZERO, NULL);
-                       if (ret) {
-                               dev_err(&pdev->dev,
-                                       "unable to set E0 EDP state\n");
-                               edp_unregister_client(data->max8831_edp_client);
-                       } else {
-                               goto edp_success;
-                       }
-               }
-       }
-
-       devm_kfree(&pdev->dev, data->max8831_edp_client);
-       data->max8831_edp_client = NULL;
-
-edp_success:
-
        bl->props.brightness = pData->dft_brightness;
 
        platform_set_drvdata(pdev, bl);
@@ -267,11 +167,10 @@ static int max8831_bl_suspend(struct device *dev)
        struct max8831_backlight_data *data = bl_get_data(bl);
        int ret;
 
-       ret = max8831_backlight_set_with_edp(bl, 0);
+       ret = max8831_backlight_set(bl, 0);
        if (data->regulator)
                regulator_disable(data->regulator);
        return ret;
-
 }
 
 static int max8831_bl_resume(struct device *dev)
index a43c7c2..a12f510 100644 (file)
 
 #include <linux/backlight.h>
 
-enum max8831_edp_states {
-       MAX8831_EDP_NEG_8,
-       MAX8831_EDP_NEG_7,
-       MAX8831_EDP_NEG_6,
-       MAX8831_EDP_NEG_5,
-       MAX8831_EDP_NEG_4,
-       MAX8831_EDP_NEG_3,
-       MAX8831_EDP_NEG_2,
-       MAX8831_EDP_NEG_1,
-       MAX8831_EDP_ZERO,
-       MAX8831_EDP_1,
-       MAX8831_EDP_2,
-       MAX8831_EDP_NUM_STATES,
-};
-
-#define MAX8831_EDP_BRIGHTNESS_UNIT    25
-
 struct platform_max8831_backlight_data {
        int id;
        const char *name;
@@ -43,8 +26,6 @@ struct platform_max8831_backlight_data {
        unsigned int dft_brightness;
        int (*notify)(struct device *dev, int brightness);
        bool (*is_powered)(void);
-       unsigned int *edp_states;
-       unsigned int *edp_brightness;
 };
 
 #endif