From patchwork Wed Dec 7 00:14:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Bostic X-Patchwork-Id: 9463573 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 E6A2660459 for ; Wed, 7 Dec 2016 00:18:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8A502849C for ; Wed, 7 Dec 2016 00:18:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD417284E9; Wed, 7 Dec 2016 00:18:08 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 56EF72849C for ; Wed, 7 Dec 2016 00:18:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEPub-00068n-FV; Wed, 07 Dec 2016 00:16:41 +0000 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEPtP-0004r9-Vy for linux-arm-kernel@lists.infradead.org; Wed, 07 Dec 2016 00:15:29 +0000 Received: by mail-oi0-x243.google.com with SMTP id u15so43563298oie.3 for ; Tue, 06 Dec 2016 16:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GfqLaQgOscRKDP4r8fgyPwPEPezW6xXhdJx2iy1kc9U=; b=r4CmOPD9zuE76g1DSFwErLgsjstPDyDUOQP9hz8ZdBAWh37tbXWTouCF/j3VRR2YnK 2d6+vnEiQdDcwBTaFdRVx6ZadPuSeh8P7G+fk9mFn97DlxI5UkKlN3A8pNU9FY1iwltJ x/2l6dU/hNn5C/zolR3sS3Ode2tKpdxcZmvR4188PIuZ7WYh3PZfs2Ly/n3Iq32ugBQ4 CpLS1nVgyuOXrOwbCqZIZX8HlGHjwr1aLhwLoq4j10EogNbsnZc5e5e2eauwia9B1Nfq Dd6MvmIZa9LzWJ/DF6OIvT9i3DDxl4VnpVX0DxMza3RsVotkJZ1L7juusKmGTq6LRKWn +pDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GfqLaQgOscRKDP4r8fgyPwPEPezW6xXhdJx2iy1kc9U=; b=PiOJShSS/sNTet+Iu7dBO+KELZFyD57KIgl7FPgSAQspS8hGmMtq9/R7kwt5u0TYLQ G4yZj8FqF7swvLF4JFfgKW2xaeIccKPNBa91/LOsZ98zxu5GgsP2DjYEpBlMTkabB/Jo HhU7Xv3wcxgqLH3jTY2Jh4W+vALS5LbsrN6Y3HSsetA4WZMKYRQY0yhtkaMxrz4EDQHF NOsBY9uha/tjz7Vp8ne3iWKGx0Q/LRLkR5EKDTFrXLvB+Au9B1rCbiKnrcy3Sas3MXcJ CETBvYLCcZc+TAC/vuKlyYWhni4kghxngBC5Deq0UGejnmvefcsTklY3YVdJH+e4vRh8 Hozg== X-Gm-Message-State: AKaTC02VZ1HT1XFaRm+/XYpmfNoOHSyfKTkk+wZPq84zBNwLBzZ6aeFMc0r5G49Q3RapFg== X-Received: by 10.157.1.140 with SMTP id e12mr37825753ote.42.1481069706935; Tue, 06 Dec 2016 16:15:06 -0800 (PST) Received: from Christophers-MacBook-Pro.local.com (45-20-192-79.lightspeed.austtx.sbcglobal.net. [45.20.192.79]) by smtp.gmail.com with ESMTPSA id r102sm8568294ota.11.2016.12.06.16.15.05 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 06 Dec 2016 16:15:06 -0800 (PST) From: Chris Bostic To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, gregkh@linuxfoundation.org, sre@kernel.org, mturquette@baylibre.com, geert+renesas@glider.be, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 03/16] drivers/fsi: add driver to device matches Date: Tue, 6 Dec 2016 18:14:24 -0600 Message-Id: <1481069677-53660-4-git-send-email-christopher.lee.bostic@gmail.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1481069677-53660-1-git-send-email-christopher.lee.bostic@gmail.com> References: <1481069677-53660-1-git-send-email-christopher.lee.bostic@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161206_161528_120558_D8FD0285 X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@aj.id.au, alistair@popple.id.au, linux-kernel@vger.kernel.org, Chris Bostic , Jeremy Kerr , benh@kernel.crashing.org, joel@jms.id.au MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeremy Kerr Driver bind to devices based on the engine types & (optional) versions. Signed-off-by: Jeremy Kerr Signed-off-by: Chris Bostic --- drivers/fsi/fsi-core.c | 21 +++++++++++++++++++++ include/linux/fsi.h | 21 +++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 3e45306..3d55bd5 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -19,8 +19,29 @@ /* FSI core & Linux bus type definitions */ +static int fsi_bus_match(struct device *dev, struct device_driver *drv) +{ + struct fsi_device *fsi_dev = to_fsi_dev(dev); + struct fsi_driver *fsi_drv = to_fsi_drv(drv); + const struct fsi_device_id *id; + + if (!fsi_drv->id_table) + return 0; + + for (id = fsi_drv->id_table; id->engine_type; id++) { + if (id->engine_type != fsi_dev->engine_type) + continue; + if (id->version == FSI_VERSION_ANY || + id->version == fsi_dev->version) + return 1; + } + + return 0; +} + struct bus_type fsi_bus_type = { .name = "fsi", + .match = fsi_bus_match, }; EXPORT_SYMBOL_GPL(fsi_bus_type); diff --git a/include/linux/fsi.h b/include/linux/fsi.h index f73886a..273cbf6 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h @@ -18,11 +18,28 @@ #include struct fsi_device { - struct device dev; + struct device dev; + u8 engine_type; + u8 version; }; +struct fsi_device_id { + u8 engine_type; + u8 version; +}; + +#define FSI_VERSION_ANY 0 + +#define FSI_DEVICE(t) \ + .engine_type = (t), .version = FSI_VERSION_ANY, + +#define FSI_DEVICE_VERSIONED(t, v) \ + .engine_type = (t), .version = (v), + + struct fsi_driver { - struct device_driver drv; + struct device_driver drv; + const struct fsi_device_id *id_table; }; #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev)