From patchwork Thu May 30 16:33:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680583 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 72F7D1CD24 for ; Thu, 30 May 2024 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086835; cv=fail; b=ZbMny21I2j1xCc8Ihg/7nSICMpL5I/R4fSI44oDqpk+TBm3YpG1jWlhL3TwYbNEvKg7s/++Fm9X4xMVtT8uIRPui36KCdHO11Ksgr6vK3l6TwcWmMWLRZHY5+CZg4REom7T7VKJzfFoXGqkpY3EDjQuG6D912V1UAFe5Q36w+dI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086835; c=relaxed/simple; bh=wWtlRTqG9GqAHJL8Q0xQuWr6nA7t5prlJ9Hb/zBLM1o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=sg0/QbTVvpaYRQbUPI/XymqEnxj6Txjjo1jLYh8o1YHpyGsAfZpPVbNLZXsOCPxHdtKTQkdxtwZJaEdO6SDrbfSAo961gm0l8qmezC4ztPDJcaF/FGg6/KYx/t2mT293Ql4kyn0vV71+YPc5f5PHGirC8COgYvrbJ/eMY3LCCJA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=Pf8F+LkL; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Pf8F+LkL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hn2vk8Ha07FcStD0MBSfbBTJzIAqX/P0FXcqZuUvoXVQqG7pGuqDCZXbWDjOfyX0S6AmaFtzjm8NDyxoeqZ8hJjM8zLeyWzJGwocC9preFNJAn4xoTEqCA7jxcXmxiq7HSQXFIhhqgpoZaziP92PHey2/+FtCzRGoI8k/YBskIwD3uKmSA4dyv+nEtF6XZ4l/ymEy/0Jx8y9LU1trinX/oMKIA1Qm7I5F5oc6gZB9icPGbZohcrogAmOT4uiumMWIkT0LyAh4s49P6GO/W+GkSQU8RyGPr9ca38yYiA/MbpvpL8yO5svQRW/5RbVg6r2IBQKTuShmdGL1rS5J/N6Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fArHhUaIGni4jJqgYTmB67JgRdNEWCmc1zs+y1v0EBo=; b=Z3XctduvvidwKgyrvAFT6RJnF8uQ2Jc50wbAZqZ86XQdTwRL93Qu60UZ7Fa3XKluRph2hi//oq2rn1eIbvuExJRmKoH7tf3rEHao2f+9ui/WorRaKHA3MNNuzk38VoAKnVbB6lNoQHGINl9LKBs9IhTNvEiYIsTwysUabx/H/D0TpNkE3R3xuyIITwq7WypR8/MTx/BZLaAxnysnANhgJs3tDHkKXfuDO/tZ5OQX144zxWk6APCFdDbV1oj+hNeSDnxsP+V+LM+8vSPszLbGGxTnKMRbj89eyM+CGyRdnQYWsxru1UxJOfxGPuq/LTN1gX2lcWzj6uEzMx9dfBSq9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fArHhUaIGni4jJqgYTmB67JgRdNEWCmc1zs+y1v0EBo=; b=Pf8F+LkLxRd0fZRtzFgQ/jCwb9WFMsn1vYI6rhn5XideZvVUy8tA6HN7XMrk1089397vYpNPibgeTgTx/9y0G23cMMU61zn3kWStgj9WTlPYlg5hbZs0uNG5xCjOSyjzNQj2qUaJr2xWD07i+21V1hE/9p/I6mWZogDNfmXXzBk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:50 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:50 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 1/8] net: dsa: ocelot: use devres in ocelot_ext_probe() Date: Thu, 30 May 2024 19:33:26 +0300 Message-Id: <20240530163333.2458884-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: ef8ca45f-66a6-4e1d-f1a6-08dc80c6493c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: 9sIOI/pgC+lu5HH3W9rA8lFQ9a2b2YqBkaJ4IaPWDwdVkxoiH3pz7WL6N6VpsOof8At5gbboi+pnK01Vx3S4WjVux0qQxhP8/hvR1Gw/xfT9Nbqerl5OghiWkPtpxjdDdyUjad0KwO95hbLFVhmjeVF+unc0lgAWlIjyF/W3Fg7mMCyo8U6Gb/ki3ZcCaPgpCxMQck4QfcU0t+jmmJdVuAx1cHbS+RlhnPpqMO3qV5lcovCVjomvNilxNX0eiWlUqc0MHwtJc218/wuSe0sPZ6vUGcpExPOYTT+2jnt4iYZaW/xwjj77cGub9t4nvrFjehg0s9Mpd9HNBKM1rdJMfzfMuRBt+/ijW2yGM1MraQHn9TEoLI2UU5sHtYmJduOxz9RZHUB2G+VE8UCrDmPTXrHDjEBDqV2lkNMtZqggVD2RnqPP3bYGgOx9G/SNPuoNqa7w4JiA8mVka1olK3q77oEYJwAZHU/vskNPVBCcw7gDkGnF9mPoYMsHHFQ6Y7w2HpYGi610au0+ea64SVYFwOCK1FQH49GsKW2WKUnILz+apwuW/p64nH2b/R5t9gq5RWfGVTznV+KNOkBsYJAr2AFb55i0OBeLm4inwC5gcAjx9MCeXJ0OARfGJT6nD2gn9P3AIOmhF361nDnUB1nByAqRrsev+cisRi/R3fjhBkROWWeXAu7aBgZ5JZcRdJULkY85SzsG0mQDNG1Yt2JK5MXOdmXulU6OzztKs5UWRIjXP1VNhL4PS+QH/S/5nSqZO4TXbCYs9TMXIfjYUgDck1B+u2N+B9RgNHoj9KiFrjUOrqJalllYRlEo7Qf9fs99INTpAgEKjDCYgkw/orudYM3+fi9scK43eA9xKun7HiO8dXN+yyA8jaIjmejqstUWcgRUY0oAdKVqDSZ7C6VBFj80TmzA1Dm/LbrzqPeGdbs5pgzV8l9UsalZoN1xR5lnKUJBKwv11lpJrMOSRUhhmGXUWmWnTwso0gGtyM+xpL0x2wdjsV95or+rQeCd0v1ImPUMbhOM/gTRr1PQg0KFXU6Pt/nCjJOU0ZoVNQc2wiGEZ1dKCjgkwrQxjWXSzRVj+u7YSNCXEi8Liwz82MvGMb/biMXQ3UN9o0vq9rtgK5awQeN9RkFAEKo/gOh/JyjfQ/jsLM60pr53h5EiSNTDh7HIfov7spvbqsTpW/nstgmSi+9fM345Wmmk9cCxjO72VuK9aDyn3bm/XK6RKi9kC2rY2SkUK1VmWkn5aFpDlCjTElRy1STu1DBaTTSOo8ERTsT02bWyBvUULmDC2vEZpg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y8Il7fejdNsIdTOZtnytHUMNZmJ5pc9O7thIvuPw/vTdkM/H+/k8WXRaKy7tEtf9wH7WfPtlg1B1O4xz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gx4B0TW1m070cQYxvef/vNNBWMnWLfMypHUPlCkyzzCqGo+YdkowhsTfcSE6hqsE3kdLEm05fS008txsHR+g9nVJsq48zzqF0K9cAOCqeBA+Zh7D+ErsUGFH2UfvcF1pzi2uzn6q62y4SD6KR9fw56Ph9Fg6SQf90TFKuOZJLlA44YAx/HNNDDJHc8NtgAdBMdB+qPFUFrP4PX2OCQ8Ddt1VfRVmXcEXbie0ZDLualRM2S0ajiW7LkQbFRHSDWpb0xb0Aooh3JblQKG+KJeYPLeHZJCNRo3XWm3SQNjw1bnrRk8x9C40MfQj0eq+kBB2d2ADMtRBqY2rogRKEGuxYOlfQr6W42dLW//K8XRB9zrI/yQoqrahjAdiuX97R6s/amlmbYCCnwrjFN1XfopbADV39SFHlgzWekGcLuOC8iK5l2AGwssrU8qcMNVUz6I8AI6q8H3ec/OwfQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef8ca45f-66a6-4e1d-f1a6-08dc80c6493c X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:50.2303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EEDuB6dPj8tMk3/C9iHcCTNcgo7M7kCibLz1s4LT7qLvTeq84u/hJvH+qBwtKft2LmojfQk+EjjXMcNsiORsfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org Russell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently. [1] https://lore.kernel.org/all/Zh1GvcOTXqb7CpQt@shell.armlinux.org.uk/ Prepare the ground in the ocelot_ext driver, by allocating the data structures using devres and deleting the kfree() calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them. Suggested-by: "Russell King (Oracle)" Signed-off-by: Vladimir Oltean Reviewed-by: Colin Foster Tested-by: Colin Foster --- drivers/net/dsa/ocelot/ocelot_ext.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/net/dsa/ocelot/ocelot_ext.c b/drivers/net/dsa/ocelot/ocelot_ext.c index a8927dc7aca4..c893f3ee238b 100644 --- a/drivers/net/dsa/ocelot/ocelot_ext.c +++ b/drivers/net/dsa/ocelot/ocelot_ext.c @@ -71,7 +71,7 @@ static int ocelot_ext_probe(struct platform_device *pdev) struct felix *felix; int err; - felix = kzalloc(sizeof(*felix), GFP_KERNEL); + felix = devm_kzalloc(dev, sizeof(*felix), GFP_KERNEL); if (!felix) return -ENOMEM; @@ -84,12 +84,9 @@ static int ocelot_ext_probe(struct platform_device *pdev) felix->info = &vsc7512_info; - ds = kzalloc(sizeof(*ds), GFP_KERNEL); - if (!ds) { - err = -ENOMEM; - dev_err_probe(dev, err, "Failed to allocate DSA switch\n"); - goto err_free_felix; - } + ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); + if (!ds) + return -ENOMEM; ds->dev = dev; ds->num_ports = felix->info->num_ports; @@ -102,17 +99,9 @@ static int ocelot_ext_probe(struct platform_device *pdev) felix->tag_proto = DSA_TAG_PROTO_OCELOT; err = dsa_register_switch(ds); - if (err) { + if (err) dev_err_probe(dev, err, "Failed to register DSA switch\n"); - goto err_free_ds; - } - - return 0; -err_free_ds: - kfree(ds); -err_free_felix: - kfree(felix); return err; } @@ -124,9 +113,6 @@ static void ocelot_ext_remove(struct platform_device *pdev) return; dsa_unregister_switch(felix->ds); - - kfree(felix->ds); - kfree(felix); } static void ocelot_ext_shutdown(struct platform_device *pdev) From patchwork Thu May 30 16:33:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680584 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 593D523741 for ; Thu, 30 May 2024 16:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086837; cv=fail; b=mpHqegoRNBfS2e1N8a5o5nUotRKqZpTg2+g6Y7qORoQ6Eq0kQuR0V5pevzIK0U3/D0cjyO9B11pX8QDOe9gOSY+4kWpYp8vqIRZybpVhJTdGr6ReRvVFuuAgU83f/FrvUznE9FiFJ1lPLPZdA20hq+09qgDSuMACCdLjnl5HiVE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086837; c=relaxed/simple; bh=evNwcIdx0c+xhOf1eF+k7XYvDJBATOWSsueER2QBjYg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nEmFeIvN/iMRqG17hygSETWZQjUTD2TzeqV+Rwgkx7hy8VGfXJ5I20Dnwi6yEFk3AllQAx+67ZWhAdxxkqSqQG6Zn6QOKJykO78uTt7H9lYnlpZpkZmp5M86S6aAET5oCfCPowQwyrUdAT0or/yN28zJkKpiZBkjERlLVMpXnBo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=a3Z6goek; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="a3Z6goek" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=blwQzutLh3NdKZbksMYo5GAdsPARj95AxrnM/143Wqd+vUuZyHmK6YJkz242dQBlmOp1taH4ueEvCilYsgVZlklnJoP4qGLsBuacGbDVwwMCw6kl8WzI7TFzDp3YhRox4IRb/cwQHkQ5qCByz2ZwEdIliHSd9+PBFhOxQb615LUWQMKpeUmloKTxZIan4CEHLadao+xWONH+0RPd/Tuf78Q8OW/ODWgEzS6o7Zl0vNfoGYvFeZvKdWW059mdyR1KA9eskqGw+JUA4qlhrPUiIIqhDJ/6fjKMN06CNol6fN5JWff8cOYUyB4Fupd8qLYDNc/cvJ8rA4+Bb5lbx5I6vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fm6nZH1dE8qk76xIgwfec9CnQryIddn37Cdcj5MGFQc=; b=g/olmUJfVCEN+jHl7mRpkp3DbqCgldwTUFZ3UoyDs3IjReKZAs5pktH7oD2ZqXn4F1+0gYGMwcWiKrIFFranqBVRgxA2bMNX1ko2h1UdLdsnjGshuGtNr3Fy7kPn0dSDF1iGECE5CrLonlWrvRaSr0kL7KIJ6m1B1upcOasyyWVtJa5uKiXJEqfu3VgVpkRMtfTDiDEP/ggvYUhPD1LWdt4I9Pn8nevoAABGnt9mxuxGlHByOsvV5ot8grx4MaLtGwUG4zXRM84aNSqX9mcs+Ld5ki1vmIkpcAfyw4ebS+r6y0x9tSKM51T3z3Hf63NQ2k0GF8UslnkVWSuLUMPOlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fm6nZH1dE8qk76xIgwfec9CnQryIddn37Cdcj5MGFQc=; b=a3Z6goekRDo2Wz+qj8TdhUy1uBZkwSGs/x75D5h/SDyBl8rTAag5Xlqo8rJLAfuXi55iVGtBqhvZuPQcTIzNWebmhSkv3yuhSDibk+xf5ZebFs+1E0EACkUy5GRwRJEkl2dJMLY//85+/vNHpvDTjhZWRrJUPoJwAUb6zlSn3Z4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:51 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:51 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 2/8] net: dsa: ocelot: use devres in seville_probe() Date: Thu, 30 May 2024 19:33:27 +0300 Message-Id: <20240530163333.2458884-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: 7defce19-6627-430f-f1f5-08dc80c649fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: A28UzsZInaHebOb/KnGF7QspbP2/T369clExVm8nF6rG9K1Z1gOjtHdcZ078SijaK8gooGgSYw8sAdvw8TFj1H2yZv22NV6OTb/UuUu0USQshig69JTNEYaPfNEAEgw3tS2PQdjvnIOVqSfF+W0EjCvB2MKC3ZLTjNwaGzDwkQugNgB5UguDXHrPrYrOOnU3/wAilpKXqG8DdSgcMXKpkTctsO5bzLAhSNSVLR2QA+JLe0fGTQTf5bIvvd/iMOSMv8xJSpCo2nAziHrT+AwspNAVqe/Ogb1/YAVb+dmWw8rRPBczbbICh2v7mTdJj+J6se28Edh795GOC28h5BVb2rOAkl/FDEMwPFxXwHAEsQXtLDdEz2dYawLuLvYaUXnU6cau+8RzTcZHZlDWnS1ZrdZSk+63Pmmy6B6SKSqRHG0EHeHFesrJqhYHFZBt9thv18rECgvYNZcah7NjzLcNS+xx7qntjB+nH74Pdg9PISk88yvtdPFuehKf2BgsBI2B5Ft5dnX4y2n8mdTqa9JyNRlIJM0/V5aPXw7plOq/HfdBsxwPIUMcvGlDJp6BD27M6LZOQjMbOG11/jM+14n6Ms/ARgZ6lOWLTNcj9to+/glO6buMcIZtww30/Yc2dUtRP/6CKqSWIQLbxgBI8dRDqA1wEn6GqDWnjTN3445c6qNV2/NWV7W93Q+50BpDMsWKeg/d+WtT2eTMUn3/ke1Bfqzv6DEHH65M34InIwUspfHwmfc6Ev8i4Jb5vkIJgadk7WmYgcVlyKXOoXZcisVvdqjVXfKkoFVFWfqMbaVvQgPRBkVYF6KnNrVgONYsDlVh/bZFZwNGvN9s6CeYS71ntpFJdNAB7luEgN4oW+XbbL4L1TZkwmR6JhI/YCFZNR/1UUQVtadcxMQfFHJzAlRrkPs+jNDH9szVSxYYj0ydGDjH+6TXJ4Fccs0QqSwpKTmO5bUHLtGgMkgLB1sy0AQSHrXwGbJpJBSg2AYt/T/s/ZtQUQ0ZpcjKoiaTVSbUmTm5VjLejk2I18tu11rMlDCkdfDsyi5GV6lm0HnAH0IjflehqX8H7sP2K0Ig0MViSFc3D6nDLeNNj/TQLyaqSREm8IYSj0//loDTZmrsjpSeNxly0bvA6HuIdggZ4yyKb5oazvqv4tUG0uDogGXUdjWKfhQbG1BDAEJGMv0wwKRk3nwHrw9atgHdBFIdSsPQ6/2Vu/tg04DzdkjRKWZ+UNpNqTMpagCqWrS+fuTyMafSZS/rIYqja/KPivTyv1zQESG15/Ya+Zl/nnVylT9NEPHvrA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tEZ/YpaRAqBx+B29VOlrfFld27dL+ZbC1EQsmXBXzfeBN+zVeqdGz2oB7E2u7ARRdXdFGJBPAJ4UhRttDsoYxAQavm1CTH+cxp8pKAzECJAhBnp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yb4ZZOlNf5XTyRlS+LhBC7F7n9RqCKvqwBVC4oC4fnK8/RPy/9BWHdSqy6zX+nybm0ubUYfeQugKJGej4WXEreW1r3eafL3syeY0fJAvQIynp7PZJsRln4zkODfmW7Zewiq4sTWyQdmd5z2IiD3vbQ7VLMBpT3X7SoyofjpgWtymxjsEA+IsyDb8PW7y7PtOYd8/Opj1ErJ3rOKT1Hd0ySgGS5SDqCE9ZvI0PNpE5KeUY6WTma8RAkOV4trgniKlqAjeGGAgXG9QiLQG6LctcIRFKjgneGy4huE+cVBmRgK0XbOVIvE9dW0jE+55tckUjNqj9sZazxkkMD2eLvuOwZ2YgdOvcLPBF/QcdbtpQqC03IdzSS74mJh5gn5WYQ+bNShE2tWHWyu+DlSFd1YnLAeJkA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7defce19-6627-430f-f1f5-08dc80c649fb X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:51.4492 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9VToEs9AVoFezR9mL0BGsirepUUVBGet0Ink/dLzKSIKY/rpQd+ACWY9c4ofVvuvEtHlO+CdRJU8V33Q5cgcXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org Russell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently. [1] https://lore.kernel.org/all/Zh1GvcOTXqb7CpQt@shell.armlinux.org.uk/ Prepare the ground in the seville_vsc9953 driver, by allocating the data structures using devres and deleting the kfree() calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them. Suggested-by: "Russell King (Oracle)" Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/seville_vsc9953.c | 44 +++++++----------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 5ac8897e232b..e63247d3dfdb 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -971,42 +971,36 @@ static const struct felix_info seville_info_vsc9953 = { static int seville_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct dsa_switch *ds; struct ocelot *ocelot; struct resource *res; struct felix *felix; int err; - felix = kzalloc(sizeof(struct felix), GFP_KERNEL); - if (!felix) { - err = -ENOMEM; - dev_err(&pdev->dev, "Failed to allocate driver memory\n"); - goto err_alloc_felix; - } + felix = devm_kzalloc(dev, sizeof(struct felix), GFP_KERNEL); + if (!felix) + return -ENOMEM; platform_set_drvdata(pdev, felix); ocelot = &felix->ocelot; - ocelot->dev = &pdev->dev; + ocelot->dev = dev; ocelot->num_flooding_pgids = 1; felix->info = &seville_info_vsc9953; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { - err = -EINVAL; - dev_err(&pdev->dev, "Invalid resource\n"); - goto err_alloc_felix; + dev_err(dev, "Invalid resource\n"); + return -EINVAL; } felix->switch_base = res->start; - ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL); - if (!ds) { - err = -ENOMEM; - dev_err(&pdev->dev, "Failed to allocate DSA switch\n"); - goto err_alloc_ds; - } + ds = devm_kzalloc(dev, sizeof(struct dsa_switch), GFP_KERNEL); + if (!ds) + return -ENOMEM; - ds->dev = &pdev->dev; + ds->dev = dev; ds->num_ports = felix->info->num_ports; ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops; @@ -1015,18 +1009,9 @@ static int seville_probe(struct platform_device *pdev) felix->tag_proto = DSA_TAG_PROTO_SEVILLE; err = dsa_register_switch(ds); - if (err) { - dev_err(&pdev->dev, "Failed to register DSA switch: %d\n", err); - goto err_register_ds; - } + if (err) + dev_err(dev, "Failed to register DSA switch: %d\n", err); - return 0; - -err_register_ds: - kfree(ds); -err_alloc_ds: -err_alloc_felix: - kfree(felix); return err; } @@ -1038,9 +1023,6 @@ static void seville_remove(struct platform_device *pdev) return; dsa_unregister_switch(felix->ds); - - kfree(felix->ds); - kfree(felix); } static void seville_shutdown(struct platform_device *pdev) From patchwork Thu May 30 16:33:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680585 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 77FD928DD0 for ; Thu, 30 May 2024 16:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086839; cv=fail; b=MEb0eUTfYY+6lCEkFOEbdZy75idMgJ+7m/uPfFugj8EVIbFD0Qsd0U9XG9nzgsOcYChQPznhXpa7V6uAtOUYD8rdJYqBtoSMHIcVreMlLvaoK5HnKDyDRXjBB3dAZ7wKqB5sRj3j9orksyacQ2oEIokUn06nXOrAuRwP1MRr73I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086839; c=relaxed/simple; bh=bmErH1C1UQDc2teZAu1mzkMi25FV87cz8h7XZCE/Bpk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mDLnnnAZpMIpYNwYal0axaPvfi7+a+xOzKVBcpQS0sNz7M01IPYd7IZjRO8kP/fRMQ6D+9lqsOZY/zJtvbneyZN5zzj6SyXLUzqg7na9OB4+PiCFYeEsFAjlXex7fS4p2sgH37HLBQAhywdaasm/raSnMWS8pzcBFVA0zQSC1zE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=JiNllkkw; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="JiNllkkw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaX4UBE/GWBn06wBVL40iMmQ+v9V/TjuJf2ajJsZhpQJnrtajFZewNCDNt4SEt1pNxCd5K3n9bM/5Sp8lrMkuypXfRTOn5CQRv4LTybAK/LnoXyMQYJTP+0ZkPt7/KANscEt3XLtM3Ra8q+HECCpDCZ5p6ix4VOURLtI31i6z0I6CNjv0DHtk7QYly2uGTfsPTkt7x8BSR4/f2nYlP8ztaRibMCkQMmg2Sk4uvc6DLDs45K+irOlyiHtNTsfizAadkRHdXgbveEQAN+XYCnMXDGTXvHo6JmUtVBa9cgiI25R9J/D3icdzaIE+A0uqadK9Dx9R5vYKMQIZKlAWzB8cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Sk9lLLxRksfRySwNqQq468tk7reXsm9ntop6o2cDKQg=; b=n737eZDrZQnF7b2SxroIrGaBBPCZ1L/IixYCtW9+p99+dHfKzeRbRUu9lBjKCobiLnr/QEiBHB42MDv6HWGnSt2SqgrfIZnUt+m2igsnwHUwmLx9TIo8h5x+IgDK0B64xxivZmJGi3vIz3KbkyIxmxMF3BijCEOmPvVPb0WnX+nlIswInNTfekrUeU2a16K+KR5YOm2hexvAD+aB0yhTJzklnc/A/49sRA8PjoT6InjHHEivQ7sqoeWLQsCRd3cgBRH2Bt/EJXrcg680zIMnxmi5zLa34gr3SazctgxDuZzHeFEi1ojpIlB5IFayIP/Z5E5sXIOaFQ+hYs5Swx8snw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sk9lLLxRksfRySwNqQq468tk7reXsm9ntop6o2cDKQg=; b=JiNllkkwDa28STupYW2aQDiaVLcb+ND7SiiLZ62OuKRPdqWGxyqoHaCq/V+rk9cUCelMT8TR8gsoUdkkRKMIasNolcXwPaPb+Tw7qJYCO6osLOmqJaN5DjuoqBVJrbr5BN4VSCRYwrjR4hCkgmU5dKmfejyIxDwvF0n59CIOoss= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:52 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 3/8] net: dsa: ocelot: delete open coded status = "disabled" parsing Date: Thu, 30 May 2024 19:33:28 +0300 Message-Id: <20240530163333.2458884-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e782ce2-f22a-48ee-42c3-08dc80c64ab5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: VTefmXH9GXZ961qUZxKHNc6ZYAonNv6iSDsKvRRsbuW0TnfDsLJEarGtP9ojyGlxgcF7VICHdqiGM26CzR0/bfCSm2oK/0hLGBNoIbPD868th7JkbYvNfPJwO/yTGr13hLcB3VJfc6v+Z5sN5cQc/Rsvo/P/VZa9g3LIHceLimlQDRQEreKoR60nrcCP58qRFqxhVzhhonu/8C6NjzvZITbKl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wSdPzmHI97EnUZCWNomWDGm4Jjk3DLwxNbNv/3OKpM6ALzA+iExHumGGyAUHcq/giNsijJohcP1JrcEE8pqAKyU0tw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GF71mLQPkasNDsEihDUo9u3mE9P8SzKZS55d7sehCUmPDxSI8NhbO1LYQfYDMhdKoy22coiA6MtQUWaOijy6Xcez/SNuE+fPYitSpZi9VtXNRtsDfLpif7QgrDP2+gx4pyv3RFs9mFBIQGZfA2V9heathOCmGGRz1XkBtzeAc8dEbENmvm8e7dkmnR6l3x3p6S4Y/RjzZAuatmlGdb19+AOnER75uOsGDNm/1/RSDfZcCQ2VNvvNeaEE/L4aIoX3bYAqWfmvnYjTrueSu86hyvV9o0wVk9YVt8J8vRKXbkWwqs0i50jv4CLl/k/xlrhOSbQrCg3AuZmhcU5OIRuBcc6ZNQm5SqGpWGasD8inl4sMEbAuRS7gdATdWwb2oUQIGRe61BGQPX/DbyIhZLXWpTGOAvOwlTQuCRiXnlMMl/GwLtEK4MtjbqCUKwzeDPiMx89DWprDJDC1+XNaO68b3OeG0EDmVYLaogj+cMks2oXnHBHcJjeEK43V43FcoxcKu6wEGcwSC88Cwl9XDlgUztqF15ZtCpSGVCFaxVjK72Y/4khUZ9A7j3DULXRFbm6ee3Fv3bicWq7Yoaveu0DNb9i9S4pOzdQQVDoLiWA1C9iLt7NeBryzbT3PCpRUAeGTSPNtlCYROHETLVd3lwXmzg4rl+KBp3Qobgh/x5cZIuCYGiLDdrY9A8ly/pntdjxeIvJVO87NgJdaBAgvS+IrgWB7IvYwx/U4JoZKpUtkCYAMdRj+mhqEmUPbHmo/DTpX/7GZrFzu+yEfyeqlXtXm36NREnfzE+i8xFdwCqsDQcJeY3QZaHEcRCZdMjy4bsrk9yA45f3b6E7A978yZxXcEV5pFFoVu5SyeAhgIS3hb9WC6787uBBmeneQg/3EoF6Sp7dsGJku868TBNdJil6b5hHQ9r0wLkfW2U8dQpyMz++uvcoDOsuuJnfBvPAJRcLGHYx8XJZQ7UlRYwnrjdZ9Co2bbsSB221+lGoa/p50YB7TWYQ+nGC/owUCDKI8gYpdV0+v+7WHIg35fE9ae6daq8NRCImWacWVBvN00PWokNVdF4scCQTdd9INZ2AjO2LHLF8VJm76FEkd2ciR4RKXNXSm4/zVvdasEE1hrhLkoFotlalS2nXSk0De1haa1mMezObnqAc/rhcG3H2Nl9nPjXzpN51uNr/rNtzrsia1Key2LV+qRfxks8KXh7FHYIjqL6i/hWyAdwq/pGhH3mg4uL6VG/3prLHZydq5xKzU+Dx2hTIEKuv3bJp9sya8Pd19Tv9D58zDfmihXUnXD91SJsd6PjmaXDU+L/yNA+TaOXdthOMPY9jam+HoFvFMnqTCg4njs4LssZcCyvbx7Oq5idUG8oQVIQatDEkyywjTJcnLxYnuCLvqkAOaJDRdQKvf8l7iE7/U4MMFB7mwTJ71Z452yQeB9QxbBUmKdh5dBu1/q2B8oeRq9rVG0SN63bkibP6q1FARe74AanIeFRea21ToGL59JQRDLuEy9vHN2lAWQ0l0kp0InDM7Tu63pZeYzu1DyRof8Jf6qjSiplxCsfda6TcjYzu3mr3BURLQS6Mgwg3N0+3WQ+kJjxb8HIbJ0zqAJ6FV2mm0nr16E7JlEA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e782ce2-f22a-48ee-42c3-08dc80c64ab5 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:52.6675 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5FdFWCUMBJ5G7uHOrx4+Jba8ycqvEvE3iEKqrfJ/REooAxYGNE+ZR8pYvRn8oClorhHw1zd3EvnwltnEde4mDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org Since commit 6fffbc7ae137 ("PCI: Honor firmware's device disabled status"), PCI device drivers with OF bindings no longer need this check. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix_vsc9959.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index d4799a908abc..eabb55da0982 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2668,11 +2668,6 @@ static int felix_pci_probe(struct pci_dev *pdev, struct felix *felix; int err; - if (pdev->dev.of_node && !of_device_is_available(pdev->dev.of_node)) { - dev_info(&pdev->dev, "device is disabled, skipping\n"); - return -ENODEV; - } - err = pci_enable_device(pdev); if (err) { dev_err(&pdev->dev, "device enable failed\n"); From patchwork Thu May 30 16:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680586 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 5957E2E84E for ; Thu, 30 May 2024 16:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086841; cv=fail; b=t6o1+3KpiLPN9AOYD0Z2YSnlmG0K/us02BBzFXG4uIDhu2T2qBC/9/TXo4vs0Sdstuo+INTRSYyr7WgcZZGbwBI6Ho28QiNWAOgoWMsLgkuhj6nXipN+vpKwp10KogYIwa2pi++Rb+8RUbgTeWA/0HGYXlEVgKWC5kweUf0UJWY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086841; c=relaxed/simple; bh=NxF07vw4znJ4Chkr8u5M/U0U8uan7AdWtpebuoeoU58=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qRhQaegvJVVh+3c/0TrEiKTLicjizXa5Bc94jnUfYzU+GpSJVZX41gelPjT4ea/h2K4JQw5HRT6fMmPKaChg0zFVksDiw6bIBicW9WGp7/GAK3DDdxI/cqt958zdv1n9QtURbVT3UA747oXFUb29Xw6unTcFOiCEX+tBiF4gBRk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=gJATBTB2; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="gJATBTB2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nySjtPpGljKPx9PW9pkJjl2oQAdxz7oehEYLJfUdqh4oSehShlYM++oQjLiutGZB2O1XPW8EHk3jW1CifQ/USxdJOO7jqiYjYIcc5Ttoe/n3nHCEfSw4xkBt8p+UeLhMAMS8ghrL/3LF1Q7h2B4yeJS8vEMwq1VNYemWgAHizYHkURdEDkmEEXwH8JPlODTKsD9b9AJaRoLUPiVCophE+jXS/jCJIN9zxwXPuTLrX5ScZ/SgCLOHm7W6fxA6enf3kceipl2VCPX5L1bq6PsRX4+FEa33KLyOFfWDiYC7IFPgfcaOuCYEyBUC9TaGuzanTRyp/bRFH8R9jVMsX3KtDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AqKEQyl309wcqmoovZloPdl+QZBS5j/r0ULZM8v4XZ4=; b=KIOFmTqTN5OjxaWz1AVeMfRn3MSm8WB+Fx3be6NhAFRkf0RciB3syRpdULi7hVbVTnsik9AaI3GsTwhhbC8IQJNv0KOgRKxiMSanv6GPsymGxatmYycTTDq75siqZCA6atso0tiN/HcvIdj8aPxn9ldn5/0KtnfY1NPJKDnWopIjKFBbEgGvXOkFjsRrxCk1iJ/O8S/MRDmVJ4+5KrYYBKt9C8+rpR9pj2nzxPY/hSlhM3uEryjGUY+DZfpKbcNvKIN3WENjfwBoOziUMZWV4jl5o8+gPtt+o+Bmume6KJJeTAk9jMEPTgXwycsq49VGOKoZ0a6ipJQYfwxL8KHTvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AqKEQyl309wcqmoovZloPdl+QZBS5j/r0ULZM8v4XZ4=; b=gJATBTB2tmxP4Sw2g0m1jQddmphXsta6hViiwhDbfyL4Fl8DCDyW40uhrCfOcrDuWwZsnungBoh3NqMGn1TLhytacIjEg5ZdAhTsLwwoRCPqebBlCHLRxCrNlbjRCX+oP9GDfgIhCQPQGHzNfSQXV8YmPZxdGZihqsvVftTFdKc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:53 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:53 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 4/8] net: dsa: ocelot: consistently use devres in felix_pci_probe() Date: Thu, 30 May 2024 19:33:29 +0300 Message-Id: <20240530163333.2458884-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: 0cc231a6-e496-4fb3-a892-08dc80c64b6e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: UkNJlV2hT60eFp3TzLToW0aJtQGbQGD5jFOjfRhR/ZF4CXSdCCKj88sLDAGZrYaTC9vw3emcaGlvNAT41GnICn+51nWVLHzNWxM70adXamBTRIuyufijl5gJfa+ctn1B8REkr291fEVX9lnSq0/pGNF9w+hcPMNkrDwYBEhd9QJxmymT2ADoqFPoyj/Vb4acLFBgOqbdBWwsY7jY03Aaq2lJfANRlAvDc1k6AV0FuGbDLUDbwFgW0wV36z9W3Ze0L27y6cF4LBGNknjbvBbMtw+DaNGx17fxU0ltmw1wrcv0UDjcEP7vub1QUwzS1Qz7Lnr7+LbbZT2QHrfeXboW4AxzaaipFTO6w4cy4NE0Z4s/m/Fmo/Xd0ZKBKCBztrSl4CUY4H4RGZropyzSpEIsO73scV4h2dvLXt7jJ2IVd1jToczDQA9T0tSVa3tA4wuXeoBV4Lhg6NLGPZOWYsLc2bO953JQ28J5kR21N8icEI9RPwD7KEG7PaJXQOQS71Fln8hk1doaIOEOEcPbPyjuKfq8MUZ8+yB/cdNk+4eWkiEj/3MjrZhZOXekX2t+D7wdJjaMFT/QQeWajltMMj3mldGsO7ArGIYveApRi98sgLtnSt8xzj9wrqHQAwBM7M9MSC8De2pkLN3J1+nfraY80LNQqqBJ7Vojw0TCkXed1ElnaQEkwDCTnhony6AQxsA4YI3lyJgx5R2S8JqwKb97geLk0OeCQHIJMkU3nmF6T+ftifLktp90LMTuehiK83SDD9Q6MoZ0ALBOUlxHvS1dd5hT6dzOfDXuUkIWxFWU9fB1X0b/aFyxd5XfFrsGF0GyyslmN+V5QoFrxG28loSI7kHm+QtXZyGmJYSaohiWNhn94tw9Sb583VfcVoupv2HMK5SchiOsuz1a4XFP2X388R2KVI5nqIdqOmFnRsKwyW6l6xewC1q1ENDIiYHsXdc/tgaSxxh1+CLcHGXWWx+Fmp89tVSTK4d/qhfBYSYZdzxJa6r3trooB2+SNRV8HVuIA37b1JhVtdQZ0JnXt1uO9gvlzrf4+h8QK/Lh5ZW4Rm2DYzpmKidWwFr7kMrfXbaMSwQzRqQhu9x+MiqTyavVUj9AzesLGwuk2hBHcXll+3iw+XYW7ia+BiDKYUfn1ntPSLX90VKoXxgXg0mS2rYbnEV02AgXvHxF0A1/wXKcxXd2/081ZjWY6vLvWkcWnt4YqLmgUZA8ZnSEA+s8gUxeu5QmJWdg/ZcfUsKOwzsKJO3ysdp7+OGqLL6lT/4vIyXRKj5FYxb1o8myDhaInmf5pQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2OeFGNC+Q2++EAMzmErXZGWlBFr7aaVeK5aBdHozQZ+ztAs3atcigH6QHj46NxGsrTRaRhYJCkHaXCCDihc2sHORfBCI+xXTWnLPiVYE1KNh25wXUy9Skhycyva0sNX1Ir2y7XLX24N4KiZQfw3u2jNApmBvELg4Ll7k4YeSmBHfDyP3QGh0IpgZAieYI1nefAtJbrTWpaCHfpP88Wh5D2TtO01CSpMA3xFG+FmvechKPLS7+dIC0MoOIZdE3Qwo8nSxxYYMfdwBgfaTvpcUJNeHt1am1iSe9v4H1NC0ePrQyyKw1srETvNT5R0tJHh3INjxlbihI3YE69rGYaYhBnJSsHDX4H+8or9PRdMm5dlCh/t3ofHXxccuvaOe2bShOclftcHs6Q5aMeRcDd5SNkbtmoTzdNsC29JGlLU3JRtYLrZGrIBY/OHM7fBYHKQ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O5RuExXtlE/UmdVb+jQco+WuMj83QYH5as7FyiF5w7LvdAiIQ2cXydbStbfPX29ef1qYHGxzDPY0tqD65g+6dV/3AcMw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0cc231a6-e496-4fb3-a892-08dc80c64b6e X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:53.8404 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dwbfaxVLmIZwZn+VNSKbskP53NQ17WFkjqYDVE6i0HOXG3gmG4ipx5HsSYWDwv6sfBVHdoWN0zlN0R5oYarYIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org Russell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init and teardown code, which could be made common [1]. The teardown code could even be simplified away if we made use of devres, something which is used here and there in the felix driver, just not very consistently. [1] https://lore.kernel.org/all/Zh1GvcOTXqb7CpQt@shell.armlinux.org.uk/ Prepare the ground in the felix_vsc9959 driver, by allocating the data structures using devres and deleting the kfree() calls. This also deletes the "Failed to allocate ..." message, since memory allocation errors are extremely loud anyway, and it's hard to miss them. Suggested-by: "Russell King (Oracle)" Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix_vsc9959.c | 40 ++++++++++---------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index eabb55da0982..34155a0ffd7e 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2663,6 +2663,7 @@ static irqreturn_t felix_irq_handler(int irq, void *data) static int felix_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct device *dev = &pdev->dev; struct dsa_switch *ds; struct ocelot *ocelot; struct felix *felix; @@ -2670,45 +2671,43 @@ static int felix_pci_probe(struct pci_dev *pdev, err = pci_enable_device(pdev); if (err) { - dev_err(&pdev->dev, "device enable failed\n"); - goto err_pci_enable; + dev_err(dev, "device enable failed: %pe\n", ERR_PTR(err)); + return err; } - felix = kzalloc(sizeof(struct felix), GFP_KERNEL); + felix = devm_kzalloc(dev, sizeof(struct felix), GFP_KERNEL); if (!felix) { err = -ENOMEM; - dev_err(&pdev->dev, "Failed to allocate driver memory\n"); - goto err_alloc_felix; + goto out_disable; } pci_set_drvdata(pdev, felix); ocelot = &felix->ocelot; - ocelot->dev = &pdev->dev; + ocelot->dev = dev; ocelot->num_flooding_pgids = OCELOT_NUM_TC; felix->info = &felix_info_vsc9959; felix->switch_base = pci_resource_start(pdev, VSC9959_SWITCH_PCI_BAR); pci_set_master(pdev); - err = devm_request_threaded_irq(&pdev->dev, pdev->irq, NULL, + err = devm_request_threaded_irq(dev, pdev->irq, NULL, &felix_irq_handler, IRQF_ONESHOT, "felix-intb", ocelot); if (err) { - dev_err(&pdev->dev, "Failed to request irq\n"); - goto err_alloc_irq; + dev_err(dev, "Failed to request irq: %pe\n", ERR_PTR(err)); + goto out_disable; } ocelot->ptp = 1; ocelot->mm_supported = true; - ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL); + ds = devm_kzalloc(dev, sizeof(struct dsa_switch), GFP_KERNEL); if (!ds) { err = -ENOMEM; - dev_err(&pdev->dev, "Failed to allocate DSA switch\n"); - goto err_alloc_ds; + goto out_disable; } - ds->dev = &pdev->dev; + ds->dev = dev; ds->num_ports = felix->info->num_ports; ds->num_tx_queues = felix->info->num_tx_queues; ds->ops = &felix_switch_ops; @@ -2719,20 +2718,14 @@ static int felix_pci_probe(struct pci_dev *pdev, err = dsa_register_switch(ds); if (err) { - dev_err_probe(&pdev->dev, err, "Failed to register DSA switch\n"); - goto err_register_ds; + dev_err_probe(dev, err, "Failed to register DSA switch\n"); + goto out_disable; } return 0; -err_register_ds: - kfree(ds); -err_alloc_ds: -err_alloc_irq: - kfree(felix); -err_alloc_felix: +out_disable: pci_disable_device(pdev); -err_pci_enable: return err; } @@ -2745,9 +2738,6 @@ static void felix_pci_remove(struct pci_dev *pdev) dsa_unregister_switch(felix->ds); - kfree(felix->ds); - kfree(felix); - pci_disable_device(pdev); } From patchwork Thu May 30 16:33:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680587 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 736CC374C2 for ; Thu, 30 May 2024 16:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086843; cv=fail; b=Xv24gUPInwQDRAU/pU40EEyU7cnwZurpS7YRqZ/B2Pqt4duVOJ7a97Shy4cW0lK+hFvvQpC3yKtwZXHD9aKS0Qodl7k74xMeEIlTk77Mt0n4aQ/MkW89rkbptjGy5oF4MdeXWbIJpWEWqP+Qby9qAmU2LTkijKvCew6Zk5CMJ9I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086843; c=relaxed/simple; bh=h2Y1Ccylv+tFg7rTYJfwhYLV+uls6p1/SjJtORJOQhM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=E5+Y0ZYVmv4vGskyl0+th3f2+t+jvl26a4UJieqZTEcAVOEXWBRkWkqyKwJF7EZ9AcLNMiCqlgLQcro0eW/rDv50gnze01J4yZlbQugzGAhJDbzMdjmzl1HP32HIx8vPv3Llg9Jh1FN5AHr6GRVIjbrKiKgnbaMssJm7pLAvtOI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=eYBqMMVK; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="eYBqMMVK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPE2DoGf93igop3snaI7mrOAo4N4HE5a3PYJYvBgEXgvLTXJch3yfdZJsUiuMJoUVicAVPol4q7SVAEd5nh5GGFwj+lrn6/aJJYIvdgeE1I5aBiEigsMlmZolRYG2j6g895UYv+yYUbIPZNcpP3JPn1UDn2dTbOrCFS7ZUArvTJjYl2p6jWlRLhmvWH0rRKFCsob2GrM5Z2j88dUcFgqzx8pk/bk+bu1LPIPj2I5kQ6NOpFQ+HcKU+EBOT+i3NtnkrX9W3vm3AEgBKSizFWq7/FLSMwEJ+s1TPlVMLJa5HjgQkhmpnCllgh02J/m5XH3x1FJQwWWMumrowj9GoeKMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MfdtFZscbyORsEWgUnbJboQocuimvSFbV1X2XjCK1FY=; b=AzedaBwTxxURSZ5PBEoLdxRXbbiw1YaRzHELBrQfK+OOfPTc8o+AZxSYi4z0rjMq+yb/30OATFC5xVVMsn1ORz3LbbRDTdW4aWSwuq1aXpuRcwrUtlyTg6dvq1oeO9m8oknYcwNmkB7ubxCGtP+fu+x4Nwug+yP+nV8FYvTnONTyPtjNBhdB0pu1ZhajzpC3015jJjbQ1a28g0AyrNfo/4P5FQ3Dnaa/1rrID6e5XQosJeZmRUB8nrNiAnmEjLAl6LXruIBCeFjokSKDhkAFqRzj2JPeDJZ0ESZoA9cdaQPPfGlnqbusx/hIeNteWAKQczwJnX8c0keWRYqOfUctNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MfdtFZscbyORsEWgUnbJboQocuimvSFbV1X2XjCK1FY=; b=eYBqMMVKzyw9cWB2nANUvGQ+0EDKRdk6bZL8++0+hixCfCAKB7SYyW300/uvcrv1domtHzkreoi/MAsdtmHo8FCpPQKufTPlo3AqP3fWHFjfJEnKSlYNW2oqvG81P9/k00YoZHDPmX6X5x4TAeP9X8r8euD6kqOLoJ9uvWkSw2Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:55 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:55 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 5/8] net: dsa: ocelot: move devm_request_threaded_irq() to felix_setup() Date: Thu, 30 May 2024 19:33:30 +0300 Message-Id: <20240530163333.2458884-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: 812fb1e1-812a-4e56-869c-08dc80c64c2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: J0acdXbD+sNJu/BavlPALmEmLtZkLbStCnSNqnXGUbnbd4WxvljJ0DUDkvf1Baf0mwkLeErbhJRzwyxEw9vRqayu1k6bI8mktcx61R7DddFS9jrPnSTWSJdUaboklaXzZFo4S8uYVmFZ0fWba831shyzlmat/wOsMQKX6nCTnVlk9/gSKei3YbZSNeCXz2xDI8tDm4puaQcT6b4seVFkEIZZ03DfqAsrJbBwDyRDEzTqf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BNxeBeszp0j1E8zXqfrlGxiepm7qkt5+8mWTrZ5GrTttZ7mKJWcUNsnbw0g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0hC3whdZtMREhjD1+2veczIEUycgdYOyFDlbwnqxCV/bD2bAPa3CUngRiS4jBjtCl/v5ALJmm6E+BWMU+xmwwP45X7V94wpjnOdAzQUMozqCw3IyngJANWdNgDyYvUvCEMRuqC5y+/0VVVC5qvdLn+JPSinhXzvVah4Ih2xxOjfCyTTsdrVQPplp4dyAVyBgXd8ptIRItEEksnWsYXVR+rkF4HcyM/mU4+5GK3/6j63CozxiGnKldBA+10433mSqCswASrdq2rOIKPM/Lda1OYAv5/AWkfeRq4E9aeaKLt+jtEbZLPI9NKgzWrf4363rr4dQYByzVs12tMnEFvYiU6GUkLNtuWzYilgEPHuP5fjmLgCH1uiNHplGsi7X7Cn6bRLM3U+1Sf4NGZAAkkiCpvYU8tc1nR3d9wmfbvDR14PfYYTROg+Xp7rddOjb42dJTYqy/KZ5/zmJzVp3EjQOTMHFo4tmAe+qbKgSFk6cOuJkDT6Z7wvpMXHQ8NK+VB0C6vRNhJHsQly4EZuPqf+pfB51C+/VC1pbj27K1jHhcMsWKzjLFZYmWUrGTqn78BZTQQhPOzEbRupbsJgdtUe9IhKt8teIQcS0/2OKS88naA8YyNAxa5kVwJQ+Rdu5i6jJSiYyKflBunuKWLCXaAE3lSR5VjIAbtrYLlQyWjzy1J0ZdYcc8qfDACf52FKhBTrzTJl77t0f8PcjTdYdP/7oNP+JE89h1SmigcqiysJKwU0yTfUTOREhRpyjqEMlptll+OtzUvD15x3PWFohrZtU33BPvBKCRKsivrEEZR6WmivRcGIIrtU8K8quoSW0t1EXI+w4x5LoofO4Gu64WdrJD2HOpsvXOEvEzjEl04QfhKYXRhEtEeVo6/ru92nSShliwjBD6rx4oY9ZeJTz57EwZazfbsvraWaV8vVFuyurVc49hAUNTrlFloXSwIsChfewPwfGo0Gux+qFzR1gOmX9gCGOdnzBni/nTJSd+SnaZ18xzA1Idwz6I+1Uye5hOa34GWk95xeLRZ97XF6U/ftQxM9i74wjTa0HPgGXtAoo67rJvrYgu4Ep582WNFt/Whk5KaPHYv9XOwCfBkHXuKu6Xc+/fku7+xElwnElympL8AEz7O52mClIQZJYv5+Mg5YAkHAZP0Vvq7SERkJd7CtDoEgIsvNXQ7PouhmepeOkLdbz9yn9a47ts7qje0fB04ll8dTLhZjGKu/GScbEB+wJFNa/FEk+ukGxe+OTnmMoz4cVlYaDkKTOtrV3YrUXCUj4P7/0I3ry7AYZ5B2jU4M0LhWIREPxS7+B3MER9V7Umvo/ML3g7pv9NG/T0PPY9chEywTFo/eyvnT9pybQho/UKow+Kurus0L98xJSJ4OjDAjQ7OUNvpn6yYRoM746VhX8Z2/jRFBKzfbvpbygjNxda+wex8QRAL0af3u7m7cUE5cq7GS7mi98YSKjQ4GrJycGNaxkxXwVIWuKfY+owe5ieA7b7sc3qNKtuF76qk38v7WCMv4vKt5x9YRUCv42M2d9arT69Bb2IKT23KYvp2fymKpSxqLsQRcjq5G/89a763m1bu0MZOYTH5CT4hV3zRQFrDyoPlAtNCz/uqsRHf4YjQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 812fb1e1-812a-4e56-869c-08dc80c64c2f X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:55.1135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iuUhQwl/9c2G77sINzwm7p9wn1umdiqnuhIVkVGFr+BMxuypGaERXTT+60bsxKrvG/hB5KuTPzwt0lnOupsNig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org The current placement of devm_request_threaded_irq() is inconvenient. It is between the allocation of the "felix" structure and dsa_register_switch(), both of which we'd like to refactor into a function that's common for all switches. But the IRQ is specific to felix_vsc9959. A closer inspection of the felix_irq_handler() code suggests that it does things that depend on the data structures having been fully initialized. For example, ocelot_get_txtstamp() takes &port->tx_skbs.lock, which has only been initialized in ocelot_init_port() which has not run yet. It is not one of those IRQF_SHARED IRQs, so CONFIG_DEBUG_SHIRQ_FIXME shouldn't apply here, and thus, it doesn't really matter, because in practice, the IRQ will not be triggered so early. Nonetheless, it is a good practice for the driver to be prepared for it to fire as soon as it is requested. Create a new felix->info method for running custom code for vsc9959 from within felix_setup(), and move the request_irq() call there. The ocelot_ext should have an IRQ as well, so this should be a step in the right direction for that model (VSC7512) as well. Some minor changes are made while moving the code. Casts from void * aren't necessary, so drop them, and rename felix_irq_handler() to the more specific vsc9959_irq_handler(). Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 9 ++++++ drivers/net/dsa/ocelot/felix.h | 1 + drivers/net/dsa/ocelot/felix_vsc9959.c | 44 ++++++++++++++------------ 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 3aa66bf9eafc..09c0800b18ab 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1597,6 +1597,15 @@ static int felix_setup(struct dsa_switch *ds) felix_port_qos_map_init(ocelot, dp->index); } + if (felix->info->request_irq) { + err = felix->info->request_irq(ocelot); + if (err) { + dev_err(ocelot->dev, "Failed to request IRQ: %pe\n", + ERR_PTR(err)); + goto out_deinit_ports; + } + } + err = ocelot_devlink_sb_register(ocelot); if (err) goto out_deinit_ports; diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index 4d3489aaa659..e67a25f6f816 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -64,6 +64,7 @@ struct felix_info { const struct phylink_link_state *state); int (*configure_serdes)(struct ocelot *ocelot, int port, struct device_node *portnp); + int (*request_irq)(struct ocelot *ocelot); }; /* Methods for initializing the hardware resources specific to a tagging diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 34155a0ffd7e..20563abd617f 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2605,6 +2605,28 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) } } +/* The INTB interrupt is shared between for PTP TX timestamp availability + * notification and MAC Merge status change on each port. + */ +static irqreturn_t vsc9959_irq_handler(int irq, void *data) +{ + struct ocelot *ocelot = data; + + ocelot_get_txtstamp(ocelot); + ocelot_mm_irq(ocelot); + + return IRQ_HANDLED; +} + +static int vsc9959_request_irq(struct ocelot *ocelot) +{ + struct pci_dev *pdev = to_pci_dev(ocelot->dev); + + return devm_request_threaded_irq(ocelot->dev, pdev->irq, NULL, + &vsc9959_irq_handler, IRQF_ONESHOT, + "felix-intb", ocelot); +} + static const struct ocelot_ops vsc9959_ops = { .reset = vsc9959_reset, .wm_enc = vsc9959_wm_enc, @@ -2645,21 +2667,9 @@ static const struct felix_info felix_info_vsc9959 = { .port_modes = vsc9959_port_modes, .port_setup_tc = vsc9959_port_setup_tc, .port_sched_speed_set = vsc9959_sched_speed_set, + .request_irq = vsc9959_request_irq, }; -/* The INTB interrupt is shared between for PTP TX timestamp availability - * notification and MAC Merge status change on each port. - */ -static irqreturn_t felix_irq_handler(int irq, void *data) -{ - struct ocelot *ocelot = (struct ocelot *)data; - - ocelot_get_txtstamp(ocelot); - ocelot_mm_irq(ocelot); - - return IRQ_HANDLED; -} - static int felix_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { @@ -2690,14 +2700,6 @@ static int felix_pci_probe(struct pci_dev *pdev, pci_set_master(pdev); - err = devm_request_threaded_irq(dev, pdev->irq, NULL, - &felix_irq_handler, IRQF_ONESHOT, - "felix-intb", ocelot); - if (err) { - dev_err(dev, "Failed to request irq: %pe\n", ERR_PTR(err)); - goto out_disable; - } - ocelot->ptp = 1; ocelot->mm_supported = true; From patchwork Thu May 30 16:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680588 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 9BD7D3A8D8 for ; Thu, 30 May 2024 16:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086845; cv=fail; b=XqdBLvwbXGAtHJuFkFs4X2hhif1++MoKlhT0vP9oULVUNg6FPtUiVJa2voCKS8KEbeQNwbXMhMjQUWl8XNFfT9b+ABe/dbwd3X081Qu1IC91VWHQ+NpjzR4cAxtnp0RBXIzfXrGGIral0HiQbJyIvz6QugxoqeoDRRW3rdiFED4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086845; c=relaxed/simple; bh=qfW+ye0G3DBgN9LNDQfQCGI2a9v1Xj8X254HCQ7sglQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cZ0xEenqtLsai/VzQaPeZj+VJ7y9gRM8GGPfHjuxtkrcowd3fj5W4NKYkaL1zz+VF5R1TPfqaYrqPsMaXtcxqyBRTZiaunY3w4rmHPRrvyF1C1JRPOpwwpMsvY3zgRZHMES06+svKpTtgsKFjr+xN+it5m9lHMgotWUwdykN/Rw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=bFNkcuFj; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="bFNkcuFj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H51iMOJPqu2h4FPE/EDG7NQNveT5R11SKllDFiIwceGzxyqqWjORShnWicxqkQWHMIuxsXeiGqyFVWZBctCqRM6evz1e795qT8RUD8kJRfwnUJhQbrZCxdJpNmBmsiqqw8swA0BX+EpyijHBXESmUD6uHwxn0JAK2/4sTgs8ftHzLriEG5WTCupim4pGtfRX0+TKxX1NJ8Os/ZIPL3lFpfoR++CNdJz++9vTeXI8vKfKEiz2Pve14pkz/hCJJQWCy5K47ohsrzeJGeuLWj1zeKY/3cAt95v1AiAZUK7YgRknJEHGtNWHkAxPjQqdsPU+idxj8/gjGi4tRRLZfZy4Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kC69P7+DJXL0P8flyTJ3LbXGPnwGwgBf0GHiUTClNI8=; b=byIohTeYogyoorABHrH8lxfPOxV0/eW/d6zwQZxY/iMLKI071QZaeIwTFs10xSJw9fj66LF0xRpct5TFpxWMEQ6K9l62Laa++Dddzz5kDDkIFu4DAlVM1LcLJEYZ7Pe1WVIYawreVZnWHGnK4A8LLW96Qbjk6ah2bbDRDnuJxIqGzUxifr3fuWXc3ES/0bH6TSUADOdsFvKI4oP/P5GsrFA9AQz92kvG5wU9RFf9/NMHWK9W952l74szd8bdnrAgSlrTLAT6IIWTzVaVTqzMmwkXNDIVstw4WmIccLu8tLMQoV/r/kRamHO8bitc3NDiw9bHEf5pqPTN5JtSAa9OvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kC69P7+DJXL0P8flyTJ3LbXGPnwGwgBf0GHiUTClNI8=; b=bFNkcuFjsLmCZbHKbHBfCr/pyVX2ioywM1H861oN5nHfXoSWZd6x037WsZeSyyIYzT+eP/S3SZwLX5fkiOGe9qitL57ftnubFgivE0AS+3CmFF/Fr/O0kT0EOzYPyUXb4CCYHSbgmRQw6vWo/lYM7Z6dpuHzEFhLkJe5kepipsM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:56 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:56 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 6/8] net: dsa: ocelot: use ds->num_tx_queues = OCELOT_NUM_TC for all models Date: Thu, 30 May 2024 19:33:31 +0300 Message-Id: <20240530163333.2458884-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: 81efcce2-0edd-457a-6c07-08dc80c64ce3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: 8+nklsUrDctqGpeir4MzqSMLfOtLiuG7CUqZvv6a5J+DhO+1y31PLO6Wdez6WCZlcueiaLhLyuq5Ad/qF4XFlqaF+6b7R6V27FZulOeTD+JNPUF1erSfMURD2DlMAZ6lFuHBRXOn01w0b80LwQmSMRXjTyM8WgX3DxI+3GqSoHztB2ardH3BM3CoFNlTB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TtqrcEXDxAoMy6/4RLQHg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LbIyDc7zlLhsTY5AxEPVx83B3d5kZiS85EJcy/i2ms4vc7lIQHSlEASKO1F+aHd/da72AKaoGpd9Csab8h7MBjYnTZNV8MIE5TwBAKGm/1Le6AgIZzWmnBpYFfu1sUuCBP/fBtUzUn1kdaxHRRAyV6/i1zQHgzWqgQWR87/agjFj/e6Sz/BVEE/Vj/KmUtvnoiKyuvNI/A7sQFBIKxGPh99dTQH9M7vnTIP4QmueXlqsM1G8pQE97/EqXDh7W1JCM5EdH3CY5ONS5kKT7kZdaMDTVq1+jJff3nivqmNptVUT06h+7xVZNlm/zZT0Gwk7bxLmw4KHW/mUWMsIWqrWcj9j9NPljbqftrvLZpfHOPGDUyj6eHuX1zQq/kqsPARrsmkE6outjhAMuf2sN5xs+PzPVHba8kn65RBBhqweGKP6y7x1p2zyF9boOnuu3AnDW/TKVw1nVwLMM26MiLl9ueXmr4rkooIhn1Dd04RMy7YO1FY4Z21WEjdZ3idKS/077UJuDa7LOxvb9U3o/2F8Qy7QUCVn6963PemP148Z+8mfJaRbj+5hJbuLJrbSrj+iirPsSBtHuZtm8bntesPg7Ez+wYwf0MW4ZWBIXUBH0f/yeOCmQHJBTKKON8QX16xU8jri46OyaKcOifN+vLXHPVahZ8KWbXCcVRUjyVnUDOQ8e9MU4LgnvWTtVTwBIymFawGs3DmwK6YVISHpT/Pp4QxuITufmfSICikEv5zi9vEtmVZXMYlBlPSjDB9NaTfs+btNOyckRUIoHyjPcXTtO0ymSB3j9v5y98dhH/rpjvFUrSZmGZhM/f8ilL18vL+mOvSaoQqkF6tUpBWkX/EPz5shpGTEaV9hHLhS6ZLzKi9MbzRa5R9269CmyF50jSy4pPutA54niBZrb4zeHAOl4OnQZ3/SSHC4FqqNiadTyVMa6r31T43my6+/jp7obz6R15ZBZnc9jIVGAaOvjngwdg3ugx5cExaJQHdNSCaa4TIQfBk93Ltxp0Ef88XozUenR7belF7BzYLGcBbOvtrfnjHap7Yj8iriKrL57YfUJ9SA/VqjToforQ6eERMW1hUeGR9Nc35UbupoulOOCJhTrzs5c93k6SQ+HU6lKhSC4fXeGaeYTKjQyroigame2Yrpt7YBPyyPKJnQ0CKVgYWogQijgVnUd1Hhn4K0oncfMBElhanoV8P6CJAPY+eoJ/hhWJRSuNzFMJcljGFIHcjuSMjZ2fox/Cy+sTyXiaOY88RJqsoukIK3+EFU08n3Djtd0NpgT8slVCiCA1gtgXlyRfFgelAzN8F+IS90KAcsQ5JCJER4iXfFZ+rUv+a/yFp4nB5OqkVwC2r/xgL/mkzahqrUKfH/l+b45Mi1Bf06+yjYdCWCSssAPfsMfJ63ZQc0UEzRkPfugXL4C0mZ1LS1+kxtZYfPZiEiYhbkYeYLX8COXAPfs/GtobXYw//QThUmQxIMBKCR/O7DZN6bn47v9m9kcnIV0xyyYk1iUap1f2cyc1EjiDlc4RBpUuA9olUgfSP8D6QwVzkzR7wCyb/dRTMN6to4b2j89VF4Rm/DP+53XTGtHJD3mmaROt/oMdseA0DGadib8GoYTBhgcjNTKQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81efcce2-0edd-457a-6c07-08dc80c64ce3 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:56.2898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zJ2eZPncM3HGApiWF9aSSW4Fe9rRw75BvciHhzQdQBF9Uv0M13odnXtTPaNbrx4vCJ2WrwoTaTUeap5+LUFoww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org Russell King points out that seville_vsc9953 populates felix->info->num_tx_queues = 8, but this doesn't make it all the way into ds->num_tx_queues (which is how the user interface netdev queues get allocated) [1]. [1]: https://lore.kernel.org/all/20240415160150.yejcazpjqvn7vhxu@skbuf/ When num_tx_queues=0 for seville, this is implicitly converted to 1 by dsa_user_create(), and this is good enough for basic operation for a switch port. The tc qdisc offload layer works with netdev TX queues, so for QoS offload we need to pretend we have multiple TX queues. The VSC9953, like ocelot_ext, doesn't export QoS offload, so it doesn't really matter. But we can definitely set num_tx_queues=8 for all switches. The felix->info->num_tx_queues construct itself seems unnecessary. It was introduced by commit de143c0e274b ("net: dsa: felix: Configure Time-Aware Scheduler via taprio offload") at a time when vsc9959 (LS1028A) was the only switch supported by the driver. 8 traffic classes, and 1 queue per traffic class, is a common architectural feature of all switches in the family. So they could all just set OCELOT_NUM_TC and be fine. Signed-off-by: Vladimir Oltean Reviewed-by: Colin Foster Tested-by: Colin Foster --- drivers/net/dsa/ocelot/felix.h | 1 - drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- drivers/net/dsa/ocelot/ocelot_ext.c | 3 +-- drivers/net/dsa/ocelot/seville_vsc9953.c | 3 ++- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index e67a25f6f816..e0bfea10ff52 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -32,7 +32,6 @@ struct felix_info { const u32 *port_modes; int num_mact_rows; int num_ports; - int num_tx_queues; struct vcap_props *vcap; u16 vcap_pol_base; u16 vcap_pol_max; diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 20563abd617f..ec8b124e8f61 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2658,7 +2658,6 @@ static const struct felix_info felix_info_vsc9959 = { .vcap_pol_max2 = 0, .num_mact_rows = 2048, .num_ports = VSC9959_NUM_PORTS, - .num_tx_queues = OCELOT_NUM_TC, .quirks = FELIX_MAC_QUIRKS, .quirk_no_xtr_irq = true, .ptp_caps = &vsc9959_ptp_caps, @@ -2711,7 +2710,8 @@ static int felix_pci_probe(struct pci_dev *pdev, ds->dev = dev; ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = felix->info->num_tx_queues; + ds->num_tx_queues = OCELOT_NUM_TC; + ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops; ds->priv = ocelot; diff --git a/drivers/net/dsa/ocelot/ocelot_ext.c b/drivers/net/dsa/ocelot/ocelot_ext.c index c893f3ee238b..9cd24f77dc49 100644 --- a/drivers/net/dsa/ocelot/ocelot_ext.c +++ b/drivers/net/dsa/ocelot/ocelot_ext.c @@ -57,7 +57,6 @@ static const struct felix_info vsc7512_info = { .vcap = vsc7514_vcap_props, .num_mact_rows = 1024, .num_ports = VSC7514_NUM_PORTS, - .num_tx_queues = OCELOT_NUM_TC, .port_modes = vsc7512_port_modes, .phylink_mac_config = ocelot_phylink_mac_config, .configure_serdes = ocelot_port_configure_serdes, @@ -90,7 +89,7 @@ static int ocelot_ext_probe(struct platform_device *pdev) ds->dev = dev; ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = felix->info->num_tx_queues; + ds->num_tx_queues = OCELOT_NUM_TC; ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops; diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index e63247d3dfdb..83bd0e1ee692 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -963,7 +963,6 @@ static const struct felix_info seville_info_vsc9953 = { .quirks = FELIX_MAC_QUIRKS, .num_mact_rows = 2048, .num_ports = VSC9953_NUM_PORTS, - .num_tx_queues = OCELOT_NUM_TC, .mdio_bus_alloc = vsc9953_mdio_bus_alloc, .mdio_bus_free = vsc9953_mdio_bus_free, .port_modes = vsc9953_port_modes, @@ -1002,6 +1001,8 @@ static int seville_probe(struct platform_device *pdev) ds->dev = dev; ds->num_ports = felix->info->num_ports; + ds->num_tx_queues = OCELOT_NUM_TC; + ds->ops = &felix_switch_ops; ds->phylink_mac_ops = &felix_phylink_mac_ops; ds->priv = ocelot; From patchwork Thu May 30 16:33:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680589 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 BE7DC3CF4F for ; Thu, 30 May 2024 16:34:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086847; cv=fail; b=omHX3gImlXMTDLY26Zfq05nWw7aSIuhwnS2y+8rkc8sgrIOAfT8vDh95qpiox1nn4n7jkD/F8QNPq4hoZCI+ResexogGIUQ0k1bIMb1zAMtDUDa87/wGBxe9pfEnhT6GgxY0M9QDmZGCxKnGAyHmfz6leVe5BRGTsdDp8abchMQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086847; c=relaxed/simple; bh=zAOi82lwElbWjk4sX9r+p1R4tyCTGDDq9+/D3EuVCPg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=P1QRlLenyolI+gIgN5yBOPqB3h3mdCuSgr6/J1nUGAtbarA2ssiPM3Ki5GiowsacL9sF1oK3j75IVcYwFigZq12HOf2Vvdn/is/+uIjsdsqk6TWg8lV910SSHthK9jhcNcrh7+WtQZ832ET55McBtzsgce1za70/bqUYwWWteDc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=NfzwVhEc; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="NfzwVhEc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RQuCU28V4XpIjOkeCPaZvBepTUvxGA63aQ/fVS7NPaRYjQQWmoRUPvSepQY+Y0x4HAJqgGPjkceb4ouogkxQNVOnugJrmsczDc8o5uoP3C389I5ZrLp0HnPHpFE6B8mFzUlCHrqqcKKdb/+MQ9xrFE1Bx+A+OU9AqKnHI5hzsdp36e++2t11TP2lFL6yDqmbzueDmlZKyS4m2Hnbu3KoRaHmiKV383BfA65VFHael7Qzbkv72OJ8goBGahnXp+TVk0k8dNYtH9xTWQoC8jiS7iOE4flp6J1/LGwENMFtjtqYzAVk/4BWmKwFyI2ULUg1CykR5r8hxRHoxHuHoCVDGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8S1pJzufn0aVv9s5+81QCgIoFK39A9YFq1fhAFT7dls=; b=CgruX28mh8rDrVTpJtXqmxCKE5A9+puRbHfJwE76M//Oyi2xZSheMFa4e/+NQ9y1V2lBAnrdfzfFFzJm9w3nR3vFLeJwTrmi6GQbJQTkotRVhDOFrTArRr05TDn8pVc+mWTIVyIewJfBcFS4J/vlLExBSInXHvYdmNsJbC8HHCHUWE9hjaNPwokMp3Ef2wlPrY3NGlWmTr79MBaHFOhB3zB0K+SBQcQ45T9YnE+E/k3obyde2medtVvW49OxSHC4lKGxwGycdgfTjCdNpOnuH9jvTR0B2x9sMyqChPmW8xkfa7OipQK9hefm1gIXs4MbFWKrcPoBqAgbHZJ6ZIim2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8S1pJzufn0aVv9s5+81QCgIoFK39A9YFq1fhAFT7dls=; b=NfzwVhEc+wB0MXCYj8fYhQLuGsvP6i6FODvlSGZNvcC9mq9EfbWQVYZ6NPgWF+Km6Pj43dIDFR9WamHdBdujkgomaMsGftLpFzG8C6BsQAjC5UDsVy2+om+NONuo4vD7bDYcQiWa1L5k0SRLgRNotfq99amjAUWMwujgSTp2RBc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:57 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 7/8] net: dsa: ocelot: common probing code Date: Thu, 30 May 2024 19:33:32 +0300 Message-Id: <20240530163333.2458884-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: 15475933-4b7a-4d53-7b9b-08dc80c64d9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: Ae24eEh1zFZqT4e2HBiW4csWZ8t3hWVkpEx/bniBHVGRQPkD/mxPIeDqgXsmjY9MF9VFRmvEOhf94PZ/E0zThTeWtgluChUIBDS951L/tC+FfAvmoVjzAWFVTRNgj1IlKu7LkgE/1S88PWTBJLRXjLNpr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qHe0hJ4CG0EE/mzzj7m1j0zAZm80YJGyA+IFLS76iKgjh8LrqRSTkQXykTJbiBtBcWqRA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Divg6tVeoEpYhnK422/+L4s9MJN96v2EoY7TlMWBwQGDkm/SCE+eKAmdKLexZW1w9ZCaAd+fIMw2IJaj4cm8OLXumkPje7EfdPwhFi5sUy0wePoEqeCB4OWAJGLBKMNsGylNHhQ6DEEbTBigHCYytdTDUM+ZBRG9TTtdA3J4K4UHMHFJwjcUaqUVYKZdhfOXG3zP9nzjdO/zAiOF3j+KNXaAvZ3K1L1Q1WpS90pIkVy8SAnPFRPuDASZy8JZla87ezrLiMVoOiZtwI1GO++zYuOtsJifCj7/+8r2xSVq+zK7MQJ6j45IfKkl+hQ0FS3jRCh7B9Hr+JqRBEiIZ0OPIgJCfNzdiKVxrldqXF5myn9syHbSXUApe3T8ueHATgAynitx5gXgQiRrqerXuE6YLGPY9IArthpyMylmBuzVubiB62Az1sF5bn3kEbUWbCef2qYfRYNkqCvrFqB9Ft/Uyu32JumhKTndIdHzcbqXItbliR0331rYPaYOyd/MzpsqliLSWsFoUUWx09BPZFKk7uvgVHgXx+R7Qy7NyLuKdhYxDf3Iw3rRd4szzy9PwuQQKruUJAtiFE2AWgApt5++qbijhHClUQ33KbWXYCaAWSPnXO6vLUcr14grsHk0Jg2xwAdWXGhwGmUSYkZYVFyKvxvwNsQrQ0PDazAX9BpUzqg88fgMluzEmpUPmXULigTMVjVIZQzw0uV/fVi6v/YHFaaghjuy1wCDjSkXRs3HyzL3z+k3iG7L4QfjmxUV0XWYUCPiv4y7ADXUXUE6fLaEcSgmI8UjXEoURInkwhN+tEHFiS8ydloLxhfhzsYndE1tuKVk5jipRHWPg5ktTmeFaNV9Su6Hsq7XKletq8mtKr0WQP1dtsOAh8QTrgYlaZIM/xEwZ/cu0KdC0k++oYBt1AfopQDvHggXP5HwTvUUuI0p8SRXa8WuLWP7cIejOmTZRRNkg72Xw0CldeDbdW/vIgB2+olAxLa7pNk9Ppo+fOq9LDjE2gFmhrg4fmI1QS4hBATif303r9B7LPaBTYTwRgxt8/xjhKvsvasRYZ6v3sc3hDnzA0w62rG96j5V2GN4KmjIGLHBoDlukUDAlWxgRbzrqSUwwPg+2qjk0DhfvPuR67Uju3kh9mzqShMiynRZoXZLG0XxK6+kvoL0tXg7Ylxm1U8WeqAa3G8hIoKBg5wwwNlFYMK3kVL1zbhGuSJS3LGZnh0g9JTHVO2LujMCGyZMzU7TrHCOCWD8HKLPv+KA9rVwQQQSRkhca8U2UsTBh31nCiLyQUqOorbvZv8nfKzUpjALcFRGzp7hAqPVf4IWObWrVdVq/SaPKEEerwjTl6ZhFzbOfuYsHOZ+7DvkIOlbQ0R3DrHVTHvzjujcIOS9sJDHkG7VBtyNDQUucXgXBcswG+Xi3wrgXz+XUCINSgFPCsthnmcY/7v4b3YeITi84Y/1YHsevLkWnbsSkZ4il9sD7YJ9OiACnTynZulQ6ICM3hlNbqdjyF1a5KjSL882lMkE0r2RJkYwnNg3v3apJn80rYl+yjMrK6LYQaUUqww54sRiqCerqlcirufWPfAHE0XI6XKpraffxUMyrrAzqzN1byZbAIHdCc+SO65Rag== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15475933-4b7a-4d53-7b9b-08dc80c64d9e X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:57.5171 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Jb0k9hKle9B/QEZWAFLbGo21winBHDRsB5DeCqG+of89S+nepoHyc6geOStX+4N9AYAoPPupEYMQrFkMfXZqvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org Russell King suggested that felix_vsc9959, seville_vsc9953 and ocelot_ext have a large portion of duplicated init code, which could be made common [1]. [1]: https://lore.kernel.org/all/Zh1GvcOTXqb7CpQt@shell.armlinux.org.uk/ Here, we take the following common steps: - "felix" and "ds" structure allocation - "felix", "ocelot" and "ds" basic structure initialization - dsa_register_switch() call and we make a common function out of them. For every driver except felix_vsc9959, this is also the entire probing procedure. For felix_vsc9959, we also need to do some PCI-specific stuff, which can easily be reordered to be done before, and unwound on failure. We also have to convert the bus-specific platform_set_drvdata() and pci_set_drvdata() calls into dev_set_drvdata(). But this should have no impact on the behavior. Suggested-by: "Russell King (Oracle)" Signed-off-by: Vladimir Oltean Tested-by: Colin Foster --- drivers/net/dsa/ocelot/felix.c | 47 ++++++++++++++++++++++++ drivers/net/dsa/ocelot/felix.h | 5 +++ drivers/net/dsa/ocelot/felix_vsc9959.c | 44 +++------------------- drivers/net/dsa/ocelot/ocelot_ext.c | 40 +------------------- drivers/net/dsa/ocelot/seville_vsc9953.c | 38 ++----------------- 5 files changed, 63 insertions(+), 111 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 09c0800b18ab..accf737f7b69 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -2195,6 +2195,53 @@ const struct dsa_switch_ops felix_switch_ops = { }; EXPORT_SYMBOL_GPL(felix_switch_ops); +int felix_register_switch(struct device *dev, resource_size_t switch_base, + int num_flooding_pgids, bool ptp, + bool mm_supported, + enum dsa_tag_protocol init_tag_proto, + const struct felix_info *info) +{ + struct dsa_switch *ds; + struct ocelot *ocelot; + struct felix *felix; + int err; + + felix = devm_kzalloc(dev, sizeof(*felix), GFP_KERNEL); + if (!felix) + return -ENOMEM; + + ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); + if (!ds) + return -ENOMEM; + + dev_set_drvdata(dev, felix); + + ocelot = &felix->ocelot; + ocelot->dev = dev; + ocelot->num_flooding_pgids = num_flooding_pgids; + ocelot->ptp = ptp; + ocelot->mm_supported = mm_supported; + + felix->info = info; + felix->switch_base = switch_base; + felix->ds = ds; + felix->tag_proto = init_tag_proto; + + ds->dev = dev; + ds->num_ports = info->num_ports; + ds->num_tx_queues = OCELOT_NUM_TC; + ds->ops = &felix_switch_ops; + ds->phylink_mac_ops = &felix_phylink_mac_ops; + ds->priv = ocelot; + + err = dsa_register_switch(ds); + if (err) + dev_err_probe(dev, err, "Failed to register DSA switch\n"); + + return err; +} +EXPORT_SYMBOL_GPL(felix_register_switch); + struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port) { struct felix *felix = ocelot_to_felix(ocelot); diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index e0bfea10ff52..85b4f8616003 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -100,6 +100,11 @@ struct felix { unsigned long host_flood_mc_mask; }; +int felix_register_switch(struct device *dev, resource_size_t switch_base, + int num_flooding_pgids, bool ptp, + bool mm_supported, + enum dsa_tag_protocol init_tag_proto, + const struct felix_info *info); struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port); int felix_netdev_to_port(struct net_device *dev); diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index ec8b124e8f61..ba37a566da39 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2673,9 +2673,7 @@ static int felix_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct device *dev = &pdev->dev; - struct dsa_switch *ds; - struct ocelot *ocelot; - struct felix *felix; + resource_size_t switch_base; int err; err = pci_enable_device(pdev); @@ -2684,45 +2682,15 @@ static int felix_pci_probe(struct pci_dev *pdev, return err; } - felix = devm_kzalloc(dev, sizeof(struct felix), GFP_KERNEL); - if (!felix) { - err = -ENOMEM; - goto out_disable; - } - - pci_set_drvdata(pdev, felix); - ocelot = &felix->ocelot; - ocelot->dev = dev; - ocelot->num_flooding_pgids = OCELOT_NUM_TC; - felix->info = &felix_info_vsc9959; - felix->switch_base = pci_resource_start(pdev, VSC9959_SWITCH_PCI_BAR); - pci_set_master(pdev); - ocelot->ptp = 1; - ocelot->mm_supported = true; + switch_base = pci_resource_start(pdev, VSC9959_SWITCH_PCI_BAR); - ds = devm_kzalloc(dev, sizeof(struct dsa_switch), GFP_KERNEL); - if (!ds) { - err = -ENOMEM; + err = felix_register_switch(dev, switch_base, OCELOT_NUM_TC, + true, true, DSA_TAG_PROTO_OCELOT, + &felix_info_vsc9959); + if (err) goto out_disable; - } - - ds->dev = dev; - ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = OCELOT_NUM_TC; - - ds->ops = &felix_switch_ops; - ds->phylink_mac_ops = &felix_phylink_mac_ops; - ds->priv = ocelot; - felix->ds = ds; - felix->tag_proto = DSA_TAG_PROTO_OCELOT; - - err = dsa_register_switch(ds); - if (err) { - dev_err_probe(dev, err, "Failed to register DSA switch\n"); - goto out_disable; - } return 0; diff --git a/drivers/net/dsa/ocelot/ocelot_ext.c b/drivers/net/dsa/ocelot/ocelot_ext.c index 9cd24f77dc49..5632a7248cd4 100644 --- a/drivers/net/dsa/ocelot/ocelot_ext.c +++ b/drivers/net/dsa/ocelot/ocelot_ext.c @@ -64,44 +64,8 @@ static const struct felix_info vsc7512_info = { static int ocelot_ext_probe(struct platform_device *pdev) { - struct device *dev = &pdev->dev; - struct dsa_switch *ds; - struct ocelot *ocelot; - struct felix *felix; - int err; - - felix = devm_kzalloc(dev, sizeof(*felix), GFP_KERNEL); - if (!felix) - return -ENOMEM; - - dev_set_drvdata(dev, felix); - - ocelot = &felix->ocelot; - ocelot->dev = dev; - - ocelot->num_flooding_pgids = 1; - - felix->info = &vsc7512_info; - - ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); - if (!ds) - return -ENOMEM; - - ds->dev = dev; - ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = OCELOT_NUM_TC; - - ds->ops = &felix_switch_ops; - ds->phylink_mac_ops = &felix_phylink_mac_ops; - ds->priv = ocelot; - felix->ds = ds; - felix->tag_proto = DSA_TAG_PROTO_OCELOT; - - err = dsa_register_switch(ds); - if (err) - dev_err_probe(dev, err, "Failed to register DSA switch\n"); - - return err; + return felix_register_switch(&pdev->dev, 0, 1, false, false, + DSA_TAG_PROTO_OCELOT, &vsc7512_info); } static void ocelot_ext_remove(struct platform_device *pdev) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 83bd0e1ee692..70782649c395 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -971,49 +971,17 @@ static const struct felix_info seville_info_vsc9953 = { static int seville_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct dsa_switch *ds; - struct ocelot *ocelot; struct resource *res; - struct felix *felix; - int err; - - felix = devm_kzalloc(dev, sizeof(struct felix), GFP_KERNEL); - if (!felix) - return -ENOMEM; - - platform_set_drvdata(pdev, felix); - - ocelot = &felix->ocelot; - ocelot->dev = dev; - ocelot->num_flooding_pgids = 1; - felix->info = &seville_info_vsc9953; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "Invalid resource\n"); return -EINVAL; } - felix->switch_base = res->start; - - ds = devm_kzalloc(dev, sizeof(struct dsa_switch), GFP_KERNEL); - if (!ds) - return -ENOMEM; - - ds->dev = dev; - ds->num_ports = felix->info->num_ports; - ds->num_tx_queues = OCELOT_NUM_TC; - - ds->ops = &felix_switch_ops; - ds->phylink_mac_ops = &felix_phylink_mac_ops; - ds->priv = ocelot; - felix->ds = ds; - felix->tag_proto = DSA_TAG_PROTO_SEVILLE; - - err = dsa_register_switch(ds); - if (err) - dev_err(dev, "Failed to register DSA switch: %d\n", err); - return err; + return felix_register_switch(dev, res->start, 1, false, false, + DSA_TAG_PROTO_SEVILLE, + &seville_info_vsc9953); } static void seville_remove(struct platform_device *pdev) From patchwork Thu May 30 16:33:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13680590 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2075.outbound.protection.outlook.com [40.107.20.75]) (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 D722B3D982 for ; Thu, 30 May 2024 16:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086849; cv=fail; b=o9SlGXoUc/RSrCNS8A87/ID8Y+2z9CjMZvJjShLgVxnzBd5d+JMSJkjfRiknKQb4l7bVeY4/atg24R0fCa9x5LBaaavzbCdsGfPWww9F9qeNc6E/jacSeKhjj901Q4gY6TtVlRiq6ZN9sZNHeBGEiVg7v9bY8Q1we+3ieUmgUCQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717086849; c=relaxed/simple; bh=9eFbGwv4Lbw/3RuorxZafYd8L/vbh1YOVo2vVn18RN4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=aoJnHWRZaIszDKmyyAZeV0m9KGU1POACyjUtNjLneUqSJpTC7nI7J0bdd+5LhKXGSyn+1nzbPyl6Zxu9bs8Oudr64pJ0sEj/W7PCnMcXMmeA5uUZ0iVUlZ9yIBFTA/xnNft7e7gjpBgShtxaMvRiZbOogbyTFzNH0CV6z0vNUqg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=iwU9nXXr; arc=fail smtp.client-ip=40.107.20.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="iwU9nXXr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kJ9VuXcdA9A1WaJzQmXJeK7q9uA6gfMfToof81pzUq3P+/gxm6DzNmC8G24WFKntEe2Qc5EAjREO2D5FIh9lu2Cnpo0N++cWmWeAXmFux+jvIaYB2qwdXaMV92W7WRsMLlOIwgSd95oTvL9r9oblqa5kpSbAGWRibw0DvVYbZF0ci0YcW8tHq/uL2JoXWqPUHc7TDxAU7if3KVm+uoTjgFtRpGvt/xOhIZjzavwnWncSYHnQ3jQflebvfSymS4LN7L3AiPfOOogvA7rVySa4xINO7tMcu0RlhMqrN1g8sHtGk0Way9dOH3A0xAvwwVc4hX9F/otQ7DR0ORbhamEZOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M7U267Jp9rFsBb6JJXqh9bVBdo4Mz0U0a7WLpahhbxw=; b=e16+Bpu06YTUVLBpYOa6lyamivZ8NFxDI2y34M6oH2PRfC3UgHfJKYc9gS8l12/QuYqMrTyOJ2BYk/B7ayRoX9nlL+87MTO5WNRuwgJGRNxKDSAsN2Vp4YREsz5hR2xratkGy+e6rfEb/a+seiNC3Q8L+qvvT34HFOL9f7RTswjYk5lyL27ia4DaJPH4LaSB6keIAm475KEjGq9Zj2xHbNwrhOexgOTFLs94otorLoUjYlMtisyRY1Z/dmd8YipwHi3wuydPbuydyIogZTpgeDMc+Ug4pTrztEus720QMdUiVD3KtwBI22YVIe0z7C62RWjhxOgQ+CY/kA0B3YXm9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M7U267Jp9rFsBb6JJXqh9bVBdo4Mz0U0a7WLpahhbxw=; b=iwU9nXXrcc/ixlIUwgoLcrUE6AeUePCcFlI02RBFW/aaXomHeQwBM8iZL0VoU3jmjOLNw2flDuDxSTbkmBcVJZM1Drk1+dY4PE30SPaNuZkRtBpJiGaOj/sy29E55oJJIylL3RihXbHK/6ymRhMEq3ur9QQ1Jgy4p4VpAV+KANE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DU0PR04MB9585.eurprd04.prod.outlook.com (2603:10a6:10:316::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 16:33:58 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.030; Thu, 30 May 2024 16:33:58 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Colin Foster , Russell King Subject: [PATCH net-next 8/8] net: dsa: ocelot: unexport felix_phylink_mac_ops and felix_switch_ops Date: Thu, 30 May 2024 19:33:33 +0300 Message-Id: <20240530163333.2458884-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530163333.2458884-1-vladimir.oltean@nxp.com> References: <20240530163333.2458884-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0102CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:802::20) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DU0PR04MB9585:EE_ X-MS-Office365-Filtering-Correlation-Id: dc5f8a2e-a91b-4911-f011-08dc80c64e52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|7416005|366007|38350700005; X-Microsoft-Antispam-Message-Info: tVGYs0rvWfEY1POJlmzmHhVQpcwBJ109Ka+DbwJsG8TL/gP6NV82hO6RXrtaimzbZ3S5TmXyEZfgxdO8A4HX3kDzPfnWlTZpbkDURNoWM95eaDXyJQd+1OvyrtVdpudwtPtmzsizj5W4+bb2VTShEmSA2fA/PlelbqVnCtopqvJITlTBioZSUuc9GNVy2sPwLzuHw2t1Eu3L0wyWQssoe7o7cljDrU0X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D0TE/qi94v59ha/VxNKarbXUHuVOobuvpQPzsAf5WKLE4LA9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(7416005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NH+tCVY+x2qQaul3lXpypuDgK0tHt16SvzU3I7v7PmEye+LqmPU4YB6YsBMkeOXT2xs/lf3h4Y38oxENbtgz40giAqvfEAY58klqn6Pr+RZnAz6PfWqebjoBxrExyY3RUbgyzAT7x5xXGUHqV9kipeU7IngLRy8vYkfOgFMAk8SvCX5EdBbW7m8I+rofI8efbq+22Ow52nJE+0/naY6xQ+C/gOiTzWT9/BEBLPQG6jtXOxSXDxRg41WUcAo8NRGNE/HlL4fMHuBVUhc7yEB9O5rFX0PeBTYZCXjd9oMGXU7vJ2uO1T66HG/c7NOhx7V7lq2KJpCtJ4m17BZjsIDx0nSIPsI70cEc/ZB5KxehWzCdpHXtLKkEtIVDoH5ljSBdqr1S3pwCI3/SzgagQI6w0mKy8h3VOk4iHKPk6WfNx2ATsyMHUZe6uOlaRe1z06b2ZzUxQdmpSBZKLEw5atVPxUmeI5/pl5sGeGoR38cV8bFzRFl4XaRZA4x2S/Z8KudkJukdXDzYZMRDyjsJE1kTQLovTSAiBjdshm66ubDkwwRGXZJ2mi2m7UCUsu8kwHI4sLigLnYGgj4mvogd6c6vBhApKUqXlICeY0J4VScyKTSjR+uJwdfMXw8VBLVRJXZFYSuml0TzFSJ253xczAPFPJ6bPrnE7km4Xlkizrb4xtRYl6xjnXsKj5uAZCRY+WK4CsWIGX9UtHLb5hmhhVXJ1QurM8M4hm7SbfmIEQ9vA3MDiEvOkAFhwRFrC0xxxZueIYIUcbpCe9dDdvInhL+Z+ip0fNWd/Gl1v3zD9zcPJlBWFoppBNDbyNISYxqR+/LEHBVVPsZHOMu5ugKSAjIJIRHSx23idJfKvB6cppmg8brJCrKH2gcE/u4XS6WCYgP24Jdj/T7Mpi3sJBRuwJjyrMoBBx0DwWCGwRUNVR1Glw8ZJbRwXL0L3TU1g97ss7KdeO870yvV9gjBSH5bgdj6cFATNIsKQfoHKSF6LNgeg3n/29Sm27H3hbLzosXaRyklojZI0kOpmnPpiOU3lrY5OLNbDiuXfhEmNJe3IRKxFOJsG7UPixB+bOVVeCx9Jy9BQVzjeHB7yMdp3JiOMQAv3GqfWa7a6WqbXaT6BYEI9PVque1E3aBrTiB4bbBPbIoInt8qolBDybCqBwD+XfAdJtIJrIwd+F644Qd8rQ+4ds9bEXPGgulVMUVh71RogaCJc0PNtRm0ugVWd1UnAPypSlYmvtf4uVgYcdU8gUv4E/8kkFmyuyCU4LXatHThdAB1xJ2fCl6gFMTr6sd5pG0Yprk8Uv9yrimUSfF3bH0iCcmyQ+i4Fc3s+MoMPf/ppi4lwg18jvt8Rrsc8oRAiHEzd/O37NI4wAS58VYHfqz4V8dyOsR4Os2bRYoKjfAk0LSZmDocesDEWdKYD0Y3nvNpsbd80AIPxTFKDx9XP2/pZQHRRKKgAr7igdIenhPfLjlYORIsdGa00/wZthCHfMdYEnDy/UP1DqpjYumGbFRbGg/zQ/iQ9QiA9GeQ8warCx1zFGFHB4tbFoYqQoTBBXqj8Y16Cg/2X5zbVEEmBGwGmIYKCsKcnXAaCyYYRyVino0YKbQz5eX71SE4KE5ga3va1Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc5f8a2e-a91b-4911-f011-08dc80c64e52 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 16:33:58.6733 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mc9fH361sZ4GLwWmQiraD4AN1EoTyE98WZj5yFmtFM2wZEBiSQwWmhjXPCfiaUY1LrjEGPC5jGDgxnSRlILUTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9585 X-Patchwork-Delegate: kuba@kernel.org Now that the common felix_register_switch() from the umbrella driver is the only entity that accesses these data structures, we can remove them from the list of the exported symbols. Signed-off-by: Vladimir Oltean Reviewed-by: Sai Krishna --- drivers/net/dsa/ocelot/felix.c | 6 ++---- drivers/net/dsa/ocelot/felix.h | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index accf737f7b69..d12c4e85baa7 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -2106,15 +2106,14 @@ static void felix_get_mm_stats(struct dsa_switch *ds, int port, ocelot_port_get_mm_stats(ocelot, port, stats); } -const struct phylink_mac_ops felix_phylink_mac_ops = { +static const struct phylink_mac_ops felix_phylink_mac_ops = { .mac_select_pcs = felix_phylink_mac_select_pcs, .mac_config = felix_phylink_mac_config, .mac_link_down = felix_phylink_mac_link_down, .mac_link_up = felix_phylink_mac_link_up, }; -EXPORT_SYMBOL_GPL(felix_phylink_mac_ops); -const struct dsa_switch_ops felix_switch_ops = { +static const struct dsa_switch_ops felix_switch_ops = { .get_tag_protocol = felix_get_tag_protocol, .change_tag_protocol = felix_change_tag_protocol, .connect_tag_protocol = felix_connect_tag_protocol, @@ -2193,7 +2192,6 @@ const struct dsa_switch_ops felix_switch_ops = { .port_set_host_flood = felix_port_set_host_flood, .port_change_conduit = felix_port_change_conduit, }; -EXPORT_SYMBOL_GPL(felix_switch_ops); int felix_register_switch(struct device *dev, resource_size_t switch_base, int num_flooding_pgids, bool ptp, diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index 85b4f8616003..211991f494e3 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -82,9 +82,6 @@ struct felix_tag_proto_ops { struct netlink_ext_ack *extack); }; -extern const struct phylink_mac_ops felix_phylink_mac_ops; -extern const struct dsa_switch_ops felix_switch_ops; - /* DSA glue / front-end for struct ocelot */ struct felix { struct dsa_switch *ds;