From ad07d8b489b07510d98773472d2a3023701f88b6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 5 Aug 2013 14:32:03 +0530 Subject: [PATCH 01/14] extcon: max8997: Fix checkpatch warning Fixes the following warning: WARNING: space prohibited before semicolon Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-max8997.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index 67d6738d85a0..e55ec38b4148 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -537,7 +537,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; From cb9005d7dacb83ba92f39fe6d2a9c0c06ca50cb3 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 7 Aug 2013 12:17:14 +0100 Subject: [PATCH 02/14] extcon: arizona: Clear trig_sts bits on all paths We want the trig_sts bits to be cleared in all cases where we consider the jack detection interrupt to have been handled. Specifically, if a duplicate detection event was suppressed these bits were not cleared causing the CODEC to not enter a low power state. This patch clears the bits on the duplicate detection code path. Reported-by: Ryo Tsutsui Signed-off-by: Charles Keepax Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-arizona.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index e55713083c78..4696df0946ed 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -1039,6 +1039,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 +1047,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); From d97abdde1753d4608766a8b7a3661d3b70117054 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 5 Aug 2013 14:30:46 +0530 Subject: [PATCH 03/14] extcon: arizona: Fix a typo in a comment Fixes an incomplete comment introduced by commit 9c2ba270 ("extcon: arizona: Simplify HPDET based identification"). Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-arizona.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 4696df0946ed..2064eac1b92b 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -514,7 +514,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"); From a33411b26e43d67d361298a822ecfd76a177183f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 5 Aug 2013 14:32:04 +0530 Subject: [PATCH 04/14] extcon: max77693: Fix checkpatch warning Fixes the following warning: WARNING: space prohibited before semicolon Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-max77693.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index b56bdaa27d4b..4849ea1e92f6 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -953,7 +953,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; @@ -1188,7 +1188,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; From a75e1c73a46eed0332d036e371f714e76d167c07 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Sat, 31 Aug 2013 13:16:49 +0900 Subject: [PATCH 05/14] extcon: Fix indentation coding style to improve readability Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-adc-jack.c | 20 ++++---- drivers/extcon/extcon-class.c | 26 +++++----- include/linux/extcon.h | 67 ++++++++++++++------------ include/linux/extcon/extcon-adc-jack.h | 42 ++++++++-------- include/linux/extcon/extcon-gpio.h | 16 +++--- 5 files changed, 87 insertions(+), 84 deletions(-) diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index 5985807e52c9..5d16428afd53 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; diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 148382faded9..a29720822847 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 * @@ -189,7 +189,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,7 +227,6 @@ 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) { @@ -339,8 +338,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 +359,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 +419,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. @@ -487,7 +487,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 +502,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. * diff --git a/include/linux/extcon.h b/include/linux/extcon.h index fcb51c88319f..c2b652dde72c 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -51,10 +51,10 @@ enum extcon_cable_name { EXTCON_USB = 0, EXTCON_USB_HOST, - EXTCON_TA, /* Travel Adaptor */ + EXTCON_TA, /* Travel Adaptor */ EXTCON_FAST_CHARGER, EXTCON_SLOW_CHARGER, - EXTCON_CHARGE_DOWNSTREAM, /* Charging an external device */ + EXTCON_CHARGE_DOWNSTREAM, /* Charging an external device */ EXTCON_HDMI, EXTCON_MHL, EXTCON_DVI, @@ -76,8 +76,8 @@ struct extcon_cable; /** * struct extcon_dev - An extcon device represents one external connector. - * @name: The name of this extcon device. Parent device name is used - * if NULL. + * @name: The name of this extcon device. Parent device name is + * used if NULL. * @supported_cable: Array of supported cable names ending with NULL. * If supported_cable is NULL, cable name related APIs * are disabled. @@ -89,21 +89,21 @@ struct extcon_cable; * be attached simulataneously. {0x7, 0} is equivalent to * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there * can be no simultaneous connections. - * @print_name: An optional callback to override the method to print the - * name of the extcon device. + * @print_name: An optional callback to override the method to print the + * name of the extcon device. * @print_state: An optional callback to override the method to print the - * status of the extcon device. - * @dev: Device of this extcon. Do not provide at register-time. - * @state: Attach/detach state of this extcon. Do not provide at - * register-time - * @nh: Notifier for the state change events from this extcon - * @entry: To support list of extcon devices so that users can search - * for extcon devices based on the extcon name. + * status of the extcon device. + * @dev: Device of this extcon. Do not provide at register-time. + * @state: Attach/detach state of this extcon. Do not provide at + * register-time. + * @nh: Notifier for the state change events from this extcon + * @entry: To support list of extcon devices so that users can search + * for extcon devices based on the extcon name. * @lock: * @max_supported: Internal value to store the number of cables. * @extcon_dev_type: Device_type struct to provide attribute_groups * customized for each extcon device. - * @cables: Sysfs subdirectories. Each represents one cable. + * @cables: Sysfs subdirectories. Each represents one cable. * * In most cases, users only need to provide "User initializing data" of * this struct when registering an extcon. In some exceptional cases, @@ -111,26 +111,27 @@ struct extcon_cable; * are overwritten by register function. */ struct extcon_dev { - /* --- Optional user initializing data --- */ - const char *name; + /* Optional user initializing data */ + const char *name; const char **supported_cable; - const u32 *mutually_exclusive; + const u32 *mutually_exclusive; - /* --- Optional callbacks to override class functions --- */ + /* Optional callbacks to override class functions */ ssize_t (*print_name)(struct extcon_dev *edev, char *buf); ssize_t (*print_state)(struct extcon_dev *edev, char *buf); - /* --- Internal data. Please do not set. --- */ - struct device *dev; - u32 state; + /* Internal data. Please do not set. */ + struct device *dev; struct raw_notifier_head nh; struct list_head entry; - spinlock_t lock; /* could be called by irq handler */ int max_supported; + spinlock_t lock; /* could be called by irq handler */ + u32 state; /* /sys/class/extcon/.../cable.n/... */ struct device_type extcon_dev_type; struct extcon_cable *cables; + /* /sys/class/extcon/.../mutually_exclusive/... */ struct attribute_group attr_g_muex; struct attribute **attrs_muex; @@ -138,13 +139,13 @@ struct extcon_dev { }; /** - * struct extcon_cable - An internal data for each cable of extcon device. - * @edev: The extcon device + * struct extcon_cable - An internal data for each cable of extcon device. + * @edev: The extcon device * @cable_index: Index of this cable in the edev - * @attr_g: Attribute group for the cable - * @attr_name: "name" sysfs entry - * @attr_state: "state" sysfs entry - * @attrs: Array pointing to attr_name and attr_state for attr_g + * @attr_g: Attribute group for the cable + * @attr_name: "name" sysfs entry + * @attr_state: "state" sysfs entry + * @attrs: Array pointing to attr_name and attr_state for attr_g */ struct extcon_cable { struct extcon_dev *edev; @@ -159,11 +160,13 @@ struct extcon_cable { /** * struct extcon_specific_cable_nb - An internal data for - * extcon_register_interest(). - * @internal_nb: a notifier block bridging extcon notifier and cable notifier. - * @user_nb: user provided notifier block for events from a specific cable. + * extcon_register_interest(). + * @internal_nb: A notifier block bridging extcon notifier + * and cable notifier. + * @user_nb: user provided notifier block for events from + * a specific cable. * @cable_index: the target cable. - * @edev: the target extcon device. + * @edev: the target extcon device. * @previous_value: the saved previous event value. */ struct extcon_specific_cable_nb { diff --git a/include/linux/extcon/extcon-adc-jack.h b/include/linux/extcon/extcon-adc-jack.h index 20e9eef25d4c..9ca958c4e94c 100644 --- a/include/linux/extcon/extcon-adc-jack.h +++ b/include/linux/extcon/extcon-adc-jack.h @@ -20,10 +20,10 @@ /** * 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) - * @min_adc - min adc value for this condition - * @max_adc - max adc value for this condition + * @state: the corresponding extcon state (if 0, this struct + * denotes the last adc_jack_cond element among the array) + * @min_adc: min adc value for this condition + * @max_adc: max adc value for this condition * * For example, if { .state = 0x3, .min_adc = 100, .max_adc = 200}, it means * that if ADC value is between (inclusive) 100 and 200, than the cable 0 and @@ -33,34 +33,34 @@ * because when no adc_jack_cond is met, state = 0 is automatically chosen. */ struct adc_jack_cond { - u32 state; /* extcon state value. 0 if invalid */ + u32 state; /* extcon state value. 0 if invalid */ u32 min_adc; u32 max_adc; }; /** * struct adc_jack_pdata - platform data for adc jack device. - * @name - name of the extcon device. If null, "adc-jack" is used. - * @consumer_channel - Unique name to identify the channel on the consumer - * side. This typically describes the channels used within - * the consumer. E.g. 'battery_voltage' - * @cable_names - array of cable names ending with null. - * @adc_contitions - array of struct adc_jack_cond conditions ending - * with .state = 0 entry. This describes how to decode - * adc values into extcon state. - * @irq_flags - irq flags used for the @irq - * @handling_delay_ms - in some devices, we need to read ADC value some - * milli-seconds after the interrupt occurs. You may - * describe such delays with @handling_delay_ms, which - * is rounded-off by jiffies. + * @name: name of the extcon device. If null, "adc-jack" is used. + * @consumer_channel: Unique name to identify the channel on the consumer + * side. This typically describes the channels used within + * the consumer. E.g. 'battery_voltage' + * @cable_names: array of cable names ending with null. + * @adc_contitions: array of struct adc_jack_cond conditions ending + * with .state = 0 entry. This describes how to decode + * adc values into extcon state. + * @irq_flags: irq flags used for the @irq + * @handling_delay_ms: in some devices, we need to read ADC value some + * milli-seconds after the interrupt occurs. You may + * describe such delays with @handling_delay_ms, which + * is rounded-off by jiffies. */ struct adc_jack_pdata { const char *name; const char *consumer_channel; - /* - * The last entry should be NULL - */ + + /* The last entry should be NULL */ const char **cable_names; + /* The last entry's state should be 0 */ struct adc_jack_cond *adc_conditions; diff --git a/include/linux/extcon/extcon-gpio.h b/include/linux/extcon/extcon-gpio.h index 2d8307f7d67d..4ce1aa7d29bd 100644 --- a/include/linux/extcon/extcon-gpio.h +++ b/include/linux/extcon/extcon-gpio.h @@ -25,14 +25,14 @@ /** * struct gpio_extcon_platform_data - A simple GPIO-controlled extcon device. - * @name The name of this GPIO extcon device. - * @gpio Corresponding GPIO. - * @debounce Debounce time for GPIO IRQ in ms. - * @irq_flags IRQ Flags (e.g., IRQF_TRIGGER_LOW). - * @state_on print_state is overriden with state_on if attached. If Null, - * default method of extcon class is used. - * @state_off print_state is overriden with state_on if detached. If Null, - * default method of extcon class is used. + * @name: The name of this GPIO extcon device. + * @gpio: Corresponding GPIO. + * @debounce: Debounce time for GPIO IRQ in ms. + * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW). + * @state_on: print_state is overriden with state_on if attached. + * If NULL, default method of extcon class is used. + * @state_off: print_state is overriden with state_on if detached. + * If NUll, default method of extcon class is used. * * Note that in order for state_on or state_off to be valid, both state_on * and state_off should be not NULL. If at least one of them is NULL, From cb8bb3a77252bd431997a61456689c778510447c Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 9 Sep 2013 14:33:32 +0900 Subject: [PATCH 06/14] extcon: Remove casting the return value which is a void pointer Casting the return value which is a void pointer is redundant. The conversion from void pointer to any other pointer type is guaranteed by the C programming language. Signed-off-by: Jingoo Han Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-class.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index a29720822847..2f2d374ccd1d 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -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); @@ -135,7 +135,7 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, { 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 +153,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) { @@ -470,7 +470,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; From 1073514b11c221081c7c1f4a14b3eee5365385fa Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 29 Aug 2013 21:29:33 -0700 Subject: [PATCH 07/14] extcon: gpio: Do not unnecessarily initialize variables Signed-off-by: Guenter Roeck Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index f874c30ddbff..6368a0f3ae6d 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -80,7 +80,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) { struct gpio_extcon_platform_data *pdata = pdev->dev.platform_data; struct gpio_extcon_data *extcon_data; - int ret = 0; + int ret; if (!pdata) return -EBUSY; From 338de0ca682ca95d3f6185459e11540c37dd8a2a Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Tue, 10 Sep 2013 19:16:18 -0700 Subject: [PATCH 08/14] extcon: gpio: Use gpio driver/chip debounce if supported This patch use gpio_set_debounce() API provided from gpiolib if SoC or device driver with gpio support gpio_set_debounce() function. Signed-off-by: Guenter Roeck Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-gpio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 6368a0f3ae6d..862743bc825f 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -100,7 +100,13 @@ static int gpio_extcon_probe(struct platform_device *pdev) 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); if (ret < 0) From 7c0f6558f893eb5eddb52ee0fa84c2d43b2c199a Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Wed, 11 Sep 2013 13:22:18 +0900 Subject: [PATCH 09/14] extcon: use dev_get_platdata() Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-adc-jack.c | 2 +- drivers/extcon/extcon-gpio.c | 2 +- drivers/extcon/extcon-palmas.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index 5d16428afd53..5694c468b958 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -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); diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 862743bc825f..cd7dbb60f60f 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -78,7 +78,7 @@ 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; diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index 89fdd05c5fd6..0c2fb68fb791 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; From 5bfbdc9caa7e16b2a77a62a9f9a63b5693e23716 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 12 Sep 2013 08:49:54 +0900 Subject: [PATCH 10/14] extcon: gpio: Add support for active-low presence to detect pins This patch add 'gpio_active_low' field to 'struct gpio_extcon_data' to check whether gpio active state is 1(high) or 0(low). Signed-off-by: Guenter Roeck Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-gpio.c | 4 ++++ include/linux/extcon/extcon-gpio.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index cd7dbb60f60f..b02c670ef01d 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); } @@ -96,6 +99,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) extcon_data->edev.name = pdata->name; 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) diff --git a/include/linux/extcon/extcon-gpio.h b/include/linux/extcon/extcon-gpio.h index 4ce1aa7d29bd..4195810f87fe 100644 --- a/include/linux/extcon/extcon-gpio.h +++ b/include/linux/extcon/extcon-gpio.h @@ -27,6 +27,9 @@ * struct gpio_extcon_platform_data - A simple GPIO-controlled extcon device. * @name: The name of this GPIO extcon device. * @gpio: Corresponding GPIO. + * @gpio_active_low: Boolean describing whether gpio active state is 1 or 0 + * If true, low state of gpio means active. + * If false, high state of gpio means active. * @debounce: Debounce time for GPIO IRQ in ms. * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW). * @state_on: print_state is overriden with state_on if attached. @@ -41,6 +44,7 @@ struct gpio_extcon_platform_data { const char *name; unsigned gpio; + bool gpio_active_low; unsigned long debounce; unsigned long irq_flags; From 4ba1a9ff5955df443a0ed6c956501f796a18abfa Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 23 Sep 2013 14:33:58 +0100 Subject: [PATCH 11/14] extcon: arizona: Correct typo in headphone detect range transitions We should move range when the measured value is greater than or equal to the max value not when greater than. Signed-off-by: Charles Keepax Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-arizona.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 2064eac1b92b..1878415bd1ae 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -388,7 +388,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 +401,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; } From 4102424302b313516d11a325e2ba614deec526a2 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 23 Sep 2013 14:33:59 +0100 Subject: [PATCH 12/14] extcon: arizona: Don't require micbias to be shifted in pdata Every other pdata field is specified unshifted the patch handles shifting for the MICBIAS from the microphone detection polarity configurations in the extcon driver rather than demanding it in pdata to match other fields. Signed-off-by: Charles Keepax Signed-off-by: Chanwoo Choi --- drivers/extcon/extcon-arizona.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index 1878415bd1ae..e54ce08f669c 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: From dae616512476024aa61d2a598461ab6eff8c0709 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 27 Sep 2013 09:19:40 +0900 Subject: [PATCH 13/14] extcon: Change field type of 'dev' in extcon_dev structure The extcon device must always need 'struct device' so this patch change field type of 'dev' instead of allocating memory for 'struct device' on extcon_dev_register() function. Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-adc-jack.c | 2 +- drivers/extcon/extcon-class.c | 52 ++++++++++++++------------------ include/linux/extcon.h | 4 +-- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index 5694c468b958..dcbade667d0c 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -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; } diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 2f2d374ccd1d..2801c14d5232 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -162,7 +162,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); @@ -230,7 +230,7 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) /* 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; @@ -238,7 +238,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; @@ -250,14 +250,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 */ @@ -556,7 +556,6 @@ static int create_extcon_class(void) static void extcon_dev_release(struct device *dev) { - kfree(dev); } static const char *muex_name = "mutually_exclusive"; @@ -594,19 +593,16 @@ 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.parent = dev; + 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); + dev_set_name(&edev->dev, "%s", edev->name); if (edev->max_supported) { char buf[10]; @@ -714,7 +710,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 +720,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 +763,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 +782,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 +806,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/include/linux/extcon.h b/include/linux/extcon.h index c2b652dde72c..0269bafb0ee8 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -93,7 +93,7 @@ struct extcon_cable; * name of the extcon device. * @print_state: An optional callback to override the method to print the * status of the extcon device. - * @dev: Device of this extcon. Do not provide at register-time. + * @dev: Device of this extcon. * @state: Attach/detach state of this extcon. Do not provide at * register-time. * @nh: Notifier for the state change events from this extcon @@ -121,7 +121,7 @@ struct extcon_dev { ssize_t (*print_state)(struct extcon_dev *edev, char *buf); /* Internal data. Please do not set. */ - struct device *dev; + struct device dev; struct raw_notifier_head nh; struct list_head entry; int max_supported; From 42d7d7539a7bcf1d493b989465283c464f4a0525 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 27 Sep 2013 09:20:26 +0900 Subject: [PATCH 14/14] extcon: Simplify extcon_dev_register() prototype by removing unnecessary parameter This patch remove extcon_dev_register()'s second parameter which means the pointer of parent device to simplify prototype of this function. So, if extcon device has the parent device, it should set the pointer of parent device to edev.dev.parent in extcon device driver instead of in extcon_dev_register(). Cc: Graeme Gregory Cc: Kishon Vijay Abraham I Cc: Charles Keepax Cc: Mark Brown Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- Documentation/extcon/porting-android-switch-class | 6 ++++-- drivers/extcon/extcon-adc-jack.c | 3 ++- drivers/extcon/extcon-arizona.c | 3 ++- drivers/extcon/extcon-class.c | 11 +++++++---- drivers/extcon/extcon-gpio.c | 3 ++- drivers/extcon/extcon-max77693.c | 3 ++- drivers/extcon/extcon-max8997.c | 3 ++- drivers/extcon/extcon-palmas.c | 3 ++- include/linux/extcon.h | 5 ++--- 9 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Documentation/extcon/porting-android-switch-class b/Documentation/extcon/porting-android-switch-class index eb0fa5f4fe88..5377f6317961 100644 --- a/Documentation/extcon/porting-android-switch-class +++ b/Documentation/extcon/porting-android-switch-class @@ -25,8 +25,10 @@ MyungJoo Ham @print_state: no change but type change (switch_dev->extcon_dev) - switch_dev_register(sdev, dev) - => extcon_dev_register(edev, dev) - : no change but type change (sdev->edev) + => extcon_dev_register(edev) + : type change (sdev->edev) + : remove second param('dev'). if edev has parent device, should store + 'dev' to 'edev.dev.parent' before registering extcon device - switch_dev_unregister(sdev) => extcon_dev_unregister(edev) : no change but type change (sdev->edev) diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index dcbade667d0c..e23f1c2e5053 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -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 e54ce08f669c..ec9a14e05fdd 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -1130,9 +1130,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 2801c14d5232..84902d3fee11 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -566,14 +566,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; @@ -597,11 +596,15 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev) return -EINVAL; } - edev->dev.parent = dev; edev->dev.class = extcon_class; edev->dev.release = extcon_dev_release; - edev->name = edev->name ? edev->name : dev_name(dev); + 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) { diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index b02c670ef01d..7e0dff58e494 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -98,6 +98,7 @@ 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; @@ -112,7 +113,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) 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 4849ea1e92f6..ab9bc24e1a52 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -1171,8 +1171,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; diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index e55ec38b4148..0b1cbb5fdf9e 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -705,8 +705,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 0c2fb68fb791..6c91976dd823 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -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; diff --git a/include/linux/extcon.h b/include/linux/extcon.h index 0269bafb0ee8..21c59af1150b 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -183,7 +183,7 @@ struct extcon_specific_cable_nb { * Following APIs are for notifiers or configurations. * Notifiers are the external port and connection devices. */ -extern int extcon_dev_register(struct extcon_dev *edev, struct device *dev); +extern int extcon_dev_register(struct extcon_dev *edev); extern void extcon_dev_unregister(struct extcon_dev *edev); extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name); @@ -241,8 +241,7 @@ extern int extcon_register_notifier(struct extcon_dev *edev, extern int extcon_unregister_notifier(struct extcon_dev *edev, struct notifier_block *nb); #else /* CONFIG_EXTCON */ -static inline int extcon_dev_register(struct extcon_dev *edev, - struct device *dev) +static inline int extcon_dev_register(struct extcon_dev *edev) { return 0; }