From patchwork Thu May 18 14:59:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 764037 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 3wTDsL3pJxz9ryT for ; Fri, 19 May 2017 01:01:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933231AbdERO7W (ORCPT ); Thu, 18 May 2017 10:59:22 -0400 Received: from goliath.siemens.de ([192.35.17.28]:34622 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932640AbdERO7V (ORCPT ); Thu, 18 May 2017 10:59:21 -0400 Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id v4IExA2w030458 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 May 2017 16:59:10 +0200 Received: from md1f2u6c.ww002.siemens.net.net ([139.25.68.37]) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id v4IEx99u022403; Thu, 18 May 2017 16:59:10 +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 v2 1/6] gpio: exar: Fix passing in of parent PCI device Date: Thu, 18 May 2017 16:59:04 +0200 Message-Id: <62280d24a7cf7c0be849c1186c909c850f4d2cc6.1495119548.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 GPIO driver for the same platform device instance as created by the exar UART driver: 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 | 4 +++- drivers/tty/serial/8250/8250_exar.c | 8 ++++++-- include/linux/platform_data/gpio-exar.h | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 include/linux/platform_data/gpio-exar.h diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 081076771217..d62e57513144 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #define EXAR_OFFSET_MPIOLVL_LO 0x90 @@ -119,7 +120,8 @@ 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 gpio_exar_pdata *pdata = pdev->dev.platform_data; + struct pci_dev *pcidev = pdata->parent; 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..0a806daaff8b 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -191,13 +192,16 @@ static void * xr17v35x_register_gpio(struct pci_dev *pcidev) { struct platform_device *pdev; + struct gpio_exar_pdata pdata; pdev = platform_device_alloc("gpio_exar", PLATFORM_DEVID_AUTO); if (!pdev) return NULL; - platform_set_drvdata(pdev, pcidev); - if (platform_device_add(pdev) < 0) { + pdata.parent = pcidev; + + if (platform_device_add_data(pdev, &pdata, sizeof(pdata)) < 0 || + platform_device_add(pdev) < 0) { platform_device_put(pdev); return NULL; } diff --git a/include/linux/platform_data/gpio-exar.h b/include/linux/platform_data/gpio-exar.h new file mode 100644 index 000000000000..1a13e9ddaf7d --- /dev/null +++ b/include/linux/platform_data/gpio-exar.h @@ -0,0 +1,22 @@ +/* + * GPIO handling for Exar XR17V35X chip + * + * Copyright (c) 2017 Siemens AG + * + * Written by Jan Kiszka + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __GPIO_EXAR_PDATA_H +#define __GPIO_EXAR_PDATA_H + +struct pci_dev; + +struct gpio_exar_pdata { + struct pci_dev *parent; +}; + +#endif /* __GPIO_EXAR_PDATA_H */