UPSTREAM: extcon: Block the bit masking operation for cable state except for extcon...
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 30 Jun 2016 17:41:18 +0000 (02:41 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 3 Aug 2016 02:07:01 +0000 (10:07 +0800)
This patch restrict the usage of extcon_update_state() in the extcon
core because the extcon_update_state() use the bit masking to change
the state of external connector. When this function is used in device drivers,
it may occur the probelm with the handling mistake of bit masking.

Also, this patch removes the extcon_get/set_state() functions because these
functions use the bit masking which is reluctant way. Instead, extcon
provides the extcon_set/get_cable_state_() functions.

Change-Id: I436b8d4f9485bb318e7d77db8902f85e2bc15778
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
(cherry picked from commit c2692f2dad4f3228579bb0b2cf2d6d9bf283f31a)

drivers/extcon/extcon.c
include/linux/extcon.h

index 9c7bd53a9f657d6da4548a6b2a097d2c2b08e8f0..c59538edcbc0a392d304614617982979f4ce93c8 100644 (file)
@@ -224,7 +224,7 @@ static ssize_t cable_state_show(struct device *dev,
  * Note that the notifier provides which bits are changed in the state
  * variable with the val parameter (second) to the callback.
  */
-int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
+static int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
 {
        char name_buf[120];
        char state_buf[120];
@@ -300,24 +300,6 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(extcon_update_state);
-
-/**
- * extcon_set_state() - Set the cable attach states of the extcon device.
- * @edev:      the extcon device
- * @state:     new cable attach status for @edev
- *
- * Note that notifier provides which bits are changed in the state
- * variable with the val parameter (second) to the callback.
- */
-int extcon_set_state(struct extcon_dev *edev, u32 state)
-{
-       if (!edev)
-               return -EINVAL;
-
-       return extcon_update_state(edev, 0xffffffff, state);
-}
-EXPORT_SYMBOL_GPL(extcon_set_state);
 
 /**
  * extcon_get_cable_state_() - Get the status of a specific cable.
index 61004413dc649594ca17b2d0453678d1b2cc621f..667b1d35af12785beea30968ee9aa9271e1a66ae 100644 (file)
@@ -149,20 +149,6 @@ extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
                                                   const unsigned int *cable);
 extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
 
-/*
- * get/set/update_state access the 32b encoded state value, which represents
- * states of all possible cables of the multistate port. For example, if one
- * calls extcon_set_state(edev, 0x7), it may mean that all the three cables
- * are attached to the port.
- */
-static inline u32 extcon_get_state(struct extcon_dev *edev)
-{
-       return edev->state;
-}
-
-extern int extcon_set_state(struct extcon_dev *edev, u32 state);
-extern int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state);
-
 /*
  * get/set_cable_state access each bit of the 32b encoded state value.
  * They are used to access the status of each cable based on the cable id.
@@ -232,22 +218,6 @@ static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
 
 static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
 
-static inline u32 extcon_get_state(struct extcon_dev *edev)
-{
-       return 0;
-}
-
-static inline int extcon_set_state(struct extcon_dev *edev, u32 state)
-{
-       return 0;
-}
-
-static inline int extcon_update_state(struct extcon_dev *edev, u32 mask,
-                                      u32 state)
-{
-       return 0;
-}
-
 static inline int extcon_get_cable_state_(struct extcon_dev *edev,
                                          unsigned int id)
 {