From patchwork Wed Sep 24 15:13:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dolev Raviv X-Patchwork-Id: 4967141 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 92D29BEEA5 for ; Wed, 24 Sep 2014 15:14:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6485420295 for ; Wed, 24 Sep 2014 15:14:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 85444202A1 for ; Wed, 24 Sep 2014 15:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754438AbaIXPOm (ORCPT ); Wed, 24 Sep 2014 11:14:42 -0400 Received: from smtp.codeaurora.org ([198.145.11.231]:48507 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754040AbaIXPOl (ORCPT ); Wed, 24 Sep 2014 11:14:41 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 77F261408E9; Wed, 24 Sep 2014 15:14:41 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 6B6FA1408EF; Wed, 24 Sep 2014 15:14:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from lx-draviv2.mea.qualcomm.com (unknown [185.23.60.4]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: draviv@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3F2AB1408E9; Wed, 24 Sep 2014 15:14:39 +0000 (UTC) From: Dolev Raviv To: James.Bottomley@HansenPartnership.com, hch@infradead.org Cc: linux-scsi@vger.kernel.org, linux-scsi-owner@vger.kernel.org, linux-arm-msm@vger.kernel.org, santoshsy@gmail.com, Subhash Jadavani , Dolev Raviv Subject: [PATCH V5 02/17] scsi: sysfs: don't add scsi_device if its already added Date: Wed, 24 Sep 2014 18:13:58 +0300 Message-Id: <1411571653-22729-3-git-send-email-draviv@codeaurora.org> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1411571653-22729-1-git-send-email-draviv@codeaurora.org> References: <1411571653-22729-1-git-send-email-draviv@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Subhash Jadavani If LLD has added scsi device (by calling scsi_add_device) before scheduling async scsi_scan_host then scsi_finish_async_scan() will end up calling scsi_sysfs_add_sdev for scsi device which was already added by LLD. This patch fixes this issue by adding a check at the start of scsi_sysfs_add_sdev() to skip the device add if it's already visible to rest of the kernel. Signed-off-by: Subhash Jadavani Signed-off-by: Dolev Raviv diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 3524b68..00890b3 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1027,6 +1027,9 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) struct request_queue *rq = sdev->request_queue; struct scsi_target *starget = sdev->sdev_target; + if (sdev->is_visible) + return 0; + error = scsi_device_set_state(sdev, SDEV_RUNNING); if (error) return error;