From patchwork Tue Sep 5 18:52:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13374935 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 B1D7CCA0FF7 for ; Tue, 5 Sep 2023 18:54:09 +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=DwnNs/1Iqw0+qhsW7yFcyCckPPFhFDwo/fGJRDjzHe4=; b=0Y0PV0iWZwJlD8 aPNQhlt21Oh90q2Uv8+PGueqWRRf7+wEz3vI1XqkbA22LX7KLJcX3lfNzQz05v4WIDWRI7RaMHjNX LB40M/TEk9Lg6i7QL4gQXfQmAtW1Y2MIbvN3m28EZvk2sYIPYSCa/H52qn8eeukAKqpKfVucd1cpH WEx53NirOFyhdr97hKaz2ZTngifcmE1WYKKfCeXYq1IY2cOoRhkNhHo9g72mmm2sWARM69dnvPWfR Z/yQNmQDI1a8196ifHiC1oaUYQAs8MEQarksqipBvGt6ii85y+fzn0MP6ZNQy/xt1ZT7qi2l6O81p I/UqrPkH0uPabrukSNdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBJ-006YWM-2T; Tue, 05 Sep 2023 18:53:45 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdbBE-006YQc-2R for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 18:53:42 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-401d6f6b2e0so912925e9.1 for ; Tue, 05 Sep 2023 11:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1693940017; x=1694544817; 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=LktKQq4MWoQ/qKoiT9d7DgSnCPQ1kCPUYmKK3IZgeGM=; b=rB6JYN9GsWpnBNSqQwnmXt06+pm+UnASe5nJKyfWEz45R9kvneNZinrbUVLZEOmxLS xG9HMGMpuOCqtV0nC2DcAA6sJ4QnfNqXqGRvYfsiUSM70je5ZwkN2EYW3hw3Gp0U5ZiN K8cPP8ceTelG5OGPyajKFfZt+hu3c0J+i8Gf3UPXLyo4inrN6+OZj7AooOEIvVigMYi6 oaCbF0sJ+9+LEkM2JNBbsr+BZ1iwjKVTjnevb52k/othnb1JULEEMLsb0YO7pmzGMWxK L/pnCWGD9DMEFvlVM7RsUcCFtAOCnWtTl3/gPKOw0bQHFnhVFmSORODamSXwD8VpQM9x Ae2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693940017; x=1694544817; 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=LktKQq4MWoQ/qKoiT9d7DgSnCPQ1kCPUYmKK3IZgeGM=; b=kAQPWDsP6Bg6pNeecUzUSTeCh1oLyfhBHxEokwSsF80x1T+xMm0L5JWwwwrTQfx9kc Qe9JDOcFdyaHR75KDB14ChZpT2bh9cSRgoHx8Xuq+5FPvhL6ZcrTyOsSqAyBhaxfDDVs zfPxNcmUUZi/PiChIXWjPaKT59nKGWlPtL2BPjiVgRnYSNLOXNd71i/yvHl2x4s3Qx5z 8CxAwtyFfQ3J9KliVnk8M2p/R5q9c/sH+nJxXjPPkc1Xb4PcroRXRVqeQk+LtvaXcsLG GPrs3deKlWZxjNvvBlAau0qMO9YtyZNBDpzqWFvDuhTWH2mznx6skA0L3W15+hcEMKRu tPbA== X-Gm-Message-State: AOJu0YzbKd0ntaem0MJLAx5Jf0foTaBQH6OT0p5jBu/0EbgoaQtus0FE bk3A/eGdx7iee/5E7eb5BYdWzg== X-Google-Smtp-Source: AGHT+IEKE+XCvxCtmXJO+rvvHv5Ifn1+auM+4ZurnpxJ8t+aLjhMPMETigx/CB4V/gfiHQTOepYw2A== X-Received: by 2002:a05:600c:4b1f:b0:401:bcec:be3e with SMTP id i31-20020a05600c4b1f00b00401bcecbe3emr598796wmp.17.1693940017155; Tue, 05 Sep 2023 11:53:37 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7a54:5dbc:6d09:48b7]) by smtp.gmail.com with ESMTPSA id 17-20020a05600c249100b003fbc30825fbsm17550010wms.39.2023.09.05.11.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 11:53:36 -0700 (PDT) From: Bartosz Golaszewski To: Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Russell King , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , Dipen Patel , Thierry Reding , Jonathan Hunter , Hans de Goede , Mark Gross Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org, platform-driver-x86@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 09/21] gpiolib: reluctantly provide gpio_device_get_chip() Date: Tue, 5 Sep 2023 20:52:57 +0200 Message-Id: <20230905185309.131295-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230905185309.131295-1-brgl@bgdev.pl> References: <20230905185309.131295-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230905_115340_796469_041ABCA5 X-CRM114-Status: GOOD ( 13.10 ) 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: Bartosz Golaszewski The process of converting all unauthorized users of struct gpio_chip to using dedicated struct gpio_device function will be long so in the meantime we must provide a way of retrieving the pointer to struct gpio_chip from a GPIO device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 18 ++++++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9715bbc698e9..408f8a7753f9 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -246,6 +246,24 @@ int gpio_device_get_base(struct gpio_device *gdev) } EXPORT_SYMBOL_GPL(gpio_device_get_base); +/** + * gpio_device_get_chip() - Get the gpio_chip implementation of this GPIO device + * @gdev: GPIO device + * + * Until we can get rid of all non-driver users struct gpio_chip, we must + * provide a way of retrieving the pointer to it from struct gpio_device. This + * is *NOT* safe as the GPIO API is considered to be hot-unpluggable and the + * chip can dissapear at any moment (unlike reference-counted struct + * gpio_device). + * + * Use at your own risk. + */ +struct gpio_chip *gpio_device_get_chip(struct gpio_device *gdev) +{ + return gdev->chip; +} +EXPORT_SYMBOL_GPL(gpio_device_get_chip); + /* dynamic allocation of GPIOs, e.g. on a hotplugged device */ static int gpiochip_find_base(int ngpio) { diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 47906bc56b3d..bb9ec741bfda 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -782,6 +782,7 @@ struct gpio_device *gpiod_to_device(struct gpio_desc *desc); /* struct gpio_device getters */ int gpio_device_get_base(struct gpio_device *gdev); +struct gpio_chip *gpio_device_get_chip(struct gpio_device *gdev); #else /* CONFIG_GPIOLIB */