diff options
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-adc-jack.c | 27 | ||||
-rw-r--r-- | drivers/extcon/extcon-arizona.c | 55 | ||||
-rw-r--r-- | drivers/extcon/extcon-class.c | 102 | ||||
-rw-r--r-- | drivers/extcon/extcon-gpio.c | 19 | ||||
-rw-r--r-- | drivers/extcon/extcon-max77693.c | 136 | ||||
-rw-r--r-- | drivers/extcon/extcon-max8997.c | 11 | ||||
-rw-r--r-- | drivers/extcon/extcon-palmas.c | 5 |
7 files changed, 194 insertions, 161 deletions
diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index 5985807e52c9..e23f1c2e5053 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -27,16 +27,16 @@ /** * struct adc_jack_data - internal data for adc_jack device driver - * @edev - extcon device. - * @cable_names - list of supported cables. - * @num_cables - size of cable_names. - * @adc_conditions - list of adc value conditions. - * @num_conditions - size of adc_conditions. - * @irq - irq number of attach/detach event (0 if not exist). - * @handling_delay - interrupt handler will schedule extcon event - * handling at handling_delay jiffies. - * @handler - extcon event handler called by interrupt handler. - * @chan - iio channel being queried. + * @edev: extcon device. + * @cable_names: list of supported cables. + * @num_cables: size of cable_names. + * @adc_conditions: list of adc value conditions. + * @num_conditions: size of adc_conditions. + * @irq: irq number of attach/detach event (0 if not exist). + * @handling_delay: interrupt handler will schedule extcon event + * handling at handling_delay jiffies. + * @handler: extcon event handler called by interrupt handler. + * @chan: iio channel being queried. */ struct adc_jack_data { struct extcon_dev edev; @@ -64,7 +64,7 @@ static void adc_jack_handler(struct work_struct *work) ret = iio_read_channel_raw(data->chan, &adc_val); if (ret < 0) { - dev_err(data->edev.dev, "read channel() error: %d\n", ret); + dev_err(&data->edev.dev, "read channel() error: %d\n", ret); return; } @@ -95,7 +95,7 @@ static irqreturn_t adc_jack_irq_thread(int irq, void *_data) static int adc_jack_probe(struct platform_device *pdev) { struct adc_jack_data *data; - struct adc_jack_pdata *pdata = pdev->dev.platform_data; + struct adc_jack_pdata *pdata = dev_get_platdata(&pdev->dev); int i, err = 0; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); @@ -110,6 +110,7 @@ static int adc_jack_probe(struct platform_device *pdev) goto out; } + data->edev.dev.parent = &pdev->dev; data->edev.supported_cable = pdata->cable_names; /* Check the length of array and set num_cables */ @@ -148,7 +149,7 @@ static int adc_jack_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); - err = extcon_dev_register(&data->edev, &pdev->dev); + err = extcon_dev_register(&data->edev); if (err) goto out; diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index e55713083c78..3c55ec856e39 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -86,8 +86,8 @@ struct arizona_extcon_info { }; static const struct arizona_micd_config micd_default_modes[] = { - { ARIZONA_ACCDET_SRC, 1 << ARIZONA_MICD_BIAS_SRC_SHIFT, 0 }, - { 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 }, + { ARIZONA_ACCDET_SRC, 1, 0 }, + { 0, 2, 1 }, }; static const struct arizona_micd_range micd_default_ranges[] = { @@ -182,7 +182,8 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) info->micd_modes[mode].gpio); regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1, ARIZONA_MICD_BIAS_SRC_MASK, - info->micd_modes[mode].bias); + info->micd_modes[mode].bias << + ARIZONA_MICD_BIAS_SRC_SHIFT); regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1, ARIZONA_ACCDET_SRC, info->micd_modes[mode].src); @@ -193,7 +194,7 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode) static const char *arizona_extcon_get_micbias(struct arizona_extcon_info *info) { - switch (info->micd_modes[0].bias >> ARIZONA_MICD_BIAS_SRC_SHIFT) { + switch (info->micd_modes[0].bias) { case 1: return "MICBIAS1"; case 2: @@ -388,7 +389,7 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info) >> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT; if (range < ARRAY_SIZE(arizona_hpdet_b_ranges) - 1 && - (val < 100 || val > 0x3fb)) { + (val < 100 || val >= 0x3fb)) { range++; dev_dbg(arizona->dev, "Moving to HPDET range %d\n", range); @@ -401,7 +402,7 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info) } /* If we go out of range report top of range */ - if (val < 100 || val > 0x3fb) { + if (val < 100 || val >= 0x3fb) { dev_dbg(arizona->dev, "Measurement out of range\n"); return ARIZONA_HPDET_MAX; } @@ -514,7 +515,7 @@ static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading, } /* - * If we measure the mic as + * If we measure the mic as high impedance */ if (!id_gpio || info->hpdet_res[1] > 50) { dev_dbg(arizona->dev, "Detected mic\n"); @@ -564,11 +565,10 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) } ret = arizona_hpdet_read(info); - if (ret == -EAGAIN) { + if (ret == -EAGAIN) goto out; - } else if (ret < 0) { + else if (ret < 0) goto done; - } reading = ret; /* Reset back to starting range */ @@ -578,11 +578,10 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data) 0); ret = arizona_hpdet_do_id(info, &reading, &mic); - if (ret == -EAGAIN) { + if (ret == -EAGAIN) goto out; - } else if (ret < 0) { + else if (ret < 0) goto done; - } /* Report high impedence cables as line outputs */ if (reading >= 5000) @@ -738,8 +737,8 @@ err: static void arizona_micd_timeout_work(struct work_struct *work) { struct arizona_extcon_info *info = container_of(work, - struct arizona_extcon_info, - micd_timeout_work.work); + struct arizona_extcon_info, + micd_timeout_work.work); mutex_lock(&info->lock); @@ -756,8 +755,8 @@ static void arizona_micd_timeout_work(struct work_struct *work) static void arizona_micd_detect(struct work_struct *work) { struct arizona_extcon_info *info = container_of(work, - struct arizona_extcon_info, - micd_detect_work.work); + struct arizona_extcon_info, + micd_detect_work.work); struct arizona *arizona = info->arizona; unsigned int val = 0, lvl; int ret, i, key; @@ -769,7 +768,8 @@ static void arizona_micd_detect(struct work_struct *work) for (i = 0; i < 10 && !(val & 0x7fc); i++) { ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); if (ret != 0) { - dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); + dev_err(arizona->dev, + "Failed to read MICDET: %d\n", ret); mutex_unlock(&info->lock); return; } @@ -777,7 +777,8 @@ static void arizona_micd_detect(struct work_struct *work) dev_dbg(arizona->dev, "MICDET: %x\n", val); if (!(val & ARIZONA_MICD_VALID)) { - dev_warn(arizona->dev, "Microphone detection state invalid\n"); + dev_warn(arizona->dev, + "Microphone detection state invalid\n"); mutex_unlock(&info->lock); return; } @@ -925,8 +926,8 @@ static irqreturn_t arizona_micdet(int irq, void *data) static void arizona_hpdet_work(struct work_struct *work) { struct arizona_extcon_info *info = container_of(work, - struct arizona_extcon_info, - hpdet_work.work); + struct arizona_extcon_info, + hpdet_work.work); mutex_lock(&info->lock); arizona_start_hpdet_acc_id(info); @@ -973,10 +974,13 @@ static irqreturn_t arizona_jackdet(int irq, void *data) &info->hpdet_work, msecs_to_jiffies(HPDET_DEBOUNCE)); - if (cancelled_mic) + if (cancelled_mic) { + int micd_timeout = info->micd_timeout; + queue_delayed_work(system_power_efficient_wq, &info->micd_timeout_work, - msecs_to_jiffies(info->micd_timeout)); + msecs_to_jiffies(micd_timeout)); + } goto out; } @@ -1039,6 +1043,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data) else info->micd_timeout = DEFAULT_MICD_TIMEOUT; +out: /* Clear trig_sts to make sure DCVDD is not forced up */ regmap_write(arizona->regmap, ARIZONA_AOD_WKUP_AND_TRIG, ARIZONA_MICD_CLAMP_FALL_TRIG_STS | @@ -1046,7 +1051,6 @@ static irqreturn_t arizona_jackdet(int irq, void *data) ARIZONA_JD1_FALL_TRIG_STS | ARIZONA_JD1_RISE_TRIG_STS); -out: mutex_unlock(&info->lock); pm_runtime_mark_last_busy(info->dev); @@ -1129,9 +1133,10 @@ static int arizona_extcon_probe(struct platform_device *pdev) } info->edev.name = "Headset Jack"; + info->edev.dev.parent = arizona->dev; info->edev.supported_cable = arizona_cable; - ret = extcon_dev_register(&info->edev, arizona->dev); + ret = extcon_dev_register(&info->edev); if (ret < 0) { dev_err(arizona->dev, "extcon_dev_register() failed: %d\n", ret); diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 148382faded9..15443d3b6be1 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -74,7 +74,7 @@ static DEFINE_MUTEX(extcon_dev_list_lock); /** * check_mutually_exclusive - Check if new_state violates mutually_exclusive - * condition. + * condition. * @edev: the extcon device * @new_state: new cable attach status for @edev * @@ -105,7 +105,7 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr, char *buf) { int i, count = 0; - struct extcon_dev *edev = (struct extcon_dev *) dev_get_drvdata(dev); + struct extcon_dev *edev = dev_get_drvdata(dev); if (edev->print_state) { int ret = edev->print_state(edev, buf); @@ -129,13 +129,12 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr, return count; } -int extcon_set_state(struct extcon_dev *edev, u32 state); static ssize_t state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { u32 state; ssize_t ret = 0; - struct extcon_dev *edev = (struct extcon_dev *) dev_get_drvdata(dev); + struct extcon_dev *edev = dev_get_drvdata(dev); ret = sscanf(buf, "0x%x", &state); if (ret == 0) @@ -153,7 +152,7 @@ static DEVICE_ATTR_RW(state); static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct extcon_dev *edev = (struct extcon_dev *) dev_get_drvdata(dev); + struct extcon_dev *edev = dev_get_drvdata(dev); /* Optional callback given by the user */ if (edev->print_name) { @@ -162,7 +161,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, return ret; } - return sprintf(buf, "%s\n", dev_name(edev->dev)); + return sprintf(buf, "%s\n", dev_name(&edev->dev)); } static DEVICE_ATTR_RO(name); @@ -189,7 +188,7 @@ static ssize_t cable_state_show(struct device *dev, /** * extcon_update_state() - Update the cable attach states of the extcon device - * only for the masked bits. + * only for the masked bits. * @edev: the extcon device * @mask: the bit mask to designate updated bits. * @state: new cable attach status for @edev @@ -227,11 +226,10 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) edev->state |= state & mask; raw_notifier_call_chain(&edev->nh, old_state, edev); - /* This could be in interrupt handler */ prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); if (prop_buf) { - length = name_show(edev->dev, NULL, prop_buf); + length = name_show(&edev->dev, NULL, prop_buf); if (length > 0) { if (prop_buf[length - 1] == '\n') prop_buf[length - 1] = 0; @@ -239,7 +237,7 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) "NAME=%s", prop_buf); envp[env_offset++] = name_buf; } - length = state_show(edev->dev, NULL, prop_buf); + length = state_show(&edev->dev, NULL, prop_buf); if (length > 0) { if (prop_buf[length - 1] == '\n') prop_buf[length - 1] = 0; @@ -251,14 +249,14 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) /* Unlock early before uevent */ spin_unlock_irqrestore(&edev->lock, flags); - kobject_uevent_env(&edev->dev->kobj, KOBJ_CHANGE, envp); + kobject_uevent_env(&edev->dev.kobj, KOBJ_CHANGE, envp); free_page((unsigned long)prop_buf); } else { /* Unlock early before uevent */ spin_unlock_irqrestore(&edev->lock, flags); - dev_err(edev->dev, "out of memory in extcon_set_state\n"); - kobject_uevent(&edev->dev->kobj, KOBJ_CHANGE); + dev_err(&edev->dev, "out of memory in extcon_set_state\n"); + kobject_uevent(&edev->dev.kobj, KOBJ_CHANGE); } } else { /* No changes */ @@ -339,8 +337,9 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state); /** * extcon_set_cable_state_() - Set the status of a specific cable. - * @edev: the extcon device that has the cable. - * @index: cable index that can be retrieved by extcon_find_cable_index(). + * @edev: the extcon device that has the cable. + * @index: cable index that can be retrieved by + * extcon_find_cable_index(). * @cable_state: the new cable status. The default semantics is * true: attached / false: detached. */ @@ -359,8 +358,8 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_); /** * extcon_set_cable_state() - Set the status of a specific cable. - * @edev: the extcon device that has the cable. - * @cable_name: cable name. + * @edev: the extcon device that has the cable. + * @cable_name: cable name. * @cable_state: the new cable status. The default semantics is * true: attached / false: detached. * @@ -419,14 +418,14 @@ static int _call_per_cable(struct notifier_block *nb, unsigned long val, /** * extcon_register_interest() - Register a notifier for a state change of a - * specific cable, not an entier set of cables of a - * extcon device. - * @obj: an empty extcon_specific_cable_nb object to be returned. + * specific cable, not an entier set of cables of a + * extcon device. + * @obj: an empty extcon_specific_cable_nb object to be returned. * @extcon_name: the name of extcon device. * if NULL, extcon_register_interest will register * every cable with the target cable_name given. * @cable_name: the target cable name. - * @nb: the notifier block to get notified. + * @nb: the notifier block to get notified. * * Provide an empty extcon_specific_cable_nb. extcon_register_interest() sets * the struct for you. @@ -452,7 +451,8 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj, if (!obj->edev) return -ENODEV; - obj->cable_index = extcon_find_cable_index(obj->edev, cable_name); + obj->cable_index = extcon_find_cable_index(obj->edev, + cable_name); if (obj->cable_index < 0) return obj->cable_index; @@ -460,7 +460,8 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj, obj->internal_nb.notifier_call = _call_per_cable; - return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb); + return raw_notifier_chain_register(&obj->edev->nh, + &obj->internal_nb); } else { struct class_dev_iter iter; struct extcon_dev *extd; @@ -470,7 +471,7 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj, return -ENODEV; class_dev_iter_init(&iter, extcon_class, NULL, NULL); while ((dev = class_dev_iter_next(&iter))) { - extd = (struct extcon_dev *)dev_get_drvdata(dev); + extd = dev_get_drvdata(dev); if (extcon_find_cable_index(extd, cable_name) < 0) continue; @@ -487,7 +488,7 @@ EXPORT_SYMBOL_GPL(extcon_register_interest); /** * extcon_unregister_interest() - Unregister the notifier registered by - * extcon_register_interest(). + * extcon_register_interest(). * @obj: the extcon_specific_cable_nb object returned by * extcon_register_interest(). */ @@ -502,7 +503,7 @@ EXPORT_SYMBOL_GPL(extcon_unregister_interest); /** * extcon_register_notifier() - Register a notifiee to get notified by - * any attach status changes from the extcon. + * any attach status changes from the extcon. * @edev: the extcon device. * @nb: a notifier block to be registered. * @@ -556,7 +557,6 @@ static int create_extcon_class(void) static void extcon_dev_release(struct device *dev) { - kfree(dev); } static const char *muex_name = "mutually_exclusive"; @@ -567,14 +567,13 @@ static void dummy_sysfs_dev_release(struct device *dev) /** * extcon_dev_register() - Register a new extcon device * @edev : the new extcon device (should be allocated before calling) - * @dev : the parent device for this extcon device. * * Among the members of edev struct, please set the "user initializing data" * in any case and set the "optional callbacks" if required. However, please * do not set the values of "internal data", which are initialized by * this function. */ -int extcon_dev_register(struct extcon_dev *edev, struct device *dev) +int extcon_dev_register(struct extcon_dev *edev) { int ret, index = 0; @@ -594,19 +593,20 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev) } if (index > SUPPORTED_CABLE_MAX) { - dev_err(edev->dev, "extcon: maximum number of supported cables exceeded.\n"); + dev_err(&edev->dev, "extcon: maximum number of supported cables exceeded.\n"); return -EINVAL; } - edev->dev = kzalloc(sizeof(struct device), GFP_KERNEL); - if (!edev->dev) - return -ENOMEM; - edev->dev->parent = dev; - edev->dev->class = extcon_class; - edev->dev->release = extcon_dev_release; + edev->dev.class = extcon_class; + edev->dev.release = extcon_dev_release; - edev->name = edev->name ? edev->name : dev_name(dev); - dev_set_name(edev->dev, "%s", edev->name); + edev->name = edev->name ? edev->name : dev_name(edev->dev.parent); + if (IS_ERR_OR_NULL(edev->name)) { + dev_err(&edev->dev, + "extcon device name is null\n"); + return -EINVAL; + } + dev_set_name(&edev->dev, "%s", edev->name); if (edev->max_supported) { char buf[10]; @@ -714,7 +714,7 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev) goto err_alloc_groups; } - edev->extcon_dev_type.name = dev_name(edev->dev); + edev->extcon_dev_type.name = dev_name(&edev->dev); edev->extcon_dev_type.release = dummy_sysfs_dev_release; for (index = 0; index < edev->max_supported; index++) @@ -724,25 +724,24 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev) edev->extcon_dev_type.groups[index] = &edev->attr_g_muex; - edev->dev->type = &edev->extcon_dev_type; + edev->dev.type = &edev->extcon_dev_type; } - ret = device_register(edev->dev); + ret = device_register(&edev->dev); if (ret) { - put_device(edev->dev); + put_device(&edev->dev); goto err_dev; } #if defined(CONFIG_ANDROID) if (switch_class) - ret = class_compat_create_link(switch_class, edev->dev, - NULL); + ret = class_compat_create_link(switch_class, &edev->dev, NULL); #endif /* CONFIG_ANDROID */ spin_lock_init(&edev->lock); RAW_INIT_NOTIFIER_HEAD(&edev->nh); - dev_set_drvdata(edev->dev, edev); + dev_set_drvdata(&edev->dev, edev); edev->state = 0; mutex_lock(&extcon_dev_list_lock); @@ -768,7 +767,6 @@ err_alloc_cables: if (edev->max_supported) kfree(edev->cables); err_sysfs_alloc: - kfree(edev->dev); return ret; } EXPORT_SYMBOL_GPL(extcon_dev_register); @@ -788,9 +786,9 @@ void extcon_dev_unregister(struct extcon_dev *edev) list_del(&edev->entry); mutex_unlock(&extcon_dev_list_lock); - if (IS_ERR_OR_NULL(get_device(edev->dev))) { - dev_err(edev->dev, "Failed to unregister extcon_dev (%s)\n", - dev_name(edev->dev)); + if (IS_ERR_OR_NULL(get_device(&edev->dev))) { + dev_err(&edev->dev, "Failed to unregister extcon_dev (%s)\n", + dev_name(&edev->dev)); return; } @@ -812,10 +810,10 @@ void extcon_dev_unregister(struct extcon_dev *edev) #if defined(CONFIG_ANDROID) if (switch_class) - class_compat_remove_link(switch_class, edev->dev, NULL); + class_compat_remove_link(switch_class, &edev->dev, NULL); #endif - device_unregister(edev->dev); - put_device(edev->dev); + device_unregister(&edev->dev); + put_device(&edev->dev); } EXPORT_SYMBOL_GPL(extcon_dev_unregister); diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index f874c30ddbff..7e0dff58e494 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -34,6 +34,7 @@ struct gpio_extcon_data { struct extcon_dev edev; unsigned gpio; + bool gpio_active_low; const char *state_on; const char *state_off; int irq; @@ -49,6 +50,8 @@ static void gpio_extcon_work(struct work_struct *work) work); state = gpio_get_value(data->gpio); + if (data->gpio_active_low) + state = !state; extcon_set_state(&data->edev, state); } @@ -78,9 +81,9 @@ static ssize_t extcon_gpio_print_state(struct extcon_dev *edev, char *buf) static int gpio_extcon_probe(struct platform_device *pdev) { - struct gpio_extcon_platform_data *pdata = pdev->dev.platform_data; + struct gpio_extcon_platform_data *pdata = dev_get_platdata(&pdev->dev); struct gpio_extcon_data *extcon_data; - int ret = 0; + int ret; if (!pdata) return -EBUSY; @@ -95,14 +98,22 @@ static int gpio_extcon_probe(struct platform_device *pdev) return -ENOMEM; extcon_data->edev.name = pdata->name; + extcon_data->edev.dev.parent = &pdev->dev; extcon_data->gpio = pdata->gpio; + extcon_data->gpio_active_low = pdata->gpio_active_low; extcon_data->state_on = pdata->state_on; extcon_data->state_off = pdata->state_off; if (pdata->state_on && pdata->state_off) extcon_data->edev.print_state = extcon_gpio_print_state; - extcon_data->debounce_jiffies = msecs_to_jiffies(pdata->debounce); + if (pdata->debounce) { + ret = gpio_set_debounce(extcon_data->gpio, + pdata->debounce * 1000); + if (ret < 0) + extcon_data->debounce_jiffies = + msecs_to_jiffies(pdata->debounce); + } - ret = extcon_dev_register(&extcon_data->edev, &pdev->dev); + ret = extcon_dev_register(&extcon_data->edev); if (ret < 0) return ret; diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index b56bdaa27d4b..da268fbc901b 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -189,14 +189,17 @@ enum max77693_muic_acc_type { /* The below accessories have same ADC value so ADCLow and ADC1K bit is used to separate specific accessory */ - MAX77693_MUIC_GND_USB_OTG = 0x100, /* ADC:0x0, VBVolot:0, ADCLow:0, ADC1K:0 */ - MAX77693_MUIC_GND_USB_OTG_VB = 0x104, /* ADC:0x0, VBVolot:1, ADCLow:0, ADC1K:0 */ - MAX77693_MUIC_GND_AV_CABLE_LOAD = 0x102,/* ADC:0x0, VBVolot:0, ADCLow:1, ADC1K:0 */ - MAX77693_MUIC_GND_MHL = 0x103, /* ADC:0x0, VBVolot:0, ADCLow:1, ADC1K:1 */ - MAX77693_MUIC_GND_MHL_VB = 0x107, /* ADC:0x0, VBVolot:1, ADCLow:1, ADC1K:1 */ + /* ADC|VBVolot|ADCLow|ADC1K| */ + MAX77693_MUIC_GND_USB_OTG = 0x100, /* 0x0| 0| 0| 0| */ + MAX77693_MUIC_GND_USB_OTG_VB = 0x104, /* 0x0| 1| 0| 0| */ + MAX77693_MUIC_GND_AV_CABLE_LOAD = 0x102,/* 0x0| 0| 1| 0| */ + MAX77693_MUIC_GND_MHL = 0x103, /* 0x0| 0| 1| 1| */ + MAX77693_MUIC_GND_MHL_VB = 0x107, /* 0x0| 1| 1| 1| */ }; -/* MAX77693 MUIC device support below list of accessories(external connector) */ +/* + * MAX77693 MUIC device support below list of accessories(external connector) + */ enum { EXTCON_CABLE_USB = 0, EXTCON_CABLE_USB_HOST, @@ -395,12 +398,12 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info, vbvolt >>= STATUS2_VBVOLT_SHIFT; /** - * [0x1][VBVolt][ADCLow][ADC1K] - * [0x1 0 0 0 ] : USB_OTG - * [0x1 1 0 0 ] : USB_OTG_VB - * [0x1 0 1 0 ] : Audio Video Cable with load - * [0x1 0 1 1 ] : MHL without charging connector - * [0x1 1 1 1 ] : MHL with charging connector + * [0x1|VBVolt|ADCLow|ADC1K] + * [0x1| 0| 0| 0] USB_OTG + * [0x1| 1| 0| 0] USB_OTG_VB + * [0x1| 0| 1| 0] Audio Video cable with load + * [0x1| 0| 1| 1] MHL without charging cable + * [0x1| 1| 1| 1] MHL with charging cable */ cable_type = ((0x1 << 8) | (vbvolt << 2) @@ -723,11 +726,11 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info) if (ret < 0) return ret; break; - case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON: /* DOCK_KEY_PREV */ - case MAX77693_MUIC_ADC_REMOTE_S7_BUTTON: /* DOCK_KEY_NEXT */ - case MAX77693_MUIC_ADC_REMOTE_S9_BUTTON: /* DOCK_VOL_DOWN */ - case MAX77693_MUIC_ADC_REMOTE_S10_BUTTON: /* DOCK_VOL_UP */ - case MAX77693_MUIC_ADC_REMOTE_S12_BUTTON: /* DOCK_KEY_PLAY_PAUSE */ + case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON: /* DOCK_KEY_PREV */ + case MAX77693_MUIC_ADC_REMOTE_S7_BUTTON: /* DOCK_KEY_NEXT */ + case MAX77693_MUIC_ADC_REMOTE_S9_BUTTON: /* DOCK_VOL_DOWN */ + case MAX77693_MUIC_ADC_REMOTE_S10_BUTTON: /* DOCK_VOL_UP */ + case MAX77693_MUIC_ADC_REMOTE_S12_BUTTON: /* DOCK_KEY_PLAY_PAUSE */ /* * Button of DOCK device * - the Prev/Next/Volume Up/Volume Down/Play-Pause button @@ -815,19 +818,21 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) case MAX77693_MUIC_GND_MHL_VB: /* * MHL cable with MHL_TA(USB/TA) cable - * - MHL cable include two port(HDMI line and separate micro- - * usb port. When the target connect MHL cable, extcon driver - * check whether MHL_TA(USB/TA) cable is connected. If MHL_TA - * cable is connected, extcon driver notify state to notifiee - * for charging battery. + * - MHL cable include two port(HDMI line and separate + * micro-usb port. When the target connect MHL cable, + * extcon driver check whether MHL_TA(USB/TA) cable is + * connected. If MHL_TA cable is connected, extcon + * driver notify state to notifiee for charging battery. * * Features of 'MHL_TA(USB/TA) with MHL cable' * - Support MHL - * - Support charging through micro-usb port without data connection + * - Support charging through micro-usb port without + * data connection */ extcon_set_cable_state(info->edev, "MHL_TA", attached); if (!cable_attached) - extcon_set_cable_state(info->edev, "MHL", cable_attached); + extcon_set_cable_state(info->edev, + "MHL", cable_attached); break; } @@ -839,47 +844,51 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */ /* * Dock-Audio device with USB/TA cable - * - Dock device include two port(Dock-Audio and micro-usb - * port). When the target connect Dock-Audio device, extcon - * driver check whether USB/TA cable is connected. If USB/TA - * cable is connected, extcon driver notify state to notifiee - * for charging battery. + * - Dock device include two port(Dock-Audio and micro- + * usb port). When the target connect Dock-Audio device, + * extcon driver check whether USB/TA cable is connected + * or not. If USB/TA cable is connected, extcon driver + * notify state to notifiee for charging battery. * * Features of 'USB/TA cable with Dock-Audio device' * - Support external output feature of audio. - * - Support charging through micro-usb port without data - * connection. + * - Support charging through micro-usb port without + * data connection. */ extcon_set_cable_state(info->edev, "USB", attached); if (!cable_attached) - extcon_set_cable_state(info->edev, "Dock-Audio", cable_attached); + extcon_set_cable_state(info->edev, "Dock-Audio", + cable_attached); break; case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */ /* * Dock-Smart device with USB/TA cable * - Dock-Desk device include three type of cable which * are HDMI, USB for mouse/keyboard and micro-usb port - * for USB/TA cable. Dock-Smart device need always exteranl - * power supply(USB/TA cable through micro-usb cable). Dock- - * Smart device support screen output of target to separate - * monitor and mouse/keyboard for desktop mode. + * for USB/TA cable. Dock-Smart device need always + * exteranl power supply(USB/TA cable through micro-usb + * cable). Dock-Smart device support screen output of + * target to separate monitor and mouse/keyboard for + * desktop mode. * * Features of 'USB/TA cable with Dock-Smart device' * - Support MHL * - Support external output feature of audio - * - Support charging through micro-usb port without data - * connection if TA cable is connected to target. - * - Support charging and data connection through micro-usb port - * if USB cable is connected between target and host - * device. + * - Support charging through micro-usb port without + * data connection if TA cable is connected to target. + * - Support charging and data connection through micro- + * usb port if USB cable is connected between target + * and host device * - Support OTG device (Mouse/Keyboard) */ - ret = max77693_muic_set_path(info, info->path_usb, attached); + ret = max77693_muic_set_path(info, info->path_usb, + attached); if (ret < 0) return ret; - extcon_set_cable_state(info->edev, "Dock-Smart", attached); + extcon_set_cable_state(info->edev, "Dock-Smart", + attached); extcon_set_cable_state(info->edev, "MHL", attached); break; @@ -889,25 +898,28 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) switch (chg_type) { case MAX77693_CHARGER_TYPE_NONE: /* - * When MHL(with USB/TA cable) or Dock-Audio with USB/TA cable - * is attached, muic device happen below two interrupt. - * - 'MAX77693_MUIC_IRQ_INT1_ADC' for detecting MHL/Dock-Audio. - * - 'MAX77693_MUIC_IRQ_INT2_CHGTYP' for detecting USB/TA cable - * connected to MHL or Dock-Audio. - * Always, happen eariler MAX77693_MUIC_IRQ_INT1_ADC interrupt - * than MAX77693_MUIC_IRQ_INT2_CHGTYP interrupt. + * When MHL(with USB/TA cable) or Dock-Audio with USB/TA + * cable is attached, muic device happen below two irq. + * - 'MAX77693_MUIC_IRQ_INT1_ADC' for detecting + * MHL/Dock-Audio. + * - 'MAX77693_MUIC_IRQ_INT2_CHGTYP' for detecting + * USB/TA cable connected to MHL or Dock-Audio. + * Always, happen eariler MAX77693_MUIC_IRQ_INT1_ADC + * irq than MAX77693_MUIC_IRQ_INT2_CHGTYP irq. * - * If user attach MHL (with USB/TA cable and immediately detach - * MHL with USB/TA cable before MAX77693_MUIC_IRQ_INT2_CHGTYP - * interrupt is happened, USB/TA cable remain connected state to - * target. But USB/TA cable isn't connected to target. The user - * be face with unusual action. So, driver should check this - * situation in spite of, that previous charger type is N/A. + * If user attach MHL (with USB/TA cable and immediately + * detach MHL with USB/TA cable before MAX77693_MUIC_IRQ + * _INT2_CHGTYP irq is happened, USB/TA cable remain + * connected state to target. But USB/TA cable isn't + * connected to target. The user be face with unusual + * action. So, driver should check this situation in + * spite of, that previous charger type is N/A. */ break; case MAX77693_CHARGER_TYPE_USB: /* Only USB cable, PATH:AP_USB */ - ret = max77693_muic_set_path(info, info->path_usb, attached); + ret = max77693_muic_set_path(info, info->path_usb, + attached); if (ret < 0) return ret; @@ -953,7 +965,7 @@ static void max77693_muic_irq_work(struct work_struct *work) mutex_lock(&info->mutex); - for (i = 0 ; i < ARRAY_SIZE(muic_irqs) ; i++) + for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) if (info->irq == muic_irqs[i].virq) irq_type = muic_irqs[i].irq; @@ -1171,8 +1183,9 @@ static int max77693_muic_probe(struct platform_device *pdev) goto err_irq; } info->edev->name = DEV_NAME; + info->edev->dev.parent = &pdev->dev; info->edev->supported_cable = max77693_extcon_cable; - ret = extcon_dev_register(info->edev, NULL); + ret = extcon_dev_register(info->edev); if (ret) { dev_err(&pdev->dev, "failed to register extcon device\n"); goto err_irq; @@ -1188,7 +1201,7 @@ static int max77693_muic_probe(struct platform_device *pdev) num_init_data = ARRAY_SIZE(default_init_data); } - for (i = 0 ; i < num_init_data ; i++) { + for (i = 0; i < num_init_data; i++) { enum max77693_irq_source irq_src = MAX77693_IRQ_GROUP_NR; @@ -1214,7 +1227,8 @@ static int max77693_muic_probe(struct platform_device *pdev) } if (pdata->muic_data) { - struct max77693_muic_platform_data *muic_pdata = pdata->muic_data; + struct max77693_muic_platform_data *muic_pdata + = pdata->muic_data; /* * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index 67d6738d85a0..6a00464658c5 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -426,7 +426,8 @@ static int max8997_muic_adc_handler(struct max8997_muic_info *info) break; case MAX8997_MUIC_ADC_FACTORY_MODE_USB_OFF: case MAX8997_MUIC_ADC_FACTORY_MODE_USB_ON: - ret = max8997_muic_handle_usb(info, MAX8997_USB_DEVICE, attached); + ret = max8997_muic_handle_usb(info, + MAX8997_USB_DEVICE, attached); if (ret < 0) return ret; break; @@ -504,7 +505,8 @@ static int max8997_muic_chg_handler(struct max8997_muic_info *info) } break; case MAX8997_CHARGER_TYPE_DOWNSTREAM_PORT: - extcon_set_cable_state(info->edev, "Charge-downstream", attached); + extcon_set_cable_state(info->edev, + "Charge-downstream", attached); break; case MAX8997_CHARGER_TYPE_DEDICATED_CHG: extcon_set_cable_state(info->edev, "TA", attached); @@ -537,7 +539,7 @@ static void max8997_muic_irq_work(struct work_struct *work) mutex_lock(&info->mutex); - for (i = 0 ; i < ARRAY_SIZE(muic_irqs) ; i++) + for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) if (info->irq == muic_irqs[i].virq) irq_type = muic_irqs[i].irq; @@ -705,8 +707,9 @@ static int max8997_muic_probe(struct platform_device *pdev) goto err_irq; } info->edev->name = DEV_NAME; + info->edev->dev.parent = &pdev->dev; info->edev->supported_cable = max8997_extcon_cable; - ret = extcon_dev_register(info->edev, NULL); + ret = extcon_dev_register(info->edev); if (ret) { dev_err(&pdev->dev, "failed to register extcon device\n"); goto err_irq; diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index 89fdd05c5fd6..6c91976dd823 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -135,7 +135,7 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb) static int palmas_usb_probe(struct platform_device *pdev) { struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); - struct palmas_usb_platform_data *pdata = pdev->dev.platform_data; + struct palmas_usb_platform_data *pdata = dev_get_platdata(&pdev->dev); struct device_node *node = pdev->dev.of_node; struct palmas_usb *palmas_usb; int status; @@ -178,9 +178,10 @@ static int palmas_usb_probe(struct platform_device *pdev) platform_set_drvdata(pdev, palmas_usb); palmas_usb->edev.supported_cable = palmas_extcon_cable; + palmas_usb->edev.dev.parent = palmas_usb->dev; palmas_usb->edev.mutually_exclusive = mutually_exclusive; - status = extcon_dev_register(&palmas_usb->edev, palmas_usb->dev); + status = extcon_dev_register(&palmas_usb->edev); if (status) { dev_err(&pdev->dev, "failed to register extcon device\n"); return status; |