From patchwork Wed Aug 17 07:15:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 9285273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E56160459 for ; Wed, 17 Aug 2016 07:23:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECF7528842 for ; Wed, 17 Aug 2016 07:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E14B52887A; Wed, 17 Aug 2016 07:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9123028842 for ; Wed, 17 Aug 2016 07:23:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbcHQHXA (ORCPT ); Wed, 17 Aug 2016 03:23:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38608 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753609AbcHQHXA (ORCPT ); Wed, 17 Aug 2016 03:23:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FB433B71E; Wed, 17 Aug 2016 07:16:10 +0000 (UTC) Received: from lemon.nay.redhat.com (dhcp-15-153.nay.redhat.com [10.66.15.153]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7H7FGWE008426; Wed, 17 Aug 2016 03:16:05 -0400 From: Fam Zheng To: linux-kernel@vger.kernel.org Cc: linux-nvme@lists.infradead.org, Keith Busch , Michael Ellerman , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, "Michael S. Tsirkin" , linux-block@vger.kernel.org, Brian Norris , Paul Mackerras , linux-mtd@lists.infradead.org, "Ed L. Cashin" , Jens Axboe , Minchan Kim , virtualization@lists.linux-foundation.org, Sergey Senozhatsky , Nitin Gupta , David Woodhouse Subject: [PATCH 10/15] mtd: Pass attribute group to device_add_disk Date: Wed, 17 Aug 2016 15:15:10 +0800 Message-Id: <1471418115-3654-11-git-send-email-famz@redhat.com> In-Reply-To: <1471418115-3654-1-git-send-email-famz@redhat.com> References: <1471418115-3654-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 17 Aug 2016 07:16:10 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously after device_add_disk returns, the KOBJ_ADD uevent is already emitted. Adding attributes after that is a poor usage of kobject, and in practice may result in race conditions with userspace, for example udev checks availability of certain attributes and initializes /dev entries conditionally. device_add_disk can handle adding attribute group better, so use it. Signed-off-by: Fam Zheng --- drivers/mtd/mtd_blkdevs.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 4ff9381..fc9265d 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -434,13 +434,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) if (new->readonly) set_disk_ro(gd, 1); - device_add_disk(&new->mtd->dev, gd, NULL); - - if (new->disk_attributes) { - ret = sysfs_create_group(&disk_to_dev(gd)->kobj, - new->disk_attributes); - WARN_ON(ret); - } + device_add_disk(&new->mtd->dev, gd, new->disk_attributes); return 0; error4: blk_cleanup_queue(new->rq);