mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
mmc: vub300: Use devm_mmc_alloc_host() helper
Use new function devm_mmc_alloc_host() to simplify the code. Reviewed-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn> Link: https://lore.kernel.org/r/f023d2caa02fab405f089c5170b686529857fb70.1748933789.git.zhoubinbin@loongson.cn Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
93f0d3ecae
commit
dcfdd698dc
|
|
@ -369,13 +369,11 @@ struct vub300_mmc_host {
|
||||||
static void vub300_delete(struct kref *kref)
|
static void vub300_delete(struct kref *kref)
|
||||||
{ /* kref callback - softirq */
|
{ /* kref callback - softirq */
|
||||||
struct vub300_mmc_host *vub300 = kref_to_vub300_mmc_host(kref);
|
struct vub300_mmc_host *vub300 = kref_to_vub300_mmc_host(kref);
|
||||||
struct mmc_host *mmc = vub300->mmc;
|
|
||||||
usb_free_urb(vub300->command_out_urb);
|
usb_free_urb(vub300->command_out_urb);
|
||||||
vub300->command_out_urb = NULL;
|
vub300->command_out_urb = NULL;
|
||||||
usb_free_urb(vub300->command_res_urb);
|
usb_free_urb(vub300->command_res_urb);
|
||||||
vub300->command_res_urb = NULL;
|
vub300->command_res_urb = NULL;
|
||||||
usb_put_dev(vub300->udev);
|
usb_put_dev(vub300->udev);
|
||||||
mmc_free_host(mmc);
|
|
||||||
/*
|
/*
|
||||||
* and hence also frees vub300
|
* and hence also frees vub300
|
||||||
* which is contained at the end of struct mmc
|
* which is contained at the end of struct mmc
|
||||||
|
|
@ -2114,7 +2112,7 @@ static int vub300_probe(struct usb_interface *interface,
|
||||||
goto error1;
|
goto error1;
|
||||||
}
|
}
|
||||||
/* this also allocates memory for our VUB300 mmc host device */
|
/* this also allocates memory for our VUB300 mmc host device */
|
||||||
mmc = mmc_alloc_host(sizeof(struct vub300_mmc_host), &udev->dev);
|
mmc = devm_mmc_alloc_host(&udev->dev, sizeof(*vub300));
|
||||||
if (!mmc) {
|
if (!mmc) {
|
||||||
retval = -ENOMEM;
|
retval = -ENOMEM;
|
||||||
dev_err(&udev->dev, "not enough memory for the mmc_host\n");
|
dev_err(&udev->dev, "not enough memory for the mmc_host\n");
|
||||||
|
|
@ -2271,7 +2269,7 @@ static int vub300_probe(struct usb_interface *interface,
|
||||||
dev_err(&vub300->udev->dev,
|
dev_err(&vub300->udev->dev,
|
||||||
"Could not find two sets of bulk-in/out endpoint pairs\n");
|
"Could not find two sets of bulk-in/out endpoint pairs\n");
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto error5;
|
goto error4;
|
||||||
}
|
}
|
||||||
retval =
|
retval =
|
||||||
usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0),
|
usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0),
|
||||||
|
|
@ -2280,14 +2278,14 @@ static int vub300_probe(struct usb_interface *interface,
|
||||||
0x0000, 0x0000, &vub300->hc_info,
|
0x0000, 0x0000, &vub300->hc_info,
|
||||||
sizeof(vub300->hc_info), 1000);
|
sizeof(vub300->hc_info), 1000);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto error5;
|
goto error4;
|
||||||
retval =
|
retval =
|
||||||
usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
|
usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
|
||||||
SET_ROM_WAIT_STATES,
|
SET_ROM_WAIT_STATES,
|
||||||
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||||
firmware_rom_wait_states, 0x0000, NULL, 0, 1000);
|
firmware_rom_wait_states, 0x0000, NULL, 0, 1000);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto error5;
|
goto error4;
|
||||||
dev_info(&vub300->udev->dev,
|
dev_info(&vub300->udev->dev,
|
||||||
"operating_mode = %s %s %d MHz %s %d byte USB packets\n",
|
"operating_mode = %s %s %d MHz %s %d byte USB packets\n",
|
||||||
(mmc->caps & MMC_CAP_SDIO_IRQ) ? "IRQs" : "POLL",
|
(mmc->caps & MMC_CAP_SDIO_IRQ) ? "IRQs" : "POLL",
|
||||||
|
|
@ -2302,7 +2300,7 @@ static int vub300_probe(struct usb_interface *interface,
|
||||||
0x0000, 0x0000, &vub300->system_port_status,
|
0x0000, 0x0000, &vub300->system_port_status,
|
||||||
sizeof(vub300->system_port_status), 1000);
|
sizeof(vub300->system_port_status), 1000);
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
goto error5;
|
goto error4;
|
||||||
} else if (sizeof(vub300->system_port_status) == retval) {
|
} else if (sizeof(vub300->system_port_status) == retval) {
|
||||||
vub300->card_present =
|
vub300->card_present =
|
||||||
(0x0001 & vub300->system_port_status.port_flags) ? 1 : 0;
|
(0x0001 & vub300->system_port_status.port_flags) ? 1 : 0;
|
||||||
|
|
@ -2310,7 +2308,7 @@ static int vub300_probe(struct usb_interface *interface,
|
||||||
(0x0010 & vub300->system_port_status.port_flags) ? 1 : 0;
|
(0x0010 & vub300->system_port_status.port_flags) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto error5;
|
goto error4;
|
||||||
}
|
}
|
||||||
usb_set_intfdata(interface, vub300);
|
usb_set_intfdata(interface, vub300);
|
||||||
INIT_DELAYED_WORK(&vub300->pollwork, vub300_pollwork_thread);
|
INIT_DELAYED_WORK(&vub300->pollwork, vub300_pollwork_thread);
|
||||||
|
|
@ -2340,8 +2338,6 @@ static int vub300_probe(struct usb_interface *interface,
|
||||||
return 0;
|
return 0;
|
||||||
error6:
|
error6:
|
||||||
timer_delete_sync(&vub300->inactivity_timer);
|
timer_delete_sync(&vub300->inactivity_timer);
|
||||||
error5:
|
|
||||||
mmc_free_host(mmc);
|
|
||||||
/*
|
/*
|
||||||
* and hence also frees vub300
|
* and hence also frees vub300
|
||||||
* which is contained at the end of struct mmc
|
* which is contained at the end of struct mmc
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user