Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp545125imu; Fri, 9 Nov 2018 01:57:10 -0800 (PST) X-Google-Smtp-Source: AJdET5eEDyYRA17Ol8vVFkyZCTxOpYUB0Z6gbRsxgRlFPBaZa5DSrO3LM9NaF4zT+Dj7h+NqaHRP X-Received: by 2002:a62:114c:: with SMTP id z73-v6mr8108070pfi.192.1541757430152; Fri, 09 Nov 2018 01:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541757430; cv=none; d=google.com; s=arc-20160816; b=zgbPTErCN8YrYDhgAvFcZq4hjjdcUzgIpbykEXOpTeGDjQcXy4ObFTV1hFuOBy4DW9 NLkygiG9dEgTObNgK+jYMe1WNqju7mK3p9/VtzQOnE/3RCCdRkdfYd5qqTdPIqq/kCq0 C03PRpX3G2IwRdtLDFBG6NxXxor6XJNaMVnHOM/Y5qmtuNJj7hIs3gILAIkTeojUU6Si 6dM10n3uGuQQzMrN9GZz9Q2V9V0pIYlQ8Hzr51a5EGeXNJ4TNnueXiRXukqOyk5I/N3o GLHUsvKafMUoNV9ILXS/G35wEMxnn56TdnoNzd3WtB7s4tpV0m6W4Lowr5FerPDnFSwq XToA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=sgR7TvkiA1mnZNGKKfCKW7uzKfmOp1yYkm3LUZfV3yo=; b=LEQbHx6sVzHO6lsVGkbC7Bd9ILDd6dn+mI3I0nqmlv9v61bUYQTEvAkMeqENpITqqp xbEAC4cNyG7SPpjwssEw/fib1nBnO7EWkSO2svf5TXqQyQd86uiYr7r99WmOCK8WQ2PS cArdtDvP67NaXC0ZNtRemLlkWfRRJQ/vUwkMJPUlbvCC9IpWEKHqIaobgK9F7HURGgHE 3zxzS9nuDUj2990nRCX63L1BKaessLlBHNIxxaP80O8BA+5ItJA3r4e+n85BiZ8+zHVG +Fj28b04G/prTyVQaP+W5EpRxW0ZzIb1tF5vhBWERydSOSySmERd/SLYV7jro78i/zB8 AtEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh6-v6si7249838plb.66.2018.11.09.01.56.55; Fri, 09 Nov 2018 01:57:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728081AbeKITgG (ORCPT + 99 others); Fri, 9 Nov 2018 14:36:06 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:42856 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbeKITgF (ORCPT ); Fri, 9 Nov 2018 14:36:05 -0500 Received: by mail-vs1-f68.google.com with SMTP id b74so679253vsd.9; Fri, 09 Nov 2018 01:56:15 -0800 (PST) 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=sgR7TvkiA1mnZNGKKfCKW7uzKfmOp1yYkm3LUZfV3yo=; b=jbxKIeHjF/KVRr4QzqyoZfLsXntMOdcu8i/0z/BttbOFhvovPWpO0RoeH4I6cA0qtX sWQDjTS+Z5x8r3AiS0N8gbY4MwjlRz68twEb4FkSsZzDGdrxX2HS89wK/eaIQnoKpfOS EobygkQCJXMXastsjq0lqi3rZM430PXmj0IVzLJk3jeItS2CUsCjaEsKs20btnq2wTgk 152X9A7NYDHjjDS4K3ThdfCPQblM+4uXa5eeAJ5ecOqHOiErtxhpn/E0b0KrCifDYetM s7Zd8EbzEaorg68zE1TeNZT328e5L/hMa3buZPqztIWMCYqPyTtYDEKfeWc9HrjJxlxP Iw1w== X-Gm-Message-State: AGRZ1gLppnB7e2dYQcBJTC8xdBIFUqulYzkc/bpmP726fb2eu+EypDER q7kVIxDMuT3viXy7jW53j07z/rzFXPyA10qYbnE= X-Received: by 2002:a67:f43:: with SMTP id 64mr3575840vsp.166.1541757374523; Fri, 09 Nov 2018 01:56:14 -0800 (PST) MIME-Version: 1.0 References: <20181106183609.207702-1-sboyd@kernel.org> <20181106183609.207702-2-sboyd@kernel.org> <154161585170.88331.1822872519370217248@swboyd.mtv.corp.google.com> In-Reply-To: <154161585170.88331.1822872519370217248@swboyd.mtv.corp.google.com> From: Geert Uytterhoeven Date: Fri, 9 Nov 2018 10:56:01 +0100 Message-ID: Subject: Re: [PATCH 1/4] of/device: Add a way to probe drivers by match data To: Stephen Boyd Cc: Rob Herring , Michael Turquette , Linux Kernel Mailing List , Linux ARM , linux-clk , linux-mediatek@lists.infradead.org, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Matthias Brugger , ryder.lee@mediatek.com, Frank Rowand Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephen, On Wed, Nov 7, 2018 at 7:37 PM Stephen Boyd wrote: > Quoting Rob Herring (2018-11-06 12:44:52) > > On Tue, Nov 6, 2018 at 12:36 PM Stephen Boyd wrote: > > > We have a handful of clk drivers that have a collection of slightly > > > variant device support keyed off of the compatible string. In each of > > > these drivers, we demux the variant and then call the "real" probe > > > function based on whatever is stored in the match data for that > > > compatible string. Let's generalize this function so that it can be > > > re-used as the platform_driver probe function directly. > > > > This looks really hacky to me. It sounds kind of general, but really > > only works if we have match data that's a single function and we lose > > any type checking on the function. > > I don't know what this means. Are you saying that we lose the ability to > type check the function pointer stored in the data member? I don't have > a good answer for this besides it's not any worse than the status quo > for the mediatek drivers. The .data field has always been void *, and is used for storing different things, depending on the driver. It's already up to the driver writer to get that right. > One alternative is to add a DT only array to the platform_driver struct > that has the platform driver probe function type and matches the index > in the of_device_id table. Then we can add some logic into > platform_drv_probe() to look for this table being set and find the probe > function to call. Then we still have match data for anything that wants > that (maybe it could be passed in to the probe function) at the cost of > having another array. I don't have a use-case for this right now so I'm > not sure this is a great idea. > > struct of_platform_driver_probe_func { > int (*probe)(struct platform_device *pdev); > }; > > struct of_platform_driver_probe_func mtk_probes[] = { > mtk_probe1, > mtk_probe2, > mtk_probe3, > }; > > struct platform_driver mtk_driver = { > .of_probes = &mtk_probes; > .driver = { > .name = "mtk-foo"; > .of_match_table = mtk_match_table, > }, > }; This looks worse to me: people tend to be very good at keeping multiple arrays in sync :-( 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