From patchwork Fri Mar 15 18:49:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13593888 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 177A3C54E58 for ; Fri, 15 Mar 2024 18:50:20 +0000 (UTC) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p1BtTsGHdKphD92fKHMfTdHZ60iuU6hHDgSf5LUS+yw=; b=WyKDP2GFS2cSfv Ivi27F/se6A9qmB7Q2nC0gfMyO/lfPe8q7nZKgiBDHKhJNu349x/VFaSm94UuKxoSPOoXAf6t+gNf V5jmOWRqR3IEdXFBAzoSeRjXDI45+DIylJYF2xOAhfWmJn8IzX8VBwTUa9udF2qv+YpxX/NWqdIRL NEwYVVPRuBdgvS2//z+kX9x4AW0uHXqlwUfb9n4ADmcKAGySFknGjQxzgPLbxsBNZ9d/TB6jaqOtu EoZ6zWNtutnUFdga9UJXShP3KIwF/P8wl3WFygkuhjfk3gNde/GUGUra86JHu1gu4YlTqGjtd6dXb VQuV4yH+tjCK0AmzUY8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlCd4-00000001DRQ-2M9s; Fri, 15 Mar 2024 18:50:06 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlCd1-00000001DPQ-2E35 for linux-arm-kernel@lists.infradead.org; Fri, 15 Mar 2024 18:50:04 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6e6b729669bso2421147b3a.3 for ; Fri, 15 Mar 2024 11:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710528602; x=1711133402; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aRqivYuE7DcmOFFhwyqSkRwN4XtrqdDpfy8FtThn+Dk=; b=Tz27Fn2aD4ATaR+z1BeSNcC/CYXanpMI8XabJ26cM2gDBURpwDXQxx8R9iUPoq2NMq k6ciOWLfWUHIfYK8Xt0vRtfB6cVLyu+pze1S0UGRO2KWYzS3n5BrzPJY1oofgt0PQ0dv 3hvjUdsFQq68N1nnSlVxGmjZkg/NKFdVUo0HZ8JhiNAybDP5ZKkpyD/G1TvQ2EAGLiK4 3gFuYiKk7Qo+ZY7aQGJRVXvkCLXjqr3Q4aFAgWgSUSPZCpxKxup0jne9PE8VlDBWqJke bIUK6Ctm0FH5MdrVHJ1BkGdWEBqab0ym7TY/b7tIf+Ucum1xnLyQE5R0cAjFhmFk0Mww rl0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710528602; x=1711133402; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aRqivYuE7DcmOFFhwyqSkRwN4XtrqdDpfy8FtThn+Dk=; b=fI+FIwjPTZk/Y4U/gns21lbQknNBtaDsJfuzH5YUb48Pu1mlTXqQ3JUHs2nv+lkArn ti8NI5ZoLhCeX2SPDVr5YqKQqwnkC88eb0ZjalHbxrHWZ3kkIPR68s8zpm48CXrRuItm igz738qjaANjwT/lqPoLSjZhVLrAwGC9PP0CWc6RQ+Rd+tsXfwmhIkJkXcn1bYXQ3OmZ pkAaVzrJWQ8YOrypFyjoxUtmvjuuNPCqWYa1va6wpgq1AhYKWTBQFFFVyJdzq8PyhhBG penOtbxh8GkgVCDhhXOl4/FNkTZiNyvDUsDOyLwXeCXEL7ynxDXzrkZfZTdTlIuv5rVT XCDQ== X-Forwarded-Encrypted: i=1; AJvYcCWKuX2GO4PxWsulhSPqNUlqpjwYbasCVKapuGSVDyuazpVCl4yMbCIYbIjGyU+2xmttjIL7tYEGwNJUgPYgcW08r8nGDsICYy9wY2ytoLifVhvdqtM= X-Gm-Message-State: AOJu0YxS85k01QMuvuBpVM4oHlEvyD3eYo3G543Pk2L0wFtuvhXpqp5m 8NlHzF48jdiOE0/u6GxPQ76eIcX6fX3OuvLz26xatJY85GSiuK/m X-Google-Smtp-Source: AGHT+IHQbXiA7SVlIsgBVryvm0PGS1QFL0t3DlqmYIaIG83GvhramGbGJdZlO3EHZsPjHP3Bdwk5+g== X-Received: by 2002:a05:6a20:7d9c:b0:1a3:53a0:da1f with SMTP id v28-20020a056a207d9c00b001a353a0da1fmr1195976pzj.12.1710528602430; Fri, 15 Mar 2024 11:50:02 -0700 (PDT) Received: from toolbox.iitism.net ([103.15.228.94]) by smtp.gmail.com with ESMTPSA id f17-20020a056a0022d100b006e6cc998be8sm3580784pfj.207.2024.03.15.11.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 11:50:02 -0700 (PDT) From: Ayush Singh To: linux-kernel@vger.kernel.org Cc: Vaishnav M A , jkridner@beagleboard.org, robertcnelson@beagleboard.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Liam Girdwood , Mark Brown , Jiri Slaby , Johan Hovold , Alex Elder , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, greybus-dev@lists.linaro.org, Ayush Singh Subject: [PATCH v3 4/8] serdev: add of_ helper to get serdev controller Date: Sat, 16 Mar 2024 00:19:02 +0530 Message-ID: <20240315184908.500352-5-ayushdevel1325@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240315184908.500352-1-ayushdevel1325@gmail.com> References: <20240315184908.500352-1-ayushdevel1325@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240315_115003_608271_50C8346D X-CRM114-Status: GOOD ( 16.13 ) 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 From: Vaishnav M A add of_find_serdev_controller_by_node to obtain a serdev_controller from the device_node, which can help if the serdev_device is not described over device tree and instantiation of the device happens from a different driver, for the same purpose an option to not delete an empty serdev controller is added. Signed-off-by: Vaishnav M A Signed-off-by: Ayush Singh --- drivers/tty/serdev/core.c | 19 +++++++++++++++++++ include/linux/serdev.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 613cb356b918..5b5b3f2b2e42 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -555,6 +555,19 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl) return 0; } +#if defined(CONFIG_OF) +struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node) +{ + struct device *dev = bus_find_device_by_of_node(&serdev_bus_type, node); + + if (!dev) + return NULL; + + return (dev->type == &serdev_ctrl_type) ? to_serdev_controller(dev) : NULL; +} +EXPORT_SYMBOL_GPL(of_find_serdev_controller_by_node); +#endif + #ifdef CONFIG_ACPI #define SERDEV_ACPI_MAX_SCAN_DEPTH 32 @@ -785,6 +798,12 @@ int serdev_controller_add(struct serdev_controller *ctrl) pm_runtime_enable(&ctrl->dev); + /* provide option to not delete a serdev controller without devices + * if property is present + */ + if (device_property_present(&ctrl->dev, "force-empty-serdev-controller")) + return 0; + ret_of = of_serdev_register_devices(ctrl); ret_acpi = acpi_serdev_register_devices(ctrl); if (ret_of && ret_acpi) { diff --git a/include/linux/serdev.h b/include/linux/serdev.h index ff78efc1f60d..287d7b9bc10a 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -117,6 +117,10 @@ static inline struct serdev_controller *to_serdev_controller(struct device *d) return container_of(d, struct serdev_controller, dev); } +#if defined(CONFIG_OF) +struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node); +#endif + static inline void *serdev_device_get_drvdata(const struct serdev_device *serdev) { return dev_get_drvdata(&serdev->dev);