Commit 386a966f authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Michael Ellerman
Browse files

vio: make remove callback return void



The driver core ignores the return value of struct bus_type::remove()
because there is only little that can be done. To simplify the quest to
make this function return void, let struct vio_driver::remove() return
void, too. All users already unconditionally return 0, this commit makes
it obvious that returning an error code is a bad idea.

Note there are two nominally different implementations for a vio bus:
one in arch/sparc/kernel/vio.c and the other in
arch/powerpc/platforms/pseries/vio.c. This patch only adapts the powerpc
one.

Before this patch for a device that was bound to a driver without a
remove callback vio_cmo_bus_remove(viodev) wasn't called. As the device
core still considers the device unbound after vio_bus_remove() returns
calling this unconditionally is the consistent behaviour which is
implemented here.

Signed-off-by: default avatarUwe Kleine-König <uwe@kleine-koenig.org>
Reviewed-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
Acked-by: default avatarLijun Pan <ljp@linux.ibm.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[mpe: Drop unneeded hvcs_remove() forward declaration, squash in
 change from sfr to drop ibmvnic_remove() forward declaration]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210225221834.160083-1-uwe@kleine-koenig.org
parent 91b6c5db
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ struct vio_driver {
	const char *name;
	const struct vio_device_id *id_table;
	int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
	int (*remove)(struct vio_dev *dev);
	void (*remove)(struct vio_dev *dev);
	/* A driver must have a get_desired_dma() function to
	 * be loaded in a CMO environment if it uses DMA.
	 */
+3 −4
Original line number Diff line number Diff line
@@ -1261,7 +1261,6 @@ static int vio_bus_remove(struct device *dev)
	struct vio_dev *viodev = to_vio_dev(dev);
	struct vio_driver *viodrv = to_vio_driver(dev->driver);
	struct device *devptr;
	int ret = 1;

	/*
	 * Hold a reference to the device after the remove function is called
@@ -1270,13 +1269,13 @@ static int vio_bus_remove(struct device *dev)
	devptr = get_device(dev);

	if (viodrv->remove)
		ret = viodrv->remove(viodev);
		viodrv->remove(viodev);

	if (!ret && firmware_has_feature(FW_FEATURE_CMO))
	if (firmware_has_feature(FW_FEATURE_CMO))
		vio_cmo_bus_remove(viodev);

	put_device(devptr);
	return ret;
	return 0;
}

/**
+1 −2
Original line number Diff line number Diff line
@@ -54,10 +54,9 @@ static int pseries_rng_probe(struct vio_dev *dev,
	return hwrng_register(&pseries_rng);
}

static int pseries_rng_remove(struct vio_dev *dev)
static void pseries_rng_remove(struct vio_dev *dev)
{
	hwrng_unregister(&pseries_rng);
	return 0;
}

static const struct vio_device_id pseries_rng_driver_ids[] = {
+1 −3
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ static int ibmvtpm_crq_send_init_complete(struct ibmvtpm_dev *ibmvtpm)
 *
 * Return: Always 0.
 */
static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
static void tpm_ibmvtpm_remove(struct vio_dev *vdev)
{
	struct tpm_chip *chip = dev_get_drvdata(&vdev->dev);
	struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
@@ -372,8 +372,6 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
	kfree(ibmvtpm);
	/* For tpm_ibmvtpm_get_desired_dma */
	dev_set_drvdata(&vdev->dev, NULL);

	return 0;
}

/**
+1 −3
Original line number Diff line number Diff line
@@ -1042,7 +1042,7 @@ static int nx842_probe(struct vio_dev *viodev,
	return ret;
}

static int nx842_remove(struct vio_dev *viodev)
static void nx842_remove(struct vio_dev *viodev)
{
	struct nx842_devdata *old_devdata;
	unsigned long flags;
@@ -1063,8 +1063,6 @@ static int nx842_remove(struct vio_dev *viodev)
	if (old_devdata)
		kfree(old_devdata->counters);
	kfree(old_devdata);

	return 0;
}

static const struct vio_device_id nx842_vio_driver_ids[] = {
Loading