Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753334AbdLNPPV (ORCPT ); Thu, 14 Dec 2017 10:15:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:52176 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753243AbdLNPOj (ORCPT ); Thu, 14 Dec 2017 10:14:39 -0500 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Michal Suchanek To: Jens Axboe , linux-kernel@vger.kernel.org Cc: Michal Suchanek Subject: [PATCH 6/6] cdrom: wait for drive to become ready Date: Thu, 14 Dec 2017 16:13:55 +0100 Message-Id: <1b333c20de3dfe22615d1b33ba2898bc72fafbbf.1513263482.git.msuchanek@suse.de> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 925 Lines: 30 When the drive closes it can take tens of seconds until the disc is analyzed. Wait for the drive to become ready or report an error. Signed-off-by: Michal Suchanek --- drivers/cdrom/cdrom.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 040d3d466cd7..a483f34b7648 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -1087,6 +1087,15 @@ int open_for_common(struct cdrom_device_info *cdi, tracktype *tracks) } cd_dbg(CD_OPEN, "the tray is now closed\n"); } + /* the door should be closed now, check for the disc */ + if (ret == CDS_DRIVE_NOT_READY) { + int poll_res = poll_event_interruptible( + CDS_DRIVE_NOT_READY != + (ret = cdo->drive_status(cdi, CDSL_CURRENT)), + 500); + if (poll_res == -ERESTARTSYS) + return poll_res; + } if (ret != CDS_DISC_OK) return -ENOMEDIUM; } -- 2.13.6