From patchwork Wed Sep 28 22:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 610912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29B6DC32771 for ; Wed, 28 Sep 2022 22:22:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234411AbiI1WWR (ORCPT ); Wed, 28 Sep 2022 18:22:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbiI1WWQ (ORCPT ); Wed, 28 Sep 2022 18:22:16 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1AA2F1628; Wed, 28 Sep 2022 15:22:14 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id cv6so3435794pjb.5; Wed, 28 Sep 2022 15:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=lGz97QYEJFNBsy5dY0VRqJEEBdi/yXtXeELS9Xem+YU=; b=pb7rQIMpcIT2b9PEO0tPbwQE08NdN3twtEDhP7iEfvtJwEnDXmjg9UhIPr8AToejNu KwQURpVDeUpwkeUuPbrYAe+W5dTcVjS8ePOlK0LE/Xc7YGVgw/rjPTKs9Zk0hRaz+8U/ qy5TqU1mqesKNf2nYsoKxdzdhnebXz9VpMdv0Sgfr0uEUU8h+9Uc5V5W1nglBy5GFaGz bjPWDbO67hs4hq/l8425BGSS05uFVAE70xvFoc4TTGd8ie3QUxAjJR87FzC1VCq+lGSL 1WXnuSB0PevlaEF3UpP0Xb4ntgv85z8f6yxdjfNq3PihpfzJSdLP6J85X3rZZcVfAo6F 04pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=lGz97QYEJFNBsy5dY0VRqJEEBdi/yXtXeELS9Xem+YU=; b=xOEanhaK44ZgGFjqlbSut5thUFJUQdGzdnD4N4AhYYmyNcbq0Uw5sA5vbdNCXqdQ/Y 9i9FdgJ/VHnwGwlht2/DGXCnxtIUDZR/bKFNslCKojZXDtMcVEHwh333trbcOv+R/hSf clKBVWF/asp3sZel0x8AxrYSWdhaUOWd/07sFmGLirdBaZo1EAgAwwZStgdjfX1tvvK/ tZ5+ocqhlEO6/ZDDXwvDoAQ5akY/0PcKFyXQdSHf5ZLLjXCJBn5p95EK/bXAKXBdKp7Z DtbdAB7S1iiRiTnr0YaskGNXPiz5BYmzTo4IrzP9kDlhhzoKKtDzqA5KeYl62fmM/CYM iDHA== X-Gm-Message-State: ACrzQf0SkzHPTH1X17JAgQZuvWPcz+j+iyMRmo59/h17Ad+RU9EaCvDF AdB3Io2RWgkPkFxOlee8xkM= X-Google-Smtp-Source: AMsMyM6IzFTHuML+YQrcZf/sqCaiIwvSpFx+BrX9KQsO42GNKkKvy23XsvpyRlC7dbgmyZSSlqYIRg== X-Received: by 2002:a17:903:234c:b0:17a:a2e:40ce with SMTP id c12-20020a170903234c00b0017a0a2e40cemr118714plh.106.1664403734229; Wed, 28 Sep 2022 15:22:14 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:1a91:59b8:faf:7b4f]) by smtp.gmail.com with ESMTPSA id ru21-20020a17090b2bd500b002008a85bac1sm2023694pjb.49.2022.09.28.15.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:22:13 -0700 (PDT) From: Dmitry Torokhov To: Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] wifi: wl1251: drop support for platform data Date: Wed, 28 Sep 2022 15:22:09 -0700 Message-Id: <20220928222210.1922758-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org There are no users of wl1251_platform_data left in the mainline kernel, so let's remove it. Signed-off-by: Dmitry Torokhov --- .../net/wireless/ti/wilink_platform_data.c | 35 --------------- drivers/net/wireless/ti/wl1251/sdio.c | 8 +--- drivers/net/wireless/ti/wl1251/spi.c | 15 ++----- include/linux/wl12xx.h | 44 ------------------- 4 files changed, 4 insertions(+), 98 deletions(-) delete mode 100644 drivers/net/wireless/ti/wilink_platform_data.c delete mode 100644 include/linux/wl12xx.h diff --git a/drivers/net/wireless/ti/wilink_platform_data.c b/drivers/net/wireless/ti/wilink_platform_data.c deleted file mode 100644 index 1de6a62d526f..000000000000 --- a/drivers/net/wireless/ti/wilink_platform_data.c +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * This file is part of wl12xx - * - * Copyright (C) 2010-2011 Texas Instruments, Inc. - */ - -#include -#include -#include - -static struct wl1251_platform_data *wl1251_platform_data; - -int __init wl1251_set_platform_data(const struct wl1251_platform_data *data) -{ - if (wl1251_platform_data) - return -EBUSY; - if (!data) - return -EINVAL; - - wl1251_platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL); - if (!wl1251_platform_data) - return -ENOMEM; - - return 0; -} - -struct wl1251_platform_data *wl1251_get_platform_data(void) -{ - if (!wl1251_platform_data) - return ERR_PTR(-ENODEV); - - return wl1251_platform_data; -} -EXPORT_SYMBOL(wl1251_get_platform_data); diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c index c9a4e9a43400..301bd0043a43 100644 --- a/drivers/net/wireless/ti/wl1251/sdio.c +++ b/drivers/net/wireless/ti/wl1251/sdio.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -197,7 +196,6 @@ static int wl1251_sdio_probe(struct sdio_func *func, struct wl1251 *wl; struct ieee80211_hw *hw; struct wl1251_sdio *wl_sdio; - const struct wl1251_platform_data *wl1251_board_data; struct device_node *np = func->dev.of_node; hw = wl1251_alloc_hw(); @@ -225,11 +223,7 @@ static int wl1251_sdio_probe(struct sdio_func *func, wl->if_priv = wl_sdio; wl->if_ops = &wl1251_sdio_ops; - wl1251_board_data = wl1251_get_platform_data(); - if (!IS_ERR(wl1251_board_data)) { - wl->irq = wl1251_board_data->irq; - wl->use_eeprom = wl1251_board_data->use_eeprom; - } else if (np) { + if (np) { wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom"); wl->irq = of_irq_get(np, 0); if (wl->irq == -EPROBE_DEFER) { diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c index 9df38726e8b0..08d9814b49c1 100644 --- a/drivers/net/wireless/ti/wl1251/spi.c +++ b/drivers/net/wireless/ti/wl1251/spi.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -226,16 +225,13 @@ static const struct wl1251_if_operations wl1251_spi_ops = { static int wl1251_spi_probe(struct spi_device *spi) { - struct wl1251_platform_data *pdata = dev_get_platdata(&spi->dev); struct device_node *np = spi->dev.of_node; struct ieee80211_hw *hw; struct wl1251 *wl; int ret; - if (!np && !pdata) { - wl1251_error("no platform data"); + if (!np) return -ENODEV; - } hw = wl1251_alloc_hw(); if (IS_ERR(hw)) @@ -259,14 +255,9 @@ static int wl1251_spi_probe(struct spi_device *spi) goto out_free; } - if (np) { - wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom"); - wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0); - } else if (pdata) { - wl->power_gpio = pdata->power_gpio; - wl->use_eeprom = pdata->use_eeprom; - } + wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom"); + wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0); if (wl->power_gpio == -EPROBE_DEFER) { ret = -EPROBE_DEFER; goto out_free; diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h deleted file mode 100644 index 03d61f1d23ab..000000000000 --- a/include/linux/wl12xx.h +++ /dev/null @@ -1,44 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * This file is part of wl12xx - * - * Copyright (C) 2009 Nokia Corporation - * - * Contact: Luciano Coelho - */ - -#ifndef _LINUX_WL12XX_H -#define _LINUX_WL12XX_H - -#include - -struct wl1251_platform_data { - int power_gpio; - /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */ - int irq; - bool use_eeprom; -}; - -#ifdef CONFIG_WILINK_PLATFORM_DATA - -int wl1251_set_platform_data(const struct wl1251_platform_data *data); - -struct wl1251_platform_data *wl1251_get_platform_data(void); - -#else - -static inline -int wl1251_set_platform_data(const struct wl1251_platform_data *data) -{ - return -ENOSYS; -} - -static inline -struct wl1251_platform_data *wl1251_get_platform_data(void) -{ - return ERR_PTR(-ENODATA); -} - -#endif - -#endif From patchwork Wed Sep 28 22:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 610549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E709C6FA82 for ; Wed, 28 Sep 2022 22:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234509AbiI1WWS (ORCPT ); Wed, 28 Sep 2022 18:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbiI1WWR (ORCPT ); Wed, 28 Sep 2022 18:22:17 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C29F1857; Wed, 28 Sep 2022 15:22:16 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id v186so13695475pfv.11; Wed, 28 Sep 2022 15:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=h9q5EucT92dTMgZ65QlxwzC3EbF26KJeQy8ojKaTJsQ=; b=ccZ7o3C4g7EKdkAFC7A6RSoIRSNWR/jTucS539ALbO/BDFLa1W0dvDXSv2dOlEIaHX 39lLdgahKAxfKYP/iPFwpr3UuCzrUMyGUO5SP4NxR7GZDuzlQ0rwDuSeWvS8gAMY86bX c7yKZREt1ye52R9db9WMsS0E+Zq7g7NfYckuIarz3Ri3J4ec6XCO63HHQJtiTDB/j6cR Kvhc2NGQnEraQwCEGiHQaL1NrB+Ow8e2rtHFBBeUtp5nYfdZfJ7+tzsj3M0CwvJf9TO0 G0KwCE3CoKoxi0z61EfWng6PCuHlF5HjKBIbiIt3ZouLC6cukYwA4aWn9rFZr4CU61Jb 0fAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=h9q5EucT92dTMgZ65QlxwzC3EbF26KJeQy8ojKaTJsQ=; b=ME+i0bwYHCb5RYP4dAL60D0NcWyujgN19AEokcKfNowWXEcQbOt1MT1Tafgp4m2tKi RMAS92YN8X938c7lFlvNVYmw8sL3gBD4ZqTI09rYvkUA1JrTON1vPEMUV9pnbjIS5Nwb tAUz5ibY1HzQAMDgRBoHdOBl7cVsQqO/dpUR04/MoxyijWcKBtUptdK6TRZzMIZ9jdiC 9Ybt+ttshKSFBh++aV15mZVyXlFO1ZMU6BTUun8vGjdujc16KsNdzBQUlBwHevspi5mE af3XoVG20xDt5wYVZzNUrElxaoiAz7/LXDAz3wDjlmEmD0U17+x6hyrDGQANMA2+HKOL V33A== X-Gm-Message-State: ACrzQf3OYe7/xtNZftn3VY8N01nfjCESCZhMQ4DE0q0ReUobt+MrtmG/ tha4NzaIDPTt3k05syOnyjw= X-Google-Smtp-Source: AMsMyM47/rVC6avgrBDqVXzsmRxaZF4fFTnlT3jhL2Jzg4kOeJ380zTeWYQVXYsbUTrE8jDhbGlTOw== X-Received: by 2002:a05:6a00:1410:b0:528:5a5a:d846 with SMTP id l16-20020a056a00141000b005285a5ad846mr93329pfu.9.1664403735320; Wed, 28 Sep 2022 15:22:15 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:1a91:59b8:faf:7b4f]) by smtp.gmail.com with ESMTPSA id ru21-20020a17090b2bd500b002008a85bac1sm2023694pjb.49.2022.09.28.15.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:22:14 -0700 (PDT) From: Dmitry Torokhov To: Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] wireless: wl1251: switch to using gpiod API Date: Wed, 28 Sep 2022 15:22:10 -0700 Message-Id: <20220928222210.1922758-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20220928222210.1922758-1-dmitry.torokhov@gmail.com> References: <20220928222210.1922758-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This switches the driver from legacy gpio API to a newer gpiod API. Signed-off-by: Dmitry Torokhov --- drivers/net/wireless/ti/wl1251/spi.c | 63 +++++++++++++------------ drivers/net/wireless/ti/wl1251/wl1251.h | 1 - 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c index 08d9814b49c1..0ef590a6db53 100644 --- a/drivers/net/wireless/ti/wl1251/spi.c +++ b/drivers/net/wireless/ti/wl1251/spi.c @@ -5,6 +5,7 @@ * Copyright (C) 2008 Nokia Corporation */ +#include #include #include #include @@ -12,15 +13,19 @@ #include #include #include -#include +#include #include -#include #include #include "wl1251.h" #include "reg.h" #include "spi.h" +struct wl1251_spi { + struct spi_device *spi; + struct gpio_desc *power_gpio; +}; + static irqreturn_t wl1251_irq(int irq, void *cookie) { struct wl1251 *wl; @@ -34,13 +39,9 @@ static irqreturn_t wl1251_irq(int irq, void *cookie) return IRQ_HANDLED; } -static struct spi_device *wl_to_spi(struct wl1251 *wl) -{ - return wl->if_priv; -} - static void wl1251_spi_reset(struct wl1251 *wl) { + struct wl1251_spi *wl_spi = wl->if_priv; u8 *cmd; struct spi_transfer t; struct spi_message m; @@ -60,7 +61,7 @@ static void wl1251_spi_reset(struct wl1251 *wl) t.len = WSPI_INIT_CMD_LEN; spi_message_add_tail(&t, &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(wl_spi->spi, &m); wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); @@ -69,6 +70,7 @@ static void wl1251_spi_reset(struct wl1251 *wl) static void wl1251_spi_wake(struct wl1251 *wl) { + struct wl1251_spi *wl_spi = wl->if_priv; struct spi_transfer t; struct spi_message m; u8 *cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); @@ -112,7 +114,7 @@ static void wl1251_spi_wake(struct wl1251 *wl) t.len = WSPI_INIT_CMD_LEN; spi_message_add_tail(&t, &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(wl_spi->spi, &m); wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); @@ -128,6 +130,7 @@ static void wl1251_spi_reset_wake(struct wl1251 *wl) static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len) { + struct wl1251_spi *wl_spi = wl->if_priv; struct spi_transfer t[3]; struct spi_message m; u8 *busy_buf; @@ -157,7 +160,7 @@ static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, t[2].len = len; spi_message_add_tail(&t[2], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(wl_spi->spi, &m); /* FIXME: check busy words */ @@ -168,6 +171,7 @@ static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, static void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len) { + struct wl1251_spi *wl_spi = wl->if_priv; struct spi_transfer t[2]; struct spi_message m; u32 *cmd; @@ -190,7 +194,7 @@ static void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, t[1].len = len; spi_message_add_tail(&t[1], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(wl_spi->spi, &m); wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); @@ -208,8 +212,10 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl) static int wl1251_spi_set_power(struct wl1251 *wl, bool enable) { - if (gpio_is_valid(wl->power_gpio)) - gpio_set_value(wl->power_gpio, enable); + struct wl1251_spi *wl_spi = wl->if_priv; + + if (wl_spi->power_gpio) + gpiod_set_value_cansleep(wl_spi->power_gpio, enable); return 0; } @@ -227,12 +233,19 @@ static int wl1251_spi_probe(struct spi_device *spi) { struct device_node *np = spi->dev.of_node; struct ieee80211_hw *hw; + struct wl1251_spi *wl_spi; struct wl1251 *wl; int ret; if (!np) return -ENODEV; + wl_spi = devm_kzalloc(&spi->dev, sizeof(*wl_spi), GFP_KERNEL); + if (!wl_spi) + return -ENOMEM; + + wl_spi->spi = spi; + hw = wl1251_alloc_hw(); if (IS_ERR(hw)) return PTR_ERR(hw); @@ -241,7 +254,7 @@ static int wl1251_spi_probe(struct spi_device *spi) SET_IEEE80211_DEV(hw, &spi->dev); spi_set_drvdata(spi, wl); - wl->if_priv = spi; + wl->if_priv = wl_spi; wl->if_ops = &wl1251_spi_ops; /* This is the only SPI value that we need to set here, the rest @@ -257,25 +270,17 @@ static int wl1251_spi_probe(struct spi_device *spi) wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom"); - wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0); - if (wl->power_gpio == -EPROBE_DEFER) { - ret = -EPROBE_DEFER; - goto out_free; - } - - if (gpio_is_valid(wl->power_gpio)) { - ret = devm_gpio_request_one(&spi->dev, wl->power_gpio, - GPIOF_OUT_INIT_LOW, "wl1251 power"); - if (ret) { + wl_spi->power_gpio = devm_gpiod_get(&spi->dev, "ti,power", + GPIOD_OUT_LOW); + ret = PTR_ERR_OR_ZERO(wl_spi->power_gpio); + if (ret) { + if (ret != -EPROBE_DEFER) wl1251_error("Failed to request gpio: %d\n", ret); - goto out_free; - } - } else { - wl1251_error("set power gpio missing in platform data"); - ret = -ENODEV; goto out_free; } + gpiod_set_consumer_name(wl_spi->power_gpio, "wl1251 power"); + wl->irq = spi->irq; if (wl->irq < 0) { wl1251_error("irq missing in platform data"); diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h index 23ae07dd4c2e..83adbc3c25dc 100644 --- a/drivers/net/wireless/ti/wl1251/wl1251.h +++ b/drivers/net/wireless/ti/wl1251/wl1251.h @@ -262,7 +262,6 @@ struct wl1251 { void *if_priv; const struct wl1251_if_operations *if_ops; - int power_gpio; int irq; bool use_eeprom;