Commit 6526b02e authored by Jerome Brunet's avatar Jerome Brunet Committed by Douglas Anderson
Browse files

drm/bridge: ti-sn65dsi86: use the auxiliary device



The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.

Use it and remove some boilerplate code.

Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20250218-aux-device-create-helper-v4-3-c3d7dfdea2e6@baylibre.com
parent 5e861a69
Loading
Loading
Loading
Loading
+7 −42
Original line number Diff line number Diff line
@@ -447,23 +447,6 @@ DEFINE_SHOW_ATTRIBUTE(status);
 * Auxiliary Devices (*not* AUX)
 */

static void ti_sn65dsi86_uninit_aux(void *data)
{
	auxiliary_device_uninit(data);
}

static void ti_sn65dsi86_delete_aux(void *data)
{
	auxiliary_device_delete(data);
}

static void ti_sn65dsi86_aux_device_release(struct device *dev)
{
	struct auxiliary_device *aux = container_of(dev, struct auxiliary_device, dev);

	kfree(aux);
}

static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,
				       struct auxiliary_device **aux_out,
				       const char *name)
@@ -471,34 +454,16 @@ static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,
	struct device *dev = pdata->dev;
	const struct i2c_client *client = to_i2c_client(dev);
	struct auxiliary_device *aux;
	int ret;
	int id;

	aux = kzalloc(sizeof(*aux), GFP_KERNEL);
	id = (client->adapter->nr << 10) | client->addr;
	aux = __devm_auxiliary_device_create(dev, KBUILD_MODNAME, name,
					     NULL, id);
	if (!aux)
		return -ENOMEM;

	aux->name = name;
	aux->id = (client->adapter->nr << 10) | client->addr;
	aux->dev.parent = dev;
	aux->dev.release = ti_sn65dsi86_aux_device_release;
	device_set_of_node_from_dev(&aux->dev, dev);
	ret = auxiliary_device_init(aux);
	if (ret) {
		kfree(aux);
		return ret;
	}
	ret = devm_add_action_or_reset(dev, ti_sn65dsi86_uninit_aux, aux);
	if (ret)
		return ret;
		return -ENODEV;

	ret = auxiliary_device_add(aux);
	if (ret)
		return ret;
	ret = devm_add_action_or_reset(dev, ti_sn65dsi86_delete_aux, aux);
	if (!ret)
	*aux_out = aux;

	return ret;
	return 0;
}

/* -----------------------------------------------------------------------------