Skip to content

Commit

Permalink
Merge tag 'extcon-next-for-3.16' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/kernel/git/chanwoo/extcon into char-misc-next

Chanwoo writes:

Update extcon for v3.16

This patchset add resource-managed functions to automatically control the memory
and unregistration operation of extcon. Also, This series support new MAX77836
extcon device driver on existing MAX14577 device because existed a little
difference between MAX77836 and MAX14577. Finally, Fix minor issue of extcon
driver.

Detailed description for patchset:
1. Add resource-managed functions
- Add resource-managed functions to automatically free the memory of extcon
structure and to control unregistration behavior as following. This new devm_*
functions applied all of extcon drivers in drivers/extcon/.
: devm_extcon_dev_register/unregister()
: devm_extcon_dev_allocate/free()
: extcon_dev_allocate/free() for devm_extcon_dev_allocate/free()

2. Add new MAX77836 extcon device
- Support MAX77836 device on existing MAX14577 device driver using
different compatible string. This patchset has dependency on MFD/
Regulator/Extcon. So, Lee Jones(MFD Maintainer) created Immutable
branch between MFD and Extcon due for v3.16 merge-window and then
I merged this patchset from MFD git repo[1] to Extcon git repo.
: [1] git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
  (branch: ib-mfd-extcon-3.16)

3. Fix minor issue of extcon driver
- extcon-palmas driver
: Fix issue of extcon device name for probe
- extcon-max14577
: Fix probe failure about handling wrong return value.
: Properly Handle return value of regmap_irq_get_virq function.
- extcon-max8997/max77693 driver
: Fix NULL pointer exception on missing pdata

4. Code clean for extcon driver
- extcon-max8997/max77693
: Use power efficient workqueue for delayed cable detection
  • Loading branch information
Greg Kroah-Hartman committed May 20, 2014
2 parents 4f06381 + 3f79a3f commit 6a57bad
Show file tree
Hide file tree
Showing 17 changed files with 1,131 additions and 314 deletions.
4 changes: 2 additions & 2 deletions drivers/extcon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ config EXTCON_ADC_JACK
Say Y here to enable extcon device driver based on ADC values.

config EXTCON_MAX14577
tristate "MAX14577 EXTCON Support"
tristate "MAX14577/77836 EXTCON Support"
depends on MFD_MAX14577
select IRQ_DOMAIN
select REGMAP_I2C
help
If you say yes here you get support for the MUIC device of
Maxim MAX14577 PMIC. The MAX14577 MUIC is a USB port accessory
Maxim MAX14577/77836. The MAX14577/77836 MUIC is a USB port accessory
detector and switch.

config EXTCON_MAX77693
Expand Down
49 changes: 20 additions & 29 deletions drivers/extcon/extcon-adc-jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* @chan: iio channel being queried.
*/
struct adc_jack_data {
struct extcon_dev edev;
struct extcon_dev *edev;

const char **cable_names;
int num_cables;
Expand All @@ -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;
}

Expand All @@ -80,7 +80,7 @@ static void adc_jack_handler(struct work_struct *work)
}
/* if no def has met, it means state = 0 (no cables attached) */

extcon_set_state(&data->edev, state);
extcon_set_state(data->edev, state);
}

static irqreturn_t adc_jack_irq_thread(int irq, void *_data)
Expand All @@ -102,33 +102,33 @@ static int adc_jack_probe(struct platform_device *pdev)
if (!data)
return -ENOMEM;

data->edev.name = pdata->name;

if (!pdata->cable_names) {
err = -EINVAL;
dev_err(&pdev->dev, "error: cable_names not defined.\n");
goto out;
return -EINVAL;
}

data->edev.dev.parent = &pdev->dev;
data->edev.supported_cable = pdata->cable_names;
data->edev = devm_extcon_dev_allocate(&pdev->dev, pdata->cable_names);
if (IS_ERR(data->edev)) {
dev_err(&pdev->dev, "failed to allocate extcon device\n");
return -ENOMEM;
}
data->edev->dev.parent = &pdev->dev;
data->edev->name = pdata->name;

/* Check the length of array and set num_cables */
for (i = 0; data->edev.supported_cable[i]; i++)
for (i = 0; data->edev->supported_cable[i]; i++)
;
if (i == 0 || i > SUPPORTED_CABLE_MAX) {
err = -EINVAL;
dev_err(&pdev->dev, "error: pdata->cable_names size = %d\n",
i - 1);
goto out;
return -EINVAL;
}
data->num_cables = i;

if (!pdata->adc_conditions ||
!pdata->adc_conditions[0].state) {
err = -EINVAL;
dev_err(&pdev->dev, "error: adc_conditions not defined.\n");
goto out;
return -EINVAL;
}
data->adc_conditions = pdata->adc_conditions;

Expand All @@ -138,42 +138,34 @@ static int adc_jack_probe(struct platform_device *pdev)
data->num_conditions = i;

data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
if (IS_ERR(data->chan)) {
err = PTR_ERR(data->chan);
goto out;
}
if (IS_ERR(data->chan))
return PTR_ERR(data->chan);

data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);

INIT_DEFERRABLE_WORK(&data->handler, adc_jack_handler);

platform_set_drvdata(pdev, data);

err = extcon_dev_register(&data->edev);
err = devm_extcon_dev_register(&pdev->dev, data->edev);
if (err)
goto out;
return err;

data->irq = platform_get_irq(pdev, 0);
if (!data->irq) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
err = -ENODEV;
goto err_irq;
return -ENODEV;
}

err = request_any_context_irq(data->irq, adc_jack_irq_thread,
pdata->irq_flags, pdata->name, data);

if (err < 0) {
dev_err(&pdev->dev, "error: irq %d\n", data->irq);
goto err_irq;
return err;
}

return 0;

err_irq:
extcon_dev_unregister(&data->edev);
out:
return err;
}

static int adc_jack_remove(struct platform_device *pdev)
Expand All @@ -182,7 +174,6 @@ static int adc_jack_remove(struct platform_device *pdev)

free_irq(data->irq, data);
cancel_work_sync(&data->handler.work);
extcon_dev_unregister(&data->edev);

return 0;
}
Expand Down
40 changes: 20 additions & 20 deletions drivers/extcon/extcon-arizona.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct arizona_extcon_info {

int hpdet_ip;

struct extcon_dev edev;
struct extcon_dev *edev;
};

static const struct arizona_micd_config micd_default_modes[] = {
Expand Down Expand Up @@ -546,7 +546,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
}

/* If the cable was removed while measuring ignore the result */
ret = extcon_get_cable_state_(&info->edev, ARIZONA_CABLE_MECHANICAL);
ret = extcon_get_cable_state_(info->edev, ARIZONA_CABLE_MECHANICAL);
if (ret < 0) {
dev_err(arizona->dev, "Failed to check cable state: %d\n",
ret);
Expand Down Expand Up @@ -581,7 +581,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
else
report = ARIZONA_CABLE_HEADPHONE;

ret = extcon_set_cable_state_(&info->edev, report, true);
ret = extcon_set_cable_state_(info->edev, report, true);
if (ret != 0)
dev_err(arizona->dev, "Failed to report HP/line: %d\n",
ret);
Expand Down Expand Up @@ -664,7 +664,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);

/* Just report headphone */
ret = extcon_update_state(&info->edev,
ret = extcon_update_state(info->edev,
1 << ARIZONA_CABLE_HEADPHONE,
1 << ARIZONA_CABLE_HEADPHONE);
if (ret != 0)
Expand Down Expand Up @@ -723,7 +723,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);

/* Just report headphone */
ret = extcon_update_state(&info->edev,
ret = extcon_update_state(info->edev,
1 << ARIZONA_CABLE_HEADPHONE,
1 << ARIZONA_CABLE_HEADPHONE);
if (ret != 0)
Expand Down Expand Up @@ -764,7 +764,7 @@ static void arizona_micd_detect(struct work_struct *work)
mutex_lock(&info->lock);

/* If the cable was removed while measuring ignore the result */
ret = extcon_get_cable_state_(&info->edev, ARIZONA_CABLE_MECHANICAL);
ret = extcon_get_cable_state_(info->edev, ARIZONA_CABLE_MECHANICAL);
if (ret < 0) {
dev_err(arizona->dev, "Failed to check cable state: %d\n",
ret);
Expand Down Expand Up @@ -812,7 +812,7 @@ static void arizona_micd_detect(struct work_struct *work)
if (info->detecting && (val & ARIZONA_MICD_LVL_8)) {
arizona_identify_headphone(info);

ret = extcon_update_state(&info->edev,
ret = extcon_update_state(info->edev,
1 << ARIZONA_CABLE_MICROPHONE,
1 << ARIZONA_CABLE_MICROPHONE);

Expand Down Expand Up @@ -999,7 +999,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)

if (info->last_jackdet == present) {
dev_dbg(arizona->dev, "Detected jack\n");
ret = extcon_set_cable_state_(&info->edev,
ret = extcon_set_cable_state_(info->edev,
ARIZONA_CABLE_MECHANICAL, true);

if (ret != 0)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
info->micd_ranges[i].key, 0);
input_sync(info->input);

ret = extcon_update_state(&info->edev, 0xffffffff, 0);
ret = extcon_update_state(info->edev, 0xffffffff, 0);
if (ret != 0)
dev_err(arizona->dev, "Removal report failed: %d\n",
ret);
Expand Down Expand Up @@ -1105,15 +1105,14 @@ static int arizona_extcon_probe(struct platform_device *pdev)
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
ret = -ENOMEM;
goto err;
return -ENOMEM;
}

info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
if (IS_ERR(info->micvdd)) {
ret = PTR_ERR(info->micvdd);
dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
goto err;
return ret;
}

mutex_init(&info->lock);
Expand Down Expand Up @@ -1151,15 +1150,19 @@ static int arizona_extcon_probe(struct platform_device *pdev)
break;
}

info->edev.name = "Headset Jack";
info->edev.dev.parent = arizona->dev;
info->edev.supported_cable = arizona_cable;
info->edev = devm_extcon_dev_allocate(&pdev->dev, arizona_cable);
if (IS_ERR(info->edev)) {
dev_err(&pdev->dev, "failed to allocate extcon device\n");
return -ENOMEM;
}
info->edev->name = "Headset Jack";
info->edev->dev.parent = arizona->dev;

ret = extcon_dev_register(&info->edev);
ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret < 0) {
dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
ret);
goto err;
return ret;
}

info->input = devm_input_allocate_device(&pdev->dev);
Expand Down Expand Up @@ -1410,8 +1413,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
err_input:
err_register:
pm_runtime_disable(&pdev->dev);
extcon_dev_unregister(&info->edev);
err:
return ret;
}

Expand Down Expand Up @@ -1445,7 +1446,6 @@ static int arizona_extcon_remove(struct platform_device *pdev)
regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
ARIZONA_JD1_ENA, 0);
arizona_clk32k_disable(arizona);
extcon_dev_unregister(&info->edev);

return 0;
}
Expand Down
Loading

0 comments on commit 6a57bad

Please sign in to comment.