Update extcon for v4.2-rc5

This patchset fix the following two issue:
 - Fix hang issue when using the extcon_[get|set]_cable_state() because these
 functions use the cable index instead of cable id.
 - Fix NULL pointer error of extcon-palmas.c by removing unneeded kfree() call.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJVux8XAAoJEJzN3yze689TZhoQAMIvvfIAEGpRA+4BEpx4YGYJ
 859FZvrSEMf9IL4ZkNmrLvH0EgaA4bCJcAajDPtvdGxJT+IMmHx8sEUNTO2Q1n2F
 fCsTP3goptipBTwy1mwIcKPR2NqLkO570qU+SiKmHidxeqRreLYvpwDM/Lu7tIZs
 GMqOU/laDWQUe3nzVr57jzo6m70MtEMNnMvPfMYYavz4aEoKOCa8VUfmOa1vgEfh
 3SVDeSMBefdYDpJYFPg2MkdsJrSOGlCQHEwJC3vj/d9AfErnhdbOBwl2nTATS1K3
 R0bUJlG8YNFkKRJZmy2nMAdV3ZTvee9/GNZ1BhOsJ9DiBifquSyHDms9JLQpMvqZ
 n+fvKzN2L/HAM1i0F62bGDb1sv6NteowM4yLvP3Mc6iCwBqkCcS8EnVx+OVgqksj
 sUtM51B771tqNwRSPU/XhLRqqSY/Do1oQE0mVLv1goF2k7XMv2AHfoSjEO9Qlg9M
 czMa2WoIyAMKdUwdhHfKRV71VTTidpKRKbYHV3SNYO337xXEv+yu0D9UbS57p7D5
 OEFnY5YuhmUNltJAiZzvR1c2LxBrawDvcc0Z/kaxVXh3qFaZuLljS/mmUZ2nRES2
 6piOWTabPKqAQgLLmAYNFi3bBVz+/A0FJWcaXezE4SjU1VMeBZqAz++vlgWmL70c
 barwnhgnNtrCyIuXmGRx
 =Iz+P
 -----END PGP SIGNATURE-----

Merge tag 'extcon-fixes-for-4.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-linus

Chanwoo writes:

Update extcon for v4.2-rc5

This patchset fix the following two issue:
- Fix hang issue when using the extcon_[get|set]_cable_state() because these
functions use the cable index instead of cable id.
- Fix NULL pointer error of extcon-palmas.c by removing unneeded kfree() call.
This commit is contained in:
Greg Kroah-Hartman 2015-07-31 17:20:52 -07:00
commit eaf7e98d43
2 changed files with 44 additions and 30 deletions

View File

@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev);
if (status) {
dev_err(&pdev->dev, "failed to register extcon device\n");
kfree(palmas_usb->edev->name);
return status;
}
@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->id_irq, status);
kfree(palmas_usb->edev->name);
return status;
}
}
@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, status);
kfree(palmas_usb->edev->name);
return status;
}
}
@ -239,15 +236,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
return 0;
}
static int palmas_usb_remove(struct platform_device *pdev)
{
struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
kfree(palmas_usb->edev->name);
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int palmas_usb_suspend(struct device *dev)
{
@ -288,7 +276,6 @@ static const struct of_device_id of_palmas_match_tbl[] = {
static struct platform_driver palmas_usb_driver = {
.probe = palmas_usb_probe,
.remove = palmas_usb_remove,
.driver = {
.name = "palmas-usb",
.of_match_table = of_palmas_match_tbl,

View File

@ -124,25 +124,35 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id
return -EINVAL;
}
static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
static int find_cable_id_by_name(struct extcon_dev *edev, const char *name)
{
unsigned int id = EXTCON_NONE;
unsigned int id = -EINVAL;
int i = 0;
if (edev->max_supported == 0)
return -EINVAL;
/* Find the the number of extcon cable */
/* Find the id of extcon cable */
while (extcon_name[i]) {
if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) {
id = i;
break;
}
i++;
}
if (id == EXTCON_NONE)
return id;
}
static int find_cable_index_by_name(struct extcon_dev *edev, const char *name)
{
unsigned int id;
if (edev->max_supported == 0)
return -EINVAL;
/* Find the the number of extcon cable */
id = find_cable_id_by_name(edev, name);
if (id < 0)
return id;
return find_cable_index_by_id(edev, id);
}
@ -228,9 +238,11 @@ static ssize_t cable_state_show(struct device *dev,
struct extcon_cable *cable = container_of(attr, struct extcon_cable,
attr_state);
int i = cable->cable_index;
return sprintf(buf, "%d\n",
extcon_get_cable_state_(cable->edev,
cable->cable_index));
cable->edev->supported_cable[i]));
}
/**
@ -263,20 +275,25 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
spin_lock_irqsave(&edev->lock, flags);
if (edev->state != ((edev->state & ~mask) | (state & mask))) {
u32 old_state;
if (check_mutually_exclusive(edev, (edev->state & ~mask) |
(state & mask))) {
spin_unlock_irqrestore(&edev->lock, flags);
return -EPERM;
}
for (index = 0; index < edev->max_supported; index++) {
if (is_extcon_changed(edev->state, state, index, &attached))
raw_notifier_call_chain(&edev->nh[index], attached, edev);
}
old_state = edev->state;
edev->state &= ~mask;
edev->state |= state & mask;
for (index = 0; index < edev->max_supported; index++) {
if (is_extcon_changed(old_state, edev->state, index,
&attached))
raw_notifier_call_chain(&edev->nh[index],
attached, edev);
}
/* This could be in interrupt handler */
prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
if (prop_buf) {
@ -361,8 +378,13 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_);
*/
int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name)
{
return extcon_get_cable_state_(edev, find_cable_index_by_name
(edev, cable_name));
unsigned int id;
id = find_cable_id_by_name(edev, cable_name);
if (id < 0)
return id;
return extcon_get_cable_state_(edev, id);
}
EXPORT_SYMBOL_GPL(extcon_get_cable_state);
@ -404,8 +426,13 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_);
int extcon_set_cable_state(struct extcon_dev *edev,
const char *cable_name, bool cable_state)
{
return extcon_set_cable_state_(edev, find_cable_index_by_name
(edev, cable_name), cable_state);
unsigned int id;
id = find_cable_id_by_name(edev, cable_name);
if (id < 0)
return id;
return extcon_set_cable_state_(edev, id, cable_state);
}
EXPORT_SYMBOL_GPL(extcon_set_cable_state);