Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp108596pxk; Thu, 24 Sep 2020 00:24:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww+UawlUsv+nojkEah84Kj9feL0Hyx1B3BfkUljgxnciErAnXzp/tBEgTvdThsUSzdASom X-Received: by 2002:a50:84a2:: with SMTP id 31mr3264618edq.138.1600932274445; Thu, 24 Sep 2020 00:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600932274; cv=none; d=google.com; s=arc-20160816; b=TrdHoOKOhxGCtodL2x6+u/OuIJw0ZxVMtyj7fN2wZKImTzzvse9f26e4307iKCvK+g NyY4ZK/hsz+hD4Z9tAyka+dL2P/8v3FvrKS9toR68ife2qnrH6ttGRDV4fqupdVBkd0Y 6Yo3Pnr61E56wfArIMngcMGAB5pnRaK8Vko0PYCS6AhsEO9tL8e86/uRTOA0rdJwlCuI roFhchaH0zKHy+9dY/J6Hu89y8XWXvjWJQfB53HWJY9uKQ5GYFOzASbywgcMoZwX5bz0 7zCyFTbzAVN9cvz3vl3o/jFTVqJHKxtSZxvy4o654Eo6vCxu6xMxjTgjOG/pZ5XPxdeS 9zOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=eiXSRRV3D/hx3Tqji6VNTmS+jCoI6Pp2GgFTTxvZRBQ=; b=mhelwZ63HjTaJH/LjefCe5n9kgZhpT8bEvOcUPia9G3oGicEjmwUKVNQuoQvDTgJwi fB9ez1M9fFj9WVX9Vk6N24RN9ZOJO1QLkIrFOSFimGfv1BHggGqr9G36tLeyQjtE1Xlv J2yXOeAWw74t8DLD0tmhRbsS6ntSXilBoP6eptkA2m2KBhM23lJd7cTb2zZmgexYb4gS 0CzwMiaxYKw2wSxyTlzC1TElQ7J9Bq/wwiXtnDQk1JgBW00Fqe6EObpPsF6Ro2tOZU+u 4ecviPOZuVJ78yeV256+y2vDLtaT9ye+RLu/KL/gO0tSsu1xZ3s0lKhajnih7/ovjVXz 5DeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy17si1442599ejb.339.2020.09.24.00.24.10; Thu, 24 Sep 2020 00:24:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbgIXHVd (ORCPT + 99 others); Thu, 24 Sep 2020 03:21:33 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:39943 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726993AbgIXHVc (ORCPT ); Thu, 24 Sep 2020 03:21:32 -0400 Received: by mail-oi1-f195.google.com with SMTP id t76so2666492oif.7; Thu, 24 Sep 2020 00:21:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eiXSRRV3D/hx3Tqji6VNTmS+jCoI6Pp2GgFTTxvZRBQ=; b=fmJJY7WJB7fBnFKrVm9ORy3BW9OM8ULy6TmE82G8R17Hlmqw7ttO1ewv1tijb6QrYh Ca66dDBJGSsOR1w+WwUGfqqWK7bxQk2bcy1saM3+tmWoaJ/FpA5yEGMFUQyoY577tcz3 GhWyqyimZfyJ0BF8So5HAQm0y2mLcQ/F2AMhfzDuSuQ3xjEaD5czfPDA/C6+4TuIjkTC B+f0FH5Gj8FH9U4K757IJyZBQ3KLN2hWZCe5KgmfFD8q2abYG3uh+Sub0z0ZN7ISwInG 87m2P/5Ui7O79kBHgxTY0o+K9eoTqDauHxbEHvfGTtx/onrpK2XqI7KNGYbPj3dLE7TW PzEQ== X-Gm-Message-State: AOAM532AHEAuf7Zy6xo7la1IbppoK3YmuFSJengig40+89XkcSEB2SV3 q5UQlQ5PYHLydn5Q64j1/Fqeuzyts/5mA8w3DHnIgMAU X-Received: by 2002:aca:52d6:: with SMTP id g205mr1770983oib.54.1600932091971; Thu, 24 Sep 2020 00:21:31 -0700 (PDT) MIME-Version: 1.0 References: <3cf40b9df80a99a3eee6d3af79437016038f0a44.1600051331.git.fthain@telegraphics.com.au> In-Reply-To: From: Geert Uytterhoeven Date: Thu, 24 Sep 2020 09:21:20 +0200 Message-ID: Subject: Re: [PATCH v2] ide/macide: Convert Mac IDE driver to platform driver To: Finn Thain Cc: "David S. Miller" , Bartlomiej Zolnierkiewicz , Joshua Thompson , linux-m68k , Linux Kernel Mailing List , linux-ide@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Finn, On Thu, Sep 24, 2020 at 3:07 AM Finn Thain wrote: > On Wed, 16 Sep 2020, Finn Thain wrote: > > 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. > > > > Sorry, I meant to say, "I could have changed ide_host_add() into > ide_host_alloc() followed by ide_host_register() ..." > > > 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"? > > I still think that "if it ain't broke, don't fix it" is actually the > "safe" option for macide.c. But I'm happy to make additional changes, test > them and send v5 if that's preferred. I'm fine with keeping this as-is, as it doesn't really matter for this particular driver. > Looking further at the drivers using ide_host_register(), I see that > falconide.c is missing a set_drvdata() call, while tx4939ide.c calls > set_drvdata() after ide_host_register(). The latter example is not a bug. > > The pattern I used, that is, calling set_drvdata() after ide_host_add(), > is actually more popular among IDE drivers than the pattern you suggested, > that is, set_drvdata() followed by ide_host_register(). Either way, I > don't see any bugs besides the one in falconide.c. > > Regarding falconide.c, my inclination is to send a fix following the more > common pattern (among IDE drivers), as below. I guess that may prompt the > subsystem maintainers to make known their views on the style question. Please do so. Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds