From patchwork Thu Dec 5 08:39:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 180861 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1676053ile; Thu, 5 Dec 2019 00:39:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxd9ZHKzh4DE/rtHMlTECsz0ruMTg+n7ttdexKo27tLRJ6Iy/HrLj9tqkua5awA+jGdG2uj X-Received: by 2002:aca:eb0f:: with SMTP id j15mr5952318oih.6.1575535165233; Thu, 05 Dec 2019 00:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575535165; cv=none; d=google.com; s=arc-20160816; b=lZrpdyFqP0xB+dhtGSr5IeaW14Ir8bd3V4jQ7HXuhIBNiSd1w+II4s5TWltdJgLlDn DYCviz61QukTK/ddBLIP0bzSHcNwKqHmTU1651a+JB9RDP3Le/zwJ7te9l53TOeSqIaK 8QzTUHqJhCh7uEhzAuf9rgM0+lwUkoG5ckjkU5ht4eLbeYT6AYPGk/RK/I5OzoE8xVan gbFOd9T30T5w4WnqG4lMccwjnvgb4DVqSCEu3wUgFvHEzdIP6d0Ds8XWLE6wtaVfvCuj mpFyTGcS2JB9rIDFD09nBg49fyidSkKx5BIhcpJvaufxQG6uoUw2DiESiaQG/HThsqy6 asMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dPHiHGXLMtKVJTTyfi/3YxEjRXA4p9wO3aFux+3B+/g=; b=LWtyB+iE1KAh+Q9oEzdTDhX/CzfGRx5a+ZCsNpB6HgSGJUqZRNS+YNZMvJot/FROyD KihKEQ3e779FSzwTJJj60EcnO58hsT9abVPWnH686MTijIywUZl7nHF0ZRCpIpQOoPvw lGagas4h11I5NP1DM7VCTl86jfUn/GKFnXYqikzmd7yvQulCpB2k/f0x3FQGBJCj4DHI GY+vM1pKJtJmMOP9MDMgJxrKnSRsfFNN+b2QCwIWbMMv8D4j/hhLpdyyEBdzqBdSfExq nqC919nfE9JGBtd9Ics05wwP+3Oy+8FY318qyUN3pPOVNwO5pVbNcKoEEkQtp8Yf2iHH hLAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uTQIIcF2; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11si4324012oic.152.2019.12.05.00.39.25; Thu, 05 Dec 2019 00:39:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uTQIIcF2; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbfLEIjY (ORCPT + 2 others); Thu, 5 Dec 2019 03:39:24 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40213 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbfLEIjY (ORCPT ); Thu, 5 Dec 2019 03:39:24 -0500 Received: by mail-lj1-f196.google.com with SMTP id s22so2536973ljs.7 for ; Thu, 05 Dec 2019 00:39:23 -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=dPHiHGXLMtKVJTTyfi/3YxEjRXA4p9wO3aFux+3B+/g=; b=uTQIIcF2OCM1e2YXyMsMVVJroHV4lOHDTBOb7sCpH3haeVpQM6/pxy4dQLoqKeKifH auSEHB+2woVLrd5QQuqyHLTcDmMenumq52ovvPDMJg5CzQ6dfD0jtDol8GMs/y3G18lb 7XOcZX8qr1wgXzyoP0hTUiFkkxwK+tNdohOLN53v8ARArOEvWct7R80c5OTvWhvTiO0K HoUDCqOMDWqC/nBwNOj5E5S28JHze2bAqN6ELXsopVgJLc3RjwFpO+QH1k4SqzTc6av/ xn9zqIFC4lCbn5SczvoCFzHZsuMVBNOwWqeErTHnSjaEWswPlbv48oxDfnX+3Uc0YBMc a8mQ== 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=dPHiHGXLMtKVJTTyfi/3YxEjRXA4p9wO3aFux+3B+/g=; b=AL0zb0UjpxAeL/l9zR4w5p8XYkMJqauJwKGGUY1VLbnf3rSya+howpNkLFXLXp+M1N gZ1PugDnNZkcaSbpKkdD7NNaeiOusoJmC3fPXBTwsnciBp71LT7bZCTxscp8/ZKdnS6F LJ3SpPcKVi2U8wXVIHfsXSB2S0UncAVnobPnCahHXLuDGPSRg/iHgRTQ1rffJyBkBWnx I+RQR1np+4Su0RWbM8uMSmu65MaMu+j+mXyL90S/ehagZ+L+ultXbDJkU7/aafHbxflQ RL5AwyHVRAKTLtEqnllq3l/nxhEAaEQ0meR9//Uw93tBq8DfswQSSIKw3F0coraMkpMn fd0A== X-Gm-Message-State: APjAAAVl4eHROcp9N9OMalpioHD30ZKGVRdzf+b2avkJ/JQlH1MKQLaT z+7edtvIyzsus9B5Fiy3i4r4xw== X-Received: by 2002:a2e:9a93:: with SMTP id p19mr4748927lji.158.1575535161997; Thu, 05 Dec 2019 00:39:21 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id c6sm4565532lfi.47.2019.12.05.00.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 00:39:20 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , Neil Armstrong , Sunny Luo Subject: [PATCH] spi: meson-spicc: Use GPIO descriptors Date: Thu, 5 Dec 2019 09:39:15 +0100 Message-Id: <20191205083915.27650-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Instead of grabbing GPIOs using the legacy interface and handling them in the setup callback, just let the core grab and use the GPIOs using descriptors. Cc: Neil Armstrong Cc: Sunny Luo Signed-off-by: Linus Walleij --- drivers/spi/spi-meson-spicc.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) -- 2.23.0 Acked-by: Neil Armstrong diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c index f3f10443f9e2..7f5680fe2568 100644 --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -19,7 +19,6 @@ #include #include #include -#include /* * The Meson SPICC controller could support DMA based transfers, but is not @@ -467,35 +466,14 @@ static int meson_spicc_unprepare_transfer(struct spi_master *master) static int meson_spicc_setup(struct spi_device *spi) { - int ret = 0; - if (!spi->controller_state) spi->controller_state = spi_master_get_devdata(spi->master); - else if (gpio_is_valid(spi->cs_gpio)) - goto out_gpio; - else if (spi->cs_gpio == -ENOENT) - return 0; - - if (gpio_is_valid(spi->cs_gpio)) { - ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); - if (ret) { - dev_err(&spi->dev, "failed to request cs gpio\n"); - return ret; - } - } - -out_gpio: - ret = gpio_direction_output(spi->cs_gpio, - !(spi->mode & SPI_CS_HIGH)); - return ret; + return 0; } static void meson_spicc_cleanup(struct spi_device *spi) { - if (gpio_is_valid(spi->cs_gpio)) - gpio_free(spi->cs_gpio); - spi->controller_state = NULL; } @@ -564,6 +542,7 @@ static int meson_spicc_probe(struct platform_device *pdev) master->prepare_message = meson_spicc_prepare_message; master->unprepare_transfer_hardware = meson_spicc_unprepare_transfer; master->transfer_one = meson_spicc_transfer_one; + master->use_gpio_descriptors = true; /* Setup max rate according to the Meson GX datasheet */ if ((rate >> 2) > SPICC_MAX_FREQ)