From patchwork Sun Jun 20 12:56:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ojaswin Mujoo X-Patchwork-Id: 12333399 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=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 0FE71C48BDF for ; Sun, 20 Jun 2021 12:58:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1FD2610CA for ; Sun, 20 Jun 2021 12:58:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1FD2610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kNU2cQlQZ3zhtyEJiY7xS+PbnELRVxEEHFo74zSkvpQ=; b=IN9FKGrIXxPf7i Y2kMHlEETghU3tuj+sHtYOS0Btl99k+VN1VYnlqpOZWb0a14vf3/mEJL/GZemvX1grC2bdMMYvM/a 2qL+7TlXBAsA/Hpf0JJxadAL2VEwK4v0yOERoWAscIIxL+nok1M9bCVlnvTQL3SZeYziJ1yES/qy8 wkieqe81qosyjGlUd7NC+HSPP2TwpFPim7QgLEexd/CkgX7lGVlKacBZFufjf9iR9KEAterKYT1G4 zY7BfRSBxAwXbGW10qb7kRUrC3Ky6zhIVTldL6OKx2o6YArTXwj2Spue9qS6cBNgxeEBzsiqnzkdS OhcYVwhvbT/WrI24i5ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lux00-0011EO-5V; Sun, 20 Jun 2021 12:56:28 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1luwzu-0011C0-GO for linux-arm-kernel@lists.infradead.org; Sun, 20 Jun 2021 12:56:24 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so10907347pjs.2 for ; Sun, 20 Jun 2021 05:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8D0iPvS5LN4cQHCvsRANY4NqRMLIH6ZhqZliXmE6Nic=; b=j9swlja8fhJH2LV6AulKGsoAFeFWrhiQJcb7ptpSVB7J2hY1MWU+3O689NaBIUIejO 1nR3FpCmUajwkV6tX6dnq9l4WKOg/76S/dotDwnfH3ew9/ceDCHdANJdnJ8+TbksALwk FdTUX3fp9koZABvZlKBoEKySzcJobWrGXilBTu+ikjGkAd0plgzDdU+/+bniB9bGQWA/ TcJCIP7k001MsXzwUB1mQPSkhrUmlZSsZjtcpWjjfEzueIAsdbaSw2xyOedf4fUepDQ8 jltme5ZqY96Sj0n+AMb7cJhMMTxZu3Jfa3y472v7kxMRvVDbDGJwGsJjQKKWMF3tnvOZ vuIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8D0iPvS5LN4cQHCvsRANY4NqRMLIH6ZhqZliXmE6Nic=; b=dAO8BSh67knKYFlqfCshFbhNvhcU4SOHSz1Fk4CjfAQVsnG6J1DH3irf2oi2lItjaf tzWeLQO/gyNbfpZXm6XumBwyKWsNxf2L5Wx3vgpR8028AqKL1ot7PpyZ3pAvgf/ZAryn 3Z09o3GyPe3x1xyn1ZRQi1NXgiUp2wsuI36NpcyMfo8l6Q4dJCLWmdSw75N5j+6Ke9hu /1N+EGHzstmk4yM+IDBNU0ffz3POxlWzveZVAFc0Yxp2uizdJaJk49ggcuLNd1rY+sSK 8tR77UnWTCa7GipbxNz58dtN4LygPZEB1DYkapVHC7TMtHGKcyY2P/zFUfYGDMKHO2Yv vRbw== X-Gm-Message-State: AOAM532uEGpzB7DrUpwvxhoLScwaBctwSoJSzI59WAT5u2zibO5BwxN8 PCtvJWEBMOcD4iXxpUzlRv8= X-Google-Smtp-Source: ABdhPJwsu0EpaSa59gJ+a7O4tSxTxzyQdDE74aLf0wJMj8QKckeTpU5yxCxDY4bBQTLl88/y0C4bOQ== X-Received: by 2002:a17:902:6b04:b029:10d:8c9e:5f56 with SMTP id o4-20020a1709026b04b029010d8c9e5f56mr13511814plk.8.1624193781798; Sun, 20 Jun 2021 05:56:21 -0700 (PDT) Received: from ojas ([122.177.154.120]) by smtp.gmail.com with ESMTPSA id 25sm13906585pgp.51.2021.06.20.05.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jun 2021 05:56:21 -0700 (PDT) Date: Sun, 20 Jun 2021 18:26:10 +0530 From: Ojaswin Mujoo To: nsaenz@kernel.org Cc: gregkh@linuxfoundation.org, stefan.wahren@i2se.com, arnd@arndb.de, dan.carpenter@oracle.com, phil@raspberrypi.com, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] staging: vchiq: Move certain declarations to vchiq_arm.h Message-ID: <7f4e8cfe00db59204b41d5a594143838bf502634.1624185152.git.ojaswin98@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210620_055622_600041_6296274C X-CRM114-Status: GOOD ( 16.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move certain declarations from vchiq_arm.c to vchiq_arm.h to allow code sharing. This will be useful when we eventually separate the vchiq char driver code from platform code, into its own file. Signed-off-by: Ojaswin Mujoo --- .../interface/vchiq_arm/vchiq_arm.c | 66 ++--------------- .../interface/vchiq_arm/vchiq_arm.h | 70 +++++++++++++++++++ 2 files changed, 75 insertions(+), 61 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index f2d8116913f2..8b18f9642e6c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -38,12 +38,6 @@ #undef MODULE_PARAM_PREFIX #define MODULE_PARAM_PREFIX DEVICE_NAME "." -/* Some per-instance constants */ -#define MAX_COMPLETIONS 128 -#define MAX_SERVICES 64 -#define MAX_ELEMENTS 8 -#define MSG_QUEUE_SIZE 128 - #define KEEPALIVE_VER 1 #define KEEPALIVE_VER_MIN KEEPALIVE_VER @@ -51,62 +45,12 @@ int vchiq_arm_log_level = VCHIQ_LOG_DEFAULT; int vchiq_susp_log_level = VCHIQ_LOG_ERROR; -struct user_service { - struct vchiq_service *service; - void __user *userdata; - struct vchiq_instance *instance; - char is_vchi; - char dequeue_pending; - char close_pending; - int message_available_pos; - int msg_insert; - int msg_remove; - struct completion insert_event; - struct completion remove_event; - struct completion close_event; - struct vchiq_header *msg_queue[MSG_QUEUE_SIZE]; -}; - -struct bulk_waiter_node { - struct bulk_waiter bulk_waiter; - int pid; - struct list_head list; -}; - -struct vchiq_instance { - struct vchiq_state *state; - struct vchiq_completion_data_kernel completions[MAX_COMPLETIONS]; - int completion_insert; - int completion_remove; - struct completion insert_event; - struct completion remove_event; - struct mutex completion_mutex; - - int connected; - int closing; - int pid; - int mark; - int use_close_delivered; - int trace; - - struct list_head bulk_waiter_list; - struct mutex bulk_waiter_list_mutex; - - struct vchiq_debugfs_node debugfs_node; -}; - -struct dump_context { - char __user *buf; - size_t actual; - size_t space; - loff_t offset; -}; +DEFINE_SPINLOCK(msg_queue_spinlock); +struct vchiq_state g_state; static struct cdev vchiq_cdev; static dev_t vchiq_devid; -static struct vchiq_state g_state; static struct class *vchiq_class; -static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; static struct platform_device *bcm2835_audio; static struct platform_device *bcm2835_codec; @@ -587,7 +531,7 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, * ***************************************************************************/ -static enum vchiq_status +enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata) { @@ -2215,7 +2159,7 @@ vchiq_fops = { * * Returns 0 on success else returns the error code. */ -static int vchiq_register_chrdev(struct device *parent) +int vchiq_register_chrdev(struct device *parent) { struct device *vchiq_dev; int ret; @@ -2274,7 +2218,7 @@ static int vchiq_register_chrdev(struct device *parent) * vchiq_deregister_chrdev - Deregister and cleanup the vchiq char * driver and device files */ -static void vchiq_deregister_chrdev(void) +void vchiq_deregister_chrdev(void) { device_destroy(vchiq_class, vchiq_devid); cdev_del(&vchiq_cdev); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index f8b1c005af62..bc9af1a0c764 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -14,6 +14,12 @@ #include "vchiq_core.h" #include "vchiq_debugfs.h" +/* Some per-instance constants */ +#define MAX_COMPLETIONS 128 +#define MAX_SERVICES 64 +#define MAX_ELEMENTS 8 +#define MSG_QUEUE_SIZE 128 + enum USE_TYPE_E { USE_TYPE_SERVICE, USE_TYPE_VCHIQ @@ -56,9 +62,63 @@ struct vchiq_drvdata { struct rpi_firmware *fw; }; +struct user_service { + struct vchiq_service *service; + void __user *userdata; + struct vchiq_instance *instance; + char is_vchi; + char dequeue_pending; + char close_pending; + int message_available_pos; + int msg_insert; + int msg_remove; + struct completion insert_event; + struct completion remove_event; + struct completion close_event; + struct vchiq_header *msg_queue[MSG_QUEUE_SIZE]; +}; + +struct bulk_waiter_node { + struct bulk_waiter bulk_waiter; + int pid; + struct list_head list; +}; + +struct vchiq_instance { + struct vchiq_state *state; + struct vchiq_completion_data_kernel completions[MAX_COMPLETIONS]; + int completion_insert; + int completion_remove; + struct completion insert_event; + struct completion remove_event; + struct mutex completion_mutex; + + int connected; + int closing; + int pid; + int mark; + int use_close_delivered; + int trace; + + struct list_head bulk_waiter_list; + struct mutex bulk_waiter_list_mutex; + + struct vchiq_debugfs_node debugfs_node; +}; + +struct dump_context { + char __user *buf; + size_t actual; + size_t space; + loff_t offset; +}; + extern int vchiq_arm_log_level; extern int vchiq_susp_log_level; +extern spinlock_t msg_queue_spinlock; +extern struct vchiq_state g_state; + int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state); @@ -112,4 +172,14 @@ vchiq_instance_get_trace(struct vchiq_instance *instance); extern void vchiq_instance_set_trace(struct vchiq_instance *instance, int trace); +extern void +vchiq_deregister_chrdev(void); + +extern int +vchiq_register_chrdev(struct device *parent); + +extern enum vchiq_status +service_callback(enum vchiq_reason reason, struct vchiq_header *header, + unsigned int handle, void *bulk_userdata); + #endif /* VCHIQ_ARM_H */