From patchwork Sat Jan 23 03:44:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 369555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7274FC43381 for ; Sat, 23 Jan 2021 03:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 461A323B21 for ; Sat, 23 Jan 2021 03:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbhAWDqC (ORCPT ); Fri, 22 Jan 2021 22:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbhAWDp4 (ORCPT ); Fri, 22 Jan 2021 22:45:56 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23508C061351 for ; Fri, 22 Jan 2021 19:44:34 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id b8so4363253plh.12 for ; Fri, 22 Jan 2021 19:44:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dJGIvDbFer174uYIU3S/UHlxuD0C4SN9Ba2a5uW/TjI=; b=OifXzFWywulgTYIb9jiyHpcD9JRWqdvQpqyIxxU2D6tsvuICK7UAWAuNdhwL9zUrAR K+Nk1PB3vJuukAby67BHb75dLenU9dJldjAEfwR/2+8xvD7W58qyqrNjKfvj0OLfm/Vm zbEeseMkg52zIyx68ryB6lk3sZbv2Q8yvg+zE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dJGIvDbFer174uYIU3S/UHlxuD0C4SN9Ba2a5uW/TjI=; b=EYs1e2ilRWgTXvKPSGiveMg6DpuxtMiSC67FBCV6nDQ/yzo2jp9GsnNSvUvIzi1d6V 8PYLLNm0OfUzB63PVj1ZvGM3dr5WGBFzGWqnVf4N8O/e5gtisZdx8YP7UvYzyTI/+rsX MrtHKD70X+ryWHTxNCMeAXA7JkQcoy8pslb8iPX6HY8vUNv/mOR51QtCca2BuBP1YbOX tpTwIyOoVY9QGFKEvbvwzAsFCZql3oQsNBfJlxibXV3dyf0BWFw7e9u+QLg95H0cYauV tqMyFmR5/MrIGh5XY8XsMftDenYuECh3JfMGyOtbziI9zmxrTP5K+FQbYYTgQNzbXCPk eAqQ== X-Gm-Message-State: AOAM533e4C17zxLB8AOIgBqsTP6AjFSfhq43I6lSCsJK+oSPIBR/bBfR Gg1tTO/5JFEQhURlNgHdhot68sjr7IPY5A== X-Google-Smtp-Source: ABdhPJwOaNd8kn+wXdYuJVArrzuHdGMUINcUY27IXOlFKIQTp/Yvg53oR2Q8FrPD6gGeNitPo2TNQw== X-Received: by 2002:a17:90b:3792:: with SMTP id mz18mr8968978pjb.23.1611373473763; Fri, 22 Jan 2021 19:44:33 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id gf23sm10480343pjb.42.2021.01.22.19.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 19:44:33 -0800 (PST) From: Stephen Boyd To: Rob Herring Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mauro Carvalho Chehab , Jacopo Mondi , Arnd Bergmann , Geert Uytterhoeven , Jacopo Mondi , Mauro Carvalho Chehab , Rob Herring , Frank Rowand , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 1/6] media: renesas-ceu: Use of_device_get_match_data() Date: Fri, 22 Jan 2021 19:44:23 -0800 Message-Id: <20210123034428.2841052-2-swboyd@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210123034428.2841052-1-swboyd@chromium.org> References: <20210123034428.2841052-1-swboyd@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This driver can use the replacement API instead of calling of_match_device() and then dereferencing the pointer that is returned. This nicely avoids referencing the match table when it is undefined with configurations where CONFIG_OF=n. Signed-off-by: Stephen Boyd Acked-by: Mauro Carvalho Chehab Acked-by: Jacopo Mondi Cc: Arnd Bergmann Cc: Geert Uytterhoeven Cc: Jacopo Mondi Cc: Mauro Carvalho Chehab Cc: Rob Herring Cc: Frank Rowand Cc: Cc: Reviewed-by: Geert Uytterhoeven --- Please ack so Rob can apply. drivers/media/platform/renesas-ceu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c index 4a633ad0e8fa..352e7c84d5ba 100644 --- a/drivers/media/platform/renesas-ceu.c +++ b/drivers/media/platform/renesas-ceu.c @@ -1679,7 +1679,7 @@ static int ceu_probe(struct platform_device *pdev) v4l2_async_notifier_init(&ceudev->notifier); if (IS_ENABLED(CONFIG_OF) && dev->of_node) { - ceu_data = of_match_device(ceu_of_match, dev)->data; + ceu_data = of_device_get_match_data(dev); num_subdevs = ceu_parse_dt(ceudev); } else if (dev->platform_data) { /* Assume SH4 if booting with platform data. */ From patchwork Sat Jan 23 03:44:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 369554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B664BC433E0 for ; Sat, 23 Jan 2021 03:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E2B823B21 for ; Sat, 23 Jan 2021 03:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726983AbhAWDrQ (ORCPT ); Fri, 22 Jan 2021 22:47:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbhAWDp4 (ORCPT ); Fri, 22 Jan 2021 22:45:56 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97995C061353 for ; Fri, 22 Jan 2021 19:44:35 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id md11so5029967pjb.0 for ; Fri, 22 Jan 2021 19:44:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ub3HDIGcGN9X98CN8/+sRfhCxNd7htSlAnp6McU6Vl8=; b=c4K/CpgL2OEAm5HKCZdSOkGLE+2LP12JHtnZH1E7VVnD+OVE1va+XuLLP4qnJCpChO 5wVaEwIAitUDXGSRbX6GXUURo561HFOY8aq+EIGY767Vkn/JLB/mqyQh6ZpnyOCF1Tzz 6DZxjQt4K7KOvCpbZatqPfAP7r6oTSE9oRDvE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ub3HDIGcGN9X98CN8/+sRfhCxNd7htSlAnp6McU6Vl8=; b=S7w4o+EhH1gZNNLAXkY5vuoo3AvrlGUcwd4xI/5mHcsJHDp4wo5hE5u5iC+ssKfdC1 a4DgHeQtxUcNY9veF/H6ZPLmKnc9PF31kb8Q2nRc+ZqCOxV9zC9gVSjXi06qMjlW2v6E AHj2S0BUX91oVgiBCQBiKk3t1aJlFf9kYfX7Y+j/35JxLXr8QDdm3zQ1yB6bCplg+s/H lZ6yQ8Y2fjTJpXCUzvkLRZsiAsi8L0SF7C9SIDHYZZESm9Q0MQ5kLrH8NGV+Kt8OMhUr ZG5wdJMyETK82ya86qEvHnQMtEZhNQUiIjDViXa1kdhQl462kn5HqVsl1R2N6OFLhCgb cfig== X-Gm-Message-State: AOAM533pOAZvNCAHJDXdY6lsJfcXYgX03eKPA7no971JZRSRY2aj7M8J H7+zHKlZGCBwibWUm+wz9c4PKA== X-Google-Smtp-Source: ABdhPJxQN2vek2DR+91n81FNJwfjyXjxDRkHHmje05Ec810oHF9xUj+nyLklqYq3FeTc2+wIm7YB3g== X-Received: by 2002:a17:902:8e82:b029:dc:3182:e0b7 with SMTP id bg2-20020a1709028e82b02900dc3182e0b7mr8170599plb.78.1611373475161; Fri, 22 Jan 2021 19:44:35 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id gf23sm10480343pjb.42.2021.01.22.19.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 19:44:34 -0800 (PST) From: Stephen Boyd To: Rob Herring Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Arnd Bergmann , Geert Uytterhoeven , Grygorii Strashko , "David S. Miller" , Rob Herring , Frank Rowand , linux-omap@vger.kernel.org Subject: [PATCH v2 2/6] drivers: net: davinci_mdio: Use of_device_get_match_data() Date: Fri, 22 Jan 2021 19:44:24 -0800 Message-Id: <20210123034428.2841052-3-swboyd@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210123034428.2841052-1-swboyd@chromium.org> References: <20210123034428.2841052-1-swboyd@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use the more modern API to get the match data out of the of match table. This saves some code, lines, and nicely avoids referencing the match table when it is undefined with configurations where CONFIG_OF=n. Signed-off-by: Stephen Boyd Cc: Arnd Bergmann Cc: Geert Uytterhoeven Cc: Grygorii Strashko Cc: "David S. Miller" Cc: Rob Herring Cc: Frank Rowand Cc: --- Please ack so Rob can apply. drivers/net/ethernet/ti/davinci_mdio.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index cfff3d48807a..a4efd5e35158 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -358,20 +358,16 @@ static int davinci_mdio_probe(struct platform_device *pdev) } if (IS_ENABLED(CONFIG_OF) && dev->of_node) { - const struct of_device_id *of_id; + const struct davinci_mdio_of_param *of_mdio_data; ret = davinci_mdio_probe_dt(&data->pdata, pdev); if (ret) return ret; snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s", pdev->name); - of_id = of_match_device(davinci_mdio_of_mtable, &pdev->dev); - if (of_id) { - const struct davinci_mdio_of_param *of_mdio_data; - - of_mdio_data = of_id->data; - if (of_mdio_data) - autosuspend_delay_ms = + of_mdio_data = of_device_get_match_data(&pdev->dev); + if (of_mdio_data) { + autosuspend_delay_ms = of_mdio_data->autosuspend_delay_ms; } } else { From patchwork Sat Jan 23 03:44:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 369556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECFD6C433DB for ; Sat, 23 Jan 2021 03:47:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B569E23B21 for ; Sat, 23 Jan 2021 03:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbhAWDqu (ORCPT ); Fri, 22 Jan 2021 22:46:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726866AbhAWDqe (ORCPT ); Fri, 22 Jan 2021 22:46:34 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 206A7C06121C for ; Fri, 22 Jan 2021 19:44:37 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id q4so4386396plr.7 for ; Fri, 22 Jan 2021 19:44:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o4yYwzF4tROKFYt2eOzFnYYTnlg9EWxAh+XeSEeStnQ=; b=FePE0Rh/xSu8xWi5GgPl3W+kOB5bPHlW3vcnaWDD+ytBGmUhW1JH1xWeFygj4Lr9rK iGCNc9AgVKYmVL8T70diPUyowZlE99uqQjdOjRyDDnAFXqPsucDLpkDCb4IuOZ0fKbEH mFQbZStlFu37UytUjY/iMsBFh0gs+NMEt449A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o4yYwzF4tROKFYt2eOzFnYYTnlg9EWxAh+XeSEeStnQ=; b=s9Sl/ltuOZ1Kl+ZNrjr3yB/wGb2iA2NGQ3sxQOqYVQQDYMx2g0VQLLt0nOAQbj9e4u 2rgmndSWrkcpJcw1KaJjIVZqxRxpYBUt5ctM3uvOusEonXJ05Fxsx/exgrGwmEAttLLH gq18E7fttWcTkD5WZUhBCe+i2gJOUyrO3PSIiikkkmmOJL+e5fn3/scB2H+5DKiqiB95 oONMLCFjMWErIBHrhuSzBfq03JcJmGUWCnRceExU0wJjwa08+JgbI2l8uSvYTPgMkgJn lzGwQn4zX7fdSCNG5xZy0438Wjcr70XmHbZd139GebkXLEv/XVR6m1dNUPNyIEz0CtML E1cA== X-Gm-Message-State: AOAM532Ryo/dKNDb+HlT4/dResy5ZeeHl8Ihyjtztzyc5gaQ9C/16uPT qPPJtek7/hdi5cSLwg0evLdEcA== X-Google-Smtp-Source: ABdhPJy66Yaa72bvz+TFvlVdOgWBeTJN96CJ6WmyZF4u0Sj7I332lxEwedbni49rsxMH4tn0yV97NA== X-Received: by 2002:a17:902:d909:b029:df:52b4:8147 with SMTP id c9-20020a170902d909b02900df52b48147mr2722252plz.33.1611373476696; Fri, 22 Jan 2021 19:44:36 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id gf23sm10480343pjb.42.2021.01.22.19.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 19:44:36 -0800 (PST) From: Stephen Boyd To: Rob Herring Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Greg Kroah-Hartman , Arnd Bergmann , Geert Uytterhoeven , Jiri Slaby , Maxime Coquelin , Alexandre Torgue , Rob Herring , Frank Rowand , linux-serial@vger.kernel.org Subject: [PATCH v2 3/6] serial: stm32: Use of_device_get_match_data() Date: Fri, 22 Jan 2021 19:44:25 -0800 Message-Id: <20210123034428.2841052-4-swboyd@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210123034428.2841052-1-swboyd@chromium.org> References: <20210123034428.2841052-1-swboyd@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This driver casts away the constness of struct stm32_usart_info that is pointed to by the of match table. Use of_device_get_match_data() instead of of_match_device() here and push the const throughout the code so that we don't cast away const. This nicely avoids referencing the match table when it is undefined with configurations where CONFIG_OF=n and fixes the const issues. Signed-off-by: Stephen Boyd Acked-by: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Geert Uytterhoeven Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: Rob Herring Cc: Frank Rowand Cc: --- Please ack so Rob can apply. drivers/tty/serial/stm32-usart.c | 71 +++++++++++++++----------------- drivers/tty/serial/stm32-usart.h | 2 +- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index f4de32d3f2af..99f04db73830 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -99,8 +99,8 @@ static int stm32_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - struct stm32_usart_config *cfg = &stm32_port->info->cfg; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_config *cfg = &stm32_port->info->cfg; u32 usartdiv, baud, cr1, cr3; bool over8; @@ -166,7 +166,7 @@ static int stm32_pending_rx(struct uart_port *port, u32 *sr, int *last_res, bool threaded) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; enum dma_status status; struct dma_tx_state state; @@ -191,7 +191,7 @@ static unsigned long stm32_get_char(struct uart_port *port, u32 *sr, int *last_res) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; unsigned long c; if (stm32_port->rx_ch) { @@ -211,7 +211,7 @@ static void stm32_receive_chars(struct uart_port *port, bool threaded) { struct tty_port *tport = &port->state->port; struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; unsigned long c; u32 sr; char flag; @@ -282,7 +282,7 @@ static void stm32_tx_dma_complete(void *arg) { struct uart_port *port = arg; struct stm32_port *stm32port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAT); stm32port->tx_dma_busy = false; @@ -294,7 +294,7 @@ static void stm32_tx_dma_complete(void *arg) static void stm32_tx_interrupt_enable(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; /* * Enables TX FIFO threashold irq when FIFO is enabled, @@ -309,7 +309,7 @@ static void stm32_tx_interrupt_enable(struct uart_port *port) static void stm32_tx_interrupt_disable(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; if (stm32_port->fifoen) stm32_clr_bits(port, ofs->cr3, USART_CR3_TXFTIE); @@ -320,7 +320,7 @@ static void stm32_tx_interrupt_disable(struct uart_port *port) static void stm32_transmit_chars_pio(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; struct circ_buf *xmit = &port->state->xmit; if (stm32_port->tx_dma_busy) { @@ -347,7 +347,7 @@ static void stm32_transmit_chars_pio(struct uart_port *port) static void stm32_transmit_chars_dma(struct uart_port *port) { struct stm32_port *stm32port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; struct circ_buf *xmit = &port->state->xmit; struct dma_async_tx_descriptor *desc = NULL; unsigned int count, i; @@ -407,7 +407,7 @@ static void stm32_transmit_chars_dma(struct uart_port *port) static void stm32_transmit_chars(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; struct circ_buf *xmit = &port->state->xmit; if (port->x_char) { @@ -447,7 +447,7 @@ static irqreturn_t stm32_interrupt(int irq, void *ptr) { struct uart_port *port = ptr; struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; u32 sr; spin_lock(&port->lock); @@ -494,7 +494,7 @@ static irqreturn_t stm32_threaded_interrupt(int irq, void *ptr) static unsigned int stm32_tx_empty(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; return readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE; } @@ -502,7 +502,7 @@ static unsigned int stm32_tx_empty(struct uart_port *port) static void stm32_set_mctrl(struct uart_port *port, unsigned int mctrl) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS)) stm32_set_bits(port, ofs->cr3, USART_CR3_RTSE); @@ -579,7 +579,7 @@ static void stm32_start_tx(struct uart_port *port) static void stm32_throttle(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; unsigned long flags; spin_lock_irqsave(&port->lock, flags); @@ -594,7 +594,7 @@ static void stm32_throttle(struct uart_port *port) static void stm32_unthrottle(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; unsigned long flags; spin_lock_irqsave(&port->lock, flags); @@ -609,7 +609,7 @@ static void stm32_unthrottle(struct uart_port *port) static void stm32_stop_rx(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; stm32_clr_bits(port, ofs->cr1, stm32_port->cr1_irq); if (stm32_port->cr3_irq) @@ -625,7 +625,7 @@ static void stm32_break_ctl(struct uart_port *port, int break_state) static int stm32_startup(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; const char *name = to_platform_device(port->dev)->name; u32 val; int ret; @@ -661,8 +661,8 @@ static int stm32_startup(struct uart_port *port) static void stm32_shutdown(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - struct stm32_usart_config *cfg = &stm32_port->info->cfg; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_config *cfg = &stm32_port->info->cfg; u32 val, isr; int ret; @@ -721,8 +721,8 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - struct stm32_usart_config *cfg = &stm32_port->info->cfg; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_config *cfg = &stm32_port->info->cfg; struct serial_rs485 *rs485conf = &port->rs485; unsigned int baud, bits; u32 usartdiv, mantissa, fraction, oversampling; @@ -921,8 +921,8 @@ static void stm32_pm(struct uart_port *port, unsigned int state, { struct stm32_port *stm32port = container_of(port, struct stm32_port, port); - struct stm32_usart_offsets *ofs = &stm32port->info->ofs; - struct stm32_usart_config *cfg = &stm32port->info->cfg; + const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; + const struct stm32_usart_config *cfg = &stm32port->info->cfg; unsigned long flags = 0; switch (state) { @@ -1081,7 +1081,7 @@ MODULE_DEVICE_TABLE(of, stm32_match); static int stm32_of_dma_rx_probe(struct stm32_port *stm32port, struct platform_device *pdev) { - struct stm32_usart_offsets *ofs = &stm32port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; struct uart_port *port = &stm32port->port; struct device *dev = &pdev->dev; struct dma_slave_config config; @@ -1152,7 +1152,7 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port, static int stm32_of_dma_tx_probe(struct stm32_port *stm32port, struct platform_device *pdev) { - struct stm32_usart_offsets *ofs = &stm32port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; struct uart_port *port = &stm32port->port; struct device *dev = &pdev->dev; struct dma_slave_config config; @@ -1202,7 +1202,6 @@ static int stm32_of_dma_tx_probe(struct stm32_port *stm32port, static int stm32_serial_probe(struct platform_device *pdev) { - const struct of_device_id *match; struct stm32_port *stm32port; int ret; @@ -1210,10 +1209,8 @@ static int stm32_serial_probe(struct platform_device *pdev) if (!stm32port) return -ENODEV; - match = of_match_device(stm32_match, &pdev->dev); - if (match && match->data) - stm32port->info = (struct stm32_usart_info *)match->data; - else + stm32port->info = of_device_get_match_data(&pdev->dev); + if (!stm32port->info) return -EINVAL; ret = stm32_init_port(stm32port, pdev); @@ -1272,7 +1269,7 @@ static int stm32_serial_remove(struct platform_device *pdev) { struct uart_port *port = platform_get_drvdata(pdev); struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; int err; pm_runtime_get_sync(&pdev->dev); @@ -1317,7 +1314,7 @@ static int stm32_serial_remove(struct platform_device *pdev) static void stm32_console_putchar(struct uart_port *port, int ch) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; while (!(readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE)) cpu_relax(); @@ -1329,8 +1326,8 @@ static void stm32_console_write(struct console *co, const char *s, unsigned cnt) { struct uart_port *port = &stm32_ports[co->index].port; struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - struct stm32_usart_config *cfg = &stm32_port->info->cfg; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_config *cfg = &stm32_port->info->cfg; unsigned long flags; u32 old_cr1, new_cr1; int locked = 1; @@ -1416,8 +1413,8 @@ static void __maybe_unused stm32_serial_enable_wakeup(struct uart_port *port, bool enable) { struct stm32_port *stm32_port = to_stm32_port(port); - struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - struct stm32_usart_config *cfg = &stm32_port->info->cfg; + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + const struct stm32_usart_config *cfg = &stm32_port->info->cfg; u32 val; if (stm32_port->wakeirq <= 0) diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index d4c916e78d40..cb4f327c46db 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -259,7 +259,7 @@ struct stm32_usart_info stm32h7_info = { struct stm32_port { struct uart_port port; struct clk *clk; - struct stm32_usart_info *info; + const struct stm32_usart_info *info; struct dma_chan *rx_ch; /* dma rx channel */ dma_addr_t rx_dma_buf; /* dma rx buffer bus address */ unsigned char *rx_buf; /* dma rx buffer cpu address */ From patchwork Sat Jan 23 03:44:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 370032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E57EC433E9 for ; Sat, 23 Jan 2021 03:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 248B323B26 for ; Sat, 23 Jan 2021 03:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbhAWDrF (ORCPT ); Fri, 22 Jan 2021 22:47:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbhAWDqk (ORCPT ); Fri, 22 Jan 2021 22:46:40 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 989F3C06121E for ; Fri, 22 Jan 2021 19:44:38 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id 15so5148329pgx.7 for ; Fri, 22 Jan 2021 19:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TAGPmP9BOJXhZhPf5GwqBeoScIfskZqY/J81LHEeHtk=; b=NZZ6yFVmNa7MxufUctRDhrA/2kE4i5M/O2laQqAIdRTg+v0WaUoejxIkipX2gg/JO8 o4NiObGkeDm7IDiHhRPngZP9FP/mimImdZ6hYrEQoilLtad2G5wBGpPWs6AAojVqSYre SZkFzokfE9dqhMRMw1Z0pgZ/GD7gWAqAQIxs4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TAGPmP9BOJXhZhPf5GwqBeoScIfskZqY/J81LHEeHtk=; b=MZATaGmllF5XXTQ4tzC5xIx601gouqhS0xHnyAJNs+HKCBm+DTYfRujY++D8P+Ax71 CufwTOP1J8PnDYRjfZ3D9uKvGZ8k0h+j4Pi2L5gw85bqOO+UqqWZPLSExi6PQ3PvvkNn ZT8U32sPscXgmqDFotCSJKSw3iI41ForAJ7sSMYjrOulFbYaY9yUI285RtkTtl7xo4iS XmdIeyhKKvZddpgubVEyK3ao6dawcrycH6TLisLrM00n/PYLCd9luHhcWViYURlOyo0y UWo8X4aQB7ME2RQTrfQ5/LepzSgTXhXFqtk/LScTqwI+0U3mwlh3dC2vdR4MEzTWPHVz v8MA== X-Gm-Message-State: AOAM533mfmRIZC6XZN/7K638d3GgBucCkboeUdX6nHxwowBTpxnDr8cu zMpcn0VSSYeFR84k5gcEzTNHTw== X-Google-Smtp-Source: ABdhPJzNLWbZDFfZmckPJlA5EOwk5QhhmGGjNE24UUnWdo/NgVHUBCoGkQOdXUeI7A/hJLgkWOm5nQ== X-Received: by 2002:a05:6a00:1385:b029:1be:ac19:3a9d with SMTP id t5-20020a056a001385b02901beac193a9dmr1557962pfg.65.1611373478208; Fri, 22 Jan 2021 19:44:38 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id gf23sm10480343pjb.42.2021.01.22.19.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 19:44:37 -0800 (PST) From: Stephen Boyd To: Rob Herring Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Greg Kroah-Hartman , Arnd Bergmann , Geert Uytterhoeven , Richard Leitner , Rob Herring , Frank Rowand , linux-usb@vger.kernel.org Subject: [PATCH v2 4/6] usb: usb251xb: Use of_device_get_match_data() Date: Fri, 22 Jan 2021 19:44:26 -0800 Message-Id: <20210123034428.2841052-5-swboyd@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210123034428.2841052-1-swboyd@chromium.org> References: <20210123034428.2841052-1-swboyd@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use the more modern API here instead of using of_match_device() and avoid casting away const from the returned pointer by pushing the const type through to the users. This nicely avoids referencing the match table when it is undefined with configurations where CONFIG_OF=n and avoids const issues. Signed-off-by: Stephen Boyd Acked-by: Greg Kroah-Hartman Cc: Arnd Bergmann Cc: Geert Uytterhoeven Cc: Richard Leitner Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Frank Rowand Cc: --- Please ack so Rob can apply. drivers/usb/misc/usb251xb.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c index 29fe5771c21b..507deef1f709 100644 --- a/drivers/usb/misc/usb251xb.c +++ b/drivers/usb/misc/usb251xb.c @@ -396,7 +396,7 @@ static void usb251xb_get_ports_field(struct usb251xb *hub, } static int usb251xb_get_ofdata(struct usb251xb *hub, - struct usb251xb_data *data) + const struct usb251xb_data *data) { struct device *dev = hub->dev; struct device_node *np = dev->of_node; @@ -630,7 +630,7 @@ static const struct of_device_id usb251xb_of_match[] = { MODULE_DEVICE_TABLE(of, usb251xb_of_match); #else /* CONFIG_OF */ static int usb251xb_get_ofdata(struct usb251xb *hub, - struct usb251xb_data *data) + const struct usb251xb_data *data) { return 0; } @@ -647,13 +647,11 @@ static int usb251xb_probe(struct usb251xb *hub) { struct device *dev = hub->dev; struct device_node *np = dev->of_node; - const struct of_device_id *of_id = of_match_device(usb251xb_of_match, - dev); + const struct usb251xb_data *usb_data = of_device_get_match_data(dev); int err; - if (np && of_id) { - err = usb251xb_get_ofdata(hub, - (struct usb251xb_data *)of_id->data); + if (np && usb_data) { + err = usb251xb_get_ofdata(hub, usb_data); if (err) { dev_err(dev, "failed to get ofdata: %d\n", err); return err; From patchwork Sat Jan 23 03:44:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 370031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 822C7C4332B for ; Sat, 23 Jan 2021 03:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B0F023B2A for ; Sat, 23 Jan 2021 03:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726896AbhAWDrH (ORCPT ); Fri, 22 Jan 2021 22:47:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbhAWDqj (ORCPT ); Fri, 22 Jan 2021 22:46:39 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7658C061224 for ; Fri, 22 Jan 2021 19:44:39 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id g15so5101619pjd.2 for ; Fri, 22 Jan 2021 19:44:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xR8YQMKfgP2HW7WhNJdeAV7/ctNsHW3A/OLYCiFLrok=; b=b639/5WXIPJKT58P9xeSP1JaicOfVaw68rgoB6ixWuLWuRnjv1R9nhdQmvtIQhf5uv sb8QrtLVBCaVNE/ke2X86B8/akvUSiqo5kNEP1p92wvub6eoMEDRgD6O2KGV/aAHj90A MBRtkikOQMmUqYogC9xlA1SIGLpgORIJq6e30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xR8YQMKfgP2HW7WhNJdeAV7/ctNsHW3A/OLYCiFLrok=; b=FHWKS+icSssBk7PjBBMlFwu572VR5mh5tFdl2H4xxQKUmiG63RJ8MKrpESp+xp3E03 PoYYgG55ErYp9Pc1a47RuVaLsrpMsUeEOBKagbHR9bVpBqvcYeZQB/UoTPluF0dLcY87 IdlyvA0pQpzQmuOnzMqPs7fS5dlnWe2mzvQMtBYQPGoummgcMLTALC5icfGXV4mDTWCp IGpqm299iG6QyKJxG9+pnhxDPuxteyAKnfD8PV/Aq5TzVi+nd3poKkyorBppoyY3A16t +q4Uvnt1EZ2ScnAcznJFOu2QRaG0wbKXLHeGBJri7DHhHCT28X0CKEGvjNXxoz+XYD46 sZ9Q== X-Gm-Message-State: AOAM530Rxpsc8ZK+yi9HbikTTXu9/1KX7ZkV7IF9RtbMg9BMiW4wRvFG 1ys4JkvCbStcZB2Y3uvtcXLLuA== X-Google-Smtp-Source: ABdhPJxjpyrtoHQKuXYDd99QrdPxjgxKSzYNJ0kZP6Q5tAl++sVk8vA/tI1Q8vi4PiUjKULQZ/QwNQ== X-Received: by 2002:a17:90a:5d13:: with SMTP id s19mr3332843pji.110.1611373479572; Fri, 22 Jan 2021 19:44:39 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id gf23sm10480343pjb.42.2021.01.22.19.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 19:44:39 -0800 (PST) From: Stephen Boyd To: Rob Herring Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Guenter Roeck , Arnd Bergmann , Geert Uytterhoeven , Jean Delvare , Rob Herring , Frank Rowand , linux-hwmon@vger.kernel.org Subject: [PATCH v2 5/6] hwmon: (lm70) Avoid undefined reference to match table Date: Fri, 22 Jan 2021 19:44:27 -0800 Message-Id: <20210123034428.2841052-6-swboyd@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210123034428.2841052-1-swboyd@chromium.org> References: <20210123034428.2841052-1-swboyd@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org We're going to remove of_match_ptr() from the definition of of_match_device() when CONFIG_OF=n. This way we can always be certain that of_match_device() acts the same when CONFIG_OF is set and when it isn't. Add of_match_ptr() here so that this doesn't break when that change is made to the of_match_device() API. Signed-off-by: Stephen Boyd Acked-by: Guenter Roeck Cc: Arnd Bergmann Cc: Geert Uytterhoeven Cc: Jean Delvare Cc: Guenter Roeck Cc: Rob Herring Cc: Frank Rowand Cc: --- Please ack so Rob can apply. drivers/hwmon/lm70.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c index ae2b84263a44..e3153ae80634 100644 --- a/drivers/hwmon/lm70.c +++ b/drivers/hwmon/lm70.c @@ -178,7 +178,7 @@ static int lm70_probe(struct spi_device *spi) struct lm70 *p_lm70; int chip; - of_match = of_match_device(lm70_of_ids, &spi->dev); + of_match = of_match_device(of_match_ptr(lm70_of_ids), &spi->dev); if (of_match) chip = (int)(uintptr_t)of_match->data; else { From patchwork Sat Jan 23 03:44:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 370033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E910EC4332B for ; Sat, 23 Jan 2021 03:46:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B66B223B26 for ; Sat, 23 Jan 2021 03:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726807AbhAWDq0 (ORCPT ); Fri, 22 Jan 2021 22:46:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726808AbhAWDqO (ORCPT ); Fri, 22 Jan 2021 22:46:14 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DA9C061225 for ; Fri, 22 Jan 2021 19:44:41 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id kx7so5023957pjb.2 for ; Fri, 22 Jan 2021 19:44:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qzVpWEoynH6taGK1dmEKcfhSuX1O4pYnplDljz5JhnI=; b=ZDnQTJDKNyO1AQ1cRjQ8PqkniCuIk/RpUwCJ6AHBruosIDFTH0frYO+JZrs4uL9C6S HkMKzgBAA92GE1iFaM7x6HOWIzqr3cb9Qe2kLqnc4QzX5aKrrSZpUhaaNMSHRl3I9x8Q 6A5o05k28QJYoGYkL4msES1sKDXAfW9YklUY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qzVpWEoynH6taGK1dmEKcfhSuX1O4pYnplDljz5JhnI=; b=ZAJKnf3s8LY/gI0Wa/oBh6R8iFib0fUwc1cPI7AMuhb7uMOO4xjbfDi/9rpqfjJ9S1 JjSAeFIbU4ZxTgm1+rZa352oAaz2wT/TIIs3SU6ExFDxhNjEPhzQ5I6YNO45BB+AZqhL CBZMYE/GL/w7KvANB9sLPbv6DWbIlcveCEwZYQvKuMU0kRjrUVS4kvg0bVMev8V2K8pZ HKOtdsfg+AHqSvc9DFcSJc4ZxkYYKF8+d9IndloocS63xb3cmUg9EHmeFOsz6TpUCqGZ HFb811dHRWDEwZT1e7w9SSS65nmLpyqpLbpmEwtvXQqWCSXo2jVdwuNZ5DzHCVx37NTf g6Hw== X-Gm-Message-State: AOAM531/wZsgKHyEnfaJUzNT6IHUHOMK35FgzzN9ixEBhUf2c6MJr0rT o32rsM7T8RQQ/0ZxBOOiaisliQ== X-Google-Smtp-Source: ABdhPJzUqWEy/sG3S+FLSW0twubig1dqKx3dPmZ1Tqg20DZKNkVEy17j+dLI6Tj53lCL0uEhQ2MnwQ== X-Received: by 2002:a17:90a:1c09:: with SMTP id s9mr9066942pjs.83.1611373480787; Fri, 22 Jan 2021 19:44:40 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id gf23sm10480343pjb.42.2021.01.22.19.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 19:44:40 -0800 (PST) From: Stephen Boyd To: Rob Herring Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Rowand , Arnd Bergmann , Geert Uytterhoeven , Rob Herring Subject: [PATCH v2 6/6] of/device: Don't NULLify match table in of_match_device() with CONFIG_OF=n Date: Fri, 22 Jan 2021 19:44:28 -0800 Message-Id: <20210123034428.2841052-7-swboyd@chromium.org> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210123034428.2841052-1-swboyd@chromium.org> References: <20210123034428.2841052-1-swboyd@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This effectively reverts 1db73ae39a97 ("of/device: Nullify match table in of_match_device() for CONFIG_OF=n") because that commit makes it more surprising to users of this API that the arguments may never be referenced by any code. This is because the pre-processor will replace the argument with NULL and then the match table will be left unreferenced by any code but the compiler optimizer doesn't know to drop it. This can lead to compilers warning that match tables are unused, when we really want to pass the match table to the API but have the compiler see that it's all inlined and not used and then drop the match table while silencing the warning. We're being too smart here and not giving the compiler the chance to do dead code elimination. Signed-off-by: Stephen Boyd Acked-by: Frank Rowand Cc: Arnd Bergmann Cc: Geert Uytterhoeven Cc: Rob Herring Cc: Frank Rowand Reviewed-by: Geert Uytterhoeven Acked-by: Geert Uytterhoeven Reviewed-by: Arnd Bergmann --- Please ack so Rob can apply. include/linux/of_device.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 07ca187fc5e4..937f32f6aecb 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -99,13 +99,11 @@ static inline int of_device_uevent_modalias(struct device *dev, static inline void of_device_node_put(struct device *dev) { } -static inline const struct of_device_id *__of_match_device( +static inline const struct of_device_id *of_match_device( const struct of_device_id *matches, const struct device *dev) { return NULL; } -#define of_match_device(matches, dev) \ - __of_match_device(of_match_ptr(matches), (dev)) static inline struct device_node *of_cpu_device_node_get(int cpu) {