diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2013-09-26 20:19:40 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-09-26 20:37:01 -0400 |
commit | dae616512476024aa61d2a598461ab6eff8c0709 (patch) | |
tree | 8fbc98fef0beb28f8dbc334624bd63cde45b2101 /drivers/extcon/extcon-class.c | |
parent | 4102424302b313516d11a325e2ba614deec526a2 (diff) |
extcon: Change field type of 'dev' in extcon_dev structure
The extcon device must always need 'struct device' so this patch change
field type of 'dev' instead of allocating memory for 'struct device' on
extcon_dev_register() function.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-class.c')
-rw-r--r-- | drivers/extcon/extcon-class.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 2f2d374ccd1d..2801c14d5232 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c | |||
@@ -162,7 +162,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, | |||
162 | return ret; | 162 | return ret; |
163 | } | 163 | } |
164 | 164 | ||
165 | return sprintf(buf, "%s\n", dev_name(edev->dev)); | 165 | return sprintf(buf, "%s\n", dev_name(&edev->dev)); |
166 | } | 166 | } |
167 | static DEVICE_ATTR_RO(name); | 167 | static DEVICE_ATTR_RO(name); |
168 | 168 | ||
@@ -230,7 +230,7 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) | |||
230 | /* This could be in interrupt handler */ | 230 | /* This could be in interrupt handler */ |
231 | prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); | 231 | prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); |
232 | if (prop_buf) { | 232 | if (prop_buf) { |
233 | length = name_show(edev->dev, NULL, prop_buf); | 233 | length = name_show(&edev->dev, NULL, prop_buf); |
234 | if (length > 0) { | 234 | if (length > 0) { |
235 | if (prop_buf[length - 1] == '\n') | 235 | if (prop_buf[length - 1] == '\n') |
236 | prop_buf[length - 1] = 0; | 236 | prop_buf[length - 1] = 0; |
@@ -238,7 +238,7 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) | |||
238 | "NAME=%s", prop_buf); | 238 | "NAME=%s", prop_buf); |
239 | envp[env_offset++] = name_buf; | 239 | envp[env_offset++] = name_buf; |
240 | } | 240 | } |
241 | length = state_show(edev->dev, NULL, prop_buf); | 241 | length = state_show(&edev->dev, NULL, prop_buf); |
242 | if (length > 0) { | 242 | if (length > 0) { |
243 | if (prop_buf[length - 1] == '\n') | 243 | if (prop_buf[length - 1] == '\n') |
244 | prop_buf[length - 1] = 0; | 244 | prop_buf[length - 1] = 0; |
@@ -250,14 +250,14 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) | |||
250 | /* Unlock early before uevent */ | 250 | /* Unlock early before uevent */ |
251 | spin_unlock_irqrestore(&edev->lock, flags); | 251 | spin_unlock_irqrestore(&edev->lock, flags); |
252 | 252 | ||
253 | kobject_uevent_env(&edev->dev->kobj, KOBJ_CHANGE, envp); | 253 | kobject_uevent_env(&edev->dev.kobj, KOBJ_CHANGE, envp); |
254 | free_page((unsigned long)prop_buf); | 254 | free_page((unsigned long)prop_buf); |
255 | } else { | 255 | } else { |
256 | /* Unlock early before uevent */ | 256 | /* Unlock early before uevent */ |
257 | spin_unlock_irqrestore(&edev->lock, flags); | 257 | spin_unlock_irqrestore(&edev->lock, flags); |
258 | 258 | ||
259 | dev_err(edev->dev, "out of memory in extcon_set_state\n"); | 259 | dev_err(&edev->dev, "out of memory in extcon_set_state\n"); |
260 | kobject_uevent(&edev->dev->kobj, KOBJ_CHANGE); | 260 | kobject_uevent(&edev->dev.kobj, KOBJ_CHANGE); |
261 | } | 261 | } |
262 | } else { | 262 | } else { |
263 | /* No changes */ | 263 | /* No changes */ |
@@ -556,7 +556,6 @@ static int create_extcon_class(void) | |||
556 | 556 | ||
557 | static void extcon_dev_release(struct device *dev) | 557 | static void extcon_dev_release(struct device *dev) |
558 | { | 558 | { |
559 | kfree(dev); | ||
560 | } | 559 | } |
561 | 560 | ||
562 | static const char *muex_name = "mutually_exclusive"; | 561 | static const char *muex_name = "mutually_exclusive"; |
@@ -594,19 +593,16 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev) | |||
594 | } | 593 | } |
595 | 594 | ||
596 | if (index > SUPPORTED_CABLE_MAX) { | 595 | if (index > SUPPORTED_CABLE_MAX) { |
597 | dev_err(edev->dev, "extcon: maximum number of supported cables exceeded.\n"); | 596 | dev_err(&edev->dev, "extcon: maximum number of supported cables exceeded.\n"); |
598 | return -EINVAL; | 597 | return -EINVAL; |
599 | } | 598 | } |
600 | 599 | ||
601 | edev->dev = kzalloc(sizeof(struct device), GFP_KERNEL); | 600 | edev->dev.parent = dev; |
602 | if (!edev->dev) | 601 | edev->dev.class = extcon_class; |
603 | return -ENOMEM; | 602 | edev->dev.release = extcon_dev_release; |
604 | edev->dev->parent = dev; | ||
605 | edev->dev->class = extcon_class; | ||
606 | edev->dev->release = extcon_dev_release; | ||
607 | 603 | ||
608 | edev->name = edev->name ? edev->name : dev_name(dev); | 604 | edev->name = edev->name ? edev->name : dev_name(dev); |
609 | dev_set_name(edev->dev, "%s", edev->name); | 605 | dev_set_name(&edev->dev, "%s", edev->name); |
610 | 606 | ||
611 | if (edev->max_supported) { | 607 | if (edev->max_supported) { |
612 | char buf[10]; | 608 | char buf[10]; |
@@ -714,7 +710,7 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev) | |||
714 | goto err_alloc_groups; | 710 | goto err_alloc_groups; |
715 | } | 711 | } |
716 | 712 | ||
717 | edev->extcon_dev_type.name = dev_name(edev->dev); | 713 | edev->extcon_dev_type.name = dev_name(&edev->dev); |
718 | edev->extcon_dev_type.release = dummy_sysfs_dev_release; | 714 | edev->extcon_dev_type.release = dummy_sysfs_dev_release; |
719 | 715 | ||
720 | for (index = 0; index < edev->max_supported; index++) | 716 | for (index = 0; index < edev->max_supported; index++) |
@@ -724,25 +720,24 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev) | |||
724 | edev->extcon_dev_type.groups[index] = | 720 | edev->extcon_dev_type.groups[index] = |
725 | &edev->attr_g_muex; | 721 | &edev->attr_g_muex; |
726 | 722 | ||
727 | edev->dev->type = &edev->extcon_dev_type; | 723 | edev->dev.type = &edev->extcon_dev_type; |
728 | } | 724 | } |
729 | 725 | ||
730 | ret = device_register(edev->dev); | 726 | ret = device_register(&edev->dev); |
731 | if (ret) { | 727 | if (ret) { |
732 | put_device(edev->dev); | 728 | put_device(&edev->dev); |
733 | goto err_dev; | 729 | goto err_dev; |
734 | } | 730 | } |
735 | #if defined(CONFIG_ANDROID) | 731 | #if defined(CONFIG_ANDROID) |
736 | if (switch_class) | 732 | if (switch_class) |
737 | ret = class_compat_create_link(switch_class, edev->dev, | 733 | ret = class_compat_create_link(switch_class, &edev->dev, NULL); |
738 | NULL); | ||
739 | #endif /* CONFIG_ANDROID */ | 734 | #endif /* CONFIG_ANDROID */ |
740 | 735 | ||
741 | spin_lock_init(&edev->lock); | 736 | spin_lock_init(&edev->lock); |
742 | 737 | ||
743 | RAW_INIT_NOTIFIER_HEAD(&edev->nh); | 738 | RAW_INIT_NOTIFIER_HEAD(&edev->nh); |
744 | 739 | ||
745 | dev_set_drvdata(edev->dev, edev); | 740 | dev_set_drvdata(&edev->dev, edev); |
746 | edev->state = 0; | 741 | edev->state = 0; |
747 | 742 | ||
748 | mutex_lock(&extcon_dev_list_lock); | 743 | mutex_lock(&extcon_dev_list_lock); |
@@ -768,7 +763,6 @@ err_alloc_cables: | |||
768 | if (edev->max_supported) | 763 | if (edev->max_supported) |
769 | kfree(edev->cables); | 764 | kfree(edev->cables); |
770 | err_sysfs_alloc: | 765 | err_sysfs_alloc: |
771 | kfree(edev->dev); | ||
772 | return ret; | 766 | return ret; |
773 | } | 767 | } |
774 | EXPORT_SYMBOL_GPL(extcon_dev_register); | 768 | EXPORT_SYMBOL_GPL(extcon_dev_register); |
@@ -788,9 +782,9 @@ void extcon_dev_unregister(struct extcon_dev *edev) | |||
788 | list_del(&edev->entry); | 782 | list_del(&edev->entry); |
789 | mutex_unlock(&extcon_dev_list_lock); | 783 | mutex_unlock(&extcon_dev_list_lock); |
790 | 784 | ||
791 | if (IS_ERR_OR_NULL(get_device(edev->dev))) { | 785 | if (IS_ERR_OR_NULL(get_device(&edev->dev))) { |
792 | dev_err(edev->dev, "Failed to unregister extcon_dev (%s)\n", | 786 | dev_err(&edev->dev, "Failed to unregister extcon_dev (%s)\n", |
793 | dev_name(edev->dev)); | 787 | dev_name(&edev->dev)); |
794 | return; | 788 | return; |
795 | } | 789 | } |
796 | 790 | ||
@@ -812,10 +806,10 @@ void extcon_dev_unregister(struct extcon_dev *edev) | |||
812 | 806 | ||
813 | #if defined(CONFIG_ANDROID) | 807 | #if defined(CONFIG_ANDROID) |
814 | if (switch_class) | 808 | if (switch_class) |
815 | class_compat_remove_link(switch_class, edev->dev, NULL); | 809 | class_compat_remove_link(switch_class, &edev->dev, NULL); |
816 | #endif | 810 | #endif |
817 | device_unregister(edev->dev); | 811 | device_unregister(&edev->dev); |
818 | put_device(edev->dev); | 812 | put_device(&edev->dev); |
819 | } | 813 | } |
820 | EXPORT_SYMBOL_GPL(extcon_dev_unregister); | 814 | EXPORT_SYMBOL_GPL(extcon_dev_unregister); |
821 | 815 | ||