From patchwork Mon Mar 3 15:07:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 870254 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 684CD21422F; Mon, 3 Mar 2025 15:10:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741014607; cv=none; b=f0tbKI2wuaVDND2B+LBYmwW+DywWeE6bind4UM+basQdwMnpfdC8whVtdCmReimTVZiGDSjxdVRHdoBaOprv87MucNOomfK6ortpULRXc/c6pdCsjR8h4THqm2qx3NMW8vYLTg4pmlXCQNnHSWhDiiuV/1eGzpv+bKWygzYFYXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741014607; c=relaxed/simple; bh=wG1LPG3PWw+Nuyv3av9wI4E1Dhhx8hVT1Q8Qt5vaaZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QhyLWktawIrsQ5I8vfOh94NSrY/eKeJhn62so12IksY74MTGg5A8kwb8LSl75qGyZCyn68F/sBIDY5ROXs0Evgx+9arYZ8Bl5s3UyuN4TGFPJ/MaeZLwrbLbk/ipZA2Ra3h3VlJTKc4pA+VFpfJdOmGOeLXw28KjdsnfDHhnDCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=d4knYuPo; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="d4knYuPo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741014606; x=1772550606; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wG1LPG3PWw+Nuyv3av9wI4E1Dhhx8hVT1Q8Qt5vaaZg=; b=d4knYuPoZPxDEiLuJJ9t+knQVqGhmvqEBfyQWKOH5cGb4aw9TvtCiLBr Pn3yvwXiBY/uFJgtf+TrdL9PhR6NPAR25JuAezLF8kQQwfIrYq8Vq2B5y Sv3kOJq1x95ZJRPqhm/Fyh7joywxtUofLtKLmbBMkqOurZvGb4VjEqptA qZvi5QfEk5vVajxw4oGLVWWG+g2wFF/KmshKVsT5RaqlUl53cC2VXim5o 2o3/uII7qCUhG+SJQ/71yv+dbo9noObO9GAfeUs4HJmAT81yQ/xUiOL0w aEuuCGgpfeHlliAVW+k8uY6R6EZarI5LqM9jzGRru+QIzgk0dgnoFWN9W w==; X-CSE-ConnectionGUID: Ya5YA/njTpa4dl9icIdfag== X-CSE-MsgGUID: axPEXjpKS6SVNi3xQwfq+A== X-IronPort-AV: E=McAfee;i="6700,10204,11362"; a="52099510" X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="52099510" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2025 07:09:02 -0800 X-CSE-ConnectionGUID: pgxIWZkQRxeqhNEnyyqc6A== X-CSE-MsgGUID: DUgtES8RR62rxCN2N6wIFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="118739576" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 03 Mar 2025 07:08:57 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 804C610A; Mon, 03 Mar 2025 17:08:56 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Alexander Aring , Stefan Schmidt , Miquel Raynal , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Linus Walleij , Bartosz Golaszewski Subject: [PATCH net-next v1 1/2] ieee802154: ca8210: Use proper setter and getters for bitwise types Date: Mon, 3 Mar 2025 17:07:39 +0200 Message-ID: <20250303150855.1294188-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250303150855.1294188-1-andriy.shevchenko@linux.intel.com> References: <20250303150855.1294188-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sparse complains that the driver doesn't respect the bitwise types: drivers/net/ieee802154/ca8210.c:1796:27: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1796:27: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1796:27: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1801:25: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1801:25: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1801:25: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1928:28: warning: incorrect type in argument 3 (different base types) drivers/net/ieee802154/ca8210.c:1928:28: expected unsigned short [usertype] dst_pan_id drivers/net/ieee802154/ca8210.c:1928:28: got restricted __le16 [addressable] [usertype] pan_id Use proper setter and getters for bitwise types. Note, in accordance with [1] the protocol is little endian. Link: https://www.cascoda.com/wp-content/uploads/2018/11/CA-8210_datasheet_0418.pdf [1] Signed-off-by: Andy Shevchenko --- drivers/net/ieee802154/ca8210.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index 753215ebc67c..a036910f6082 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -1446,8 +1446,7 @@ static u8 mcps_data_request( command.pdata.data_req.src_addr_mode = src_addr_mode; command.pdata.data_req.dst.mode = dst_address_mode; if (dst_address_mode != MAC_MODE_NO_ADDR) { - command.pdata.data_req.dst.pan_id[0] = LS_BYTE(dst_pan_id); - command.pdata.data_req.dst.pan_id[1] = MS_BYTE(dst_pan_id); + put_unaligned_le16(dst_pan_id, command.pdata.data_req.dst.pan_id); if (dst_address_mode == MAC_MODE_SHORT_ADDR) { command.pdata.data_req.dst.address[0] = LS_BYTE( dst_addr->short_address @@ -1795,12 +1794,12 @@ static int ca8210_skb_rx( } hdr.source.mode = data_ind[0]; dev_dbg(&priv->spi->dev, "srcAddrMode: %#03x\n", hdr.source.mode); - hdr.source.pan_id = *(u16 *)&data_ind[1]; + hdr.source.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[1])); dev_dbg(&priv->spi->dev, "srcPanId: %#06x\n", hdr.source.pan_id); memcpy(&hdr.source.extended_addr, &data_ind[3], 8); hdr.dest.mode = data_ind[11]; dev_dbg(&priv->spi->dev, "dstAddrMode: %#03x\n", hdr.dest.mode); - hdr.dest.pan_id = *(u16 *)&data_ind[12]; + hdr.dest.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[12])); dev_dbg(&priv->spi->dev, "dstPanId: %#06x\n", hdr.dest.pan_id); memcpy(&hdr.dest.extended_addr, &data_ind[14], 8); @@ -1927,7 +1926,7 @@ static int ca8210_skb_tx( status = mcps_data_request( header.source.mode, header.dest.mode, - header.dest.pan_id, + le16_to_cpu(header.dest.pan_id), (union macaddr *)&header.dest.extended_addr, skb->len - mac_len, &skb->data[mac_len], From patchwork Mon Mar 3 15:07:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 870255 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B882212B04; Mon, 3 Mar 2025 15:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741014605; cv=none; b=ZvCgGs24BSUJHNQqdqYre5oyNiiJlb7ZKc8Ov80dygyH2epXXYj+LMm0H+XP2Y+vZjD/Gfed00u55ekT3qeoKMHjtm+yffBZ7qtd+YlzF+qvNiJJvi8QJdCpQhLcBnUZ7rNhV76PIZBJ6gX7S3aGyuBsh55TBYBVpzRdNfKyLu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741014605; c=relaxed/simple; bh=+nmCVhTXoru3X0wWJqoQLsXNFK1aXTMN9Yyx21EeHNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tkK94p4OXCiGs0ZLc6XQAQ5bKl3+ZF32XxyYqfrgN1YDfKKNwgBbU8QhUdiI7T72mzpushJxZWsGc2KGlAMuduj/pQ1we5AJOCM+SAwG+WprP6I7xsVbikyytfmcuhx/ibcwuWABpA54N1Xt5asPebiUhd61UTTahoSCTZgdyTA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FuW5LXJ/; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FuW5LXJ/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741014603; x=1772550603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+nmCVhTXoru3X0wWJqoQLsXNFK1aXTMN9Yyx21EeHNo=; b=FuW5LXJ/ZbmFdSW5L102GCMdfeL3iIcarVT36+yeVIaDY25a2dM8E0S+ hbRkSgv666vyTf847zGRpjgTAx8ShoLtNb3bF4m6YnKvcPKtBoEm/W1RR FRVPl7p3QJJqjv+q8DNmcwHh6jMSRoI4fx7bEZltHI1jCDgNFdB45BUGI cljTBIVTsjUiGapuagybTGecmJhwv1L42kOqO1yDN4a0IH174ISOHu1TR K8DiFIb8vRN6U08oPA1Y45Syq6g0Pnxno6omfyT7bN7J68RFgKaqSnSEz sIXktAnsGIgNkpCvO8N1Nspf6ppPcKR5MYg796Y0LXerB6NRPu3OiMEwV A==; X-CSE-ConnectionGUID: +OHKg/u8SxOiFK+zMXwrOQ== X-CSE-MsgGUID: czEH5OC8RauRlHnEPelrPg== X-IronPort-AV: E=McAfee;i="6700,10204,11362"; a="52099481" X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="52099481" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2025 07:09:01 -0800 X-CSE-ConnectionGUID: K1pD2p+pRQeKrxUygAZjJQ== X-CSE-MsgGUID: 5u9d68B3QyageQIsd99Bsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="118739574" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 03 Mar 2025 07:08:57 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8FC25191; Mon, 03 Mar 2025 17:08:56 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Alexander Aring , Stefan Schmidt , Miquel Raynal , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Linus Walleij , Bartosz Golaszewski Subject: [PATCH net-next v1 2/2] ieee802154: ca8210: Switch to using gpiod API Date: Mon, 3 Mar 2025 17:07:40 +0200 Message-ID: <20250303150855.1294188-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250303150855.1294188-1-andriy.shevchenko@linux.intel.com> References: <20250303150855.1294188-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This updates the driver to gpiod API, and removes yet another use of of_get_named_gpio(). Signed-off-by: Andy Shevchenko --- drivers/net/ieee802154/ca8210.c | 63 ++++++++++++--------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index a036910f6082..2342f1927dc9 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -52,12 +52,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -350,8 +348,8 @@ struct work_priv_container { * @extclockenable: true if the external clock is to be enabled * @extclockfreq: frequency of the external clock * @extclockgpio: ca8210 output gpio of the external clock - * @gpio_reset: gpio number of ca8210 reset line - * @gpio_irq: gpio number of ca8210 interrupt line + * @reset_gpio: GPIO of ca8210 reset line + * @irq_gpio: GPIO of ca8210 interrupt line * @irq_id: identifier for the ca8210 irq * */ @@ -359,8 +357,8 @@ struct ca8210_platform_data { bool extclockenable; unsigned int extclockfreq; unsigned int extclockgpio; - int gpio_reset; - int gpio_irq; + struct gpio_desc *reset_gpio; + struct gpio_desc *irq_gpio; int irq_id; }; @@ -631,10 +629,10 @@ static void ca8210_reset_send(struct spi_device *spi, unsigned int ms) struct ca8210_priv *priv = spi_get_drvdata(spi); long status; - gpio_set_value(pdata->gpio_reset, 0); + gpiod_set_value(pdata->reset_gpio, 0); reinit_completion(&priv->ca8210_is_awake); msleep(ms); - gpio_set_value(pdata->gpio_reset, 1); + gpiod_set_value(pdata->reset_gpio, 1); priv->promiscuous = false; /* Wait until wakeup indication seen */ @@ -2784,25 +2782,14 @@ static void ca8210_unregister_ext_clock(struct spi_device *spi) */ static int ca8210_reset_init(struct spi_device *spi) { - int ret; - struct ca8210_platform_data *pdata = spi->dev.platform_data; + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); - pdata->gpio_reset = of_get_named_gpio( - spi->dev.of_node, - "reset-gpio", - 0 - ); + pdata->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(pdata->reset_gpio)) + dev_crit(dev, "Reset GPIO did not set to output mode\n"); - ret = gpio_direction_output(pdata->gpio_reset, 1); - if (ret < 0) { - dev_crit( - &spi->dev, - "Reset GPIO %d did not set to output mode\n", - pdata->gpio_reset - ); - } - - return ret; + return PTR_ERR_OR_ZERO(pdata->reset_gpio); } /** @@ -2813,23 +2800,19 @@ static int ca8210_reset_init(struct spi_device *spi) */ static int ca8210_interrupt_init(struct spi_device *spi) { + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); int ret; - struct ca8210_platform_data *pdata = spi->dev.platform_data; - pdata->gpio_irq = of_get_named_gpio( - spi->dev.of_node, - "irq-gpio", - 0 - ); + pdata->irq_gpio = devm_gpiod_get(dev, "irq", GPIOD_IN); + if (IS_ERR(pdata->irq_gpio)) { + dev_crit(dev, "Could not retrieve IRQ GPIO\n"); + return PTR_ERR(pdata->irq_gpio); + } - pdata->irq_id = gpio_to_irq(pdata->gpio_irq); + pdata->irq_id = gpiod_to_irq(pdata->irq_gpio); if (pdata->irq_id < 0) { - dev_crit( - &spi->dev, - "Could not get irq for gpio pin %d\n", - pdata->gpio_irq - ); - gpio_free(pdata->gpio_irq); + dev_crit(dev, "Could not get irq for IRQ GPIO\n"); return pdata->irq_id; } @@ -2840,10 +2823,8 @@ static int ca8210_interrupt_init(struct spi_device *spi) "ca8210-irq", spi_get_drvdata(spi) ); - if (ret) { + if (ret) dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id); - gpio_free(pdata->gpio_irq); - } return ret; }