Commit 83c2768b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'char-misc-4.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc fixes from Greg KH:
 "Here are some extcon fixes for 4.2-rc6 that resolve some reported
  problems.

  All have been in linux-next for a while"

* tag 'char-misc-4.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  extcon: Fix extcon_cable_get_state() from getting old state after notification
  extcon: Fix hang and extcon_get/set_cable_state().
  extcon: palmas: Fix NULL pointer error
parents 981dae74 eaf7e98d
...@@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev) ...@@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev); status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev);
if (status) { if (status) {
dev_err(&pdev->dev, "failed to register extcon device\n"); dev_err(&pdev->dev, "failed to register extcon device\n");
kfree(palmas_usb->edev->name);
return status; return status;
} }
...@@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev) ...@@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) { if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->id_irq, status); palmas_usb->id_irq, status);
kfree(palmas_usb->edev->name);
return status; return status;
} }
} }
...@@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev) ...@@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) { if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, status); palmas_usb->vbus_irq, status);
kfree(palmas_usb->edev->name);
return status; return status;
} }
} }
...@@ -239,15 +236,6 @@ static int palmas_usb_probe(struct platform_device *pdev) ...@@ -239,15 +236,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
return 0; 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 #ifdef CONFIG_PM_SLEEP
static int palmas_usb_suspend(struct device *dev) static int palmas_usb_suspend(struct device *dev)
{ {
...@@ -288,7 +276,6 @@ static const struct of_device_id of_palmas_match_tbl[] = { ...@@ -288,7 +276,6 @@ static const struct of_device_id of_palmas_match_tbl[] = {
static struct platform_driver palmas_usb_driver = { static struct platform_driver palmas_usb_driver = {
.probe = palmas_usb_probe, .probe = palmas_usb_probe,
.remove = palmas_usb_remove,
.driver = { .driver = {
.name = "palmas-usb", .name = "palmas-usb",
.of_match_table = of_palmas_match_tbl, .of_match_table = of_palmas_match_tbl,
......
...@@ -124,25 +124,35 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id ...@@ -124,25 +124,35 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id
return -EINVAL; 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; int i = 0;
if (edev->max_supported == 0) /* Find the id of extcon cable */
return -EINVAL;
/* Find the the number of extcon cable */
while (extcon_name[i]) { while (extcon_name[i]) {
if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) { if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) {
id = i; id = i;
break; 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; 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); return find_cable_index_by_id(edev, id);
} }
...@@ -228,9 +238,11 @@ static ssize_t cable_state_show(struct device *dev, ...@@ -228,9 +238,11 @@ static ssize_t cable_state_show(struct device *dev,
struct extcon_cable *cable = container_of(attr, struct extcon_cable, struct extcon_cable *cable = container_of(attr, struct extcon_cable,
attr_state); attr_state);
int i = cable->cable_index;
return sprintf(buf, "%d\n", return sprintf(buf, "%d\n",
extcon_get_cable_state_(cable->edev, 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) ...@@ -263,20 +275,25 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
spin_lock_irqsave(&edev->lock, flags); spin_lock_irqsave(&edev->lock, flags);
if (edev->state != ((edev->state & ~mask) | (state & mask))) { if (edev->state != ((edev->state & ~mask) | (state & mask))) {
u32 old_state;
if (check_mutually_exclusive(edev, (edev->state & ~mask) | if (check_mutually_exclusive(edev, (edev->state & ~mask) |
(state & mask))) { (state & mask))) {
spin_unlock_irqrestore(&edev->lock, flags); spin_unlock_irqrestore(&edev->lock, flags);
return -EPERM; return -EPERM;
} }
for (index = 0; index < edev->max_supported; index++) { old_state = edev->state;
if (is_extcon_changed(edev->state, state, index, &attached))
raw_notifier_call_chain(&edev->nh[index], attached, edev);
}
edev->state &= ~mask; edev->state &= ~mask;
edev->state |= 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 */ /* This could be in interrupt handler */
prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
if (prop_buf) { if (prop_buf) {
...@@ -361,8 +378,13 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_); ...@@ -361,8 +378,13 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_);
*/ */
int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name)
{ {
return extcon_get_cable_state_(edev, find_cable_index_by_name unsigned int id;
(edev, cable_name));
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); EXPORT_SYMBOL_GPL(extcon_get_cable_state);
...@@ -404,8 +426,13 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_); ...@@ -404,8 +426,13 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_);
int extcon_set_cable_state(struct extcon_dev *edev, int extcon_set_cable_state(struct extcon_dev *edev,
const char *cable_name, bool cable_state) const char *cable_name, bool cable_state)
{ {
return extcon_set_cable_state_(edev, find_cable_index_by_name unsigned int id;
(edev, cable_name), cable_state);
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); EXPORT_SYMBOL_GPL(extcon_set_cable_state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment