From patchwork Thu Jan 12 22:24:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Bostic X-Patchwork-Id: 9514301 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 0DAAF601E7 for ; Thu, 12 Jan 2017 22:24:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 125EE28709 for ; Thu, 12 Jan 2017 22:24:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037A128714; Thu, 12 Jan 2017 22:24:48 +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=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E54628709 for ; Thu, 12 Jan 2017 22:24:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cRnnY-0001sU-Jg; Thu, 12 Jan 2017 22:24:44 +0000 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cRnnU-0001qe-UU for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2017 22:24:42 +0000 Received: by mail-oi0-x241.google.com with SMTP id j15so4814831oih.0 for ; Thu, 12 Jan 2017 14:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+E5uu3RZOC21+2sz/CDLybr9cKGC8MwNRH5qzUuDe8o=; b=Na3jeXXZt6tmRlY6QK51m3x1R2zjbiHY+tShrKsH4yA0hzna+Ow8eklCB5KN5PCLVd XId/yhd/wuG4d3kMSZt/2CIh+WE6oJOABsMptvv/zujhqe94Xoh2MTujDX+v7MYs0Bh8 3kF+knaitsscLS/kHlgZcsClC1HLFJ3y3aKxDO5s3qat+WeKJvcNEKfysbBcoqkklCWG txbA8MUCixcWB7vI7MYubY0zLzVLeoKKuVjPjSWyHNPX4EzLFHCXztnoSOqKro+oujcU KOu3RfeYtw7XxzuQzn9QS3kASJSPYNlfLLJ8fUIxuDM6nUU7IXLfR0bnqYVGXnrx9475 Qseg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+E5uu3RZOC21+2sz/CDLybr9cKGC8MwNRH5qzUuDe8o=; b=bvaylhOyAzDsqLP5sx/8vR+9As8Cp1OV/f1IufZ3iiO3mPhsZw3Ie4sRUSj1aKGK8G dYP8M/QzPFSjy/zqibmFJFTdV4ZdUo4JwvMmZ5SwGBOauFXdzDkh6sZKVAvyAReSatAl 9hGNuJSfE69FPpt8t/UKLvYIxbn5+DWFYQrYO7nrNJGNd/VSiurjPGkiUo+vmHBgWU/H nkxygoh1pr4iUB7hx2eMnbpXMih4HbHthzgQkh7ei3iOxb0YxRk+gvO5c7HPrIMdm4jn vXIc5YC6mK5UPk3lModWURTk6/LcE6oazio6HOVj1+PSiwrP51qihywPIHTmqFZj5+Sy fDkQ== X-Gm-Message-State: AIkVDXKLY9h9dWjat/8EYqKgdgriMxTTiUhNzwix5PvuMBH9UvAdeZo0QE50x/PCreQ8VQ== X-Received: by 10.202.231.77 with SMTP id e74mr1244840oih.85.1484259858423; Thu, 12 Jan 2017 14:24:18 -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 f68sm5023720oih.20.2017.01.12.14.24.16 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 12 Jan 2017 14:24:17 -0800 (PST) From: christopher.lee.bostic@gmail.com To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, gregkh@linuxfoundation.org, mturquette@baylibre.com, geert+renesas@glider.be, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, joel@jms.id.au, jk@ozlabs.org, linux-kernel@vger.kernel.org, andrew@aj.id.au, alistair@popple.id.au, benh@kernel.crashing.org Subject: [PATCH v2 03/18] drivers/fsi: Add fsi master definition Date: Thu, 12 Jan 2017 16:24:14 -0600 Message-Id: <1484259854-79127-1-git-send-email-christopher.lee.bostic@gmail.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170112_142441_044176_00EE1FB9 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Bostic 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 Signed-off-by: Jeremy Kerr Signed-off-by: Chris Bostic --- V2 - Change atomic global keeping track of master number to ida simple interface. - Add valid pointer checks on entry to register and unregister. --- drivers/fsi/fsi-core.c | 28 ++++++++++++++++++++++++++++ drivers/fsi/fsi-master.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 drivers/fsi/fsi-master.h diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 3d55bd5..c7469fe 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -16,6 +16,34 @@ #include #include #include +#include + +#include "fsi-master.h" + +static DEFINE_IDA(master_ida); + +/* FSI master support */ + +int fsi_master_register(struct fsi_master *master) +{ + if (!master || !master->dev) + return -EINVAL; + + master->idx = ida_simple_get(&master_ida, 0, 0, GFP_KERNEL); + get_device(master->dev); + return 0; +} +EXPORT_SYMBOL_GPL(fsi_master_register); + +void fsi_master_unregister(struct fsi_master *master) +{ + if (!master || !master->dev) + return; + + ida_simple_remove(&master_ida, master->idx); + put_device(master->dev); +} +EXPORT_SYMBOL_GPL(fsi_master_unregister); /* FSI core & Linux bus type definitions */ diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h new file mode 100644 index 0000000..e75a810 --- /dev/null +++ b/drivers/fsi/fsi-master.h @@ -0,0 +1,37 @@ +/* + * FSI master definitions. These comprise the core <--> master interface, + * to allow the core to interact with the (hardware-specific) masters. + * + * Copyright (C) IBM Corporation 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef DRIVERS_FSI_MASTER_H +#define DRIVERS_FSI_MASTER_H + +#include + +struct fsi_master { + struct device *dev; + int idx; + int n_links; + int (*read)(struct fsi_master *, int link, + uint8_t slave, uint32_t addr, + void *val, size_t size); + int (*write)(struct fsi_master *, int link, + uint8_t slave, uint32_t addr, + const void *val, size_t size); +}; + +extern int fsi_master_register(struct fsi_master *master); +extern void fsi_master_unregister(struct fsi_master *master); + +#endif /* DRIVERS_FSI_MASTER_H */