From patchwork Wed Mar 5 10:55:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14002452 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 D5AA420C497; Wed, 5 Mar 2025 10:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172225; cv=none; b=kSQIs+kfJC43cjLH2DYfjwB8iKfnlJ0ZQIhXm0ufOy2PDI3nHIYek8LY+VllsK1YjoBut+zqKgUwjR3ZNxK+yyic2ocLTBvNANY/Goe98Yfx3ukFzN3noz4ioHqLP0xj6V+UARhmr1un6bNY+Zna1OcR8mq5NCq252G3B2ZbeZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172225; c=relaxed/simple; bh=RSx3iAtB8qEjTFC1vJZKBwt/OD98kvw3pGfE1JEQ6Kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OCicHEn1gnCI93lO1sXk1JS8yCO6XZxUllFxO07F9hNPWp7czzm0cvB/b+PFTpM+5GtgXKznLWDl4amRx2qEa/cDUwOOh8wX3qitEU87kc9bnw75e+QgxsUZARSxB0NOi3MduCIoKlaXPMDvdtITPdzc+tleQNZSYhDbO7bollc= 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=jU/U3HHl; arc=none smtp.client-ip=192.198.163.7 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="jU/U3HHl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741172224; x=1772708224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RSx3iAtB8qEjTFC1vJZKBwt/OD98kvw3pGfE1JEQ6Kc=; b=jU/U3HHlKkraeFK8fvl+lvYHi+l9CoZRilGQ7l1/aTgP1yjUUDfvGAqN naCtO2qTpFIjk+FWlIGKfIQjv+ReszphOjDB4kvpZAqaBrmx1MFyEpzRK GqU4XIx/St2cUZYzmtZLgX0r5DpolGSnMHCsvGKbD+1jXnFK/w8rGkYaV 7HtOB4KybCss4Hxrkin3j4Ao+I4TOBurg6OEoQkVnSOb3LGFrCTLN+uOd vsdtzYL4F+VZHzega16BklyBsjdzeytxkEwE/9Nf9RldsjYXyQJ0hF2JY b9t/n9DKmQ2Gf32lhfKzvN7CAy7NsU96VXnGQk/BP/egozXQNisr8mmgN Q==; X-CSE-ConnectionGUID: V7FdItoKQ7ytFBbyBEb1UA== X-CSE-MsgGUID: /YB2AByNTMqsVbBI7pBA2w== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="67497627" X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="67497627" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 02:57:02 -0800 X-CSE-ConnectionGUID: ib2IBscjQoqkM/xZqFXrDA== X-CSE-MsgGUID: blUSDORYTqe4xLO375bbGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="118483427" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 05 Mar 2025 02:56:58 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 884D21FD; Wed, 05 Mar 2025 12:56:57 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Miquel Raynal , Linus Walleij , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bartosz Golaszewski , Alexander Aring , Stefan Schmidt Subject: [PATCH net-next v4 1/4] ieee802154: ca8210: Use proper setters and getters for bitwise types Date: Wed, 5 Mar 2025 12:55:34 +0200 Message-ID: <20250305105656.2133487-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> References: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-wpan@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 setters 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] Reviewed-by: Miquel Raynal Reviewed-by: Linus Walleij 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 Wed Mar 5 10:55:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14002451 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 D5B03212FBC; Wed, 5 Mar 2025 10:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172225; cv=none; b=CKYXezlR4V1JjKDwwmguAhyhwktB0O9yP6bBzZV0TzpjBXbwo+P8g9cMAb6zXiBwQxTv4CkTjCLNox0yZDmlUqbP/oWjdnx7f4kt+8xeSzSW4ik3zqavPl1kZXrESar+PhIOPedTVkNv5qpmrxmE57haZ/JJrqDkhNjdCMcsgts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172225; c=relaxed/simple; bh=Y2DxWO9SVL0K/7sX3lxmLJs8FOiKJR3NxXXhMoLiKJc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nJ7HQFasdqBUpIkZFFHS9K3LEi/iVyjB/8mOArrGYvcdCC45NDYK2L6XXVLgTUD2TIrjBy8+HANSSimQc33HSKMwTdeR258J1A9tsjjyKiDikB/LKzn11/2YbIbvZv+h6dQduBXC+AgF6/uv+qn1B03DOIX5fzLoywL5u3czOFc= 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=UmyNqYFm; arc=none smtp.client-ip=198.175.65.15 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="UmyNqYFm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741172224; x=1772708224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y2DxWO9SVL0K/7sX3lxmLJs8FOiKJR3NxXXhMoLiKJc=; b=UmyNqYFm8R0idLSBQ2Q6X+K4VtPAHulO0dhdCPVBENnGWSWv4FAvjZIh FLTqBkXpod08hTKE16xP/kEeDGP89b1sI18zXPJ6DJMme8aURmrzgSjpP A6zQ1ymquzmRmNTbyBroBalR1r1VCqdh3lqiH/S49PzSEKEJnBoZlyaje 8ELD90qCk+07GdRlrot3TI4b6FbZYskyWO3KXd3a2WcZKvYYttoxUj64t YdVxxOvP0P96s0Y4EmPZJaQlxPBRDjQtgKyWBVTzj/I4BmZvW/w8EDYsP u9CDCBey3k8vL6xN7fm9cKYalbtkvkI09WpScmu4ifsC9LkoeJjUjO0qj g==; X-CSE-ConnectionGUID: sXnWUcU6TLKpxEyY2tyhzw== X-CSE-MsgGUID: FiNIwXSwRqSVeAyv8bSyLQ== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="45783897" X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="45783897" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 02:57:03 -0800 X-CSE-ConnectionGUID: xLex4o6FRe+ZXqdDwTS+Zg== X-CSE-MsgGUID: upi6mBhWRgujJF6ntR6ceA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="123245746" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 05 Mar 2025 02:56:58 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 93305296; Wed, 05 Mar 2025 12:56:57 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Miquel Raynal , Linus Walleij , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bartosz Golaszewski , Alexander Aring , Stefan Schmidt Subject: [PATCH net-next v4 2/4] ieee802154: ca8210: Get platform data via dev_get_platdata() Date: Wed, 5 Mar 2025 12:55:35 +0200 Message-ID: <20250305105656.2133487-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> References: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Access to platform data via dev_get_platdata() getter to make code cleaner. Reviewed-by: Linus Walleij Reviewed-by: Miquel Raynal Signed-off-by: Andy Shevchenko --- drivers/net/ieee802154/ca8210.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index a036910f6082..65f042c8734b 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -627,7 +627,8 @@ static int ca8210_spi_transfer( */ static void ca8210_reset_send(struct spi_device *spi, unsigned int ms) { - struct ca8210_platform_data *pdata = spi->dev.platform_data; + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); struct ca8210_priv *priv = spi_get_drvdata(spi); long status; @@ -2736,9 +2737,10 @@ static int ca8210_config_extern_clk( */ static int ca8210_register_ext_clock(struct spi_device *spi) { + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); struct device_node *np = spi->dev.of_node; struct ca8210_priv *priv = spi_get_drvdata(spi); - struct ca8210_platform_data *pdata = spi->dev.platform_data; if (!np) return -EFAULT; @@ -2784,8 +2786,9 @@ static void ca8210_unregister_ext_clock(struct spi_device *spi) */ static int ca8210_reset_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_reset = of_get_named_gpio( spi->dev.of_node, @@ -2813,8 +2816,9 @@ 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, From patchwork Wed Mar 5 10:55:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14002455 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 5909722A4DF; Wed, 5 Mar 2025 10:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172228; cv=none; b=ctKLFBYTXWqSNtnpO9x1LBGDncbhcTLtg3CDpPGBtH+oHIgUcmw2Di9a4bIwWju8RShYSa+1awn+ugdC7D9gHL9AjfdVrWBdRzTCzo6Kq4FvbqdCJmufi+Vk8wN3SvwXoI8SECcvq+KTS+cb5lQCP10gHHtn6KfAa5VDdOq9TFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172228; c=relaxed/simple; bh=4mWiSaWYOBSBHZ9umfa/gZfpmXrkDhdbnk2oA30pHHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CkgxQLb/kKTz3Gi2wILapkzpt8PfEL0d57BR7hfvNsleC+r2WoucEb+mlgZX2wWh4zdx6bzkzP1o0z+tOrFv2Y/4q7dOTIocxtsFGgq2jn4tzndShbST9ZAwlV5KqBs3k+XjXns8ODpTQoK+eOJztltWrMq4t7O+s6XMpKt7pkg= 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=er8CLQyT; arc=none smtp.client-ip=198.175.65.15 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="er8CLQyT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741172227; x=1772708227; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4mWiSaWYOBSBHZ9umfa/gZfpmXrkDhdbnk2oA30pHHE=; b=er8CLQyTvMNhcpnAn1WYg5mwPobTT4oMT8FyVLwWFN0gANGzRrSkw2p7 FcGXaqpg3pNwI1SVasfzj0K5/kWT5rsO/ticRFItcp62H88+qLifdgXex r9eS2BKD0QNRhAgyGwLaWPoSOGs2hA93c0e/Vo/HTUt0X3endP+MbH0hI 4Vi5hUYKHHbUmPCpfFwmo5ug7g8UdUWp3kDKVaGCkyPGWNXEk5IcyE3hv YFxyzMD/saSVdcFNcmIdxpu8w/1fCnoJAw7zLyoDiS6/lgjLhQ5bvqhpf irNjqpMxSCtgH6jMFia5CNlGw9repEi45zMaxSWPRlwiwshecNAaDqbdE Q==; X-CSE-ConnectionGUID: QjBeELr5ReuYCX/2qubWlQ== X-CSE-MsgGUID: Bp4bxZTZQC6OiAcUUfZTiw== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="45783928" X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="45783928" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 02:57:04 -0800 X-CSE-ConnectionGUID: YdFP/EZ3RLi2eaiBqmj98g== X-CSE-MsgGUID: 7P8XXUEXQyKZmFetVQl47g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="123245749" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 05 Mar 2025 02:56:58 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A218B2CA; Wed, 05 Mar 2025 12:56:57 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Miquel Raynal , Linus Walleij , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bartosz Golaszewski , Alexander Aring , Stefan Schmidt Subject: [PATCH net-next v4 3/4] ieee802154: ca8210: Switch to using gpiod API Date: Wed, 5 Mar 2025 12:55:36 +0200 Message-ID: <20250305105656.2133487-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> References: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-wpan@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(). With this, invert the logic of the reset pin which is active-low and add a quirk for the legacy and incorrect device tree descriptions. Reviewed-by: Linus Walleij Reviewed-by: Miquel Raynal Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-of.c | 9 ++++++ drivers/net/ieee802154/ca8210.c | 57 +++++++++++---------------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index a7370fa48556..280d56736844 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -203,6 +203,15 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np, */ { "qi,lb60", "rb-gpios", true }, #endif +#if IS_ENABLED(CONFIG_IEEE802154_CA8210) + /* + * According to the datasheet, the NRST pin 27 is an active-low + * signal. However, the device tree schema and admittedly + * the out-of-tree implementations have been used for a long + * time incorrectly by describing reset GPIO as active-high. + */ + { "cascoda,ca8210", "reset-gpio", false }, +#endif #if IS_ENABLED(CONFIG_PCI_LANTIQ) /* * According to the PCI specification, the RST# pin is an diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index 65f042c8734b..ebc4f1b18e7b 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: ca8210 reset GPIO descriptor + * @irq_gpio: ca8210 interrupt GPIO descriptor * @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; }; @@ -632,10 +630,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, 1); reinit_completion(&priv->ca8210_is_awake); msleep(ms); - gpio_set_value(pdata->gpio_reset, 1); + gpiod_set_value(pdata->reset_gpio, 0); priv->promiscuous = false; /* Wait until wakeup indication seen */ @@ -2788,24 +2786,14 @@ static int ca8210_reset_init(struct spi_device *spi) { struct device *dev = &spi->dev; struct ca8210_platform_data *pdata = dev_get_platdata(dev); - int ret; - pdata->gpio_reset = of_get_named_gpio( - spi->dev.of_node, - "reset-gpio", - 0 - ); - - 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 - ); + pdata->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(pdata->reset_gpio)) { + dev_crit(dev, "Reset GPIO did not set to output mode\n"); + return PTR_ERR(pdata->reset_gpio); } - return ret; + return 0; } /** @@ -2820,20 +2808,15 @@ static int ca8210_interrupt_init(struct spi_device *spi) struct ca8210_platform_data *pdata = dev_get_platdata(dev); int ret; - 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; } @@ -2844,10 +2827,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; } From patchwork Wed Mar 5 10:55:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14002454 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 D9437223714; Wed, 5 Mar 2025 10:57:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172227; cv=none; b=LXW5NsFo6vkijZAYjwCoTZ5aHTwVZRsf4twGSIYcH50GmL+W2IrIZ7cy1lODV2HGGX3IY+ofF66LjqqxUTsYmYUJYjdkYh6MozYlKGq3SsEdV2Ep87V8F13p7HkJfGiF/f5TS32OZz7RjNy2EsYirpLklRXfAix6jD2U59Ji6kE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172227; c=relaxed/simple; bh=WX8dmil2AirHqiEUBrw0AiYasFZtpK3RZuuWUW3dBzI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FqFc/RKHIvRvaGhFEAmdPysGKgcHGC65+0ZZvld27NqUdkoz7xFVmk43qatYZm1raU6Fmn0fOvkPG76929bUHJ7Jb9RHmIEe4hRFm6elbFnszHOhKzJSnR40pzo9cv8gJwo9I8daxr3rBbCamt0/+kUaOVQL59z3Pe40NFY5RsA= 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=GsyFrjkj; arc=none smtp.client-ip=192.198.163.7 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="GsyFrjkj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741172226; x=1772708226; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WX8dmil2AirHqiEUBrw0AiYasFZtpK3RZuuWUW3dBzI=; b=GsyFrjkjCYC8nQc2TaHUIDIEYp0dPgQ7G8nSwePkUbEsoBlmnrtHwQe8 5TYOXmy79tG6VyB9oddoM8P4V+iF/BHx86U+x3R1mTDEotzCOoiAVhJ14 wtfYDfrcaKntwfn9A9s7kOCPLJeIWWbv5Ybwm5ehlFahdVVXpgEfV6NAx Uyf8OM6dqPvmsHFChhrktZYXEXFebk9cybHyuRi5/zsDbgixKaXz0s//T OEVaJEpa03EKRxuEOrs4Iiy+dmzbUA4ZvQ56Awvna4H5ayrg3myorbgpa BGCsV8kfnUFVHhkYxpAK6DX8b+62H9be53R4cI4DJA9WBsssuSQtepP6Z w==; X-CSE-ConnectionGUID: 0ynDwd3WTS25sSRPZoPFoQ== X-CSE-MsgGUID: Izd3iMrwToqyJxr493D2tg== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="67497646" X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="67497646" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 02:57:03 -0800 X-CSE-ConnectionGUID: Di/Q7k2RSK65jce0wtbufA== X-CSE-MsgGUID: 2FkXNLdUTT6xks+0slydOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="118483428" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 05 Mar 2025 02:56:58 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B16F6324; Wed, 05 Mar 2025 12:56:57 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Miquel Raynal , Linus Walleij , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bartosz Golaszewski , Alexander Aring , Stefan Schmidt Subject: [PATCH net-next v4 4/4] dt-bindings: ieee802154: ca8210: Update polarity of the reset pin Date: Wed, 5 Mar 2025 12:55:37 +0200 Message-ID: <20250305105656.2133487-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> References: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The code has been updated to follow what datasheet says about the polarity of the reset pin, which is active-low. Update the device tree bindings accordingly. Signed-off-by: Andy Shevchenko Acked-by: Conor Dooley --- Documentation/devicetree/bindings/net/ieee802154/ca8210.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/ieee802154/ca8210.txt b/Documentation/devicetree/bindings/net/ieee802154/ca8210.txt index a1046e636fa1..f1bd07a0097d 100644 --- a/Documentation/devicetree/bindings/net/ieee802154/ca8210.txt +++ b/Documentation/devicetree/bindings/net/ieee802154/ca8210.txt @@ -20,7 +20,7 @@ Example: reg = <0>; spi-max-frequency = <3000000>; spi-cpol; - reset-gpio = <&gpio1 1 GPIO_ACTIVE_HIGH>; + reset-gpio = <&gpio1 1 GPIO_ACTIVE_LOW>; irq-gpio = <&gpio1 2 GPIO_ACTIVE_HIGH>; extclock-enable; extclock-freq = 16000000;