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

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>

+16 -14
+14 -12
drivers/extcon/extcon-adc-jack.c
··· 3 3 * 4 4 * Analog Jack extcon driver with ADC-based detection capability. 5 5 * 6 + * Copyright (C) 2016 Samsung Electronics 7 + * Chanwoo Choi <cw00.choi@samsung.com> 8 + * 6 9 * Copyright (C) 2012 Samsung Electronics 7 10 * MyungJoo Ham <myungjoo.ham@samsung.com> 8 11 * ··· 61 58 struct adc_jack_data *data = container_of(to_delayed_work(work), 62 59 struct adc_jack_data, 63 60 handler); 64 - u32 state = 0; 61 + struct adc_jack_cond *def; 65 62 int ret, adc_val; 66 63 int i; 67 64 ··· 73 70 74 71 /* Get state from adc value with adc_conditions */ 75 72 for (i = 0; i < data->num_conditions; i++) { 76 - struct adc_jack_cond *def = &data->adc_conditions[i]; 77 - if (!def->state) 78 - break; 73 + def = &data->adc_conditions[i]; 79 74 if (def->min_adc <= adc_val && def->max_adc >= adc_val) { 80 - state = def->state; 81 - break; 75 + extcon_set_cable_state_(data->edev, def->id, true); 76 + return; 82 77 } 83 78 } 84 - /* if no def has met, it means state = 0 (no cables attached) */ 85 79 86 - extcon_set_state(data->edev, state); 80 + /* Set the detached state if adc value is not included in the range */ 81 + for (i = 0; i < data->num_conditions; i++) { 82 + def = &data->adc_conditions[i]; 83 + extcon_set_cable_state_(data->edev, def->id, false); 84 + } 87 85 } 88 86 89 87 static irqreturn_t adc_jack_irq_thread(int irq, void *_data) ··· 118 114 return -ENOMEM; 119 115 } 120 116 121 - if (!pdata->adc_conditions || 122 - !pdata->adc_conditions[0].state) { 117 + if (!pdata->adc_conditions) { 123 118 dev_err(&pdev->dev, "error: adc_conditions not defined.\n"); 124 119 return -EINVAL; 125 120 } 126 121 data->adc_conditions = pdata->adc_conditions; 127 122 128 123 /* Check the length of array and set num_conditions */ 129 - for (i = 0; data->adc_conditions[i].state; i++) 130 - ; 124 + for (i = 0; data->adc_conditions[i].id != EXTCON_NONE; i++); 131 125 data->num_conditions = i; 132 126 133 127 data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
+2 -2
include/linux/extcon/extcon-adc-jack.h
··· 20 20 21 21 /** 22 22 * struct adc_jack_cond - condition to use an extcon state 23 - * @state: the corresponding extcon state (if 0, this struct 24 23 * denotes the last adc_jack_cond element among the array) 24 + * @id: the unique id of each external connector 25 25 * @min_adc: min adc value for this condition 26 26 * @max_adc: max adc value for this condition 27 27 * ··· 33 33 * because when no adc_jack_cond is met, state = 0 is automatically chosen. 34 34 */ 35 35 struct adc_jack_cond { 36 - u32 state; /* extcon state value. 0 if invalid */ 36 + unsigned int id; 37 37 u32 min_adc; 38 38 u32 max_adc; 39 39 };