Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+44 -30
-13
drivers/extcon/extcon-palmas.c
··· 200 200 status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev); 201 201 if (status) { 202 202 dev_err(&pdev->dev, "failed to register extcon device\n"); 203 - kfree(palmas_usb->edev->name); 204 203 return status; 205 204 } 206 205 ··· 213 214 if (status < 0) { 214 215 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", 215 216 palmas_usb->id_irq, status); 216 - kfree(palmas_usb->edev->name); 217 217 return status; 218 218 } 219 219 } ··· 227 229 if (status < 0) { 228 230 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", 229 231 palmas_usb->vbus_irq, status); 230 - kfree(palmas_usb->edev->name); 231 232 return status; 232 233 } 233 234 } 234 235 235 236 palmas_enable_irq(palmas_usb); 236 237 device_set_wakeup_capable(&pdev->dev, true); 237 - return 0; 238 - } 239 - 240 - static int palmas_usb_remove(struct platform_device *pdev) 241 - { 242 - struct palmas_usb *palmas_usb = platform_get_drvdata(pdev); 243 - 244 - kfree(palmas_usb->edev->name); 245 - 246 238 return 0; 247 239 } 248 240 ··· 276 288 277 289 static struct platform_driver palmas_usb_driver = { 278 290 .probe = palmas_usb_probe, 279 - .remove = palmas_usb_remove, 280 291 .driver = { 281 292 .name = "palmas-usb", 282 293 .of_match_table = of_palmas_match_tbl,
+44 -17
drivers/extcon/extcon.c
··· 124 124 return -EINVAL; 125 125 } 126 126 127 - static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) 127 + static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) 128 128 { 129 - unsigned int id = EXTCON_NONE; 129 + unsigned int id = -EINVAL; 130 130 int i = 0; 131 131 132 - if (edev->max_supported == 0) 133 - return -EINVAL; 134 - 135 - /* Find the the number of extcon cable */ 132 + /* Find the id of extcon cable */ 136 133 while (extcon_name[i]) { 137 134 if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) { 138 135 id = i; 139 136 break; 140 137 } 138 + i++; 141 139 } 142 140 143 - if (id == EXTCON_NONE) 141 + return id; 142 + } 143 + 144 + static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) 145 + { 146 + unsigned int id; 147 + 148 + if (edev->max_supported == 0) 144 149 return -EINVAL; 150 + 151 + /* Find the the number of extcon cable */ 152 + id = find_cable_id_by_name(edev, name); 153 + if (id < 0) 154 + return id; 145 155 146 156 return find_cable_index_by_id(edev, id); 147 157 } ··· 238 228 struct extcon_cable *cable = container_of(attr, struct extcon_cable, 239 229 attr_state); 240 230 231 + int i = cable->cable_index; 232 + 241 233 return sprintf(buf, "%d\n", 242 234 extcon_get_cable_state_(cable->edev, 243 - cable->cable_index)); 235 + cable->edev->supported_cable[i])); 244 236 } 245 237 246 238 /** ··· 275 263 spin_lock_irqsave(&edev->lock, flags); 276 264 277 265 if (edev->state != ((edev->state & ~mask) | (state & mask))) { 266 + u32 old_state; 267 + 278 268 if (check_mutually_exclusive(edev, (edev->state & ~mask) | 279 269 (state & mask))) { 280 270 spin_unlock_irqrestore(&edev->lock, flags); 281 271 return -EPERM; 282 272 } 283 273 284 - for (index = 0; index < edev->max_supported; index++) { 285 - if (is_extcon_changed(edev->state, state, index, &attached)) 286 - raw_notifier_call_chain(&edev->nh[index], attached, edev); 287 - } 288 - 274 + old_state = edev->state; 289 275 edev->state &= ~mask; 290 276 edev->state |= state & mask; 277 + 278 + for (index = 0; index < edev->max_supported; index++) { 279 + if (is_extcon_changed(old_state, edev->state, index, 280 + &attached)) 281 + raw_notifier_call_chain(&edev->nh[index], 282 + attached, edev); 283 + } 291 284 292 285 /* This could be in interrupt handler */ 293 286 prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); ··· 378 361 */ 379 362 int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) 380 363 { 381 - return extcon_get_cable_state_(edev, find_cable_index_by_name 382 - (edev, cable_name)); 364 + unsigned int id; 365 + 366 + id = find_cable_id_by_name(edev, cable_name); 367 + if (id < 0) 368 + return id; 369 + 370 + return extcon_get_cable_state_(edev, id); 383 371 } 384 372 EXPORT_SYMBOL_GPL(extcon_get_cable_state); 385 373 ··· 426 404 int extcon_set_cable_state(struct extcon_dev *edev, 427 405 const char *cable_name, bool cable_state) 428 406 { 429 - return extcon_set_cable_state_(edev, find_cable_index_by_name 430 - (edev, cable_name), cable_state); 407 + unsigned int id; 408 + 409 + id = find_cable_id_by_name(edev, cable_name); 410 + if (id < 0) 411 + return id; 412 + 413 + return extcon_set_cable_state_(edev, id, cable_state); 431 414 } 432 415 EXPORT_SYMBOL_GPL(extcon_set_cable_state); 433 416