Skip to content

Commit

Permalink
vio: make remove callback return void
Browse files Browse the repository at this point in the history
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: Uwe Kleine-König <uwe@kleine-koenig.org>
Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Acked-by: Lijun Pan <ljp@linux.ibm.com>
Acked-by: Greg 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: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210225221834.160083-1-uwe@kleine-koenig.org
  • Loading branch information
ukleinek authored and mpe committed Mar 2, 2021
1 parent 91b6c5d commit 386a966
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 37 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/vio.h
Expand Up @@ -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.
*/
Expand Down
7 changes: 3 additions & 4 deletions arch/powerpc/platforms/pseries/vio.c
Expand Up @@ -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
Expand All @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions drivers/char/hw_random/pseries-rng.c
Expand Up @@ -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[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/char/tpm/tpm_ibmvtpm.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions drivers/crypto/nx/nx-842-pseries.c
Expand Up @@ -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;
Expand All @@ -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[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/crypto/nx/nx.c
Expand Up @@ -783,7 +783,7 @@ static int nx_probe(struct vio_dev *viodev, const struct vio_device_id *id)
return nx_register_algs();
}

static int nx_remove(struct vio_dev *viodev)
static void nx_remove(struct vio_dev *viodev)
{
dev_dbg(&viodev->dev, "entering nx_remove for UA 0x%x\n",
viodev->unit_address);
Expand Down Expand Up @@ -811,8 +811,6 @@ static int nx_remove(struct vio_dev *viodev)
nx_unregister_skcipher(&nx_ecb_aes_alg, NX_FC_AES,
NX_MODE_AES_ECB);
}

return 0;
}


Expand Down
4 changes: 1 addition & 3 deletions drivers/misc/ibmvmc.c
Expand Up @@ -2288,15 +2288,13 @@ static int ibmvmc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
return -EPERM;
}

static int ibmvmc_remove(struct vio_dev *vdev)
static void ibmvmc_remove(struct vio_dev *vdev)
{
struct crq_server_adapter *adapter = dev_get_drvdata(&vdev->dev);

dev_info(adapter->dev, "Entering remove for UA 0x%x\n",
vdev->unit_address);
ibmvmc_release_crq_queue(adapter);

return 0;
}

static struct vio_device_id ibmvmc_device_table[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/ibm/ibmveth.c
Expand Up @@ -1758,7 +1758,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
return 0;
}

static int ibmveth_remove(struct vio_dev *dev)
static void ibmveth_remove(struct vio_dev *dev)
{
struct net_device *netdev = dev_get_drvdata(&dev->dev);
struct ibmveth_adapter *adapter = netdev_priv(netdev);
Expand All @@ -1771,8 +1771,6 @@ static int ibmveth_remove(struct vio_dev *dev)

free_netdev(netdev);
dev_set_drvdata(&dev->dev, NULL);

return 0;
}

static struct attribute veth_active_attr;
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/ethernet/ibm/ibmvnic.c
Expand Up @@ -78,7 +78,6 @@ MODULE_LICENSE("GPL");
MODULE_VERSION(IBMVNIC_DRIVER_VERSION);

static int ibmvnic_version = IBMVNIC_INITIAL_VERSION;
static int ibmvnic_remove(struct vio_dev *);
static void release_sub_crqs(struct ibmvnic_adapter *, bool);
static int ibmvnic_reset_crq(struct ibmvnic_adapter *);
static int ibmvnic_send_crq_init(struct ibmvnic_adapter *);
Expand Down Expand Up @@ -5396,7 +5395,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
return rc;
}

static int ibmvnic_remove(struct vio_dev *dev)
static void ibmvnic_remove(struct vio_dev *dev)
{
struct net_device *netdev = dev_get_drvdata(&dev->dev);
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
Expand Down Expand Up @@ -5437,8 +5436,6 @@ static int ibmvnic_remove(struct vio_dev *dev)
device_remove_file(&dev->dev, &dev_attr_failover);
free_netdev(netdev);
dev_set_drvdata(&dev->dev, NULL);

return 0;
}

static ssize_t failover_store(struct device *dev, struct device_attribute *attr,
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/ibmvscsi/ibmvfc.c
Expand Up @@ -6038,7 +6038,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
* Return value:
* 0
**/
static int ibmvfc_remove(struct vio_dev *vdev)
static void ibmvfc_remove(struct vio_dev *vdev)
{
struct ibmvfc_host *vhost = dev_get_drvdata(&vdev->dev);
LIST_HEAD(purge);
Expand Down Expand Up @@ -6070,7 +6070,6 @@ static int ibmvfc_remove(struct vio_dev *vdev)
spin_unlock(&ibmvfc_driver_lock);
scsi_host_put(vhost->host);
LEAVE;
return 0;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions drivers/scsi/ibmvscsi/ibmvscsi.c
Expand Up @@ -2335,7 +2335,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
return -1;
}

static int ibmvscsi_remove(struct vio_dev *vdev)
static void ibmvscsi_remove(struct vio_dev *vdev)
{
struct ibmvscsi_host_data *hostdata = dev_get_drvdata(&vdev->dev);

Expand All @@ -2356,8 +2356,6 @@ static int ibmvscsi_remove(struct vio_dev *vdev)
spin_unlock(&ibmvscsi_driver_lock);

scsi_host_put(hostdata->host);

return 0;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
Expand Up @@ -3595,7 +3595,7 @@ static int ibmvscsis_probe(struct vio_dev *vdev,
return rc;
}

static int ibmvscsis_remove(struct vio_dev *vdev)
static void ibmvscsis_remove(struct vio_dev *vdev)
{
struct scsi_info *vscsi = dev_get_drvdata(&vdev->dev);

Expand All @@ -3622,8 +3622,6 @@ static int ibmvscsis_remove(struct vio_dev *vdev)
list_del(&vscsi->list);
spin_unlock_bh(&ibmvscsis_dev_lock);
kfree(vscsi);

return 0;
}

static ssize_t system_id_show(struct device *dev,
Expand Down
4 changes: 1 addition & 3 deletions drivers/tty/hvc/hvcs.c
Expand Up @@ -317,7 +317,6 @@ static void hvcs_hangup(struct tty_struct * tty);

static int hvcs_probe(struct vio_dev *dev,
const struct vio_device_id *id);
static int hvcs_remove(struct vio_dev *dev);
static int __init hvcs_module_init(void);
static void __exit hvcs_module_exit(void);
static int hvcs_initialize(void);
Expand Down Expand Up @@ -819,7 +818,7 @@ static int hvcs_probe(
return 0;
}

static int hvcs_remove(struct vio_dev *dev)
static void hvcs_remove(struct vio_dev *dev)
{
struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev);
unsigned long flags;
Expand Down Expand Up @@ -849,7 +848,6 @@ static int hvcs_remove(struct vio_dev *dev)

printk(KERN_INFO "HVCS: vty-server@%X removed from the"
" vio bus.\n", dev->unit_address);
return 0;
};

static struct vio_driver hvcs_vio_driver = {
Expand Down

0 comments on commit 386a966

Please sign in to comment.