Skip to content

Commit 386a966

Browse files
ukleinekmpe
authored andcommitted
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: 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
1 parent 91b6c5d commit 386a966

13 files changed

Lines changed: 15 additions & 37 deletions

File tree

arch/powerpc/include/asm/vio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct vio_driver {
113113
const char *name;
114114
const struct vio_device_id *id_table;
115115
int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
116-
int (*remove)(struct vio_dev *dev);
116+
void (*remove)(struct vio_dev *dev);
117117
/* A driver must have a get_desired_dma() function to
118118
* be loaded in a CMO environment if it uses DMA.
119119
*/

arch/powerpc/platforms/pseries/vio.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,6 @@ static int vio_bus_remove(struct device *dev)
12611261
struct vio_dev *viodev = to_vio_dev(dev);
12621262
struct vio_driver *viodrv = to_vio_driver(dev->driver);
12631263
struct device *devptr;
1264-
int ret = 1;
12651264

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

12721271
if (viodrv->remove)
1273-
ret = viodrv->remove(viodev);
1272+
viodrv->remove(viodev);
12741273

1275-
if (!ret && firmware_has_feature(FW_FEATURE_CMO))
1274+
if (firmware_has_feature(FW_FEATURE_CMO))
12761275
vio_cmo_bus_remove(viodev);
12771276

12781277
put_device(devptr);
1279-
return ret;
1278+
return 0;
12801279
}
12811280

12821281
/**

drivers/char/hw_random/pseries-rng.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ static int pseries_rng_probe(struct vio_dev *dev,
5454
return hwrng_register(&pseries_rng);
5555
}
5656

57-
static int pseries_rng_remove(struct vio_dev *dev)
57+
static void pseries_rng_remove(struct vio_dev *dev)
5858
{
5959
hwrng_unregister(&pseries_rng);
60-
return 0;
6160
}
6261

6362
static const struct vio_device_id pseries_rng_driver_ids[] = {

drivers/char/tpm/tpm_ibmvtpm.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static int ibmvtpm_crq_send_init_complete(struct ibmvtpm_dev *ibmvtpm)
343343
*
344344
* Return: Always 0.
345345
*/
346-
static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
346+
static void tpm_ibmvtpm_remove(struct vio_dev *vdev)
347347
{
348348
struct tpm_chip *chip = dev_get_drvdata(&vdev->dev);
349349
struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
@@ -372,8 +372,6 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
372372
kfree(ibmvtpm);
373373
/* For tpm_ibmvtpm_get_desired_dma */
374374
dev_set_drvdata(&vdev->dev, NULL);
375-
376-
return 0;
377375
}
378376

379377
/**

drivers/crypto/nx/nx-842-pseries.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ static int nx842_probe(struct vio_dev *viodev,
10421042
return ret;
10431043
}
10441044

1045-
static int nx842_remove(struct vio_dev *viodev)
1045+
static void nx842_remove(struct vio_dev *viodev)
10461046
{
10471047
struct nx842_devdata *old_devdata;
10481048
unsigned long flags;
@@ -1063,8 +1063,6 @@ static int nx842_remove(struct vio_dev *viodev)
10631063
if (old_devdata)
10641064
kfree(old_devdata->counters);
10651065
kfree(old_devdata);
1066-
1067-
return 0;
10681066
}
10691067

10701068
static const struct vio_device_id nx842_vio_driver_ids[] = {

drivers/crypto/nx/nx.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ static int nx_probe(struct vio_dev *viodev, const struct vio_device_id *id)
783783
return nx_register_algs();
784784
}
785785

786-
static int nx_remove(struct vio_dev *viodev)
786+
static void nx_remove(struct vio_dev *viodev)
787787
{
788788
dev_dbg(&viodev->dev, "entering nx_remove for UA 0x%x\n",
789789
viodev->unit_address);
@@ -811,8 +811,6 @@ static int nx_remove(struct vio_dev *viodev)
811811
nx_unregister_skcipher(&nx_ecb_aes_alg, NX_FC_AES,
812812
NX_MODE_AES_ECB);
813813
}
814-
815-
return 0;
816814
}
817815

818816

drivers/misc/ibmvmc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,15 +2288,13 @@ static int ibmvmc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
22882288
return -EPERM;
22892289
}
22902290

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

22952295
dev_info(adapter->dev, "Entering remove for UA 0x%x\n",
22962296
vdev->unit_address);
22972297
ibmvmc_release_crq_queue(adapter);
2298-
2299-
return 0;
23002298
}
23012299

23022300
static struct vio_device_id ibmvmc_device_table[] = {

drivers/net/ethernet/ibm/ibmveth.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
17581758
return 0;
17591759
}
17601760

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

17721772
free_netdev(netdev);
17731773
dev_set_drvdata(&dev->dev, NULL);
1774-
1775-
return 0;
17761774
}
17771775

17781776
static struct attribute veth_active_attr;

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ MODULE_LICENSE("GPL");
7878
MODULE_VERSION(IBMVNIC_DRIVER_VERSION);
7979

8080
static int ibmvnic_version = IBMVNIC_INITIAL_VERSION;
81-
static int ibmvnic_remove(struct vio_dev *);
8281
static void release_sub_crqs(struct ibmvnic_adapter *, bool);
8382
static int ibmvnic_reset_crq(struct ibmvnic_adapter *);
8483
static int ibmvnic_send_crq_init(struct ibmvnic_adapter *);
@@ -5396,7 +5395,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
53965395
return rc;
53975396
}
53985397

5399-
static int ibmvnic_remove(struct vio_dev *dev)
5398+
static void ibmvnic_remove(struct vio_dev *dev)
54005399
{
54015400
struct net_device *netdev = dev_get_drvdata(&dev->dev);
54025401
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -5437,8 +5436,6 @@ static int ibmvnic_remove(struct vio_dev *dev)
54375436
device_remove_file(&dev->dev, &dev_attr_failover);
54385437
free_netdev(netdev);
54395438
dev_set_drvdata(&dev->dev, NULL);
5440-
5441-
return 0;
54425439
}
54435440

54445441
static ssize_t failover_store(struct device *dev, struct device_attribute *attr,

drivers/scsi/ibmvscsi/ibmvfc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6038,7 +6038,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
60386038
* Return value:
60396039
* 0
60406040
**/
6041-
static int ibmvfc_remove(struct vio_dev *vdev)
6041+
static void ibmvfc_remove(struct vio_dev *vdev)
60426042
{
60436043
struct ibmvfc_host *vhost = dev_get_drvdata(&vdev->dev);
60446044
LIST_HEAD(purge);
@@ -6070,7 +6070,6 @@ static int ibmvfc_remove(struct vio_dev *vdev)
60706070
spin_unlock(&ibmvfc_driver_lock);
60716071
scsi_host_put(vhost->host);
60726072
LEAVE;
6073-
return 0;
60746073
}
60756074

60766075
/**

0 commit comments

Comments
 (0)