From patchwork Tue Nov 20 07:47:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1000290 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ide-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="JPb6KOls"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zd8t3xCWz9rxp for ; Tue, 20 Nov 2018 18:47:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725898AbeKTSPZ (ORCPT ); Tue, 20 Nov 2018 13:15:25 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37555 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbeKTSPZ (ORCPT ); Tue, 20 Nov 2018 13:15:25 -0500 Received: by mail-lf1-f67.google.com with SMTP id p17so650311lfh.4 for ; Mon, 19 Nov 2018 23:47:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=H47kqIIDR0ZzSLnz8D1/0M7TemsbSrEQiyUJhiQjyW8=; b=JPb6KOlsfVSLEW72EGqoY5bMZnV62qhBFm0wBrK0KFQGUCtFc3sxKwNnSk1V68wThf cVJ14fNAtHiz9xxikDBUtgQlH2YX1BbM4TKOzg+aaI2mGMZWNCmE4eTYr3BFHNXlicf3 DB2AYoxD8eKCJKRC2/3LLjfTDFND3UmYcxrqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=H47kqIIDR0ZzSLnz8D1/0M7TemsbSrEQiyUJhiQjyW8=; b=n4O11tYPhC2rIZdL3upuHCOtmw8lRx1VxWLzK+3PpzNk+druIlN8RZCox8QXj8LTob QjuIMGgJo3Sdbu1papyng3CJ+ugQ/eb+Et0IFaIqtx1L+LPFL2roINW2BlBm6hn+Bm5b dIIUEmrmm4KYtHoD1L9rH3XuF4r4PrEiGMqlaBnA8dQXvpCEd2xzlR2ibm1T+7KIUENG Iin1IoEnZdKcP9n9atqqENUN7MVRt454W/lr7waI1HU7G/fKFj4HB6op3M+YvhV+vE4m AL0fhw9IVyZqmdhXBmNdz09Xwn6Eut9OBo4AM3Sqp4/6b3CkwspLxqgcxG0xcw6TqJae 0Qmw== X-Gm-Message-State: AGRZ1gI5UOG/wV31vk/pThyHvzadsHqaka0wTw9ViThyDMZl2moRIXE3 dL7CZWWmWR/02sjmjFEOifA5qw== X-Google-Smtp-Source: AJdET5e0cZ6UwM0SxucCpcXoXS6akLmNfzN8SmQ66fcR/yi7nHQh/kapuJSn7ftNebntqhNJgjbLlQ== X-Received: by 2002:a19:7d42:: with SMTP id y63mr489945lfc.47.1542700058231; Mon, 19 Nov 2018 23:47:38 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d10sm6021394lfa.71.2018.11.19.23.47.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Nov 2018 23:47:37 -0800 (PST) From: Linus Walleij To: Jens Axboe , Bartlomiej Zolnierkiewicz Cc: linux-ide@vger.kernel.org, Linus Walleij , Ralf Baechle , Waldemar Brodkorb , Matt Redfearn Subject: [PATCH] ata: rb532_cf: Convert to use GPIO descriptors Date: Tue, 20 Nov 2018 08:47:32 +0100 Message-Id: <20181120074732.4326-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Pass a GPIO descriptor for the device instead of a hardcoded GPIO number from the global GPIO numberspace. Use gpio descriptors throughout. Cut the now completely unused platform data for the CF slot. Cc: Ralf Baechle Cc: Waldemar Brodkorb Cc: Matt Redfearn Signed-off-by: Linus Walleij --- arch/mips/include/asm/mach-rc32434/rb.h | 6 ---- arch/mips/rb532/devices.c | 12 +++++-- drivers/ata/pata_rb532_cf.c | 45 ++++++------------------- 3 files changed, 19 insertions(+), 44 deletions(-) diff --git a/arch/mips/include/asm/mach-rc32434/rb.h b/arch/mips/include/asm/mach-rc32434/rb.h index aac8ce8902e7..5dfd4d66d6fc 100644 --- a/arch/mips/include/asm/mach-rc32434/rb.h +++ b/arch/mips/include/asm/mach-rc32434/rb.h @@ -71,12 +71,6 @@ struct korina_device { struct net_device *dev; }; -struct cf_device { - int gpio_pin; - void *dev; - struct gendisk *gd; -}; - struct mpmc_device { unsigned char state; spinlock_t lock; diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c index 2b23ad640f39..828d8cc3a5df 100644 --- a/arch/mips/rb532/devices.c +++ b/arch/mips/rb532/devices.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -127,14 +128,18 @@ static struct resource cf_slot0_res[] = { } }; -static struct cf_device cf_slot0_data = { - .gpio_pin = CF_GPIO_NUM +static struct gpiod_lookup_table cf_slot0_gpio_table = { + .dev_id = "pata-rb532-cf", + .table = { + GPIO_LOOKUP("gpio0", CF_GPIO_NUM, + NULL, GPIO_ACTIVE_HIGH), + { }, + }, }; static struct platform_device cf_slot0 = { .id = -1, .name = "pata-rb532-cf", - .dev.platform_data = &cf_slot0_data, .resource = cf_slot0_res, .num_resources = ARRAY_SIZE(cf_slot0_res), }; @@ -305,6 +310,7 @@ static int __init plat_setup_devices(void) dev_set_drvdata(&korina_dev0.dev, &korina_dev0_data); + gpiod_add_lookup_table(&cf_slot0_gpio_table); return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs)); } diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c index 653b9a0bf727..66bb5bff126b 100644 --- a/drivers/ata/pata_rb532_cf.c +++ b/drivers/ata/pata_rb532_cf.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -49,7 +49,7 @@ struct rb532_cf_info { void __iomem *iobase; - unsigned int gpio_line; + struct gpio_desc *gpio_line; unsigned int irq; }; @@ -60,7 +60,7 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance) struct ata_host *ah = dev_instance; struct rb532_cf_info *info = ah->private_data; - if (gpio_get_value(info->gpio_line)) { + if (gpiod_get_value(info->gpio_line)) { irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW); ata_sff_interrupt(info->irq, dev_instance); } else { @@ -106,10 +106,9 @@ static void rb532_pata_setup_ports(struct ata_host *ah) static int rb532_pata_driver_probe(struct platform_device *pdev) { int irq; - int gpio; + struct gpio_desc *gpiod; struct resource *res; struct ata_host *ah; - struct cf_device *pdata; struct rb532_cf_info *info; int ret; @@ -125,23 +124,12 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) return -ENOENT; } - pdata = dev_get_platdata(&pdev->dev); - if (!pdata) { - dev_err(&pdev->dev, "no platform data specified\n"); - return -EINVAL; - } - - gpio = pdata->gpio_pin; - if (gpio < 0) { + gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN); + if (IS_ERR(gpiod)) { dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq); - return -ENOENT; - } - - ret = gpio_request(gpio, DRV_NAME); - if (ret) { - dev_err(&pdev->dev, "GPIO request failed\n"); - return ret; + return PTR_ERR(gpiod); } + gpiod_set_consumer_name(gpiod, DRV_NAME); /* allocate host */ ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS); @@ -153,7 +141,7 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) return -ENOMEM; ah->private_data = info; - info->gpio_line = gpio; + info->gpio_line = gpiod; info->irq = irq; info->iobase = devm_ioremap_nocache(&pdev->dev, res->start, @@ -161,26 +149,14 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) if (!info->iobase) return -ENOMEM; - ret = gpio_direction_input(gpio); - if (ret) { - dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n", - ret); - goto err_free_gpio; - } - rb532_pata_setup_ports(ah); ret = ata_host_activate(ah, irq, rb532_pata_irq_handler, IRQF_TRIGGER_LOW, &rb532_pata_sht); if (ret) - goto err_free_gpio; + return ret; return 0; - -err_free_gpio: - gpio_free(gpio); - - return ret; } static int rb532_pata_driver_remove(struct platform_device *pdev) @@ -189,7 +165,6 @@ static int rb532_pata_driver_remove(struct platform_device *pdev) struct rb532_cf_info *info = ah->private_data; ata_host_detach(ah); - gpio_free(info->gpio_line); return 0; }