forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extcon: adc-jack: Remove the usage of extcon_set_state()
This patch removes the usage of extcon_set_state() because it uses the bit masking to change the state of external connectors. The extcon framework should handle the state by extcon_set/get_cable_state_() with extcon id. Signed-off-by: Chanwoo Choi <[email protected]>
- Loading branch information
1 parent
5475e63
commit a7da72e
Showing
2 changed files
with
16 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
* | ||
* Analog Jack extcon driver with ADC-based detection capability. | ||
* | ||
* Copyright (C) 2016 Samsung Electronics | ||
* Chanwoo Choi <[email protected]> | ||
* | ||
* Copyright (C) 2012 Samsung Electronics | ||
* MyungJoo Ham <[email protected]> | ||
* | ||
|
@@ -58,7 +61,7 @@ static void adc_jack_handler(struct work_struct *work) | |
struct adc_jack_data *data = container_of(to_delayed_work(work), | ||
struct adc_jack_data, | ||
handler); | ||
u32 state = 0; | ||
struct adc_jack_cond *def; | ||
int ret, adc_val; | ||
int i; | ||
|
||
|
@@ -70,17 +73,18 @@ static void adc_jack_handler(struct work_struct *work) | |
|
||
/* Get state from adc value with adc_conditions */ | ||
for (i = 0; i < data->num_conditions; i++) { | ||
struct adc_jack_cond *def = &data->adc_conditions[i]; | ||
if (!def->state) | ||
break; | ||
def = &data->adc_conditions[i]; | ||
if (def->min_adc <= adc_val && def->max_adc >= adc_val) { | ||
state = def->state; | ||
break; | ||
extcon_set_cable_state_(data->edev, def->id, true); | ||
return; | ||
} | ||
} | ||
/* if no def has met, it means state = 0 (no cables attached) */ | ||
|
||
extcon_set_state(data->edev, state); | ||
/* Set the detached state if adc value is not included in the range */ | ||
for (i = 0; i < data->num_conditions; i++) { | ||
def = &data->adc_conditions[i]; | ||
extcon_set_cable_state_(data->edev, def->id, false); | ||
} | ||
} | ||
|
||
static irqreturn_t adc_jack_irq_thread(int irq, void *_data) | ||
|
@@ -114,16 +118,14 @@ static int adc_jack_probe(struct platform_device *pdev) | |
return -ENOMEM; | ||
} | ||
|
||
if (!pdata->adc_conditions || | ||
!pdata->adc_conditions[0].state) { | ||
if (!pdata->adc_conditions) { | ||
dev_err(&pdev->dev, "error: adc_conditions not defined.\n"); | ||
return -EINVAL; | ||
} | ||
data->adc_conditions = pdata->adc_conditions; | ||
|
||
/* Check the length of array and set num_conditions */ | ||
for (i = 0; data->adc_conditions[i].state; i++) | ||
; | ||
for (i = 0; data->adc_conditions[i].id != EXTCON_NONE; i++); | ||
data->num_conditions = i; | ||
|
||
data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters