Received: by 2002:ab2:7444:0:b0:1ef:eae8:a797 with SMTP id f4csp30887lqn; Fri, 15 Mar 2024 11:51:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSKLwXFSvW93jhhO7w/EHmnlbJQh9hsHWrnqNN+50syrV6rjUjSBVQ+EKKgjB9eBHZQO7HyRZCVssa9O9Xuv1uua3swCth1lzPq3oawA== X-Google-Smtp-Source: AGHT+IEASzYf3gatjlMPieh0VjkhdXSFS4UJ9Zzf27Ak0whM2b+ZIxTkmeDwnaHr5v+IxIrTILak X-Received: by 2002:a05:6a21:3405:b0:1a3:3521:c660 with SMTP id yn5-20020a056a21340500b001a33521c660mr6445106pzb.37.1710528677708; Fri, 15 Mar 2024 11:51:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710528677; cv=pass; d=google.com; s=arc-20160816; b=Y0lDKWLI8f++uw+C7birPnboV+k83PlplwzHB+xhlwcIEZZZ77GlusubLkIqyqKTHI vE3t03xK9waO164pdnATmb0Wb1whauHVxGCwrDpSgfAU2K9w+1riNJRzo5KBfe6ANivD mvqoCi45dqMrgEuwSUGB4r6Ic+0GrueKFd4OTv6GgtRQfkOxqbSLgRoAWhJ3z/9ZFzA7 V3G5eTgMIZbuB45wDtgiPXe92GPHbrwTnMa54N+zKegn+SEhDA41C3/TKHIwAIzolgT4 PSlW3EQifMNJkicWIUGmIXIy1sgqklY4G+VHjK89vLlZJdz+YgQUQXeV3h/2PDc+33Sg qUCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=aRqivYuE7DcmOFFhwyqSkRwN4XtrqdDpfy8FtThn+Dk=; fh=wbYAiEU11T4jsvz/PNrFrNQGwsLfB6phKSGyyY7Vs6U=; b=OtmC3kg411PtIx8sMnKDyyFJ359KtjiXe0W7sQuCLNImP6EWM8hQ4VaWmDGd2+OJJZ LvzhScSUjCEmb8gfalmo92zhxOV2OHJmREkIUJ9op9XzbC0fcbEf5G1epX+8AbxgZhDX DRsny76icnAC4T2Noovgv1+oJbgrCCZ28g+CO4LwseG1ROufP7WhKFYz4dDaOHdXSKnM /M8zDu36wHpG2WJP14xpZKy6JRFzGb1/G+Qp9y6x5QJO+r/zY4lbrMweck9V6afwpBNt KTkGAECdLeNo6bSQQ2nh7EGAzryWNPzr9ZFrtE3G2u1ESs9cV6Wpmck7JCmeEwDj/9ed uesQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=b9hVQkrS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-104810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104810-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v11-20020a17090abb8b00b0029c74535d74si3224990pjr.35.2024.03.15.11.51.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 11:51:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=b9hVQkrS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-104810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104810-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F4A9285574 for ; Fri, 15 Mar 2024 18:51:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDF1954735; Fri, 15 Mar 2024 18:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b9hVQkrS" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03E0D535BF; Fri, 15 Mar 2024 18:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710528607; cv=none; b=XFbgGuIoOjaFConX3LHAyvHYKD6GR66rpL7xq1R4sThaKGbpKuuOJ3gS42t7q6WziAxL0XDOuw8s4mQB8vE0Yp440HKTaNqluTOgV4OgSwk5P1TdIm5xu13/FfP6wLfkv65LuCww9v+pHAUeGVeDONY/ooNgHIcPa+XZUtc2Q6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710528607; c=relaxed/simple; bh=HKO1HfQMaGl/CCeE/Ln6SsQv/qM6IwNciXbv0btirr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ry6uy2SDLkPctarVEVRimsNQQeww2aQJRyPKBwgE3R6MyGAjWIPy9j7xu0sH19KoIIwYHBApI0f3+aUhyNME2D7vvuA5bSTcUCHbT+AxtxCbmFazNDg/n00yUk0YJoRKIvIDbvxkPRxrf/DGD4QUG22rkSEXv0FidmljuvA53Yw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b9hVQkrS; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e6f4ad4c57so1251623b3a.2; 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=vger.kernel.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=b9hVQkrSu/NrMhqToThWIFikGzZR38NsaYglJ8YgDHHuFzVDv7wfUAeJ3IiXzZSEF2 R6WdLUAUuPNHpi3e24Us21T6WhdYd1l4x3+AQt/8XN6caSFr8M9y8j3XvfWE4MbSXdLe RtAi4DWATZKZhouAWSFYF3TZJcr4OztNiKbhvWwdWWLLeFSFW4OCAcjXmY1FsnFPHIZj h+I72yeZSdvTW32LW6WjTxJzjv+i3nJFpO26qRZSz/FIUabg0ovhtkR2OrwV5paOSYol VjwhfD/OP1k2gxSvY5y7u2wT64w75tIVZIlugXc6MhHwaKs5BNeV6rv3QS6iF3AEtC1x WrAg== 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=DY2j9jcIXe9qBKfxtgTM3xd2FfX7AId3jNtukldBYssYueYlTlQy+AUw3cZ0uNfqAj EC4SpAKca6Jt2oGg+xdAolAPkyoOlzJbdBjOW03bhe/u8Nrk1WaFOOxgnrW1+FhAs0Qe Fud5eKllt0UNENjwi2e1YDTeQ5m3uq+A7R2q+3MJipfArSsyuCODVKB+T8IsaWsueKxQ 5c/oq9NJ6A0Sw5d2Gte2K92+ZcHFlKIGwj8cVrJBO3QLzySeDV3ei/9sMegN484oVJLN MpOXEIQ+lV2PGomDcfEPIEnaKsThrBmk08UXydqPxENfbnnmGyHAj28Z1KeyuPIJjT1u PkYg== X-Forwarded-Encrypted: i=1; AJvYcCUAv3e5yL9tfsbqwb9F0MiB0lgngBDKxys1vc8aEcag5Wm2Shaqds30aOQIqqDvk/yAPE0Hl/f6CbWgeYglrSxrRcrfW/g195kFUXBx+/utk02Y/wOzVBl1nWZaSwUyv/Gpyu4YKx1B9PQ2Yd10oG1sLlxcNe0SSwrdVCZIfAdV2A61Qg== X-Gm-Message-State: AOJu0YwA4rPX8S9VUK2c1cHd6ejwAfqphDd0yv0fvgHInch+7ZFnsA3X cYt8BZFgeOs8f+LK7yDH8N0ls0TEomgpyoZonhbUycCkDf85lV5e+kxdzrLSj9u2tA== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.44.0