1
0
Fork 0

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 <cw00.choi@samsung.com>
steinar/wifi_calib_4_9_kernel
Chanwoo Choi 2016-07-18 16:16:29 +09:00 committed by Kishon Vijay Abraham I
parent cdc0583202
commit cc60211237
2 changed files with 16 additions and 14 deletions

View File

@ -3,6 +3,9 @@
* *
* Analog Jack extcon driver with ADC-based detection capability. * Analog Jack extcon driver with ADC-based detection capability.
* *
* Copyright (C) 2016 Samsung Electronics
* Chanwoo Choi <cw00.choi@samsung.com>
*
* Copyright (C) 2012 Samsung Electronics * Copyright (C) 2012 Samsung Electronics
* MyungJoo Ham <myungjoo.ham@samsung.com> * MyungJoo Ham <myungjoo.ham@samsung.com>
* *
@ -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 *data = container_of(to_delayed_work(work),
struct adc_jack_data, struct adc_jack_data,
handler); handler);
u32 state = 0; struct adc_jack_cond *def;
int ret, adc_val; int ret, adc_val;
int i; int i;
@ -70,17 +73,18 @@ static void adc_jack_handler(struct work_struct *work)
/* Get state from adc value with adc_conditions */ /* Get state from adc value with adc_conditions */
for (i = 0; i < data->num_conditions; i++) { for (i = 0; i < data->num_conditions; i++) {
struct adc_jack_cond *def = &data->adc_conditions[i]; def = &data->adc_conditions[i];
if (!def->state)
break;
if (def->min_adc <= adc_val && def->max_adc >= adc_val) { if (def->min_adc <= adc_val && def->max_adc >= adc_val) {
state = def->state; extcon_set_cable_state_(data->edev, def->id, true);
break; 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) 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; return -ENOMEM;
} }
if (!pdata->adc_conditions || if (!pdata->adc_conditions) {
!pdata->adc_conditions[0].state) {
dev_err(&pdev->dev, "error: adc_conditions not defined.\n"); dev_err(&pdev->dev, "error: adc_conditions not defined.\n");
return -EINVAL; return -EINVAL;
} }
data->adc_conditions = pdata->adc_conditions; data->adc_conditions = pdata->adc_conditions;
/* Check the length of array and set num_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->num_conditions = i;
data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel); data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);

View File

@ -20,8 +20,8 @@
/** /**
* struct adc_jack_cond - condition to use an extcon state * struct adc_jack_cond - condition to use an extcon state
* @state: the corresponding extcon state (if 0, this struct
* denotes the last adc_jack_cond element among the array) * denotes the last adc_jack_cond element among the array)
* @id: the unique id of each external connector
* @min_adc: min adc value for this condition * @min_adc: min adc value for this condition
* @max_adc: max adc value for this condition * @max_adc: max adc value for this condition
* *
@ -33,7 +33,7 @@
* because when no adc_jack_cond is met, state = 0 is automatically chosen. * because when no adc_jack_cond is met, state = 0 is automatically chosen.
*/ */
struct adc_jack_cond { struct adc_jack_cond {
u32 state; /* extcon state value. 0 if invalid */ unsigned int id;
u32 min_adc; u32 min_adc;
u32 max_adc; u32 max_adc;
}; };