diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2015-04-03 16:35:14 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2015-04-06 19:23:35 -0700 |
commit | 0a409a7bce9c77cced95c8cb7e3883905b761f31 (patch) | |
tree | 086e6c44b92107be191451903ff6c0a8ed51bf98 | |
parent | ed4197c4e1cd9be7dc94178a777d3c25bdf862eb (diff) | |
download | deviced-0a409a7bce9c77cced95c8cb7e3883905b761f31.tar.gz deviced-0a409a7bce9c77cced95c8cb7e3883905b761f31.tar.bz2 deviced-0a409a7bce9c77cced95c8cb7e3883905b761f31.zip |
extcon: Do not invoke the update() if the status is the same as before
Do not invoke the update func. if the status is the same as before.
And do not printout error logs for not matched device.
The information of not matched device is already printed out on booting time.
So it's redundant logs.
Change-Id: I8bd2696036bb4633eb05a128d5a9de46dc35fed1
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
-rw-r--r-- | src/extcon/cradle.c | 2 | ||||
-rw-r--r-- | src/extcon/earjack.c | 2 | ||||
-rwxr-xr-x | src/extcon/extcon.c | 9 | ||||
-rwxr-xr-x | src/extcon/extcon.h | 11 | ||||
-rw-r--r-- | src/extcon/hdmi.c | 2 | ||||
-rw-r--r-- | src/usb/usb.c | 2 |
6 files changed, 19 insertions, 9 deletions
diff --git a/src/extcon/cradle.c b/src/extcon/cradle.c index 6b4d6b2b..6aabe5f9 100644 --- a/src/extcon/cradle.c +++ b/src/extcon/cradle.c @@ -121,4 +121,4 @@ static struct extcon_ops cradle_extcon_ops = { .update = cradle_update, }; -EXTCON_OPS_REGISTER(&cradle_extcon_ops); +EXTCON_OPS_REGISTER(cradle_extcon_ops) diff --git a/src/extcon/earjack.c b/src/extcon/earjack.c index db2118cc..c5deaeb5 100644 --- a/src/extcon/earjack.c +++ b/src/extcon/earjack.c @@ -58,4 +58,4 @@ static struct extcon_ops earjack_extcon_ops = { .update = earjack_update, }; -EXTCON_OPS_REGISTER(&earjack_extcon_ops) +EXTCON_OPS_REGISTER(earjack_extcon_ops) diff --git a/src/extcon/extcon.c b/src/extcon/extcon.c index 3285aab2..80ef7381 100755 --- a/src/extcon/extcon.c +++ b/src/extcon/extcon.c @@ -85,12 +85,15 @@ static int extcon_update(const char *name, const char *value) return -EINVAL; dev = find_extcon(name); - if (!dev) { - _E("fail to find matched extcon device : name(%s)", name); + if (!dev) return -EINVAL; - } status = atoi(value); + + /* Do not invoke update func. if it's the same value */ + if (dev->status == status) + return 0; + _I("Changed %s device : %d -> %d", name, dev->status, status); dev->status = status; diff --git a/src/extcon/extcon.h b/src/extcon/extcon.h index b06c6299..eb10fc98 100755 --- a/src/extcon/extcon.h +++ b/src/extcon/extcon.h @@ -45,11 +45,18 @@ struct extcon_ops { #define EXTCON_OPS_REGISTER(dev) \ static void __CONSTRUCTOR__ extcon_init(void) \ { \ - add_extcon(dev); \ + /** + * If there is no predefined status value, + * default status will set as a negative value(-1). + * It will be updated as the initial value in booting time. + */ \ + if (!dev.status) \ + dev.status = -1; \ + add_extcon(&dev); \ } \ static void __DESTRUCTOR__ extcon_exit(void) \ { \ - remove_extcon(dev); \ + remove_extcon(&dev); \ } void add_extcon(struct extcon_ops *dev); diff --git a/src/extcon/hdmi.c b/src/extcon/hdmi.c index 29fc511f..5a6a1d89 100644 --- a/src/extcon/hdmi.c +++ b/src/extcon/hdmi.c @@ -118,4 +118,4 @@ static struct extcon_ops hdmi_extcon_ops = { .update = hdmi_update, }; -EXTCON_OPS_REGISTER(&hdmi_extcon_ops); +EXTCON_OPS_REGISTER(hdmi_extcon_ops) diff --git a/src/usb/usb.c b/src/usb/usb.c index 44d5d2d0..c122ae9b 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -206,4 +206,4 @@ struct extcon_ops extcon_usb_ops = { .update = usb_state_changed, }; -EXTCON_OPS_REGISTER(&extcon_usb_ops) +EXTCON_OPS_REGISTER(extcon_usb_ops) |