From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755368Ab0IFX7T (ORCPT ); Mon, 6 Sep 2010 19:59:19 -0400 Received: from smtp103.sbc.mail.ne1.yahoo.com ([98.138.84.214]:20948 "HELO smtp103.sbc.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755042Ab0IFX7P (ORCPT ); Mon, 6 Sep 2010 19:59:15 -0400 X-Yahoo-SMTP: fzDSGlOswBCWnIOrNw7KwwK1j9PqyNbe5PtLKiS4dDU.UNl_t6bdEZu9tTLW X-YMail-OSG: YwID2JoVM1lusgJIBD3GTGDDcaQmxFxx_Pz7ZlQr7BY0lAu WEEku2sZdi4_SFGz2Gxc1.4xW3s5IUAddc0xUNyssk1UDynb26qOsGaqiLyw uuZHW.8wcz50LAk.vpu0MvreqZ8DQtLc8h7hnFQEEZWjUILWNoixeW2tEt5n 62fkJd1GDd.67UUCj6Cd4.fj4uFgDBOnGkD3i6juNVhnP8Cehz_QWL.OGcRM qrc6we3t35LzKpvJVnCKUlkCynk62hYHhZ1F0hW5u.qR6yT_YacPW8OFK8tI xmtM5KpejtoZmpd_XQNiJKKQ6Ov2fStX3mTs8i9ze60HYBlndbgJsjwGPU7w EW83lwgP51Nufzn4yug-- X-Yahoo-Newman-Property: ymail-3 From: "Nicholas A. Bellinger" To: linux-scsi , linux-kernel , Douglas Gilbert , Richard Sharpe , Dmitry Torokhov Cc: Christoph Hellwig , FUJITA Tomonori , Mike Christie , Hannes Reinecke , James Bottomley , Greg KH , Nicholas Bellinger Subject: [PATCH v2] scsi_debug: Convert to use root_device_register() and root_device_unregister() Date: Mon, 6 Sep 2010 16:59:11 -0700 Message-Id: <1283817551-23380-1-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.5.6.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Bellinger Hi Dough and Co, This patch updates the scsi_debug virtual LLD to use root_device_register() and root_device_unregister() from include/linux/device.h instead of device_register() and device_unregister() respectively within scsi_debug_init() and scsi_debug_exit() This simply involved converting the static struct device pseudo_primary into a pointer that is setup by the call to root_device_register(). This patch also contains the correct IS_ERR() conditional check of root_device_register() from within scsi_debug_init(). Thanks to Richard Sharpe and Dmitry Torokhov for their help with this item. Signed-off-by: Nicholas A. Bellinger --- drivers/scsi/scsi_debug.c | 27 +++++++++------------------ 1 files changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index b02bdc6..86d483e 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -3207,23 +3207,14 @@ static void do_remove_driverfs_files(void) driver_remove_file(&sdebug_driverfs_driver, &driver_attr_add_host); } -static void pseudo_0_release(struct device *dev) -{ - if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) - printk(KERN_INFO "scsi_debug: pseudo_0_release() called\n"); -} - -static struct device pseudo_primary = { - .init_name = "pseudo_0", - .release = pseudo_0_release, -}; +struct device *pseudo_primary; static int __init scsi_debug_init(void) { unsigned long sz; int host_to_add; int k; - int ret; + int ret = 0; switch (scsi_debug_sector_size) { case 512: @@ -3352,10 +3343,10 @@ static int __init scsi_debug_init(void) map_region(0, 2); } - ret = device_register(&pseudo_primary); - if (ret < 0) { - printk(KERN_WARNING "scsi_debug: device_register error: %d\n", - ret); + pseudo_primary = root_device_register("pseudo_0"); + if (IS_ERR(pseudo_primary)) { + printk(KERN_WARNING "scsi_debug: root_device_register() error\n"); + ret = PTR_ERR(pseudo_primary); goto free_vm; } ret = bus_register(&pseudo_lld_bus); @@ -3402,7 +3393,7 @@ del_files: bus_unreg: bus_unregister(&pseudo_lld_bus); dev_unreg: - device_unregister(&pseudo_primary); + root_device_unregister(pseudo_primary); free_vm: if (map_storep) vfree(map_storep); @@ -3423,7 +3414,7 @@ static void __exit scsi_debug_exit(void) do_remove_driverfs_files(); driver_unregister(&sdebug_driverfs_driver); bus_unregister(&pseudo_lld_bus); - device_unregister(&pseudo_primary); + root_device_unregister(pseudo_primary); if (dif_storep) vfree(dif_storep); @@ -3474,7 +3465,7 @@ static int sdebug_add_adapter(void) spin_unlock(&sdebug_host_list_lock); sdbg_host->dev.bus = &pseudo_lld_bus; - sdbg_host->dev.parent = &pseudo_primary; + sdbg_host->dev.parent = pseudo_primary; sdbg_host->dev.release = &sdebug_release_adapter; dev_set_name(&sdbg_host->dev, "adapter%d", scsi_debug_add_host); -- 1.5.6.5