From patchwork Fri Dec 21 20:10:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 10741017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 746F513B5 for ; Fri, 21 Dec 2018 20:10:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 653212848B for ; Fri, 21 Dec 2018 20:10:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58CD428538; Fri, 21 Dec 2018 20:10:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CA982848B for ; Fri, 21 Dec 2018 20:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391741AbeLUUKR (ORCPT ); Fri, 21 Dec 2018 15:10:17 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37258 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729035AbeLUUKQ (ORCPT ); Fri, 21 Dec 2018 15:10:16 -0500 Received: by mail-pl1-f194.google.com with SMTP id b5so2958928plr.4 for ; Fri, 21 Dec 2018 12:10:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lt9FvTpgStJOyqqnXY0Wnnce4CRGicf9dMiO13VI9JY=; b=ejuOFVtbK32V6TO4vzGgC/EgWIZFLUjeSRG/4iv2psFeXf6vnQPhzvBY2h4p9WovLt uEQSQ6e8ZKhS7krSI26Xzf8HuAYPhiXz/NJfM81LogUDs88j7m6IBXf2bBvoxqN8Nsgv s1iTvdSfcaIP0djcN/E2J228rtUSUnRVSFfs0= 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:in-reply-to :references; bh=Lt9FvTpgStJOyqqnXY0Wnnce4CRGicf9dMiO13VI9JY=; b=J3+NCUKNL4G98wIbh0D0TeDvwHBhb6LBnrNtvDM49R1eSIEdar2S/0k5JWWNxjDNbr HP9UxJF5W8BwuONE/aw+M2F9wQmoid3XzA368udef5wgw9EVt5MPzjUh0mXn/588dZgp msl6PO3u68zVidltCT9pwzzaFKe+BVhrGkirNglefZIOGepAdaF9xJ6u+JnnWPit5hhp EviOeSTgXLmLhjUO/Tj8icqlwqxhUI+FMqlfOETQo6HsMPcuNDEdtuIld9t4rbVzWkAl 5DJVImdplhJhx1atlV00O6gzG5WlmLsFfThCwQks9GCl0jsRR7zE5kFolpfcSW8dcOdP xl3A== X-Gm-Message-State: AJcUukdrDiVGWUP674oVXdFVpHk6wWmQ4rKaWbGyIgWQ8TJb2yQTuofM 7lclMcjE6/DLvQYQYBDpSlh+Gg== X-Google-Smtp-Source: ALg8bN7UovACwqAuu/438jnBRkm904vff5vgv7E7nzPEVB9WRPmdX/ukoIFO5Vc0XNLlt1MUuyMp0w== X-Received: by 2002:a17:902:6948:: with SMTP id k8mr3869361plt.2.1545423016252; Fri, 21 Dec 2018 12:10:16 -0800 (PST) Received: from evgreen2.mtv.corp.google.com ([2620:15c:202:201:ffda:7716:9afc:1301]) by smtp.gmail.com with ESMTPSA id o1sm35300406pgn.63.2018.12.21.12.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Dec 2018 12:10:15 -0800 (PST) From: Evan Green To: Andy Gross , Bjorn Andersson Cc: Brian Norris , Ben Chan , Evan Green , linux-arm-msm@vger.kernel.org, David Brown , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] soc: qcom: rmtfs-mem: Add class to enable uevents Date: Fri, 21 Dec 2018 12:10:00 -0800 Message-Id: <20181221201001.160613-2-evgreen@chromium.org> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181221201001.160613-1-evgreen@chromium.org> References: <20181221201001.160613-1-evgreen@chromium.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the qcom_rmtfs_memN devices are entirely invisible to the udev world. Add a class to the rmtfs device so that uevents fire when the device is added. Signed-off-by: Evan Green Reviewed-by: Brian Norris Reviewed-by: Bjorn Andersson --- Changes in v2: - Moved class registration/deregistration into init/exit routines (Brian) drivers/soc/qcom/rmtfs_mem.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index 97bb5989aa211..99a1363ece254 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -132,6 +132,11 @@ static int qcom_rmtfs_mem_release(struct inode *inode, struct file *filp) return 0; } +static struct class rmtfs_class = { + .owner = THIS_MODULE, + .name = "rmtfs", +}; + static const struct file_operations qcom_rmtfs_mem_fops = { .owner = THIS_MODULE, .open = qcom_rmtfs_mem_open, @@ -199,8 +204,8 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) dev_set_name(&rmtfs_mem->dev, "qcom_rmtfs_mem%d", client_id); rmtfs_mem->dev.id = client_id; + rmtfs_mem->dev.class = &rmtfs_class; rmtfs_mem->dev.devt = MKDEV(MAJOR(qcom_rmtfs_mem_major), client_id); - ret = cdev_device_add(&rmtfs_mem->cdev, &rmtfs_mem->dev); if (ret) { dev_err(&pdev->dev, "failed to add cdev: %d\n", ret); @@ -239,7 +244,6 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev); put_device: put_device(&rmtfs_mem->dev); - return ret; } @@ -258,7 +262,6 @@ static int qcom_rmtfs_mem_remove(struct platform_device *pdev) cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev); put_device(&rmtfs_mem->dev); - return 0; } @@ -277,32 +280,42 @@ static struct platform_driver qcom_rmtfs_mem_driver = { }, }; -static int qcom_rmtfs_mem_init(void) +static int __init qcom_rmtfs_mem_init(void) { int ret; + ret = class_register(&rmtfs_class); + if (ret) + return ret; + ret = alloc_chrdev_region(&qcom_rmtfs_mem_major, 0, QCOM_RMTFS_MEM_DEV_MAX, "qcom_rmtfs_mem"); if (ret < 0) { pr_err("qcom_rmtfs_mem: failed to allocate char dev region\n"); - return ret; + goto unregister_class; } ret = platform_driver_register(&qcom_rmtfs_mem_driver); if (ret < 0) { pr_err("qcom_rmtfs_mem: failed to register rmtfs_mem driver\n"); - unregister_chrdev_region(qcom_rmtfs_mem_major, - QCOM_RMTFS_MEM_DEV_MAX); + goto unregister_chrdev; } + return 0; + +unregister_chrdev: + unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX); +unregister_class: + class_unregister(&rmtfs_class); return ret; } module_init(qcom_rmtfs_mem_init); -static void qcom_rmtfs_mem_exit(void) +static void __exit qcom_rmtfs_mem_exit(void) { platform_driver_unregister(&qcom_rmtfs_mem_driver); unregister_chrdev_region(qcom_rmtfs_mem_major, QCOM_RMTFS_MEM_DEV_MAX); + class_unregister(&rmtfs_class); } module_exit(qcom_rmtfs_mem_exit);