From patchwork Thu Jun 25 20:14:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 191745 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1150533ilg; Thu, 25 Jun 2020 13:14:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYDcXuRH8Ds1z0PlwRA3HVgNlT+0GdmIgx5jQtsaCoxiVS3as2OpkmC0oiIMviy3JXutKA X-Received: by 2002:a50:e387:: with SMTP id b7mr32730755edm.190.1593116072330; Thu, 25 Jun 2020 13:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593116072; cv=none; d=google.com; s=arc-20160816; b=uc+b7NvUgoHJhMzFWRh9ee6UWyZKMkBTTTnIZRATcAlCw/yuQbx435sBUgzkbJDTjo ke9qfRRzajOmmjXp0oD6Q0OCyyuyi8Y74UFMzZTrClwucq8faFF3Q4mEZm9lKg1/egfB 7eXRNXCovDuIti7mQVOYCuCtSzhODHNnJeC79+dfOiXiv95yRT6IAQTHGR9Mx7dYCR9z 7f36JLPwNZRNZ2L7NNAw0qqK3iRy1a6B3CwBi2xW2ubnHZ49GNWVZQaTk7jTDQE24kkn a1sq32kCciMUnKOoxRjEi+XD195g96umhUaieQQbLv483el4TVmVE0G5/3l08ySlUUBn 4Uxg== 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=cOOG0dpEOffBjseoi1YjATO6CBoVo7fEFEkfhiQPdy8=; b=uDW8YGACI6h5FeLT74ccxqWf3udDxm8RxhXkmliNd7C95iYyJwgNmOB51kV//pgwZs Nqij2f+4h6UfBdrqbqkUJn8n8xrAljT2UKiiE/iLdeeTL5xC4pA+LUcv9/ZBwZSwfh3K fJQ8KzLEctAOMeueXOk1wreFUZ9QaywQ+S1qu8nvw2kJl2gfhAWEP9dFJNGwz3+3S+xa tTSBVo7cymnykYIqMsrA2r9miyg/tjwhH+EwAd3pdzCEfhANBA9pW03FbgrUx3MlGY8m 1D78Y9aPV5BPvLTRdJhluOWMvJQeSduqrmYams2tHXCrYamtNHeUxiyU/wNxoua7xLUx h5FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aqicq1Cx; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id 27si5919978edv.33.2020.06.25.13.14.32; Thu, 25 Jun 2020 13:14:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aqicq1Cx; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 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 S2407076AbgFYUOb (ORCPT + 2 others); Thu, 25 Jun 2020 16:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406983AbgFYUOa (ORCPT ); Thu, 25 Jun 2020 16:14:30 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E370C08C5C1 for ; Thu, 25 Jun 2020 13:14:30 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id c11so3910904lfh.8 for ; Thu, 25 Jun 2020 13:14:30 -0700 (PDT) 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=cOOG0dpEOffBjseoi1YjATO6CBoVo7fEFEkfhiQPdy8=; b=aqicq1Cx2FmkhvshvL+wsPW55/g+rvOg2mOcbBavnzNkoOkUi3qigNKAJke4Y8sGos SAr8MIqsDf7zGUWS92FUNJUShi4F55OmkaWz9yfv8x5a/eGEwaD3IkbRcE2YLDlhjndj oJeZ3XGm1tYctPKMwya1nYGVsufXI7fFfWhN/0XaNSAgX9ZM6WLEKlqs8UfULsyR1xSN HErFGfizqBGo/5dQh8PiPpnMVqNAYRw0/xL3tyVFlIgVsgRv/QScZD6jvGgyYMSw7BnG kDEHfmij+vQHQn5Kkyw+zB+XGKnWiWrewKSYKrlo6au4YR4UudPFUK2/0Cs998Ob1lq+ KZnA== 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=cOOG0dpEOffBjseoi1YjATO6CBoVo7fEFEkfhiQPdy8=; b=RhXNLeapLSzvnaKUzYnI067RbuChfLqs+Dp4iMNg2AO3sqpm4tsGL3mSI13LfZYGje fvMkvUO76KaKeakMQDVdGN+/pyN98t63Sv0iHzKTgWYDBqOYAkxk6zJNVRhkPQA7Hixv kAwU6cSjdWympqo/V5kLpIc+A9jTIkZrQQn8ev2x16AZqnfrWJP1DHIGxNDSqQhLcCn0 yDsK1qWC7VKPG9YRU/FX0WUaHJ+R3t+KS4Gi/bmJxaH+1VPQ1VIqdlxiyzuyPH23KNm/ JJfEH8BVHGozKLwBz3tTh/+kAYNj+PjdxhsXjc3vfXHJqmcfPOZuuPkdIFgL85/RPLi5 eOqg== X-Gm-Message-State: AOAM5326B9DA3+DIJJOxndbMW08n8HQh15A5fJDUVWxSAixuNuOm941/ WHiHstHDDP4FxCOgzCPPzVqMaQ== X-Received: by 2002:a19:4143:: with SMTP id o64mr19187962lfa.157.1593116068739; Thu, 25 Jun 2020 13:14:28 -0700 (PDT) Received: from genomnajs.lan (c-d63ee155.152980-0-69706f6e6c79.bbcust.telenor.se. [85.225.62.214]) by smtp.gmail.com with ESMTPSA id u7sm7206991lfi.45.2020.06.25.13.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 13:14:27 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , Ionela Voinescu , Sifan Naeem Subject: [PATCH] spi: img-spfi: Convert to use GPIO descriptors Date: Thu, 25 Jun 2020 22:14:22 +0200 Message-Id: <20200625201422.208640-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This converts the IMG SPFI SPI driver to use GPIO descriptors as obtained from the core instead of GPIO numbers. The driver was already relying on the core code to look up the GPIO numbers from the device tree and allocate memory for storing state etc. By moving to use descriptors handled by the core we can delete the setup/cleanup functions and the device state handler that were only dealing with this. Cc: Ionela Voinescu Cc: Sifan Naeem Signed-off-by: Linus Walleij --- drivers/spi/spi-img-spfi.c | 56 +------------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) -- 2.25.4 diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c index 8543f5ed1099..b068537375d6 100644 --- a/drivers/spi/spi-img-spfi.c +++ b/drivers/spi/spi-img-spfi.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -102,10 +101,6 @@ struct img_spfi { bool rx_dma_busy; }; -struct img_spfi_device_data { - bool gpio_requested; -}; - static inline u32 spfi_readl(struct img_spfi *spfi, u32 reg) { return readl(spfi->regs + reg); @@ -442,54 +437,6 @@ static int img_spfi_unprepare(struct spi_master *master, return 0; } -static int img_spfi_setup(struct spi_device *spi) -{ - int ret = -EINVAL; - struct img_spfi_device_data *spfi_data = spi_get_ctldata(spi); - - if (!spfi_data) { - spfi_data = kzalloc(sizeof(*spfi_data), GFP_KERNEL); - if (!spfi_data) - return -ENOMEM; - spfi_data->gpio_requested = false; - spi_set_ctldata(spi, spfi_data); - } - if (!spfi_data->gpio_requested) { - ret = gpio_request_one(spi->cs_gpio, - (spi->mode & SPI_CS_HIGH) ? - GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, - dev_name(&spi->dev)); - if (ret) - dev_err(&spi->dev, "can't request chipselect gpio %d\n", - spi->cs_gpio); - else - spfi_data->gpio_requested = true; - } else { - if (gpio_is_valid(spi->cs_gpio)) { - int mode = ((spi->mode & SPI_CS_HIGH) ? - GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH); - - ret = gpio_direction_output(spi->cs_gpio, mode); - if (ret) - dev_err(&spi->dev, "chipselect gpio %d setup failed (%d)\n", - spi->cs_gpio, ret); - } - } - return ret; -} - -static void img_spfi_cleanup(struct spi_device *spi) -{ - struct img_spfi_device_data *spfi_data = spi_get_ctldata(spi); - - if (spfi_data) { - if (spfi_data->gpio_requested) - gpio_free(spi->cs_gpio); - kfree(spfi_data); - spi_set_ctldata(spi, NULL); - } -} - static void img_spfi_config(struct spi_master *master, struct spi_device *spi, struct spi_transfer *xfer) { @@ -659,12 +606,11 @@ static int img_spfi_probe(struct platform_device *pdev) master->max_speed_hz = max_speed_hz; } - master->setup = img_spfi_setup; - master->cleanup = img_spfi_cleanup; master->transfer_one = img_spfi_transfer_one; master->prepare_message = img_spfi_prepare; master->unprepare_message = img_spfi_unprepare; master->handle_err = img_spfi_handle_err; + master->use_gpio_descriptors = true; spfi->tx_ch = dma_request_chan(spfi->dev, "tx"); if (IS_ERR(spfi->tx_ch)) {