Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A56DB47D93E; Thu, 20 Aug 2026 16:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787244230; cv=none; b=lpWrX7yaphP93IvahU25SY5UwyWNsyYKslHzFUKoFi/RkO40fIN0cEL0x4qOmSq+e7YugCvvRORI15v6+/ZkS6pntkgEYVo9xErR7opp0TPxTVUEwcc7/k8wAgb6qkkJZy5llUMBa+hj973euFVgtc22itVT4SC334XQgfNkWvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787244230; c=relaxed/simple; bh=4yrSc3FX+ffkKzcjfpcrlVMOHZ0B1mo2uuMJ9rGuelA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WC15XIR/uYp+T4wdAl5EaG14RweCW2wOaIze/6SwMd289B2zVKgJzBojqsu0qWuaDaibmYDXjtkMT3nWQfCHMnjQtl6f908Z6vA+PtSY8AuoAqgwuFxVGPt31+2D+7CLtjYj0lgrREBKgM/wFcH2+doLsyiwVa0cjtEzePhN2cQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sqbK6nti; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sqbK6nti" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 103DE1F00A3A; Thu, 20 Aug 2026 16:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787244228; bh=SSg9ZVxVgPIrUe5wWh2Ls7drWdJ/jStRNRgU27VAD/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sqbK6nti/sHE65rIWLo5elFTR0psT8gDf8MVfS2an8cBydwCDGtv/3Fq5bkKUqYjX 9M32WB80z0pse+NlcBPnW5NW4XsDnpF6eRCcMTbzGVEhcNnRCh7cHwh6iRlWWMMjoB NtYlIn0M5gKYyyT4IzFMlwo0f1rNRvPMKfTS7znM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Tapio Reijonen , Linus Walleij , Bartosz Golaszewski , Hugo Villeneuve , Sasha Levin Subject: [PATCH 5.10 058/235] serial: max310x: implement gpio_chip::get_direction() Date: Thu, 20 Aug 2026 16:54:54 +0200 Message-ID: <20260820145218.206195325@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145216.426568665@linuxfoundation.org> References: <20260820145216.426568665@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tapio Reijonen [ Upstream commit a483b1a91b33b7533280e7c3efd2bc1275caef18 ] It's strongly recommended for GPIO drivers to always implement the .get_direction() callback - even when the direction is tracked in software. The GPIO core emits a warning when the callback is missing and a user reads the direction of a line, e.g. via /sys/kernel/debug/gpio. The MAX310X keeps the GPIO direction in the GPIOCFG register (a set bit selects output), which the existing direction_input/output callbacks already program, so the current direction can be read back directly. Fixes: f65444187a66 ("serial: New serial driver MAX310X") Cc: stable Signed-off-by: Tapio Reijonen Reviewed-by: Linus Walleij Reviewed-by: Bartosz Golaszewski Reviewed-by: Hugo Villeneuve Link: https://patch.msgid.link/20260615-b4-serial-max310x-gpio-get-direction-v2-1-4704ba2b181a@vaisala.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/max310x.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1235,6 +1235,17 @@ static void max310x_gpio_set(struct gpio value ? 1 << (offset % 4) : 0); } +static int max310x_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) +{ + struct max310x_port *s = gpiochip_get_data(chip); + struct uart_port *port = &s->p[offset / 4].port; + unsigned int val; + + val = max310x_port_read(port, MAX310X_GPIOCFG_REG); + + return val & BIT(offset % 4) ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN; +} + static int max310x_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) { struct max310x_port *s = gpiochip_get_data(chip); @@ -1441,6 +1452,7 @@ static int max310x_probe(struct device * s->gpio.owner = THIS_MODULE; s->gpio.parent = dev; s->gpio.label = devtype->name; + s->gpio.get_direction = max310x_gpio_get_direction; s->gpio.direction_input = max310x_gpio_direction_input; s->gpio.get = max310x_gpio_get; s->gpio.direction_output= max310x_gpio_direction_output;