Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2424a733 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'extcon-next-for-3.13' of...

Merge tag 'extcon-next-for-3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next

Chanwoo writes:

Update extcon for 3.13

This patchset modify extcon core to remove unnecessary allocation sequence for
'dev' instance and change extcon_dev_register() interface. extcon-gpio use
gpiolib API to get debounce time and include small fix of extcon core/device
driver.

Detailed description for patchset:
1. Modify extcon core driver
- The extcon-gpio driver use gpio_set_debounce() API provided from gpiolib
if gpio driver for SoC support gpio_set_debounce() function and support 'gpio_
activ_low' filed to check whether gpio active state is 1(high) or 0(low).
- Change field type of 'dev' in structure extcon_dev and remove the sequence
of allocating memory of 'struct dev' on extcon_dev_register() function because
extcon device must need 'struct device.
- Change extcon_dev_register() prototype to simplify it and remove unnecessary
parameter as below:

2. Fix coding style and typo
- extcon core     : Fix indentation coding style and remove unnecessary casting
- extcon-max8997  : Fix checkpatch warning
- extcon-max77693 : Fix checkpatch warning
- extcon-arizona  : Fix typo of comment and modify minor issue
- extcon-palmas   : Use dev_get_platdata()

3. Modify extcon-arizona driver
- Modify minor issue about micbias and comparision statement
parents 33b06938 42d7d753
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -25,8 +25,10 @@ MyungJoo Ham <myungjoo.ham@samsung.com>
    @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)
+14 −13
Original line number Diff line number Diff line
@@ -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
 * @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.
 * @handler:		extcon event handler called by interrupt handler.
 * @chan:		iio channel being queried.
 */
struct adc_jack_data {
	struct extcon_dev edev;
@@ -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;
	}

@@ -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);
@@ -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;

+11 −9
Original line number Diff line number Diff line
@@ -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:
@@ -388,7 +389,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 +402,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;
		}
@@ -514,7 +515,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");
@@ -1042,6 +1043,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 |
@@ -1049,7 +1051,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);
@@ -1132,9 +1133,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);
+46 −49
Original line number Diff line number Diff line
@@ -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);
@@ -134,7 +134,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)
@@ -152,7 +152,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) {
@@ -161,7 +161,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);

@@ -226,11 +226,10 @@ 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) {
			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 +237,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 +249,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 */
@@ -339,7 +338,8 @@ 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().
 * @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.
 */
@@ -471,7 +471,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;
@@ -557,7 +557,6 @@ static int create_extcon_class(void)

static void extcon_dev_release(struct device *dev)
{
	kfree(dev);
}

static const char *muex_name = "mutually_exclusive";
@@ -568,14 +567,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;

@@ -595,19 +593,20 @@ 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.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);
	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) {
		char buf[10];
@@ -715,7 +714,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++)
@@ -725,25 +724,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);
@@ -769,7 +767,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);
@@ -789,9 +786,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;
	}

@@ -813,10 +810,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);

+15 −4
Original line number Diff line number Diff line
@@ -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);
}

@@ -78,9 +81,9 @@ 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 = 0;
	int ret;

	if (!pdata)
		return -EBUSY;
@@ -95,14 +98,22 @@ 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;
	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);
	ret = extcon_dev_register(&extcon_data->edev);
	if (ret < 0)
		return ret;

Loading