From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C1DAC43461 for ; Tue, 15 Sep 2020 22:57:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12B7020770 for ; Tue, 15 Sep 2020 22:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727499AbgIOW5h (ORCPT ); Tue, 15 Sep 2020 18:57:37 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:46572 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727419AbgIOW5E (ORCPT ); Tue, 15 Sep 2020 18:57:04 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 9B1CF272F2; Tue, 15 Sep 2020 18:56:57 -0400 (EDT) Date: Wed, 16 Sep 2020 08:56:58 +1000 (AEST) From: Finn Thain To: Geert Uytterhoeven cc: "David S. Miller" , Bartlomiej Zolnierkiewicz , Joshua Thompson , linux-m68k , Linux Kernel Mailing List , linux-ide@vger.kernel.org Subject: Re: [PATCH v2] ide/macide: Convert Mac IDE driver to platform driver In-Reply-To: Message-ID: References: <3cf40b9df80a99a3eee6d3af79437016038f0a44.1600051331.git.fthain@telegraphics.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Sep 2020, Geert Uytterhoeven wrote: > > > > --- a/drivers/ide/macide.c > > > > +++ b/drivers/ide/macide.c > > > > > > > @@ -109,42 +110,61 @@ static const char *mac_ide_name[] = > > > > * Probe for a Macintosh IDE interface > > > > */ > > > > > > > > -static int __init macide_init(void) > > > > +static int mac_ide_probe(struct platform_device *pdev) > > > > { > > > > > > > printk(KERN_INFO "ide: Macintosh %s IDE controller\n", > > > > mac_ide_name[macintosh_config->ide_type - 1]); > > > > > > > > - macide_setup_ports(&hw, base, irq); > > > > + macide_setup_ports(&hw, mem->start, irq->start); > > > > > > > > - return ide_host_add(&d, hws, 1, NULL); > > > > + rc = ide_host_add(&d, hws, 1, &host); > > > > + if (rc) > > > > + return rc; > > > > + > > > > + platform_set_drvdata(pdev, host); > > > > > > Move one up, to play it safe? > > > > > > > You mean, before calling ide_host_add? The 'host' pointer is uninitialized > > prior to that call. > > Oh right, so the IDE subsystem doesn't let you use the drvdata inside > your driver (besides in remove()) in a safe way :-( > The IDE subsystem does allow other patterns here. I could have changed ide_host_alloc() into ide_host_register() followed by ide_host_add() but I could not see any benefit from that change. A quick search for "platform_device" shows that the driver does not use any uninitialized driver_data pointer (because ide_ifr is a global). In your message of September 9th you readily reached the same conclusion when you reviewed v1. If mac_ide_probe() followed the usual pattern it might make review easier (as reviewers may not wish to consider the entire driver) but does that really make the code more "safe"?