From patchwork Sat May 13 07:29:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 761956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wPzLF629Bz9s7y for ; Sat, 13 May 2017 17:41:25 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751663AbdEMHlZ (ORCPT ); Sat, 13 May 2017 03:41:25 -0400 Received: from thoth.sbs.de ([192.35.17.2]:34196 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbdEMHlY (ORCPT ); Sat, 13 May 2017 03:41:24 -0400 Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id v4D7T9qY020368 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 May 2017 09:29:09 +0200 Received: from localhost.localdomain ([146.254.78.19]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id v4D7T8NC030047; Sat, 13 May 2017 09:29:09 +0200 From: Jan Kiszka To: Greg Kroah-Hartman , Linus Walleij , Alexandre Courbot Cc: Linux Kernel Mailing List , linux-serial@vger.kernel.org, linux-gpio@vger.kernel.org, Sudip Mukherjee , Andy Shevchenko , Sascha Weisenberger Subject: [PATCH 2/8] gpio: exar: Fix passing in of parent PCI device Date: Sat, 13 May 2017 09:29:00 +0200 Message-Id: <20f1d241d134f9f4932a26e4bd873ffc250affce.1494660546.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This fixes reloading of the driver for the same device: First of all, the driver sets drvdata to its own value during probing and does not restore the original value on exit. But this won't help anyway as the core clears drvdata after the driver left. Use stable platform_data instead. Signed-off-by: Jan Kiszka --- drivers/gpio/gpio-exar.c | 2 +- drivers/tty/serial/8250/8250_exar.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 081076771217..0a2085faf271 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -119,7 +119,7 @@ static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) static int gpio_exar_probe(struct platform_device *pdev) { - struct pci_dev *pcidev = platform_get_drvdata(pdev); + struct pci_dev *pcidev = *(struct pci_dev **)pdev->dev.platform_data; struct exar_gpio_chip *exar_gpio; void __iomem *p; int index, ret; diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index b4fa585156c7..2d056d1eeca3 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -196,8 +196,12 @@ xr17v35x_register_gpio(struct pci_dev *pcidev) if (!pdev) return NULL; - platform_set_drvdata(pdev, pcidev); - if (platform_device_add(pdev) < 0) { + /* + * platform_device_add_data kmemdups the data, therefore we can safely + * pass a stack reference. + */ + if (platform_device_add_data(pdev, &pcidev, sizeof(pcidev)) < 0 || + platform_device_add(pdev) < 0) { platform_device_put(pdev); return NULL; }