From patchwork Wed Apr 27 09:09:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: job jin X-Patchwork-Id: 568495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A534C433F5 for ; Wed, 27 Apr 2022 11:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232882AbiD0LaV (ORCPT ); Wed, 27 Apr 2022 07:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232853AbiD0LaU (ORCPT ); Wed, 27 Apr 2022 07:30:20 -0400 X-Greylist: delayed 3615 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 27 Apr 2022 04:27:09 PDT Received: from qq.com (smtpbg478.qq.com [59.36.132.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A7C34BAF for ; Wed, 27 Apr 2022 04:27:09 -0700 (PDT) X-QQ-mid: bizesmtp64t1651050605tiahcm92 Received: from localhost.localdomain ( [113.57.152.160]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 27 Apr 2022 17:10:04 +0800 (CST) X-QQ-SSF: 01400000002000B0D000000A0000000 X-QQ-FEAT: k0yT7W7BRd2hJ3e44CTTxZClb4VhkQvqeT8/1vbIYdFEXyYRmRAwUKNJDbxwE bSyNufrz103kdN+HSbexV3zJ8frcy35rH0dSEjze32oxJ67/YIg1Ui0wQp6jPjn8sdrWouw 6976pNoA+b9xTCtCGDlASzzAo7GYAHhfsvSoxHvnHqa+FcOK+Cho3d6AGJe0ZnzzrSHCFmm xQX6+ciD4+yQzVq4GHlS39n+Cp4rnT9gUp+fINjO2aG+gzX7OSyOH7yH0DpFVoacHuI4ZLx 4TSq8q5Cf/PbqPJGvV1TIKb+dn/PEScJtoBQxsWLRYegEU3g+82O1ClsQ0NXVyEWh+hNc0V r5UDk6YJJlj4Ih5JBAdRqHCXfY1Ag== X-QQ-GoodBg: 1 From: jinxiaobo To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, jinxiaobo Subject: [PATCH] scsi: sr: Fix some cdroms automatically ejected when booting into the system Date: Wed, 27 Apr 2022 17:09:06 +0800 Message-Id: <20220427090906.2257940-1-jinxiaobo@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign3 X-QQ-Bgrelay: 1 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org sr_get_events() has been called before udev starts when SCSI CDROM is built-in and AHCI SATA is bulit-in,so sr events propagated to user space are not handled. if both is loadable, udev will handle sr events, some cdroms may eject. We need call sr_get_events() once before device_add_disk() to keep the same result, whether both are built-in or loadable. Signed-off-by: jinxiaobo --- drivers/scsi/sr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index cbd92891a762..043b3ab72d7a 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -676,6 +676,7 @@ static int sr_probe(struct device *dev) set_capacity(disk, cd->capacity); disk->private_data = cd; + sr_get_events(sdev); if (register_cdrom(disk, &cd->cdi)) goto fail_minor;