From patchwork Mon Aug 19 04:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24A62C3DA4A for ; Mon, 19 Aug 2024 05:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cjo9bqr1UtOoJLuXizHH4agDHMHJlsbeIYUVnrax5+8=; b=pyMIfAi1bmRajwBSQS1D/dDZzu Wu7B1dNQH7FjNYnu8zGBz8BjS2p5Mt7TXkMpp4JQ0kujtmADaKbuaApdSlLgWzis5JAG4eI1o6IXq KH0pQgXhwiMOf6Z/8pj6ZXqP00ityQPbY7z+aQ+ivsGfDW94T3vStgTzMEeG45jW7xD3IEswCnXPo 5ENKcrBfegOLKR6wTNB0dVsstoMIgRAWToUCli7aCOVtfxipW0dr3EJG4va9vB5XaVK9DQMmcNStA 6VHnmIXxMhuZ/TWJ9EHVIeXBeyJt1vTxEA/odRQ0FNyFGzfGvT25VRVVmZ5cCCzsRJgI/oYvnTT6D 4925UuNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuUe-00000000LsW-23iY; Mon, 19 Aug 2024 04:59:48 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTM-00000000LVi-0N2e for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:29 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-20227ba378eso8962725ad.0 for ; Sun, 18 Aug 2024 21:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043507; x=1724648307; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cjo9bqr1UtOoJLuXizHH4agDHMHJlsbeIYUVnrax5+8=; b=Ws14vfqw+ion0EJtZGBDczvBsVGblrJEbKj5aKabA8hT6+CQ+u1uFWE7IdNMwx26Vg ohjYlLOdD6s2pNwwoqC/cXBAdradMB5OFr9/LTW2CElTODaNKJENn7T6HpQR4HyYal/A gNQeMH8/W+VSLwseArNswtb0lkTQ6R/+ryuADwFP38c09p//LSAFdGjb+p2J9AcJ6g37 7sHN0XxXTH85X0KNH3xCSfroL3IlFD9u67KTda0v0BTvb5cZFeQLvf53H51gEO3IxjO3 YYxFLWBO6xHimpn02mGJgrBzfTrTaxhdGiTc/1aQ50XiUWHOi541eMbl+UXADRmcFky2 NCWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043507; x=1724648307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cjo9bqr1UtOoJLuXizHH4agDHMHJlsbeIYUVnrax5+8=; b=V7ZB18K0oRxDyF52y13gsMRVx5yoQL2e/sTDGaLfuIJlb5b3khcQgsrKaOpnRoMI5u ZZtOBjpbwjfkZlrRf1+IptCKJ8MNjrHDT8imLb0cTusXuqiDQxUjIUOkSPhzvKz6xN+f TYbaNvZizpmHprfiSA33uXhHNqY3VELfKQIMNLwtqZYJNUAmlfBN2ixFV6Scej0bwIVG weZyssONFuxqlcXJ+AYN2XMsDmkO5jFSWkPIT38g1McAl/uXX0nmvl+nQ167zohEDjqN y6d/fVI/5oWHDg8Nz1lrvqvgQcWF9iP0iQmQkkdtriSBRuaryJ7FzHzJXW80gensyXiZ VBCA== X-Forwarded-Encrypted: i=1; AJvYcCXjgqxXFTzhlZ8gpaIEPwIUkZcap5oPhhuOok9wMBRA4NtngKidHGe3XcVyr0VKC0MHOmWJOlMehwhWQ5vvf+M/@lists.infradead.org X-Gm-Message-State: AOJu0YwglgWEGEw9F5w0cY+Qty3Jp8veKirh5M7G6qixTYFjsCgjmv8j cR04t3ZcjmJFRjNfGUuNOD3lU4UHjTI8oylpgtCEnJ/5nwkFekt2 X-Google-Smtp-Source: AGHT+IEgWjgzFxk/W9ikkgzvRwbFFaUk2esxhBqzuQvA+hd7no2/ruCI6LWlDXbaFRBGOsR6Bd85AQ== X-Received: by 2002:a17:902:f60f:b0:201:daee:6fae with SMTP id d9443c01a7336-20203f2c389mr139215625ad.48.1724043506539; Sun, 18 Aug 2024 21:58:26 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:26 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 01/14] Input: samsung-keypad - switch to using devm_clk_get_prepared() Date: Sun, 18 Aug 2024 21:57:58 -0700 Message-ID: <20240819045813.2154642-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215828_149714_2069825D X-CRM114-Status: GOOD ( 15.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to using devm_clk_get_prepared() instead of combining devm_clk_get() with clk_prepare(), which simplifies the code and ensures that the clock is unprepared at the right time relative to releasing other managed resources. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/samsung-keypad.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index e212eff7687c..a5fac7de8b5d 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -361,18 +361,12 @@ static int samsung_keypad_probe(struct platform_device *pdev) if (!keypad->base) return -EBUSY; - keypad->clk = devm_clk_get(&pdev->dev, "keypad"); + keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad"); if (IS_ERR(keypad->clk)) { dev_err(&pdev->dev, "failed to get keypad clk\n"); return PTR_ERR(keypad->clk); } - error = clk_prepare(keypad->clk); - if (error) { - dev_err(&pdev->dev, "keypad clock prepare failed\n"); - return error; - } - keypad->input_dev = input_dev; keypad->pdev = pdev; keypad->row_shift = row_shift; @@ -399,7 +393,7 @@ static int samsung_keypad_probe(struct platform_device *pdev) keypad->keycodes, input_dev); if (error) { dev_err(&pdev->dev, "failed to build keymap\n"); - goto err_unprepare_clk; + return error; } input_set_capability(input_dev, EV_MSC, MSC_SCAN); @@ -411,7 +405,7 @@ static int samsung_keypad_probe(struct platform_device *pdev) keypad->irq = platform_get_irq(pdev, 0); if (keypad->irq < 0) { error = keypad->irq; - goto err_unprepare_clk; + return error; } error = devm_request_threaded_irq(&pdev->dev, keypad->irq, NULL, @@ -419,7 +413,7 @@ static int samsung_keypad_probe(struct platform_device *pdev) dev_name(&pdev->dev), keypad); if (error) { dev_err(&pdev->dev, "failed to register keypad interrupt\n"); - goto err_unprepare_clk; + return error; } device_init_wakeup(&pdev->dev, pdata->wakeup); @@ -439,20 +433,12 @@ static int samsung_keypad_probe(struct platform_device *pdev) err_disable_runtime_pm: pm_runtime_disable(&pdev->dev); -err_unprepare_clk: - clk_unprepare(keypad->clk); return error; } static void samsung_keypad_remove(struct platform_device *pdev) { - struct samsung_keypad *keypad = platform_get_drvdata(pdev); - pm_runtime_disable(&pdev->dev); - - input_unregister_device(keypad->input_dev); - - clk_unprepare(keypad->clk); } static int samsung_keypad_runtime_suspend(struct device *dev) From patchwork Mon Aug 19 04:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 818C1C3DA4A for ; Mon, 19 Aug 2024 05:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2/Y0JUcD5C4Iagug6Oy1owYtKAXHbmgAHcwaCUa/T4M=; b=cByvJ3Abtbwtqtd2dz4AGCiYh5 4VQ7yQ3a65pizVfOEG9TF3gbBPD37HKMealRidikcrju2EG0grJF4VBkMiKCbaVhl2d2q/Ytgjl+x IBpcM+9jH0KKZcYvbbxdyKf0QY13gvmkMLEIGFVH91RwQ6AOcrboo3jDNyQf9BR6h/1UmS7i8gSEX k5vYPJdrlnMFZpkLq1V1cFnQFm1P0hC/pstj/HQCwHNxMuPzuFAoAVZhyXbLPPsGK1Ty+AUthTa2I dJGTz21D6RGXX7EDFUBe9Rkq/0QWp125XJIW5Sp9/ViuQd7pLV+BcATU+zP7ID4uRN8XKVR+tgkJ6 BZY0/Beg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuVI-00000000M5Q-1Lcf; Mon, 19 Aug 2024 05:00:28 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTN-00000000LWC-10X1 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:30 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2020b730049so16806215ad.3 for ; Sun, 18 Aug 2024 21:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043508; x=1724648308; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2/Y0JUcD5C4Iagug6Oy1owYtKAXHbmgAHcwaCUa/T4M=; b=QquKi3Uvb/E03UdDT0DbCwe9QLInNWueIGYARmmg3BMnElrzIouJYYFb9tCkAUsnpg Dkcg3rywpTOeWRgMO9pQZwiNacridhUQj6JYnX3bb4awaWIzxd02YU3eRlXptB2PcePK KyuOZQIDiU1U73t3XuCnUutMQeUcIoffJAsFCMolxYK/ENshaDqKrZq12lb5mlTXwwpk Nd6d4/rS1gDyVBJiITnFT24wTHyahnCPQGu2ap2VyQY3GxJalUxy7GW8fWBX5/BfTyEw thDdKUdLPn8VecJAHTmEaFI22CfO7f0F5Q5Iv6FyGrXpvGO5zO/NA7cLfm98d2cW2l1/ woxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043508; x=1724648308; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2/Y0JUcD5C4Iagug6Oy1owYtKAXHbmgAHcwaCUa/T4M=; b=V5YO5r9+KmzdBRBkfKuhApxeS8DmzNuENfriOben3TsOr4I+eM5dcamOUXIStiUPdf 9Q78Q/ppWnkQIpGbyUSyPBd0smUvUFvKFlW2GyaKt3WieEXl4D5n7uuAdjZI6k6Xqgzm uOmDX3355FVKVEioEjRNT9bpW8j68WBvmSdIhFQ+Kg22NbSCcb/mXM8zokHd+/7pTksQ 0F846KLbhMel9ktA3Ka24pio01ivwGzuveKTi6K1lf6NhngGuxpP1WOI1ZCnnxVNhgqV UIFMFP8wHY7aW86joxcuN3rN5jVB72BTWxhigqJdd+RNTXUdbinb7aMTNu5KOoBw/djx sM2w== X-Forwarded-Encrypted: i=1; AJvYcCWa9XUWkxBRWJWytoktUR55eKE89h4IIPQ0m/+/zdCPCXrhfjyf/5jWhhP/W9q2l8Poln0aJ/hZrFgrHR179RLspPi3qg7WccYvstJKQuKYbz0wspk= X-Gm-Message-State: AOJu0YzV0qCg9nWMz6Pv3BPQCsD5Y4lL++Up4xWILj0B6CxJ/hltzzFy xXVLjpClmFZvzpsg4T/zE2CQN+KzgFd3mxacB8GV32Ejq5qdlHxD X-Google-Smtp-Source: AGHT+IF1FebuvREI1PKd696ezenX7q5OEaQirUD2qmXuoFQq8cvKEdSNbcfFQPZuyxucVQtm6Vli6w== X-Received: by 2002:a17:902:d2c3:b0:202:1984:d507 with SMTP id d9443c01a7336-2021984d79emr48288425ad.30.1724043507950; Sun, 18 Aug 2024 21:58:27 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:27 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 02/14] Input: samsung-keypad - do not set input device's parent explicitly Date: Sun, 18 Aug 2024 21:57:59 -0700 Message-ID: <20240819045813.2154642-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215829_303392_993B9EE6 X-CRM114-Status: GOOD ( 12.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver uses devm_input_allocate_device() to allocate instances of input device, which sets the parent appropriately. Remove extraneous assignment. Signed-off-by: Dmitry Torokhov Reviewed-by: Krzysztof Kozlowski --- drivers/input/keyboard/samsung-keypad.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index a5fac7de8b5d..46c0d0c900f6 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -383,7 +383,6 @@ static int samsung_keypad_probe(struct platform_device *pdev) input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; - input_dev->dev.parent = &pdev->dev; input_dev->open = samsung_keypad_open; input_dev->close = samsung_keypad_close; From patchwork Mon Aug 19 04:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767884 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A533C3DA4A for ; Mon, 19 Aug 2024 05:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LOtLgRKGQX67ieoH/CsjydrcIz7BO5T8N0kmB5YnlVI=; b=ftYCnBmzvU+WMvv6KsaKz0Fq6+ VKos14jhZgQ1IseNq4liAC+Fab6l3ypMk+sRNgdtxpc3/C8qV2Km1IjxS93BlKJ5cabhJVl/Stevg j+CdWpX6AhS3SuDUtde1loKk4skacY/JTPkev+4NuqEDMIG4YL6ZvF6fUq79wNudmGG4tfEmcdqfp 3gC4kDfEuOxPLmhUTClsvIVNwdiuNYyJ4kibikEjvLOvoHvrumRlqPWLNLEJ4m4Jh8JScxuE7agNZ hWG0bDtrolRck+u00KUFcsUXo9IzaXL1HLR3ok4Ba9j+BNbvLeQa4YV1umj9hUP4ZBBlCG9N5zq7i YxUyestA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuVx-00000000MI5-2SQT; Mon, 19 Aug 2024 05:01:09 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTO-00000000LWb-2doe for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:31 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2020e83eca1so18381755ad.2 for ; Sun, 18 Aug 2024 21:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043510; x=1724648310; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LOtLgRKGQX67ieoH/CsjydrcIz7BO5T8N0kmB5YnlVI=; b=ej8Ph3+HTfXePX/1BdAPgBT8c3Qtxx8jR2bPCgSmw0m+zccgzZVUuYagZ/hOBSFNz9 g+xks8Vhhw9A8pdmNAWDaJDfzN6h3iZdmhnJ0/bDR9Miqu4SlGv7FFRPp1ztuYj6X3ik Qosic/0DrJcDrljkEDn5eMOFQlH8T8VCd6laBmEG3JPM0vuymKwhLY4BCuj5Mn/P664M HoUxdHc+SFc7WsLt4NMWHYFk6ZS43HpRnObe+TFS05vyLAQMwMFMglLKetGDPW1g9EKp /cathb8VYX4omlVZlxPBGQWfG/nCGlKhhd5RHImYtulxdPr+rHZrrMMwWNH6W6GaCCGf 4MEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043510; x=1724648310; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LOtLgRKGQX67ieoH/CsjydrcIz7BO5T8N0kmB5YnlVI=; b=neSimnir/3RXfStkL/tpSdmh8aj/P1j4nx4Nwvy+n1yjm2lGQXhqcB+J6bnsUYCBmt +CtD8UvAQcpAuOWrkinFGak7nCKx+y9fL+DvtGZlSDsiSlBUn8NVfzZwPEVrH8O43kMl IjndaH/Vq3LTDin/4e2Pmb+02aYSmnzS9Qb109PrAEYhEXt78Gr3cZDrGLdeoa9+r+9e QEmNzwVyydmwemV68pWJj0dmmf+wppucikEnGK1IcSor6DCV2pwIUJp8WOcVowsX7FKg rclkrDt7u/eLJC1yTt7tahdeInELiLXWIT9JTQ6A5Iibfr80LnjUSPAMF9qKFDCRABFR XNKA== X-Forwarded-Encrypted: i=1; AJvYcCWfa2KbJ6Y2PONsjMELRwlHAeVvAtEjgaLSssGdL6pq5IzhxwAgNZ3Lo3fUwo2cAxMRHe78FuAwqwvbtYtwnQx/KqopAHxD3IPJZ75IhhFwo73zpqc= X-Gm-Message-State: AOJu0Yz/8WAcC2blpCm/p9DqWoq+R6YWVdKvxmK73trzaManl78CUeHd TaV63tP7gn2uAxruFz19ySx+Hu88ho4vCHtmStjJ3wFTEZ22KmSV94FfeA== X-Google-Smtp-Source: AGHT+IG7z/IgqBi5/Yx/2Hbbxy5OTXuTpDW4aR1o4zjIypuyxKSQLBYOYO5MbFoTrw1EKbtLekzQNw== X-Received: by 2002:a17:902:c408:b0:1fa:fbe1:284e with SMTP id d9443c01a7336-20203c084f2mr85137675ad.0.1724043509348; Sun, 18 Aug 2024 21:58:29 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:28 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 03/14] Input: samsung-keypad - do not combine memory allocation checks Date: Sun, 18 Aug 2024 21:58:00 -0700 Message-ID: <20240819045813.2154642-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215830_695380_525A07A4 X-CRM114-Status: GOOD ( 15.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver uses devm API to allocate resources so there's no reason to do allocations first and then check and release everything at once. Check results immediately after doing allocation of each resource. Signed-off-by: Dmitry Torokhov Reviewed-by: Krzysztof Kozlowski --- drivers/input/keyboard/samsung-keypad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 46c0d0c900f6..2be3bfa87ce1 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -349,8 +349,11 @@ static int samsung_keypad_probe(struct platform_device *pdev) keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad) + keymap_size, GFP_KERNEL); + if (!keypad) + return -ENOMEM; + input_dev = devm_input_allocate_device(&pdev->dev); - if (!keypad || !input_dev) + if (!input_dev) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); From patchwork Mon Aug 19 04:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81517C3DA4A for ; Mon, 19 Aug 2024 05:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ITu37U4/rpe9ZTz2X5NzcdA46rL5xwCcVFnyhFY3V3s=; b=Q/Q/rzIrI3HUZxDi+W9xWEiKJj QG0jzR+dodqmzBftUV2GWcz4zM79AX9h37rmwtKYtLxZjtP9PysAqOYb/eYDPtP0Kkeqj8noYotsV op5LduTPleT65Sqis9xr8lHXQ73EY3uaVgHQJ4++Osyh31vpBLzUKhwA0g8cp0hLEQXvHRzLxNueA NVvR5CuVsnnzZuv7bGmbmvmxijc6rDrkbhDboQ3HIkNpqBPn+/MrTibl7QibZZxujFRfYHvPQe+nF MkvEAyFwvq/XJa8eDsa5CfN+9kh85CQHW18Khb+lL7eG7ZUmxeJLlxbZtptJHAsahGNYkY8rwB6pt JQYtKNqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuWb-00000000MTJ-47uv; Mon, 19 Aug 2024 05:01:49 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTP-00000000LWv-2eeJ for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:32 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-201f7fb09f6so23877965ad.2 for ; Sun, 18 Aug 2024 21:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043511; x=1724648311; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ITu37U4/rpe9ZTz2X5NzcdA46rL5xwCcVFnyhFY3V3s=; b=AVboSnIa/lPChQ4PCMDDnX9uJA8jBcrXtYfnfdpoMswMtMu0Iko826wY77k6Fq0fro zedu874IufXoXA3MujAi+dCioW+lnfrHsvMUu91j1HLLvJ/OJjhLDFJnJAiMcmPkWf3f LV3Uzb5fl4pbxxDYClLrli1Zpvk8+W0WSgOqnUr4kUaff6cUPlH9Z63he0PnBm8Mj/v7 Bwnv68L1j153O5jgM3g2LTrbcInMKqcbtWdZY+YaPIkdgBR1ZbCca2sLoZNvZjl86j09 V8u6KmOmKBh96s2nRMoUj6LuYyFlX/Mbh86Pt0EzF5HBi+uDGQT6o1tYAylSYX8guPjI n8EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043511; x=1724648311; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ITu37U4/rpe9ZTz2X5NzcdA46rL5xwCcVFnyhFY3V3s=; b=Be76CSZooSFkpPyxRCEtakq0JinsaZ3H+vevSUCItuUy85zBckbBqF6J56r8R0l5UA lD6qwx/1u3/L17ilh+CFltyIE62sk4g3e22bV50PS58c7yYPJxi8oeAdvnGuetVN/pfO Wi1SPgQRsMmK0JUbaUg7KsdXlA3FVAG7GlJmdlv9xxzIL3zRJxnaoQ3NiL6Zt8AXXVWp KLtoQhq3XCvRp8QIS8ZjrU3jq4hO8pA3XgH5zSvsqnaK41QV7XRH47pkazgFpXVnrJvD E4kbQxiKKezR0zT9wJHh6RXSjSwCvOUpefu9nAdf4F4srbFa4dxN0a26XxP5Dxv989ya Scyg== X-Forwarded-Encrypted: i=1; AJvYcCXvqeAomg3h+9zZ3vasSllOawm2hY7RnHMKFRmwawbzfCHH5UVBkshY8Tzmjz1hrwxtubPqzPOX0srEJpfd5X9N2dro8wOvKxdcAjEb3JxJYS0T6F4= X-Gm-Message-State: AOJu0Ywl7I39VsPQ02iejrzFViyOg6Luoqu9qVyatxety5nKxsJw9nEd vgTsRjkYrjGirIHsQhy33HJ87c6HWoLxNvVTA6vBAL1Lj4WivWZV X-Google-Smtp-Source: AGHT+IGyYm8REzQMteDxukf92aWZeLkKfujBq+Mrydghp3vE1mMv5rcx7DHM0ZE+eHHIzMw7eFWBmw== X-Received: by 2002:a17:903:1d2:b0:202:3107:e769 with SMTP id d9443c01a7336-2023107e9f7mr33840835ad.22.1724043510499; Sun, 18 Aug 2024 21:58:30 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:30 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 04/14] Input: samsung-keypad - use struct_size() helper Date: Sun, 18 Aug 2024 21:58:01 -0700 Message-ID: <20240819045813.2154642-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215831_688946_4380260C X-CRM114-Status: GOOD ( 13.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When allocating memory for the keypad use struct_size() helper to be protected from overflows. Signed-off-by: Dmitry Torokhov Reviewed-by: Krzysztof Kozlowski --- drivers/input/keyboard/samsung-keypad.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 2be3bfa87ce1..7adcd2657bca 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -318,7 +318,6 @@ static int samsung_keypad_probe(struct platform_device *pdev) struct resource *res; struct input_dev *input_dev; unsigned int row_shift; - unsigned int keymap_size; int error; pdata = dev_get_platdata(&pdev->dev); @@ -345,9 +344,10 @@ static int samsung_keypad_probe(struct platform_device *pdev) pdata->cfg_gpio(pdata->rows, pdata->cols); row_shift = get_count_order(pdata->cols); - keymap_size = (pdata->rows << row_shift) * sizeof(keypad->keycodes[0]); - keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad) + keymap_size, + keypad = devm_kzalloc(&pdev->dev, + struct_size(keypad, keycodes, + pdata->rows << row_shift), GFP_KERNEL); if (!keypad) return -ENOMEM; From patchwork Mon Aug 19 04:58:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE5A5C3DA4A for ; Mon, 19 Aug 2024 05:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lNWm/LHzPulP7AbD+r4Ifgq3N7WHw34TpzWbrByhISE=; b=cfcwpouU9uG+jSp4GEPwb+sOHW 4o2nmeMYUvblqbNB6y175YK/+SjjRzYm7Bytoo8tMIOyZYTvE7iJ6ANMekSy0rsLyhr1wlCoIhIsJ esd8CL2ZuJrzHtGHxksI/OZv+cfv1QALWq19U8mvUgmarkNSmU3Ry8BCNyX/2PHrrUz0hfFmJ9zF4 dncV2sWo/GhrN+/ibJ3Pgb0GRe/DuMKSbw3zw4tdeUI9jKI+sRSPK++rU2xJkiza4BgG6D+rT8Oz9 ihYz7efO5/mP+5/ZzkoH6Fn5nIHhEBvYxC/il3Pg4JF3ta3U+88oFNsXCm1hrG7NSinzDtA8oaVLQ mzPFL2Aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuXG-00000000Mg9-3oev; Mon, 19 Aug 2024 05:02:31 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTQ-00000000LXG-3K95 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:34 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-201fbd0d7c2so22032595ad.0 for ; Sun, 18 Aug 2024 21:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043512; x=1724648312; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lNWm/LHzPulP7AbD+r4Ifgq3N7WHw34TpzWbrByhISE=; b=EGfUFt6bpVrk430mZYjBgAVgdfnrcbQcbRawEia4X9H+bNKah2cSh7li1BF9nWSJJj aoGCUFrKk+bQJVEVrpiPjRAOBBNAqo3IxuOcbmZakmuVbV1T5fiW/GGv2J4BW4UchQOP uDU1i+7eIK34chh9uPkP/ysp/HuWsKxg979+Wzo8P9bojhfX5o1nF5TK327VLGfMYz+O 8BUKGipFy3oqblDNW/V1JqAF6Lvf3t5aSQaONETkH9BLdYlH4AgUNFcl3xDcVcIZu/lX 6aFWHohVSt+OqxXnMGr/Q/WAVJepnK/AiKbucxPhbKxlpfmt0VlA5CJdxd3sYPkwhMDg ukIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043512; x=1724648312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lNWm/LHzPulP7AbD+r4Ifgq3N7WHw34TpzWbrByhISE=; b=JriGSs6V3P69pmHWjBg84zmnI8s9ea4A+/Vr1e92v/ppGIIysa0+WYJGOJNCNdG/tI iXNlYz6XgSZzG4OTWWlCvZIU+lsWDhFinCgdCNEAeXPnwtVHBeVtpFKIvSKSB8iPMdNg lQkSRO2AhsBqvOs2Co1fm/uMCRGoPANdhUKh0le0ePsXumFEP2XNfUQYNU7sfeKyc96w QO8WriKeevtSoMd1jp99s6gICR6L6vAHtW38Tcd5IfeKRb/5RXiKMdRwxpL11spQHt3P bkVrZu4KXW6YYsGUKFcldLSnF6J09m5ozpY1T+Xc5IYY/ENoy6jCz3QaEdqxY8+7frjn Rjgw== X-Forwarded-Encrypted: i=1; AJvYcCVQO3qowGrowgIDRA1gGjKTrY9SBWGAJ7ySuySiLJpDghlw40rKchQC0VLo6dWJ4v47CJPpVM2smDYhGeSTdcsM4S2WFP0r5KzBwuGNf3aJT3apV2U= X-Gm-Message-State: AOJu0Yzd63iOezPB49VRu+xO2shXUvjcTFf3pwJTtfp/l5PU13uCbOkv gsmY6kVAeTcXJafrTzJiY+CRO+6CB4Dyd89YUaieLp46w5sUB232 X-Google-Smtp-Source: AGHT+IF+5xTqa6T/wiF74i1cJmY0LmEvr8qfMTP1VOfYfjLyAhlqt4pH3GHhaxtukOfpWaiyJZ9e4A== X-Received: by 2002:a17:903:946:b0:202:232b:2dd8 with SMTP id d9443c01a7336-202232b3046mr32707215ad.55.1724043511647; Sun, 18 Aug 2024 21:58:31 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:31 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 05/14] Input: samsung-keypad - use devm to disable runtime PM Date: Sun, 18 Aug 2024 21:58:02 -0700 Message-ID: <20240819045813.2154642-6-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215832_849663_02E4A486 X-CRM114-Status: GOOD ( 17.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To make sure that runtime PM is disabled at the right time relative to all other devm-managed resources use devm_add_action_or_reset() to register a handler that will disable it. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/samsung-keypad.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 7adcd2657bca..924327de4d8f 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -310,6 +310,13 @@ samsung_keypad_parse_dt(struct device *dev) } #endif +static void samsung_disable_runtime_pm(void *data) +{ + struct samsung_keypad *keypad = data; + + pm_runtime_disable(&keypad->pdev->dev); +} + static int samsung_keypad_probe(struct platform_device *pdev) { const struct samsung_keypad_platdata *pdata; @@ -420,11 +427,16 @@ static int samsung_keypad_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, pdata->wakeup); platform_set_drvdata(pdev, keypad); + pm_runtime_enable(&pdev->dev); + error = devm_add_action_or_reset(&pdev->dev, samsung_disable_runtime_pm, + keypad); + if (error) + return error; error = input_register_device(keypad->input_dev); if (error) - goto err_disable_runtime_pm; + return error; if (pdev->dev.of_node) { devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap); @@ -432,15 +444,6 @@ static int samsung_keypad_probe(struct platform_device *pdev) devm_kfree(&pdev->dev, (void *)pdata); } return 0; - -err_disable_runtime_pm: - pm_runtime_disable(&pdev->dev); - return error; -} - -static void samsung_keypad_remove(struct platform_device *pdev) -{ - pm_runtime_disable(&pdev->dev); } static int samsung_keypad_runtime_suspend(struct device *dev) @@ -575,7 +578,6 @@ MODULE_DEVICE_TABLE(platform, samsung_keypad_driver_ids); static struct platform_driver samsung_keypad_driver = { .probe = samsung_keypad_probe, - .remove_new = samsung_keypad_remove, .driver = { .name = "samsung-keypad", .of_match_table = of_match_ptr(samsung_keypad_dt_match), From patchwork Mon Aug 19 04:58:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E57DC3DA4A for ; Mon, 19 Aug 2024 05:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ygqoPfWAW6OFjzFeMVvvEaUInHc1K7ny5EjqPZNE9l4=; b=vm91UTNoApfzSNzlL4VMyhQMfx ZX17ucwd1DFy5HRWs98pTVK7N8B4tKlx0442shbif1ltQEmpGjeVGwtEJ3AqSWY/SFxtYhezUQVO6 5XszAh8quyWxeEojuZigUGqsgRbh8vWevxIwtZJTTIX8eSNh9toCLMqpGUmdMuFC260zFO0nQ5gfN tP9fk4M7PQmn6c/UqpYLdn131BbbadKuBgEPKFREPAtz5e6nZPXGgB4TbM8eD+Or8/Cu9ni9VyPs/ T3gTQK96NaAlaVz9sgABl7rQR5Q1yPL9uf6sGMlT/VJw8PTyVXK+8bSNhvM/xJa8rmRyJNJs71rUu g6lHmCNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuXt-00000000Mm7-3ny1; Mon, 19 Aug 2024 05:03:10 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTS-00000000LXb-0SCM for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:35 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-7a1c7857a49so2215514a12.1 for ; Sun, 18 Aug 2024 21:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043513; x=1724648313; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ygqoPfWAW6OFjzFeMVvvEaUInHc1K7ny5EjqPZNE9l4=; b=DSW55EGVrVvP+/uJ/NEhQBQpVt5UvWsDiljoE+/PfNWglci9kxADSa83pxVq+3gymt sfCrsgvQWi2pwiUTIG80eqAs3Ft9lzeaLISUCp7yW/O1vGwYpbhzqpgyhkLk1/htFYcL NWOcrFtKc8E7IaawlcQNqFp2BO7Rd06B49SEYGxM3vYlMgExR97T2p3/Leip2iyD1J1D a8GJKaZsX/YnrHctzsb9XpwH4jdEvqCG1cVs6TY7nQhZxbgE9EnBHYzXG07JLX1zTiLR UF2gdfBKvW+iyobIRKwC1VYcvpDuKhvcnxJXL3TlX68s178sigfeJu9fT0VJIAFJdcv6 NQJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043513; x=1724648313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ygqoPfWAW6OFjzFeMVvvEaUInHc1K7ny5EjqPZNE9l4=; b=Z/p8cGR/vzQd+EYr4M/v0wSxxNq6SoZzNCAnBAeKjb4rQIl1MjWj6dMCWqDLQ1v9rY jeZtvVY0k3i4im1JMzuq/AYT82s8Sr0/mEeQM3Ay6L/MsQKAjwk+YCTXdYhU5b8Qmq8t XCE9hJiaTxhhYvtdBfMXCzEH60Q6E5NRKB+B/Ij/SzEbxS6YGEYw+6dMt5a4RYFoKCWV jeZoqR3gEYDFisaEqvhxKJ9mbrs3Nhz/RsPXcIsVa3yKK0O5hK+vWtmaUXD+T6uDsBQU w+OShMfrcDVQjO7XWbg2su1tg/atsYf8FkKbBqiWkh/aIPgd1a9uk01eDiPyHr3gzqU+ b64g== X-Forwarded-Encrypted: i=1; AJvYcCXADInQbbUFAi6w9u3pQNb4WaCwH/kWun+GCDvVH17deHCfsu8xQ38rpMQifoK0UNqCfD2EbdzBZi5wLf87r27d+R3+62OAVdTlvomGV3nwNSHBLsM= X-Gm-Message-State: AOJu0YzRQMkWMZPK7u2FexYQ68IUWcLquSr7x2eXQOFU4pl8BSnsKCYy oiEXFa3yH1yiva3cFu+/JlnQ48ZqrJKwxA11XaDYIbOlLmbAntTB X-Google-Smtp-Source: AGHT+IFeaM8qHan63qZff53j+wzJZr72I4+OcPJOuBS6lMPEx82cmFqJMPlxZb5d4552hWK/VzOVjw== X-Received: by 2002:a05:6a20:bf24:b0:1ca:6b6e:9aaa with SMTP id adf61e73a8af0-1ca6b6e9b33mr5884996637.2.1724043512829; Sun, 18 Aug 2024 21:58:32 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:32 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 06/14] Input: samsung-keypad - use guard notation to acquire mutex Date: Sun, 18 Aug 2024 21:58:03 -0700 Message-ID: <20240819045813.2154642-7-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215834_177275_AB3A0519 X-CRM114-Status: GOOD ( 12.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Guard notation is more compact and ensures that the mutex will be released when control leaves the function. Signed-off-by: Dmitry Torokhov Reviewed-by: Krzysztof Kozlowski --- drivers/input/keyboard/samsung-keypad.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 924327de4d8f..71f5b85b02bd 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -519,15 +519,13 @@ static int samsung_keypad_suspend(struct device *dev) struct samsung_keypad *keypad = platform_get_drvdata(pdev); struct input_dev *input_dev = keypad->input_dev; - mutex_lock(&input_dev->mutex); + guard(mutex)(&input_dev->mutex); if (input_device_enabled(input_dev)) samsung_keypad_stop(keypad); samsung_keypad_toggle_wakeup(keypad, true); - mutex_unlock(&input_dev->mutex); - return 0; } @@ -537,15 +535,13 @@ static int samsung_keypad_resume(struct device *dev) struct samsung_keypad *keypad = platform_get_drvdata(pdev); struct input_dev *input_dev = keypad->input_dev; - mutex_lock(&input_dev->mutex); + guard(mutex)(&input_dev->mutex); samsung_keypad_toggle_wakeup(keypad, false); if (input_device_enabled(input_dev)) samsung_keypad_start(keypad); - mutex_unlock(&input_dev->mutex); - return 0; } From patchwork Mon Aug 19 04:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 635EEC52D7C for ; Mon, 19 Aug 2024 05:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GbiMwPq3Y/nPoKn5NoCTFyPZoEyShBkGNc/6+CRLeBY=; b=joqolLmDMCdYTyU5ZjseYvcYMx ht7LeLkb4aegb/Oy/0IvZvWrloIIEQWLIub3aWiCngrjYJ13ojIuUWYd5sQ/TFHVEjvASNlO7n/9x 3A/Id2uqDVVXPWMG120y0NnRHAaKQkZtb9g1Vh1CxcCCiQwhpqi9iiH9fEPImg1KwJg+kebMhTFHC uXCTKDQoipsvTkPZg7nmb3as86wK5EFiUA9xkrbA5wz+FLA8XlCwxfoFYowaSxc4uClunRgP+DGN7 Uvd9mNJkGHk20jCAed48OXEb0j+Z2EIP/n4G/8D/VwbjhbUv81u4c5AlAY8+9umz1LqxBSpPD6Qy/ GwPrRwZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuYW-00000000Mu6-3awJ; Mon, 19 Aug 2024 05:03:48 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTS-00000000LXw-37bl for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:36 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-6e7b121be30so2565094a12.1 for ; Sun, 18 Aug 2024 21:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043514; x=1724648314; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GbiMwPq3Y/nPoKn5NoCTFyPZoEyShBkGNc/6+CRLeBY=; b=FOAwheCOeZg0AhOh0g6s/tu2RU5suWecimiEbd2fdHFKcZ6oraJ9HVfDH1MxqhFljO ++2ieR4ZSa8Uru5MzxrPdYjwta+fxvDscXTwyg28hy+eEM5VQ1Z6BcZsDt3sWGlAf35C AySgyRqX6x6edOqtTHS0v4EfxgvU83yO69mcciaRLCpTo1PZH4dCtatPhl1Rpx2TWzDI yideKC4LMMnd4fRfTUKk79JJ6VdEFXBAbHUUmlTQ8NzYu3coyi1LfVQpaZWLxeBEkKau YIg21erdhOUT1kbTIaeTtyyermGgxPXIrC9ojUiX6y+OTo4/1N65DjZIUDIWufjTsyYQ YOMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043514; x=1724648314; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GbiMwPq3Y/nPoKn5NoCTFyPZoEyShBkGNc/6+CRLeBY=; b=hWEPYqojAnt2J3QNUbO/Ao78fbe9iEqGt7mhdsQpK2lTkrpeEseKawnW11nAz3QQLf ntoIzi+PnSPxmoz5OTMvd7XlcrCbmbrqAqQYGND7T+JI4BKMXQfKOhczz9706ZG40jfI 4crpk1DIIQSKW3O6HZDcZLL1JZhKuHhlisgByoaSG+6vGeKLRJyvBXpX3BeGQTiYuY8g rftpk6iwDnnKpImZLAIVMPDlfAei32OQA4avUP9ct7kF4ZwJIidgVsQHIh6izluA81Pr axpjCeJxsFGsxOEMZvdaipBg+gBMtsarSKKwTfEQISMqaQd6Lob/dKJw6gXM9rWxKoMy mNUA== X-Forwarded-Encrypted: i=1; AJvYcCWq4hwTckKsds12eTx3pSQ/Pg3BWlof2e0w3mBfZSlDE3dLSxGKgbtCyXsB98DxJ23ZT1qHEWoFNq4zIjCeLjrxZP1ZziblS0wjefxQTF0KBQBx5Fk= X-Gm-Message-State: AOJu0YwG0MoM0usA5QGsxhs9ahAgOl7tVJ26wyopL6HkxDUVEpCII+Ij pboVCoR0NEdULcaHns4AdANPfr8oPpSI9HfvQa/tKulDlhH9p/Mf X-Google-Smtp-Source: AGHT+IFp6g7gj1q9g/hAQPH/hWIvrIWdD8isSKVV2meWPkpCAa22AHAmY/T8N9X055w0cjPiBY+Frw== X-Received: by 2002:a05:6a20:2d29:b0:1c6:ac08:8dd2 with SMTP id adf61e73a8af0-1c904f913aemr10517941637.15.1724043513929; Sun, 18 Aug 2024 21:58:33 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:33 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 07/14] Input: samsung-keypad - use per-chip parameters Date: Sun, 18 Aug 2024 21:58:04 -0700 Message-ID: <20240819045813.2154642-8-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215834_803707_0192664F X-CRM114-Status: GOOD ( 19.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of doing conditional logic based on the chip type, define per-chip parameter structure, and reference it in the match data (either of_device_id or platform_device_id). Signed-off-by: Dmitry Torokhov Reviewed-by: Krzysztof Kozlowski --- drivers/input/keyboard/samsung-keypad.c | 61 +++++++++++++++---------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 71f5b85b02bd..ccc1186e43b6 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -44,8 +44,7 @@ #define S5PV210_KEYIFSTSCLR_R_INT_OFFSET 16 /* SAMSUNG_KEYIFCOL */ -#define SAMSUNG_KEYIFCOL_MASK (0xff << 0) -#define S5PV210_KEYIFCOLEN_MASK (0xff << 8) +#define SAMSUNG_KEYIFCOL_MASK 0xff /* SAMSUNG_KEYIFROW */ #define SAMSUNG_KEYIFROW_MASK (0xff << 0) @@ -54,12 +53,12 @@ /* SAMSUNG_KEYIFFC */ #define SAMSUNG_KEYIFFC_MASK (0x3ff << 0) -enum samsung_keypad_type { - KEYPAD_TYPE_SAMSUNG, - KEYPAD_TYPE_S5PV210, +struct samsung_chip_info { + unsigned int column_shift; }; struct samsung_keypad { + const struct samsung_chip_info *chip; struct input_dev *input_dev; struct platform_device *pdev; struct clk *clk; @@ -68,7 +67,6 @@ struct samsung_keypad { bool stopped; bool wake_enabled; int irq; - enum samsung_keypad_type type; unsigned int row_shift; unsigned int rows; unsigned int cols; @@ -83,13 +81,8 @@ static void samsung_keypad_scan(struct samsung_keypad *keypad, unsigned int val; for (col = 0; col < keypad->cols; col++) { - if (keypad->type == KEYPAD_TYPE_S5PV210) { - val = S5PV210_KEYIFCOLEN_MASK; - val &= ~(1 << col) << 8; - } else { - val = SAMSUNG_KEYIFCOL_MASK; - val &= ~(1 << col); - } + val = SAMSUNG_KEYIFCOL_MASK & ~(1 << col); + val <<= keypad->chip->column_shift; writel(val, keypad->base + SAMSUNG_KEYIFCOL); mdelay(1); @@ -321,6 +314,7 @@ static int samsung_keypad_probe(struct platform_device *pdev) { const struct samsung_keypad_platdata *pdata; const struct matrix_keymap_data *keymap_data; + const struct platform_device_id *id; struct samsung_keypad *keypad; struct resource *res; struct input_dev *input_dev; @@ -385,11 +379,17 @@ static int samsung_keypad_probe(struct platform_device *pdev) keypad->stopped = true; init_waitqueue_head(&keypad->wait); - if (pdev->dev.of_node) - keypad->type = of_device_is_compatible(pdev->dev.of_node, - "samsung,s5pv210-keypad"); - else - keypad->type = platform_get_device_id(pdev)->driver_data; + keypad->chip = device_get_match_data(&pdev->dev); + if (!keypad->chip) { + id = platform_get_device_id(pdev); + if (id) + keypad->chip = (const void *)id->driver_data; + } + + if (!keypad->chip) { + dev_err(&pdev->dev, "Unable to determine chip type"); + return -EINVAL; + } input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; @@ -551,11 +551,24 @@ static const struct dev_pm_ops samsung_keypad_pm_ops = { samsung_keypad_runtime_resume, NULL) }; +static const struct samsung_chip_info samsung_s3c6410_chip_info = { + .column_shift = 0, +}; + +static const struct samsung_chip_info samsung_s5pv210_chip_info = { + .column_shift = 8, +}; + #ifdef CONFIG_OF static const struct of_device_id samsung_keypad_dt_match[] = { - { .compatible = "samsung,s3c6410-keypad" }, - { .compatible = "samsung,s5pv210-keypad" }, - {}, + { + .compatible = "samsung,s3c6410-keypad", + .data = &samsung_s3c6410_chip_info, + }, { + .compatible = "samsung,s5pv210-keypad", + .data = &samsung_s5pv210_chip_info, + }, + { } }; MODULE_DEVICE_TABLE(of, samsung_keypad_dt_match); #endif @@ -563,12 +576,12 @@ MODULE_DEVICE_TABLE(of, samsung_keypad_dt_match); static const struct platform_device_id samsung_keypad_driver_ids[] = { { .name = "samsung-keypad", - .driver_data = KEYPAD_TYPE_SAMSUNG, + .driver_data = (kernel_ulong_t)&samsung_s3c6410_chip_info, }, { .name = "s5pv210-keypad", - .driver_data = KEYPAD_TYPE_S5PV210, + .driver_data = (kernel_ulong_t)&samsung_s5pv210_chip_info, }, - { }, + { } }; MODULE_DEVICE_TABLE(platform, samsung_keypad_driver_ids); From patchwork Mon Aug 19 04:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F6AAC3DA4A for ; Mon, 19 Aug 2024 05:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YN/1Xk9FI8/pPGNyqXKAqL6DAUxzZAXBVprXsawgfYo=; b=kqEduRfYFGBAAKRhWwKbjR3uUa tm1vkBiv/bbJw3OUQb8yONoUIethP/eEkgml9Z0Obz/Y5ykQQ90INrgY6y0x+DRBSTZ9vqzCMAXzR 5fqMfDkDsjVc6UNfIeaLDU5NH/K6I8joadA2ITpcV69OsdevqJQ6Tu0FeZIPGGkN0oNqm1ybhnjJA cYHHu8zC2dz/Dz5xfdujESXtC8qCfQ5x7dSEtkfzbD63ojYiNEoETncJfRk2Wi4G0K8W1tUMOwYUF +ixQV/Cbbrr3YErLcdVzjaRCVd0h6VkllZ8LTVzetIo4Bhhgeked7EnQtEYl1Dksd6baU6YHoAUan o2Sw5ftA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuZA-00000000N1D-00Bn; Mon, 19 Aug 2024 05:04:28 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTU-00000000LYj-2z6k for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:38 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-7c691c8f8dcso2544627a12.1 for ; Sun, 18 Aug 2024 21:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043516; x=1724648316; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YN/1Xk9FI8/pPGNyqXKAqL6DAUxzZAXBVprXsawgfYo=; b=g5cj6T1dMjwLsd07h7PwAoeuoW13MokvVs3RYMwJzZ6MkNZeAlFW87XrrYiv/wZtMi OKagHmoPb6jSaIuzJDvHG1c9fOUREOjWfvvl+lTHFtPm3PE+MZAP5hWcjdsC3vuc3P0B QTHRo2KoA/QE4Xkm7QQgxi28MUEbumLeDuNBUSgaCNG/K55WR6OntwEgDGhsjMfLqjiM Gek5YcIq4nneNzy2RvqUuSocOk10yxDSRZbmqNxIvrwL0sYg6Pww7hF+1Gk99LxxRO0N bXWeaWGae39Ozo035UtZDwmcqslkOyeSQEnsVJ/ZEoxvm9qzgAYwHsUckM0QD3ThsGCb dTnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043516; x=1724648316; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YN/1Xk9FI8/pPGNyqXKAqL6DAUxzZAXBVprXsawgfYo=; b=NBSy+EtzgPC0qqs++U7CB6l9DSaoWnPrrqMjgDkfkmLNUXZy/8nAol9v8Bx/nFE3gN jA4WubQ8KCB74SGkv28zC5qS3/hC6iYQns5wMRkUJcGv1SYpoSm0XmqHZMPEi5AEkzr8 Bdgvgmt7igBskcoe+MXdiScHip66EnWzXxDRdsnt9qpzIIhSZT+PGn5ny6HDqje9aYe3 WS1Ooi1HkLymPhVlnZRvGT54RvyW3hrLm8ZwCD7X9su/9wM43xdf+6i1ipMWXrf5CTVG +v7iPRth0M/xh744qa2l5zs1P5etqOSlf8bJN59tTk3weD8heVx9V6i1RCM+OsR7xEnh dUxg== X-Forwarded-Encrypted: i=1; AJvYcCUfVDCXA3zQ2T+1pxCzG0cS8lEnh08LOpe69IxqPmo46QhDHo+R/7OEKDAN3uf1g/M68lP2ORHyIrr1enWdDB07@lists.infradead.org X-Gm-Message-State: AOJu0YwL3iGzz6AoX+rIHgUbn73F6MrH1wubo4EXvwNp3tt2OJx2ihX7 JC37ur0gDw3AFlcjXo4uMehVTIiAPEhUVFrZUWjqqIcQm1YyAiv4 X-Google-Smtp-Source: AGHT+IHR03pBCS1HkPAq1A4u2Bf9+fNk6P6rh0uFVCEmo/wkeYC6u4wMHRida67w/ccHn9mU0XZ+eQ== X-Received: by 2002:a05:6a20:ce4a:b0:1c3:b2b3:442d with SMTP id adf61e73a8af0-1c90502616dmr10682336637.40.1724043515380; Sun, 18 Aug 2024 21:58:35 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:34 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 08/14] Input: samsung-keypad - use BIT() and GENMASK() where appropriate Date: Sun, 18 Aug 2024 21:58:05 -0700 Message-ID: <20240819045813.2154642-9-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215836_781825_0EADFADE X-CRM114-Status: GOOD ( 13.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of using (1 << ) construct use BIT() helper. Convert (1 << ) - 1 to GENMASK(). Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/samsung-keypad.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index ccc1186e43b6..e262137b6838 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -7,6 +7,7 @@ * Author: Donghwa Lee */ +#include #include #include #include @@ -29,11 +30,11 @@ #define SAMSUNG_KEYIFFC 0x10 /* SAMSUNG_KEYIFCON */ -#define SAMSUNG_KEYIFCON_INT_F_EN (1 << 0) -#define SAMSUNG_KEYIFCON_INT_R_EN (1 << 1) -#define SAMSUNG_KEYIFCON_DF_EN (1 << 2) -#define SAMSUNG_KEYIFCON_FC_EN (1 << 3) -#define SAMSUNG_KEYIFCON_WAKEUPEN (1 << 4) +#define SAMSUNG_KEYIFCON_INT_F_EN BIT(0) +#define SAMSUNG_KEYIFCON_INT_R_EN BIT(1) +#define SAMSUNG_KEYIFCON_DF_EN BIT(2) +#define SAMSUNG_KEYIFCON_FC_EN BIT(3) +#define SAMSUNG_KEYIFCON_WAKEUPEN BIT(4) /* SAMSUNG_KEYIFSTSCLR */ #define SAMSUNG_KEYIFSTSCLR_P_INT_MASK (0xff << 0) @@ -81,14 +82,14 @@ static void samsung_keypad_scan(struct samsung_keypad *keypad, unsigned int val; for (col = 0; col < keypad->cols; col++) { - val = SAMSUNG_KEYIFCOL_MASK & ~(1 << col); + val = SAMSUNG_KEYIFCOL_MASK & ~BIT(col); val <<= keypad->chip->column_shift; writel(val, keypad->base + SAMSUNG_KEYIFCOL); mdelay(1); val = readl(keypad->base + SAMSUNG_KEYIFROW); - row_state[col] = ~val & ((1 << keypad->rows) - 1); + row_state[col] = ~val & GENMASK(keypad->rows - 1, 0); } /* KEYIFCOL reg clear */ @@ -112,10 +113,10 @@ static bool samsung_keypad_report(struct samsung_keypad *keypad, continue; for (row = 0; row < keypad->rows; row++) { - if (!(changed & (1 << row))) + if (!(changed & BIT(row))) continue; - pressed = row_state[col] & (1 << row); + pressed = row_state[col] & BIT(row); dev_dbg(&keypad->input_dev->dev, "key %s, row: %d, col: %d\n", From patchwork Mon Aug 19 04:58:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F33FAC3DA4A for ; Mon, 19 Aug 2024 05:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2rL9e50K+KTD0iWv/ZJJXKGxKFtaByRAx8vVdC/BQNE=; b=iKMe2FFGqdHwidlc8fc0Vner6Q /GvT0gPGn8wRIsax5NmIsiz0DWLbuoHfdqSY+xGvzHFBmAgR7b7Bt5KuqayMvycZm9yPlIHWpXpEz eUOp8LdhOwAPAo7NvnanEOyL3XEyPbfV5q8RqbR7SCpXhzulNkQixS9ZY7hA8C5HFtX0KVii/c5m4 tiNCLvx3+5IsHcSZlKl+kAj2/MD0DtQ2TkJscZ++uAeA1lM86MwHKtmIKmk0h6kcAL+IZWtLKPry+ OiPAZsXFAIq2F8SjaeSNFZK8OJYziyhGGZvsh9C2Yya5jiQwNqh7pARgmbxHJjqzMt/FANDAtZh5t VAxjStHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuZn-00000000NBk-2EBm; Mon, 19 Aug 2024 05:05:07 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTV-00000000LZ8-1WIw for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:38 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-201df0b2df4so30677865ad.0 for ; Sun, 18 Aug 2024 21:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043517; x=1724648317; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2rL9e50K+KTD0iWv/ZJJXKGxKFtaByRAx8vVdC/BQNE=; b=MUSiHwO3G1NQO8Thmt5LuV9lvxsK7nUQW9rBVwkiFcbVPEtMU5y+d+Al/dKgeOxUAi yiVkC/xwVxv9YLtAUMjTzVPGQAZJqH/0d/zK1EYnzLAlMZi5gpjxiLTd+hRPTx8lHYjR hhoLwGe48F8xob6R8PK2jZhp3OtME6p4OTsyu8QxR6N/fTVutnAfPIp5G7XJbZMem1rz J5pfZxEmgBVevRJSggOXqfNgVRW13Aak/0rDrW1374JAGfc5eYXLdIn+uHB8ODck6I3q HOgyS4llXFcJuWeb0ZAas56NnjbAcU+Fdt4ZmT0hiNP+BRbhvG6Q27KcSJcSjg6VASpB s81w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043517; x=1724648317; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2rL9e50K+KTD0iWv/ZJJXKGxKFtaByRAx8vVdC/BQNE=; b=RI1OrazD/1gq1BuoGppuMPjiaxyQWbKDPkG0eJX3dy8i17g3siJksSFRs8x7sus+GT NBhJf3E8P3mTENRKZi1TCa0TgWucaXnPSgwfPXkljpP2bHvQGHvkidU2TBREmICsh61J 3t859b84nbhsj0YvK2n2FRjeYESsjFwrBFnFgNn9KzQ1YpO+WMMwJMvAXgxNxYAMd6fb ITrnBdgdgr3Z3R2G1OHpjwOzVQetgUbYi4Np2tuCCtNUd5s6sZcDL2Sa3BVUoZ9V6hT+ tSFIvAn1jZlgZjMfk5i699cHrDqG6Szeo1rhYBrrnTLLlBXXxC5y5WQaznbI1OakPoYw rUVA== X-Forwarded-Encrypted: i=1; AJvYcCV5QA9nKNEcGxqrQtyv11N9XT4ZC4JdDdFxc4GxKxc8WkBdNqtPHBMV5CFRLpxGKeQrTQzTN0siv0jKNsPn88N/rpkpaZrfbviw7sKyPnYJ/Qg373A= X-Gm-Message-State: AOJu0YyleeaIr2sk/SNfxO11WqxqH2NiwgWNwk5gaIlFbh0JU8kCalTK DeLY1Blpzf2zuExIUXWTyxsWKL8Dp476kT2SvZT1CRIVqc1AB+0b X-Google-Smtp-Source: AGHT+IHRfw+SZ9RF2mv8HemU9qcOBYNa4aOGEE+5+suKU5vhvp5qcT10dqeZbTjbknB4zaBQdB79yA== X-Received: by 2002:a17:902:f988:b0:201:ff75:fa3a with SMTP id d9443c01a7336-20203ea01c9mr85637105ad.23.1724043516489; Sun, 18 Aug 2024 21:58:36 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:36 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 09/14] dt-bindings: input: samsung,s3c6410-keypad: introduce compact binding Date: Sun, 18 Aug 2024 21:58:06 -0700 Message-ID: <20240819045813.2154642-10-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215837_424894_E0398C0D X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The binding with a sub-node per each key is very verbose and is hard to use with static device properties. Allow standard matrix keymap binding in addition to the verbose one. Signed-off-by: Dmitry Torokhov --- .../input/samsung,s3c6410-keypad.yaml | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/input/samsung,s3c6410-keypad.yaml b/Documentation/devicetree/bindings/input/samsung,s3c6410-keypad.yaml index a53569aa0ee7..28a318a0ff7e 100644 --- a/Documentation/devicetree/bindings/input/samsung,s3c6410-keypad.yaml +++ b/Documentation/devicetree/bindings/input/samsung,s3c6410-keypad.yaml @@ -16,6 +16,10 @@ description: maintainers: - Krzysztof Kozlowski +allOf: + - $ref: input.yaml# + - $ref: matrix-keymap.yaml# + properties: compatible: enum: @@ -37,6 +41,10 @@ properties: wakeup-source: true + keypad,num-columns: true + keypad,num-rows: true + linux,keymap: true + linux,input-no-autorepeat: type: boolean description: @@ -81,12 +89,33 @@ patternProperties: - keypad,row - linux,code +dependencies: + linux,keymap: + required: + - keypad,num-columns + - keypad,num-rows + required: - compatible - reg - interrupts - - samsung,keypad-num-columns - - samsung,keypad-num-rows + +if: + required: + - linux,keymap +then: + properties: + samsung,keypad-num-columns: false + samsung,keypad-num-rows: false + patternProperties: + '^key-[0-9a-z]+$': false +else: + properties: + keypad,num-columns: false + keypad,num-rows: false + required: + - samsung,keypad-num-columns + - samsung,keypad-num-rows additionalProperties: false @@ -94,8 +123,9 @@ examples: - | #include #include + #include - keypad@100a0000 { + keypad1@100a0000 { compatible = "samsung,s5pv210-keypad"; reg = <0x100a0000 0x100>; interrupts = ; @@ -119,3 +149,24 @@ examples: linux,code = <3>; }; }; + - | + #include + #include + #include + + keypad2@100a0000 { + compatible = "samsung,s5pv210-keypad"; + reg = <0x100a0000 0x100>; + interrupts = ; + clocks = <&clock CLK_KEYIF>; + clock-names = "keypad"; + + keypad,num-rows = <2>; + keypad,num-columns = <8>; + linux,keymap = < + MATRIX_KEY(0, 3, 2) + MATRIX_KEY(0, 4, 3) + >; + linux,input-no-autorepeat; + wakeup-source; + }; From patchwork Mon Aug 19 04:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767906 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5043C52D7C for ; Mon, 19 Aug 2024 05:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5L9I6imIfpvf63yPfkptA7xMzZO0c5Qjz4Mu6DS54Gw=; b=mqOrQKQ1i9Iq17x01dSwI6july IcP06QXtg/fdvSYRiuqYSQCa1fUqNEKf6jFda3cb7dkcYLlK98eoui3iEPoBxodJ+ISRw0a0nJRnU lSF2mC3H9ADYo7w2qIi2dgTX0LOzRwPo5Al1h1r7HY3/EQYmM1FgQCchVVDb5PDM8Nq+2nsFcz0gj 11pDMJzcIWhJCP5nTM67yzepNDnoCjJLQo7XrpU8Fc+g6KRTNGxFaP8b6ddvXaRRtaiDLq6EZlgaN MhgHxPnWpX8ib/A+uHW+WYRiqMy8AvEZHXkHAJ99Xpx0/9X/pWpgOKbOvdliFZ2Qb5kIPp9itqvOT 8/khKLnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuaQ-00000000NT6-2DkN; Mon, 19 Aug 2024 05:05:46 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTW-00000000LZm-2lKA for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:39 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-7c3d9a5e050so2414498a12.2 for ; Sun, 18 Aug 2024 21:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043518; x=1724648318; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5L9I6imIfpvf63yPfkptA7xMzZO0c5Qjz4Mu6DS54Gw=; b=k85m8KOVT+xbLXlUegJjtVQj9HpzFlrgL7rD8RMBI957kJG3jgSp0nm/63Ql2uornD b4LBD8jAOid40ORiZ3bFv1axj2Zm1HBXFw+v3CJFfhaPVLwwSXn7TgybS7z6gAZwM+T/ QOajMRqHtXovRXL8PfGsJwzIp0t3Wa/gsVSL/StFFSJgmTAJUsBq4bhWt2MipGNS89Nd rDAGWD93Vvi1Jn4F0u1UkEmk9kxL1VzGmKfBxBWCi+3hx75F2rYoEJLZ8Bckvq6kIVAw QSb5kVsGigjnr5EUeH5H9CZ7MfGL0AMBpthTexe+Z5IwPGWEV/V0KYT3abkNJvnFVpqx p8Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043518; x=1724648318; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5L9I6imIfpvf63yPfkptA7xMzZO0c5Qjz4Mu6DS54Gw=; b=btUuN/2I7nHWKubSVAyWZUwuxoVaJC4pAOO6FkBr7NkoIZ/sBjgc/Q5kKYaFnfkO7k QsbSITi4FriPK8W707DusPi3NuIKUIFT3l9YWAonlZGzue0tJ0T0nYX61xWIdY2PYzrE m1FGmT5Tv2/i0mThBVa3KsxB86Jnju8vvk8jwj4ptXiHiW/d2typ2zlNvAs2VNFvnOQ9 VvZaiG7QlZJXoVhnFOe/ZUvVWR7NwgfEZ9RFF7GZyYGHUPdoBtMi/iIGymVWDXuJv1oY TCLnDn9mFHvy7Ke7TgzP5o5vdV2fIzFRtmnryt8OR/kxHyBPIUFOOlfrxBDvx+QCowB9 xg0Q== X-Forwarded-Encrypted: i=1; AJvYcCW6HOkGDoSEERe8C1DesfEYxkqqA7EOw2xNC4U9d9w33HVJuFC2f12Wi6IjIFBCdeAyrifKqNXRQnax22cWJZqbFGMBCZ1vyTC+Ocg7XoxoYswEXro= X-Gm-Message-State: AOJu0YyIMP8x7ugLZ1EQ0y8UG/st9RX16QYYAZ2+vS/6GU165qwSIBGR V9IhxQUpAHzOWGFt7yHQ4DqeEzNt3kN7SE3kPFczrEou6mIrvEwLDl0Wtg== X-Google-Smtp-Source: AGHT+IFOXUP47XrlReJyTvezC1ueWJrGGZqHqPG5DuxuErxhgxqYthREfB9dhnYaAiK/2wzqkmdXDQ== X-Received: by 2002:a05:6a21:8181:b0:1c9:bb89:4d66 with SMTP id adf61e73a8af0-1c9bb894f08mr7201660637.3.1724043517786; Sun, 18 Aug 2024 21:58:37 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:37 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 10/14] Input: samsung-keypad - handle compact binding Date: Sun, 18 Aug 2024 21:58:07 -0700 Message-ID: <20240819045813.2154642-11-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215838_721617_8A4CFBCE X-CRM114-Status: GOOD ( 21.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for standard matrix keymap binding (in addition to the existing verbose binding with a sub-node for each key). This will allow easier conversions from platform data to device properties when using static device properties. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/samsung-keypad.c | 122 +++++++++++++----------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index e262137b6838..df2427ac63d7 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -231,78 +231,85 @@ static void samsung_keypad_close(struct input_dev *input_dev) samsung_keypad_stop(keypad); } -#ifdef CONFIG_OF -static struct samsung_keypad_platdata * -samsung_keypad_parse_dt(struct device *dev) +static const struct matrix_keymap_data * +samsung_parse_verbose_keymap(struct device *dev) { - struct samsung_keypad_platdata *pdata; struct matrix_keymap_data *keymap_data; - uint32_t *keymap, num_rows = 0, num_cols = 0; - struct device_node *np = dev->of_node, *key_np; + struct fwnode_handle *child; + u32 *keymap; unsigned int key_count; - if (!np) { - dev_err(dev, "missing device tree data\n"); - return ERR_PTR(-EINVAL); - } - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) { - dev_err(dev, "could not allocate memory for platform data\n"); - return ERR_PTR(-ENOMEM); - } - - of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows); - of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols); - if (!num_rows || !num_cols) { - dev_err(dev, "number of keypad rows/columns not specified\n"); - return ERR_PTR(-EINVAL); - } - pdata->rows = num_rows; - pdata->cols = num_cols; - keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL); if (!keymap_data) { dev_err(dev, "could not allocate memory for keymap data\n"); return ERR_PTR(-ENOMEM); } - pdata->keymap_data = keymap_data; - key_count = of_get_child_count(np); - keymap_data->keymap_size = key_count; - keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL); + key_count = device_get_child_node_count(dev); + keymap = devm_kcalloc(dev, key_count, sizeof(*keymap), GFP_KERNEL); if (!keymap) { dev_err(dev, "could not allocate memory for keymap\n"); return ERR_PTR(-ENOMEM); } + + keymap_data->keymap_size = key_count; keymap_data->keymap = keymap; - for_each_child_of_node(np, key_np) { + device_for_each_child_node(dev, child) { u32 row, col, key_code; - of_property_read_u32(key_np, "keypad,row", &row); - of_property_read_u32(key_np, "keypad,column", &col); - of_property_read_u32(key_np, "linux,code", &key_code); + + fwnode_property_read_u32(child, "keypad,row", &row); + fwnode_property_read_u32(child, "keypad,column", &col); + fwnode_property_read_u32(child, "linux,code", &key_code); + *keymap++ = KEY(row, col, key_code); } - pdata->no_autorepeat = of_property_read_bool(np, "linux,input-no-autorepeat"); + return keymap_data; +} - pdata->wakeup = of_property_read_bool(np, "wakeup-source") || - /* legacy name */ - of_property_read_bool(np, "linux,input-wakeup"); +static const struct samsung_keypad_platdata * +samsung_keypad_parse_properties(struct device *dev) +{ + const struct matrix_keymap_data *keymap_data; + struct samsung_keypad_platdata *pdata; + u32 num_rows = 0, num_cols = 0; + int error; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(dev, "could not allocate memory for platform data\n"); + return ERR_PTR(-ENOMEM); + } + device_property_read_u32(dev, "samsung,keypad-num-rows", &num_rows); + device_property_read_u32(dev, "samsung,keypad-num-columns", &num_cols); + + error = matrix_keypad_parse_properties(dev, &num_rows, &num_cols); + if (error) + return ERR_PTR(error); + + pdata->rows = num_rows; + pdata->cols = num_cols; + + if (!device_property_present(dev, "linux,keymap")) { + keymap_data = samsung_parse_verbose_keymap(dev); + if (IS_ERR(keymap_data)) + return ERR_CAST(keymap_data); + + pdata->keymap_data = keymap_data; + } - return pdata; -} -#else -static struct samsung_keypad_platdata * -samsung_keypad_parse_dt(struct device *dev) -{ - dev_err(dev, "no platform data defined\n"); - return ERR_PTR(-EINVAL); + pdata->no_autorepeat = + device_property_read_bool(dev, "linux,input-no-autorepeat"); + + pdata->wakeup = device_property_read_bool(dev, "wakeup-source") || + /* legacy name */ + device_property_read_bool(dev, "linux,input-wakeup"); + + return pdata; } -#endif static void samsung_disable_runtime_pm(void *data) { @@ -314,7 +321,6 @@ static void samsung_disable_runtime_pm(void *data) static int samsung_keypad_probe(struct platform_device *pdev) { const struct samsung_keypad_platdata *pdata; - const struct matrix_keymap_data *keymap_data; const struct platform_device_id *id; struct samsung_keypad *keypad; struct resource *res; @@ -323,18 +329,17 @@ static int samsung_keypad_probe(struct platform_device *pdev) int error; pdata = dev_get_platdata(&pdev->dev); - if (!pdata) { - pdata = samsung_keypad_parse_dt(&pdev->dev); + if (pdata) { + if (!pdata->keymap_data) { + dev_err(&pdev->dev, "no keymap data defined\n"); + return -EINVAL; + } + } else { + pdata = samsung_keypad_parse_properties(&pdev->dev); if (IS_ERR(pdata)) return PTR_ERR(pdata); } - keymap_data = pdata->keymap_data; - if (!keymap_data) { - dev_err(&pdev->dev, "no keymap data defined\n"); - return -EINVAL; - } - if (!pdata->rows || pdata->rows > SAMSUNG_MAX_ROWS) return -EINVAL; @@ -398,7 +403,7 @@ static int samsung_keypad_probe(struct platform_device *pdev) input_dev->open = samsung_keypad_open; input_dev->close = samsung_keypad_close; - error = matrix_keypad_build_keymap(keymap_data, NULL, + error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, pdata->rows, pdata->cols, keypad->keycodes, input_dev); if (error) { @@ -439,11 +444,12 @@ static int samsung_keypad_probe(struct platform_device *pdev) if (error) return error; - if (pdev->dev.of_node) { + if (!dev_get_platdata(&pdev->dev)) { devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap); devm_kfree(&pdev->dev, (void *)pdata->keymap_data); devm_kfree(&pdev->dev, (void *)pdata); } + return 0; } From patchwork Mon Aug 19 04:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36C5AC52D7C for ; Mon, 19 Aug 2024 05:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=t5aFFwx+23c+SuWLKFR8CIgT2nsj1neFDbQ+3clMGIs=; b=KoCVqHXZ+mMrzoKxZJFaOaidNL LaNotjqBmJtD0xBvi+6buoKmyV0J+0YPy0QuBZdjUjQ/7g5knQa+t2XdWjxwlLJA/K+ZBBmniUKLO io6aL3Jkm13/ylgDT72up9AJs3WDVv4/VVbCXV3prWPGjpyi3wDoV+uk5nrzFDmZhqKaBORQKc7/3 uHQES1N69kLhg9cVyt83NO2CkUjVJnGLgjsttef1nep4cmFeFhTXomxYnPRacknPfurwUhfW6txus HmNmxknOHICkzZIYivlw4Rr1BwpqkrMQXMVwcHTbzPwLgLJMEgpKRE9M34fjNcpLMyjtNDxXl2w+t 3FKglkaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfub3-00000000Nay-0tw7; Mon, 19 Aug 2024 05:06:25 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTY-00000000LaB-0Z0q for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:42 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-76cb5b6b3e4so2643667a12.1 for ; Sun, 18 Aug 2024 21:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043519; x=1724648319; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t5aFFwx+23c+SuWLKFR8CIgT2nsj1neFDbQ+3clMGIs=; b=L5dBDljWwv5VB5xf+qB8v8UqpRGzWaPLwztdtJgcOxhPZLOyoi6wWKwxtR76WyKQQS UjLpOwFFpcR+T48i0s6/axpWD6tYJXKnrNilR88OFA2S/dhqoj71KaGZdwixGDVqqwaG B7hA23L2sreElAgBih+osGioDpOrg6kdAHL57nKu109jI0JAklXh5LPaWetRF3FnRsSj PuMNmJebk39/gJt3qpN2tXXzht9R0jm3JcYQsFYJifpcRYL9XaIRC/Xc7L8jb20Sv0g4 O832fkNCWKlfkyeN0KSoI9hC/9adrcMKexKjFxAZt/dNoRzHbcWEfFGIFBjQ1RyTBZDj YvSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043519; x=1724648319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t5aFFwx+23c+SuWLKFR8CIgT2nsj1neFDbQ+3clMGIs=; b=JEcwtfdjxiyoqIjyqqtcfYr6/ASBj/WbWGBLCe6O4IRoQhtsbJX5U7blIMde6umD24 ZKIgY5O7LRBU5D20jZ7Cw577M9O8HhT3wiuXQI4NElMnO3GP1gOXrHSR5Nr3Mm1uTeUc U/ercUQxFQ2R1U5uIojak74JqFUCBlAcwh29K8kCNz3QbDzDOj4msIt0LEwh1hNRJyx7 OTq0bMbp0kGxe/p3DMP4U+x/8vgp6lzzzF3y4d0YnwoZziCmM+LYtJ/2qpHNg/tfvCCq xaiXGkHLD/WyBovsfs+xPW3kdXOrlKl1wfI0nVrh1laremNdQgue9QDJkd7D4xU5YZfs cCYA== X-Forwarded-Encrypted: i=1; AJvYcCUnukbli3cUwYKsayuHJ7i+ctS3/DbL9CPV2ZRJemDCsWqo28FeFv0MtRkrANERTq3XkEfWSx5eZSXyxCbzucMI@lists.infradead.org X-Gm-Message-State: AOJu0YwkAJ+2pzWVJk8ZcpqM18vzJADFsx9s9DcjgoW046rs0mX6CwW3 CSxHimURR8fWRbYUGXHY3Y/fdASOpkt4PFNIDqqxXyoTP8MJKodv X-Google-Smtp-Source: AGHT+IF6+c/SUIcS1ZDv+kTMg0oMY4h55VBLJNBOlG+3D942PdoJjASXKzlhOZtFhmJ1ew44Ehhw0Q== X-Received: by 2002:a05:6a21:9214:b0:1c4:21c0:ea0f with SMTP id adf61e73a8af0-1c905028143mr9543505637.33.1724043518915; Sun, 18 Aug 2024 21:58:38 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:38 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 11/14] ARM: s3c: crag6410: switch keypad device to software properties Date: Sun, 18 Aug 2024 21:58:08 -0700 Message-ID: <20240819045813.2154642-12-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215840_211084_C7177031 X-CRM114-Status: GOOD ( 26.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch the keypad device to use software properties to describe the keypad. This will allow dropping support for platform data from the samsung-keypad driver. Signed-off-by: Dmitry Torokhov Acked-by: Krzysztof Kozlowski --- arch/arm/mach-s3c/Kconfig | 5 --- arch/arm/mach-s3c/Kconfig.s3c64xx | 1 - arch/arm/mach-s3c/Makefile.s3c64xx | 1 - arch/arm/mach-s3c/devs.c | 27 ------------ arch/arm/mach-s3c/devs.h | 1 - arch/arm/mach-s3c/keypad.h | 27 ------------ arch/arm/mach-s3c/mach-crag6410.c | 56 ++++++++++++++++++------ arch/arm/mach-s3c/setup-keypad-s3c64xx.c | 20 --------- 8 files changed, 42 insertions(+), 96 deletions(-) delete mode 100644 arch/arm/mach-s3c/keypad.h delete mode 100644 arch/arm/mach-s3c/setup-keypad-s3c64xx.c diff --git a/arch/arm/mach-s3c/Kconfig b/arch/arm/mach-s3c/Kconfig index b3656109f1f7..2e77bb4f3a8c 100644 --- a/arch/arm/mach-s3c/Kconfig +++ b/arch/arm/mach-s3c/Kconfig @@ -111,11 +111,6 @@ config S3C64XX_DEV_SPI0 Compile in platform device definitions for S3C64XX's type SPI controller 0 -config SAMSUNG_DEV_KEYPAD - bool - help - Compile in platform device definitions for keypad - config SAMSUNG_DEV_PWM bool help diff --git a/arch/arm/mach-s3c/Kconfig.s3c64xx b/arch/arm/mach-s3c/Kconfig.s3c64xx index 8f40af063ad6..cc1257fbf642 100644 --- a/arch/arm/mach-s3c/Kconfig.s3c64xx +++ b/arch/arm/mach-s3c/Kconfig.s3c64xx @@ -116,7 +116,6 @@ config MACH_WLF_CRAGG_6410 select S3C_DEV_I2C1 select S3C_DEV_USB_HOST select S3C_DEV_USB_HSOTG - select SAMSUNG_DEV_KEYPAD select SAMSUNG_DEV_PWM help Machine support for the Wolfson Cragganmore S3C6410 variant. diff --git a/arch/arm/mach-s3c/Makefile.s3c64xx b/arch/arm/mach-s3c/Makefile.s3c64xx index 61287ad2ea42..1686b1f344f8 100644 --- a/arch/arm/mach-s3c/Makefile.s3c64xx +++ b/arch/arm/mach-s3c/Makefile.s3c64xx @@ -32,7 +32,6 @@ obj-y += dev-audio-s3c64xx.o obj-$(CONFIG_S3C64XX_SETUP_FB_24BPP) += setup-fb-24bpp-s3c64xx.o obj-$(CONFIG_S3C64XX_SETUP_I2C0) += setup-i2c0-s3c64xx.o obj-$(CONFIG_S3C64XX_SETUP_I2C1) += setup-i2c1-s3c64xx.o -obj-$(CONFIG_S3C64XX_SETUP_KEYPAD) += setup-keypad-s3c64xx.o obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio-s3c64xx.o obj-$(CONFIG_S3C64XX_SETUP_SPI) += setup-spi-s3c64xx.o obj-$(CONFIG_S3C64XX_SETUP_USB_PHY) += setup-usb-phy-s3c64xx.o diff --git a/arch/arm/mach-s3c/devs.c b/arch/arm/mach-s3c/devs.c index 8c26d592d2a3..31827cfc5700 100644 --- a/arch/arm/mach-s3c/devs.c +++ b/arch/arm/mach-s3c/devs.c @@ -40,7 +40,6 @@ #include "devs.h" #include "fb.h" #include -#include "keypad.h" #include "pwm-core.h" #include "sdhci.h" #include "usb-phy.h" @@ -266,32 +265,6 @@ void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd) } #endif /* CONFIG_S3C_DEV_I2C1 */ -/* KEYPAD */ - -#ifdef CONFIG_SAMSUNG_DEV_KEYPAD -static struct resource samsung_keypad_resources[] = { - [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD, SZ_32), - [1] = DEFINE_RES_IRQ(IRQ_KEYPAD), -}; - -struct platform_device samsung_device_keypad = { - .name = "samsung-keypad", - .id = -1, - .num_resources = ARRAY_SIZE(samsung_keypad_resources), - .resource = samsung_keypad_resources, -}; - -void __init samsung_keypad_set_platdata(struct samsung_keypad_platdata *pd) -{ - struct samsung_keypad_platdata *npd; - - npd = s3c_set_platdata(pd, sizeof(*npd), &samsung_device_keypad); - - if (!npd->cfg_gpio) - npd->cfg_gpio = samsung_keypad_cfg_gpio; -} -#endif /* CONFIG_SAMSUNG_DEV_KEYPAD */ - /* PWM Timer */ #ifdef CONFIG_SAMSUNG_DEV_PWM diff --git a/arch/arm/mach-s3c/devs.h b/arch/arm/mach-s3c/devs.h index 21c00786c264..2737990063b1 100644 --- a/arch/arm/mach-s3c/devs.h +++ b/arch/arm/mach-s3c/devs.h @@ -39,7 +39,6 @@ extern struct platform_device s3c_device_i2c1; extern struct platform_device s3c_device_ohci; extern struct platform_device s3c_device_usb_hsotg; -extern struct platform_device samsung_device_keypad; extern struct platform_device samsung_device_pwm; /** diff --git a/arch/arm/mach-s3c/keypad.h b/arch/arm/mach-s3c/keypad.h deleted file mode 100644 index 9754b9a29945..000000000000 --- a/arch/arm/mach-s3c/keypad.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Samsung Platform - Keypad platform data definitions - * - * Copyright (C) 2010 Samsung Electronics Co.Ltd - * Author: Joonyoung Shim - */ - -#ifndef __PLAT_SAMSUNG_KEYPAD_H -#define __PLAT_SAMSUNG_KEYPAD_H - -#include - -/** - * samsung_keypad_set_platdata - Set platform data for Samsung Keypad device. - * @pd: Platform data to register to device. - * - * Register the given platform data for use with Samsung Keypad device. - * The call will copy the platform data, so the board definitions can - * make the structure itself __initdata. - */ -extern void samsung_keypad_set_platdata(struct samsung_keypad_platdata *pd); - -/* defined by architecture to configure gpio. */ -extern void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols); - -#endif /* __PLAT_SAMSUNG_KEYPAD_H */ diff --git a/arch/arm/mach-s3c/mach-crag6410.c b/arch/arm/mach-s3c/mach-crag6410.c index e5df2cb51ab2..16b6ef312aaf 100644 --- a/arch/arm/mach-s3c/mach-crag6410.c +++ b/arch/arm/mach-s3c/mach-crag6410.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -53,7 +54,6 @@ #include "gpio-cfg.h" #include -#include "keypad.h" #include "devs.h" #include "cpu.h" #include @@ -176,7 +176,7 @@ static struct s3c_fb_platdata crag6410_lcd_pdata = { /* 2x6 keypad */ -static uint32_t crag6410_keymap[] = { +static const uint32_t crag6410_keymap[] __initconst = { /* KEY(row, col, keycode) */ KEY(0, 0, KEY_VOLUMEUP), KEY(0, 1, KEY_HOME), @@ -192,17 +192,41 @@ static uint32_t crag6410_keymap[] = { KEY(1, 5, KEY_CAMERA), }; -static struct matrix_keymap_data crag6410_keymap_data = { - .keymap = crag6410_keymap, - .keymap_size = ARRAY_SIZE(crag6410_keymap), +static const struct property_entry crag6410_keypad_props[] __initconst = { + PROPERTY_ENTRY_U32("keypad,num-columns", 6), + PROPERTY_ENTRY_U32("keypad,num-rows", 2), + PROPERTY_ENTRY_U32_ARRAY("linux,keymap", crag6410_keymap), + { } }; -static struct samsung_keypad_platdata crag6410_keypad_data = { - .keymap_data = &crag6410_keymap_data, - .rows = 2, - .cols = 6, +static const struct resource crag6410_keypad_resources[] __initconst = { + [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD, SZ_32), + [1] = DEFINE_RES_IRQ(IRQ_KEYPAD), }; +static const struct platform_device_info crag6410_keypad_info __initconst = { + .name = "samsung-keypad", + .id = PLATFORM_DEVID_NONE, + .res = crag6410_keypad_resources, + .num_res = ARRAY_SIZE(crag6410_keypad_resources), + .properties = crag6410_keypad_props, +}; + +static void __init crag6410_setup_keypad(void) +{ + struct platform_device *pd; + + /* Set all the necessary GPK pins to special-function 3: KP_ROW[x] */ + s3c_gpio_cfgrange_nopull(S3C64XX_GPK(8), 2, S3C_GPIO_SFN(3)); + + /* Set all the necessary GPL pins to special-function 3: KP_COL[x] */ + s3c_gpio_cfgrange_nopull(S3C64XX_GPL(0), 6, S3C_GPIO_SFN(3)); + + pd = platform_device_register_full(&crag6410_keypad_info); + if (IS_ERR(pd)) + pr_err("failed to instantiate keypad device"); +} + static struct gpio_keys_button crag6410_gpio_keys[] = { [0] = { .code = KEY_SUSPEND, @@ -358,7 +382,7 @@ static struct platform_device wallvdd_device = { }, }; -static struct platform_device *crag6410_devices[] __initdata = { +static struct platform_device *crag6410_devs0[] __initdata = { &s3c_device_hsmmc0, &s3c_device_hsmmc2, &s3c_device_i2c0, @@ -369,8 +393,10 @@ static struct platform_device *crag6410_devices[] __initdata = { &samsung_device_pwm, &s3c64xx_device_iis0, &s3c64xx_device_iis1, - &samsung_device_keypad, &crag6410_gpio_keydev, +}; + +static struct platform_device *crag6410_devs1[] __initdata = { &crag6410_dm9k_device, &s3c64xx_device_spi0, &crag6410_mmgpio, @@ -864,13 +890,15 @@ static void __init crag6410_machine_init(void) gpiod_add_lookup_table(&crag_wm1250_ev1_gpiod_table); i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); - samsung_keypad_set_platdata(&crag6410_keypad_data); - gpiod_add_lookup_table(&crag_spi0_gpiod_table); s3c64xx_spi0_set_platdata(0, 2); pwm_add_table(crag6410_pwm_lookup, ARRAY_SIZE(crag6410_pwm_lookup)); - platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices)); + platform_add_devices(crag6410_devs0, ARRAY_SIZE(crag6410_devs0)); + + crag6410_setup_keypad(); + + platform_add_devices(crag6410_devs1, ARRAY_SIZE(crag6410_devs1)); gpio_led_register_device(-1, &gpio_leds_pdata); diff --git a/arch/arm/mach-s3c/setup-keypad-s3c64xx.c b/arch/arm/mach-s3c/setup-keypad-s3c64xx.c deleted file mode 100644 index 8463ad37c6ab..000000000000 --- a/arch/arm/mach-s3c/setup-keypad-s3c64xx.c +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// Copyright (c) 2010 Samsung Electronics Co., Ltd. -// http://www.samsung.com/ -// -// GPIO configuration for S3C64XX KeyPad device - -#include -#include "gpio-cfg.h" -#include "keypad.h" -#include "gpio-samsung.h" - -void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols) -{ - /* Set all the necessary GPK pins to special-function 3: KP_ROW[x] */ - s3c_gpio_cfgrange_nopull(S3C64XX_GPK(8), rows, S3C_GPIO_SFN(3)); - - /* Set all the necessary GPL pins to special-function 3: KP_COL[x] */ - s3c_gpio_cfgrange_nopull(S3C64XX_GPL(0), cols, S3C_GPIO_SFN(3)); -} From patchwork Mon Aug 19 04:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AD82C3DA4A for ; Mon, 19 Aug 2024 05:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nUndIWERZKRj9I2TwNCsJPKiHZoV4U6VZkZuTz/CWC4=; b=p644sifmjr2Q5AHDpr/yblyM0Y AaxBHCw6nz62yBz0Qth1e2eo3RqEVncIZisLMWNGt+MqkziIrsGP/h+M2jV7ji4vng9T5m9X4bPDn vSsN5YDBZuKxiaZSng63qhUMAmSi31ZlkqpkIGaEl+SGb0hUYSJgCgS7lb4hnGmis0fI9tQaDgfII 05i5Bp896ClD5TL9OT5S6HszI19RkmSu91FqBV7ubsOekOyYEcnExl8WXoWEz4WgV9YzPtp/B8hT4 9L7AL+tWC+r3Y+KTGbHRL57CklCNXDYpe/oDy/KQC9/UDWLDy6tKwDYlO4PZWvIk5ZXZLYDq264U0 +aZTyZLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfubg-00000000Nig-0LxE; Mon, 19 Aug 2024 05:07:04 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTZ-00000000Lal-0tUy for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:42 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-20230059241so4338035ad.3 for ; Sun, 18 Aug 2024 21:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043520; x=1724648320; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nUndIWERZKRj9I2TwNCsJPKiHZoV4U6VZkZuTz/CWC4=; b=kLLDNC7lkyFG5LWNtceHiYGG1P5WM6ReaVeUv8pwE8BrMTe53wb5oPJKoIjVC2rnZ7 my3d2sHWG4J0DwgCy8AZlogp5DhMYypCerhL6lh+tufcCLOSN/1olid5e8mHyO94lnDN oIyfn7jWp1leEUNtdC4RTFqK+qe6VgD2kmBH5HWiCtuMnjaBPthPqlbbsdlN7vbhN2Ls 4kdD9O1QDD3IW7YsYgrqKMoKL5rukT3EBEv4IOBLfz/yeGidgaZt6XGWOBaQ0yYw3ucU ffw4VAhA0WjDn0cqjiKOBzvJ4TCGI7iGOx8yozjkg4RfNU7lw8V5FuecLqYS+gLUyRTi uBCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043520; x=1724648320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nUndIWERZKRj9I2TwNCsJPKiHZoV4U6VZkZuTz/CWC4=; b=A511WuWNPQ3CWOtMBjiir10PcEDwMWCEMZ0GT1QinaUFsWACZaXo862p4Uez57teqp na1Q9dlAYDxwF/OdJrYrRziauYu4rIH42P3pPJb3+c4eAhm2hEdjYOspQQimaeIQsftL Nq9PqKt6yDhJfIV/d6e2rbWuQmaoibc5D332zeYo6m5cB4M+UrEtUVCy/axLDHRd4/gW IyuaWLfGZe7g2lZWHyWqJHNZSge+PElpt+yOAS0JoYeMyCX6XlHQ624HOnvlZG4QoSR1 C3B0cUKlG75UVzg38DOVPdCjPyxDJLEh28ljDeNyqQ7zpdTP8924SLevXAjdGBFYO4K1 Yxfw== X-Forwarded-Encrypted: i=1; AJvYcCWbTBza8QP2R1oAhFk1Auo+Mh+jruYGNZNkslD+fVen/35AxuMJED/bzAmNukI58nJtslUe9+B7cSkFcSz/TrilnOfVsrHTkb22WIz2chPafywsjtU= X-Gm-Message-State: AOJu0YyQNK/E/qNRS5ACLRr9mcUK6QK9mWaKoX/63T9SS5pHkxwwY96u XeIMCf/G/9N7dJiuos6tp62bKmTRNmp70iNG4o9yrjY7KBCgsP75 X-Google-Smtp-Source: AGHT+IE8wP1IODXwo9Jr5pjb8LD7AgNjePF3eWo7XxmUYWOTaK20CLj2D3LT7nPWl3GEhcIqE16bMA== X-Received: by 2002:a17:902:d10b:b0:1fb:6d12:2c1c with SMTP id d9443c01a7336-20203e9b06emr68765385ad.19.1724043520237; Sun, 18 Aug 2024 21:58:40 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:39 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 12/14] Input: samsung-keypad - remove support for platform data Date: Sun, 18 Aug 2024 21:58:09 -0700 Message-ID: <20240819045813.2154642-13-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215841_306249_1634D99F X-CRM114-Status: GOOD ( 30.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Because there are no more users of samsung_keypad_platdata left in the kernel remove support for it from the driver. The driver supports generic device properties so all configuration should be done using them instead of a custom platform data. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/samsung-keypad.c | 190 +++++++++--------------- include/linux/input/samsung-keypad.h | 39 ----- 2 files changed, 70 insertions(+), 159 deletions(-) delete mode 100644 include/linux/input/samsung-keypad.h diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index df2427ac63d7..78fa55498fc3 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,9 @@ #include #include #include -#include + +#define SAMSUNG_MAX_ROWS 8 +#define SAMSUNG_MAX_COLS 8 #define SAMSUNG_KEYIFCON 0x00 #define SAMSUNG_KEYIFSTSCLR 0x04 @@ -231,84 +234,43 @@ static void samsung_keypad_close(struct input_dev *input_dev) samsung_keypad_stop(keypad); } -static const struct matrix_keymap_data * -samsung_parse_verbose_keymap(struct device *dev) +static int samsung_keypad_parse_keymap(struct samsung_keypad *keypad) { - struct matrix_keymap_data *keymap_data; + struct matrix_keymap_data keymap_data = { 0 }; + struct device *dev = &keypad->pdev->dev; struct fwnode_handle *child; u32 *keymap; unsigned int key_count; - - keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL); - if (!keymap_data) { - dev_err(dev, "could not allocate memory for keymap data\n"); - return ERR_PTR(-ENOMEM); - } + int retval; key_count = device_get_child_node_count(dev); - keymap = devm_kcalloc(dev, key_count, sizeof(*keymap), GFP_KERNEL); - if (!keymap) { - dev_err(dev, "could not allocate memory for keymap\n"); - return ERR_PTR(-ENOMEM); - } - - keymap_data->keymap_size = key_count; - keymap_data->keymap = keymap; - - device_for_each_child_node(dev, child) { - u32 row, col, key_code; - - fwnode_property_read_u32(child, "keypad,row", &row); - fwnode_property_read_u32(child, "keypad,column", &col); - fwnode_property_read_u32(child, "linux,code", &key_code); - - *keymap++ = KEY(row, col, key_code); - } - - return keymap_data; -} - -static const struct samsung_keypad_platdata * -samsung_keypad_parse_properties(struct device *dev) -{ - const struct matrix_keymap_data *keymap_data; - struct samsung_keypad_platdata *pdata; - u32 num_rows = 0, num_cols = 0; - int error; + if (key_count) { + keymap = kcalloc(key_count, sizeof(*keymap), GFP_KERNEL); + if (!keymap) { + dev_err(dev, "could not allocate memory for keymap\n"); + return -ENOMEM; + } - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) { - dev_err(dev, "could not allocate memory for platform data\n"); - return ERR_PTR(-ENOMEM); - } + keymap_data.keymap = keymap; + keymap_data.keymap_size = key_count; - device_property_read_u32(dev, "samsung,keypad-num-rows", &num_rows); - device_property_read_u32(dev, "samsung,keypad-num-columns", &num_cols); + device_for_each_child_node(dev, child) { + u32 row, col, key_code; - error = matrix_keypad_parse_properties(dev, &num_rows, &num_cols); - if (error) - return ERR_PTR(error); + fwnode_property_read_u32(child, "keypad,row", &row); + fwnode_property_read_u32(child, "keypad,column", &col); + fwnode_property_read_u32(child, "linux,code", &key_code); - pdata->rows = num_rows; - pdata->cols = num_cols; - - if (!device_property_present(dev, "linux,keymap")) { - keymap_data = samsung_parse_verbose_keymap(dev); - if (IS_ERR(keymap_data)) - return ERR_CAST(keymap_data); - - pdata->keymap_data = keymap_data; + *keymap++ = KEY(row, col, key_code); + } } - - pdata->no_autorepeat = - device_property_read_bool(dev, "linux,input-no-autorepeat"); - - pdata->wakeup = device_property_read_bool(dev, "wakeup-source") || - /* legacy name */ - device_property_read_bool(dev, "linux,input-wakeup"); - - return pdata; + retval = matrix_keypad_build_keymap(key_count ? &keymap_data : NULL, + NULL, keypad->rows, keypad->cols, + keypad->keycodes, + keypad->input_dev); + kfree(keymap_data.keymap); + return retval; } static void samsung_disable_runtime_pm(void *data) @@ -320,68 +282,39 @@ static void samsung_disable_runtime_pm(void *data) static int samsung_keypad_probe(struct platform_device *pdev) { - const struct samsung_keypad_platdata *pdata; const struct platform_device_id *id; + struct device *dev = &pdev->dev; struct samsung_keypad *keypad; struct resource *res; struct input_dev *input_dev; unsigned int row_shift; + u32 num_rows = 0, num_cols = 0; + bool wakeup; int error; - pdata = dev_get_platdata(&pdev->dev); - if (pdata) { - if (!pdata->keymap_data) { - dev_err(&pdev->dev, "no keymap data defined\n"); - return -EINVAL; - } - } else { - pdata = samsung_keypad_parse_properties(&pdev->dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - } + device_property_read_u32(dev, "samsung,keypad-num-rows", &num_rows); + device_property_read_u32(dev, "samsung,keypad-num-columns", &num_cols); - if (!pdata->rows || pdata->rows > SAMSUNG_MAX_ROWS) - return -EINVAL; + error = matrix_keypad_parse_properties(dev, &num_rows, &num_cols); + if (error) + return error; - if (!pdata->cols || pdata->cols > SAMSUNG_MAX_COLS) + if (num_rows > SAMSUNG_MAX_ROWS || num_cols > SAMSUNG_MAX_COLS) return -EINVAL; - /* initialize the gpio */ - if (pdata->cfg_gpio) - pdata->cfg_gpio(pdata->rows, pdata->cols); - - row_shift = get_count_order(pdata->cols); + row_shift = get_count_order(num_cols); keypad = devm_kzalloc(&pdev->dev, struct_size(keypad, keycodes, - pdata->rows << row_shift), + num_rows << row_shift), GFP_KERNEL); if (!keypad) return -ENOMEM; - input_dev = devm_input_allocate_device(&pdev->dev); - if (!input_dev) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENODEV; - - keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!keypad->base) - return -EBUSY; - - keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad"); - if (IS_ERR(keypad->clk)) { - dev_err(&pdev->dev, "failed to get keypad clk\n"); - return PTR_ERR(keypad->clk); - } - - keypad->input_dev = input_dev; keypad->pdev = pdev; keypad->row_shift = row_shift; - keypad->rows = pdata->rows; - keypad->cols = pdata->cols; + keypad->rows = num_rows; + keypad->cols = num_cols; keypad->stopped = true; init_waitqueue_head(&keypad->wait); @@ -397,26 +330,45 @@ static int samsung_keypad_probe(struct platform_device *pdev) return -EINVAL; } + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) + return -ENOMEM; + + keypad->input_dev = input_dev; + input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; input_dev->open = samsung_keypad_open; input_dev->close = samsung_keypad_close; - error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, - pdata->rows, pdata->cols, - keypad->keycodes, input_dev); + error = samsung_keypad_parse_keymap(keypad); if (error) { dev_err(&pdev->dev, "failed to build keymap\n"); return error; } input_set_capability(input_dev, EV_MSC, MSC_SCAN); - if (!pdata->no_autorepeat) + + if (!device_property_read_bool(&pdev->dev, "linux,input-no-autorepeat")) __set_bit(EV_REP, input_dev->evbit); input_set_drvdata(input_dev, keypad); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + + keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!keypad->base) + return -EBUSY; + + keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad"); + if (IS_ERR(keypad->clk)) { + dev_err(&pdev->dev, "failed to get keypad clk\n"); + return PTR_ERR(keypad->clk); + } + keypad->irq = platform_get_irq(pdev, 0); if (keypad->irq < 0) { error = keypad->irq; @@ -431,7 +383,11 @@ static int samsung_keypad_probe(struct platform_device *pdev) return error; } - device_init_wakeup(&pdev->dev, pdata->wakeup); + wakeup = device_property_read_bool(dev, "wakeup-source") || + /* legacy name */ + device_property_read_bool(dev, "linux,input-wakeup"); + device_init_wakeup(&pdev->dev, wakeup); + platform_set_drvdata(pdev, keypad); pm_runtime_enable(&pdev->dev); @@ -444,12 +400,6 @@ static int samsung_keypad_probe(struct platform_device *pdev) if (error) return error; - if (!dev_get_platdata(&pdev->dev)) { - devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap); - devm_kfree(&pdev->dev, (void *)pdata->keymap_data); - devm_kfree(&pdev->dev, (void *)pdata); - } - return 0; } diff --git a/include/linux/input/samsung-keypad.h b/include/linux/input/samsung-keypad.h deleted file mode 100644 index ab6b97114c08..000000000000 --- a/include/linux/input/samsung-keypad.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Samsung Keypad platform data definitions - * - * Copyright (C) 2010 Samsung Electronics Co.Ltd - * Author: Joonyoung Shim - */ - -#ifndef __SAMSUNG_KEYPAD_H -#define __SAMSUNG_KEYPAD_H - -#include - -#define SAMSUNG_MAX_ROWS 8 -#define SAMSUNG_MAX_COLS 8 - -/** - * struct samsung_keypad_platdata - Platform device data for Samsung Keypad. - * @keymap_data: pointer to &matrix_keymap_data. - * @rows: number of keypad row supported. - * @cols: number of keypad col supported. - * @no_autorepeat: disable key autorepeat. - * @wakeup: controls whether the device should be set up as wakeup source. - * @cfg_gpio: configure the GPIO. - * - * Initialisation data specific to either the machine or the platform - * for the device driver to use or call-back when configuring gpio. - */ -struct samsung_keypad_platdata { - const struct matrix_keymap_data *keymap_data; - unsigned int rows; - unsigned int cols; - bool no_autorepeat; - bool wakeup; - - void (*cfg_gpio)(unsigned int rows, unsigned int cols); -}; - -#endif /* __SAMSUNG_KEYPAD_H */ From patchwork Mon Aug 19 04:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A03EC3DA4A for ; Mon, 19 Aug 2024 05:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4eUVnJCiaOH4gHrsZTqwSAhSPsq16l6gA97EkZUZefw=; b=2oZczd6WDPxgUzTFUFBJj6y5FQ NsEMJjNlaXxvQt6z0pclNAjCTGkxx/1um6HwfX6/tZxLWcXDxwqvHqMK+nRFgUefkTIR2t2hsFulE VfqUrYSIdf0dg0X0J44CqWkjlpQGh7zGfy/Uc2l2oIGplxTLK1esLyh7iOnTs7JivKcnQnwf2yi0l ngZB8D07w6lRs89h22ggllQmEP9393r1x0RkSvQHtDFEWL8PIgLr1DvaL0HYFvbYfB2smdsLsWLYi Mzze1SGIzb2oCbokVzbpMXZZPQvbaIeqlh70aFx+FJvm/1kPYL5DK3aYS7/PzKdKhy5Wrv8K1odG+ Z9uWlk0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfucI-00000000Nof-2sH2; Mon, 19 Aug 2024 05:07:42 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTa-00000000Lb3-12ib for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:43 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-7a115c427f1so2377413a12.0 for ; Sun, 18 Aug 2024 21:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043522; x=1724648322; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4eUVnJCiaOH4gHrsZTqwSAhSPsq16l6gA97EkZUZefw=; b=ih3Em4NJv7NHeA2OCstdDyRTvBJHbJtdWy4yaK9qsFR+t23bv8NyPCzyScMZZhC6yf TcJUzEls7ZIsExYZj07mk3mpDjsBZqtUWLZAYhNzLQOIDtdYDnRb2pWxQEOe5CD5k7au teJAycyeQDL3PF0lCdtr5yPfKCiUlIzVFN3RL3hTQnDagdMRgqdlMUKCAq650wAdN6gM Cx5uv9EgH5UnA451796qYiZ6ChDZHs48Y1C0SazRyA0xGGc9JYswZgZUsXoWNuTyFHuU 1GDgTukqmlaFnFNOvO1+vzQXsiB/fnXPRzEvIZVmYUDbdWeHC1EGpLBncCGPcvyye5D+ GA/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043522; x=1724648322; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4eUVnJCiaOH4gHrsZTqwSAhSPsq16l6gA97EkZUZefw=; b=uOg1p5KnwHxvdLjlO7CU/eXpXJuLghOMfNoSawZuaNaJIJOK+ejbxEUaxKk6gkUwAi S5MokwtNeWaFrO+ijD/ZIS+eH7wEIqFRsxoJtedRjYDLa1awrchw1hZ0G+C5L4SVjt0r hDOIHt7eTvzwXQHWcCv1ZGmfrq+rZjHBly60SoeoQBNg76GNTAI6KklODnvLIfFxgLx0 YuHA+tqnvaVmW9vTQa37ocz0fR06sUxD95xz4wwBCXsj8DrvFSoMEvsQ77bWpvtySGTj j6tjXD+khrM1f6xeKHxglVg4LvS7MnYk41sDGPR5thXkYHxFOS7tEdjsKsXXGav07XfH NIDw== X-Forwarded-Encrypted: i=1; AJvYcCX6JUWlVFfjIXxb5R4/V2d/04GK9VaXD6y961H0jVuqvQ5ywx9HMhNc/ld4Ch4B7T2bTdUmzWCG5FFYnZQxei0aavsQ+b6bcbeQcNm5UyQ3FJepjKc= X-Gm-Message-State: AOJu0Yz9CRdflPvVjS7nBJGDrCvkN9pO9kPmCOVOsiIskaHMIozv2r4B h86R27EYgvpoDpmz0NpW1/cVCa4RlQzvo+SWS8hwVaxQdyVYot1TVzMqSA== X-Google-Smtp-Source: AGHT+IGRVSygdM6hpmh+EBYSfTexfu4NsM7V1O+dclZkiFZItYo/YpJLstamCl3xCNYn6/J/5tsEyw== X-Received: by 2002:a05:6a20:c990:b0:1c6:a825:8bc1 with SMTP id adf61e73a8af0-1c904fb6ea7mr9172205637.29.1724043521355; Sun, 18 Aug 2024 21:58:41 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:41 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 13/14] ARM: s3c: crag6410: use software nodes/properties to set up GPIO keys Date: Sun, 18 Aug 2024 21:58:10 -0700 Message-ID: <20240819045813.2154642-14-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215842_319434_4D8A7252 X-CRM114-Status: GOOD ( 23.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch the gpio-keys device to use software inodes/properties to describe the buttons and switches. This will allow dropping support for platform data from the gpio-keys driver in the future. Signed-off-by: Dmitry Torokhov Acked-by: Krzysztof Kozlowski --- arch/arm/mach-s3c/gpio-samsung-s3c64xx.h | 5 ++ arch/arm/mach-s3c/gpio-samsung.c | 35 +++++++++++ arch/arm/mach-s3c/mach-crag6410.c | 80 +++++++++++++++++------- 3 files changed, 99 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h b/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h index 8ed144a0d474..7cf16cc085ea 100644 --- a/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h +++ b/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h @@ -13,6 +13,8 @@ #ifdef CONFIG_GPIO_SAMSUNG +#include + /* GPIO bank sizes */ #define S3C64XX_GPIO_A_NR (8) #define S3C64XX_GPIO_B_NR (7) @@ -89,6 +91,9 @@ enum s3c_gpio_number { /* define the number of gpios we need to the one after the GPQ() range */ #define GPIO_BOARD_START (S3C64XX_GPQ(S3C64XX_GPIO_Q_NR) + 1) +extern const struct software_node samsung_gpiochip_nodes[]; +#define SAMSUNG_GPIO_NODE(node) &samsung_gpiochip_nodes[(node) - 'A'] + #endif /* GPIO_SAMSUNG */ #endif /* GPIO_SAMSUNG_S3C64XX_H */ diff --git a/arch/arm/mach-s3c/gpio-samsung.c b/arch/arm/mach-s3c/gpio-samsung.c index 87daaa09e2c3..82f325112d30 100644 --- a/arch/arm/mach-s3c/gpio-samsung.c +++ b/arch/arm/mach-s3c/gpio-samsung.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -788,6 +789,38 @@ static struct samsung_gpio_chip s3c64xx_gpios_2bit[] = { }, }; +const struct software_node samsung_gpiochip_nodes[] = { + SOFTWARE_NODE("GPA", NULL, NULL), + SOFTWARE_NODE("GPB", NULL, NULL), + SOFTWARE_NODE("GPC", NULL, NULL), + SOFTWARE_NODE("GPD", NULL, NULL), + SOFTWARE_NODE("GPE", NULL, NULL), + SOFTWARE_NODE("GPF", NULL, NULL), + SOFTWARE_NODE("GPG", NULL, NULL), + SOFTWARE_NODE("GPH", NULL, NULL), + SOFTWARE_NODE("GPI", NULL, NULL), + SOFTWARE_NODE("GPJ", NULL, NULL), + SOFTWARE_NODE("GPK", NULL, NULL), + SOFTWARE_NODE("GPL", NULL, NULL), + SOFTWARE_NODE("GPM", NULL, NULL), + SOFTWARE_NODE("GPN", NULL, NULL), + SOFTWARE_NODE("GPO", NULL, NULL), + SOFTWARE_NODE("GPP", NULL, NULL), + SOFTWARE_NODE("GPQ", NULL, NULL), +}; +#define NUM_SAMSUNG_GPIOCHIPS ARRAY_SIZE(samsung_gpiochip_nodes) + +static void __init samsung_setup_gpiochip_nodes(void) +{ + const struct software_node *group[NUM_SAMSUNG_GPIOCHIPS + 1] = { 0 }; + int i; + + for (i = 0; i < NUM_SAMSUNG_GPIOCHIPS; i++) + group[i] = &samsung_gpiochip_nodes[i]; + + software_node_register_node_group(group); +} + /* TODO: cleanup soc_is_* */ static __init int samsung_gpiolib_init(void) { @@ -811,6 +844,8 @@ static __init int samsung_gpiolib_init(void) S3C64XX_VA_GPIO); samsung_gpiolib_add_4bit2_chips(s3c64xx_gpios_4bit2, ARRAY_SIZE(s3c64xx_gpios_4bit2)); + + samsung_setup_gpiochip_nodes(); } return 0; diff --git a/arch/arm/mach-s3c/mach-crag6410.c b/arch/arm/mach-s3c/mach-crag6410.c index 16b6ef312aaf..6aa74db08af9 100644 --- a/arch/arm/mach-s3c/mach-crag6410.c +++ b/arch/arm/mach-s3c/mach-crag6410.c @@ -18,11 +18,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -227,32 +229,68 @@ static void __init crag6410_setup_keypad(void) pr_err("failed to instantiate keypad device"); } -static struct gpio_keys_button crag6410_gpio_keys[] = { - [0] = { - .code = KEY_SUSPEND, - .gpio = S3C64XX_GPL(10), /* EINT 18 */ - .type = EV_KEY, - .wakeup = 1, - .active_low = 1, - }, - [1] = { - .code = SW_FRONT_PROXIMITY, - .gpio = S3C64XX_GPN(11), /* EINT 11 */ - .type = EV_SW, - }, +static const struct software_node crag6410_gpio_keys_node = { + .name = "crag6410-gpio-keys", }; -static struct gpio_keys_platform_data crag6410_gpio_keydata = { - .buttons = crag6410_gpio_keys, - .nbuttons = ARRAY_SIZE(crag6410_gpio_keys), +static const struct property_entry crag6410_suspend_key_props[] = { + PROPERTY_ENTRY_U32("linux,code", KEY_SUSPEND), + PROPERTY_ENTRY_GPIO("gpios", + SAMSUNG_GPIO_NODE('L'), 10, /* EINT 18 */ + GPIO_ACTIVE_LOW), + PROPERTY_ENTRY_BOOL("wakeup-source"), + { } }; -static struct platform_device crag6410_gpio_keydev = { - .name = "gpio-keys", - .id = 0, - .dev.platform_data = &crag6410_gpio_keydata, +static const struct software_node crag6410_suspend_key_node = { + .parent = &crag6410_gpio_keys_node, + .properties = crag6410_suspend_key_props, +}; + +static const struct property_entry crag6410_prox_sw_props[] = { + PROPERTY_ENTRY_U32("linux,type", EV_SW), + PROPERTY_ENTRY_U32("linux,code", SW_FRONT_PROXIMITY), + PROPERTY_ENTRY_GPIO("gpios", + SAMSUNG_GPIO_NODE('N'), 11, /* EINT 11 */ + GPIO_ACTIVE_HIGH), + { } +}; + +static const struct software_node crag6410_prox_sw_node = { + .parent = &crag6410_gpio_keys_node, + .properties = crag6410_prox_sw_props, }; +static const struct software_node *crag6410_gpio_keys_swnodes[] = { + &crag6410_gpio_keys_node, + &crag6410_suspend_key_node, + &crag6410_prox_sw_node, + NULL +}; + +static void __init crag6410_setup_gpio_keys(void) +{ + struct platform_device_info keys_info = { + .name = "gpio-keys", + .id = 0, + }; + struct platform_device *pd; + int err; + + err = software_node_register_node_group(crag6410_gpio_keys_swnodes); + if (err) { + pr_err("failed to register gpio-keys software nodes: %d\n", err); + return; + } + + keys_info.fwnode = software_node_fwnode(&crag6410_gpio_keys_node); + + pd = platform_device_register_full(&keys_info); + err = PTR_ERR_OR_ZERO(pd); + if (err) + pr_err("failed to create gpio-keys device: %d\n", err); +} + static struct resource crag6410_dm9k_resource[] = { [0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5, 2), [1] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5 + (1 << 8), 2), @@ -393,7 +431,6 @@ static struct platform_device *crag6410_devs0[] __initdata = { &samsung_device_pwm, &s3c64xx_device_iis0, &s3c64xx_device_iis1, - &crag6410_gpio_keydev, }; static struct platform_device *crag6410_devs1[] __initdata = { @@ -897,6 +934,7 @@ static void __init crag6410_machine_init(void) platform_add_devices(crag6410_devs0, ARRAY_SIZE(crag6410_devs0)); crag6410_setup_keypad(); + crag6410_setup_gpio_keys(); platform_add_devices(crag6410_devs1, ARRAY_SIZE(crag6410_devs1)); From patchwork Mon Aug 19 04:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4D56C3DA4A for ; Mon, 19 Aug 2024 05:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mcaRHM3+7D0S7NodLplOw/AYGyYPhnOV3W4X3E8TpD0=; b=ZAsoJgCfL77NksV1LsH2MJZ+Wx j1tFTt/W+T+pDer8JdquoyTPrFI2ygpw+LlFIhPevjBA8tuW5MgwjIyg6YppYaZW0Sbrug1MCxuCH MuzeCZSFchK8m7Wb6Plhf6T+GxDfTdS4k2zu2Ikbc1a24PHHbmbpyr2PNQ7Sz7DXTh/CiRAZSWG7X P5HtER5xO/3mRDaXA2qnWAn7vl59LtpRBKkonqFtcXKWyRRz/oAFvVA4Ce+3laOuueCm+2MFr/A1a 0SFkazqVtJAw7IbXFWLoQ0630lPdBuNIuGX20oj2+sJoOQF4nsWHFvbuUlRGW/kpjQvPMzCm3zRsd QZmBreXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfucv-00000000Ntq-1PxL; Mon, 19 Aug 2024 05:08:21 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTc-00000000Lbp-0MX7 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:45 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fc47abc040so29505365ad.0 for ; Sun, 18 Aug 2024 21:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043523; x=1724648323; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mcaRHM3+7D0S7NodLplOw/AYGyYPhnOV3W4X3E8TpD0=; b=VfUTa4W+dRSPi4gq8Rg05kPZql6RGCjFqe84aH9i7/QKjy1my5Jv66MF4B4Z2n8u2B kgQ+DFU3vD6S6qcM4obut6S2bxmO3biezcXSlIOTdmxyXPxyvjYItGXi5tccnHkaFF5C E8/wwDduKR3dGMGdZn5ucYMmFLWHXrR9NYNLIh1x9urI8Y/QwgpOoFt+Hpo6tQXq1Gp0 dl2H7gOi36oXSkPMo+pZ8EJMtX/nrI4/shRwHLps9caFICoKRR7m5HmA3i7KhTE4r1b8 8rqs1wT3pisrY3NCxvfBdBttpCxPBPbr9Q0eOBuGTnVaNIwA64pDSY3hKgQK78kT5d6W m4PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043523; x=1724648323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mcaRHM3+7D0S7NodLplOw/AYGyYPhnOV3W4X3E8TpD0=; b=gMG4M/w8RrAgTUp8VFkqJnv8OZnr1PbSWGxkCHzCKUiJyYVs8k7VapZ2b3ExiPosB/ qWNIM4srRSEDpeOwstLb1bDhJW1fWU+bIBiQMCP3ijggzABrvDALTL4i8IkyqtAfh669 4OALm67zwlZDwNBOpScYQrPXAl3tWiSVmq1DCM8Iaa3Bh7CnNQW/R+dSvbO7mZNyctdk ZSHOFoiMwJ/lPKdbg0qQKafcHro0uo/Dior2km5Drjq2ne0sNNMKuYyHVigNvswbEVjj FpaUUFydtBA8QclAwzY9nd967bW6aeP9MdtbAhSm/wUvRNZRO23qztUJDSLJgQF27+dZ kaYw== X-Forwarded-Encrypted: i=1; AJvYcCXVZ3kTnDMY4hkX68H60lOiMir35D+5b5IKapCPDvcK+H3PkSkAdRt1IEtdXFq1XvV5fbwmcJ/lg+8HcSQRgYygbSAgXb5sd33sKHvfvxu6cLr/W/I= X-Gm-Message-State: AOJu0Yw6Qx8Lk4bCy4FWVjGR39z8xLTg7W+QP5nQz0bm4v5xoJq5y2qt qPbZW2W4EC7X1tXYP+gE53+wsHI3jLPGoSEdfPD2eMNmG5EVFu7B X-Google-Smtp-Source: AGHT+IHM1aUHr6FlaVm7qvuOxYje+ccNPFOl/JhsZ8ri8UtXMzODBg9MkExumxB7dA0FrEYWROONhg== X-Received: by 2002:a17:902:cec9:b0:202:1033:8d25 with SMTP id d9443c01a7336-202195f9591mr81380085ad.35.1724043522899; Sun, 18 Aug 2024 21:58:42 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:42 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 14/14] ARM: s3c: crag6410 - convert GPIO lookup tables to property entries Date: Sun, 18 Aug 2024 21:58:11 -0700 Message-ID: <20240819045813.2154642-15-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215844_157795_CADF3672 X-CRM114-Status: GOOD ( 24.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Static property entries support defining GPIOs and are more similar to device tree properties and are not prone to losing link between device and a lookup table because of changes in device name. Convert the board to use them. This also fixes issue with recent conversion to GPIO descriptors where GPIO lookup tables were specifying incorrect GPIO chip name ("GPIO" vs "GP"). Fixes: 10a366f36e2a ("ASoC: wm1250-ev1: Convert to GPIO descriptors") Fixes: a45cf3cc72dd ("spi: s3c64xx: Convert to use GPIO descriptors") Fixes: 9a5ed0bac86e ("regulator: wm831x: Convert to use GPIO descriptors") Signed-off-by: Dmitry Torokhov Acked-by: Krzysztof Kozlowski --- arch/arm/mach-s3c/devs.c | 35 ---------- arch/arm/mach-s3c/devs.h | 1 - arch/arm/mach-s3c/mach-crag6410.c | 108 ++++++++++++++++++------------ 3 files changed, 67 insertions(+), 77 deletions(-) diff --git a/arch/arm/mach-s3c/devs.c b/arch/arm/mach-s3c/devs.c index 31827cfc5700..e24967cc648b 100644 --- a/arch/arm/mach-s3c/devs.c +++ b/arch/arm/mach-s3c/devs.c @@ -336,38 +336,3 @@ void __init dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat *pd) npd->phy_exit = s3c_usb_phy_exit; } #endif /* CONFIG_S3C_DEV_USB_HSOTG */ - -#ifdef CONFIG_S3C64XX_DEV_SPI0 -static struct resource s3c64xx_spi0_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_SPI0), -}; - -struct platform_device s3c64xx_device_spi0 = { - .name = "s3c6410-spi", - .id = 0, - .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource), - .resource = s3c64xx_spi0_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init s3c64xx_spi0_set_platdata(int src_clk_nr, int num_cs) -{ - struct s3c64xx_spi_info pd; - - /* Reject invalid configuration */ - if (!num_cs || src_clk_nr < 0) { - pr_err("%s: Invalid SPI configuration\n", __func__); - return; - } - - pd.num_cs = num_cs; - pd.src_clk_nr = src_clk_nr; - pd.cfg_gpio = s3c64xx_spi0_cfg_gpio; - - s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi0); -} -#endif /* CONFIG_S3C64XX_DEV_SPI0 */ diff --git a/arch/arm/mach-s3c/devs.h b/arch/arm/mach-s3c/devs.h index 2737990063b1..90a86ade3570 100644 --- a/arch/arm/mach-s3c/devs.h +++ b/arch/arm/mach-s3c/devs.h @@ -27,7 +27,6 @@ extern struct platform_device *s3c24xx_uart_src[]; extern struct platform_device s3c64xx_device_iis0; extern struct platform_device s3c64xx_device_iis1; -extern struct platform_device s3c64xx_device_spi0; extern struct platform_device s3c_device_fb; extern struct platform_device s3c_device_hsmmc0; diff --git a/arch/arm/mach-s3c/mach-crag6410.c b/arch/arm/mach-s3c/mach-crag6410.c index 6aa74db08af9..a7a25239793e 100644 --- a/arch/arm/mach-s3c/mach-crag6410.c +++ b/arch/arm/mach-s3c/mach-crag6410.c @@ -435,7 +435,6 @@ static struct platform_device *crag6410_devs0[] __initdata = { static struct platform_device *crag6410_devs1[] __initdata = { &crag6410_dm9k_device, - &s3c64xx_device_spi0, &crag6410_mmgpio, &crag6410_lcd_powerdev, &crag6410_backlight_device, @@ -654,22 +653,13 @@ static struct wm831x_pdata crag_pmic_pdata = { .touch = &touch_pdata, }; -/* - * VDDARM is eventually ending up as a regulator hanging on the MFD cell device - * "wm831x-buckv.1" spawn from drivers/mfd/wm831x-core.c. - * - * From the note on the platform data we can see that this is clearly DVS1 - * and assigned as dcdc1 resource to the MFD core which sets .id of the cell - * spawning the DVS1 platform device to 1, then the cell platform device - * name is calculated from 10*instance + id resulting in the device name - * "wm831x-buckv.11" - */ -static struct gpiod_lookup_table crag_pmic_gpiod_table = { - .dev_id = "wm831x-buckv.11", - .table = { - GPIO_LOOKUP("GPIOK", 0, "dvs", GPIO_ACTIVE_HIGH), - { }, - }, +static const struct property_entry crag_pmic_properties[] = { + PROPERTY_ENTRY_GPIO("dvs-gpios", + SAMSUNG_GPIO_NODE('K'), 0, GPIO_ACTIVE_HIGH), + { } +}; +static const struct software_node crag_pmic_swnode = { + .properties = crag_pmic_properties, }; static struct i2c_board_info i2c_devs0[] = { @@ -680,6 +670,7 @@ static struct i2c_board_info i2c_devs0[] = { { I2C_BOARD_INFO("wm8312", 0x34), .platform_data = &crag_pmic_pdata, .irq = S3C_EINT(23), + .swnode = &crag_pmic_swnode, }, }; @@ -774,17 +765,22 @@ static struct wm831x_pdata glenfarclas_pmic_pdata = { .disable_touch = true, }; -static struct gpiod_lookup_table crag_wm1250_ev1_gpiod_table = { - /* The WM1250-EV1 is device 0027 on I2C bus 1 */ - .dev_id = "1-0027", - .table = { - GPIO_LOOKUP("GPION", 12, "clk-ena", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 12, "clk-sel0", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 13, "clk-sel1", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 14, "osr", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 8, "master", GPIO_ACTIVE_HIGH), - { }, - }, +static const struct property_entry crag_wm1250_ev1_properties[] = { + PROPERTY_ENTRY_GPIO("clk-ena-gpios", + SAMSUNG_GPIO_NODE('N'), 12, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("clk-sel0-gpios", + SAMSUNG_GPIO_NODE('L'), 12, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("clk-sel1-gpios", + SAMSUNG_GPIO_NODE('L'), 13, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("osr-gpios", + SAMSUNG_GPIO_NODE('L'), 14, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("master-gpios", + SAMSUNG_GPIO_NODE('L'), 8, GPIO_ACTIVE_HIGH), + { } +}; + +static const struct software_node crag_wm1250_ev1_swnode = { + .properties = crag_wm1250_ev1_properties, }; static struct i2c_board_info i2c_devs1[] = { @@ -797,7 +793,8 @@ static struct i2c_board_info i2c_devs1[] = { { I2C_BOARD_INFO("wlf-gf-module", 0x24) }, { I2C_BOARD_INFO("wlf-gf-module", 0x25) }, { I2C_BOARD_INFO("wlf-gf-module", 0x26) }, - { I2C_BOARD_INFO("wm1250-ev1", 0x27), }, + { I2C_BOARD_INFO("wm1250-ev1", 0x27), + .swnode = &crag_wm1250_ev1_swnode, }, }; static struct s3c2410_platform_i2c i2c1_pdata = { @@ -887,15 +884,48 @@ static const struct gpio_led_platform_data gpio_leds_pdata = { static struct dwc2_hsotg_plat crag6410_hsotg_pdata; -static struct gpiod_lookup_table crag_spi0_gpiod_table = { - .dev_id = "s3c6410-spi.0", - .table = { - GPIO_LOOKUP_IDX("GPIOC", 3, "cs", 0, GPIO_ACTIVE_LOW), - GPIO_LOOKUP_IDX("GPION", 5, "cs", 1, GPIO_ACTIVE_LOW), - { }, - }, +static const struct software_node_ref_args crag6410_spi0_gpio_refs[] = { + SOFTWARE_NODE_REFERENCE(SAMSUNG_GPIO_NODE('C'), 3, GPIO_ACTIVE_LOW), + SOFTWARE_NODE_REFERENCE(SAMSUNG_GPIO_NODE('N'), 5, GPIO_ACTIVE_LOW), +}; + +static const struct property_entry crag6410_spi0_properties[] __initconst = { + PROPERTY_ENTRY_REF_ARRAY("cs-gpios", crag6410_spi0_gpio_refs), + { } }; +static const struct resource crag6410_spi0_resource[] __initconst = { + [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256), + [1] = DEFINE_RES_IRQ(IRQ_SPI0), +}; + +static const struct s3c64xx_spi_info crag6410_spi0_platform_data __initconst = { + .num_cs = 2, + .cfg_gpio = s3c64xx_spi0_cfg_gpio, +}; + +static const struct platform_device_info crag6410_spi0_info __initconst = { + .name = "s3c6410-spi", + .id = 0, + .res = crag6410_spi0_resource, + .num_res = ARRAY_SIZE(crag6410_spi0_resource), + .data = &crag6410_spi0_platform_data, + .size_data = sizeof(crag6410_spi0_platform_data), + .dma_mask = DMA_BIT_MASK(32), + .properties = crag6410_spi0_properties, +}; + +static void __init crag6410_setup_spi0(void) +{ + struct platform_device *pd; + int err; + + pd = platform_device_register_full(&crag6410_spi0_info); + err = PTR_ERR_OR_ZERO(pd); + if (err) + pr_err("failed to create spi0 device: %d\n", err); +} + static void __init crag6410_machine_init(void) { /* Open drain IRQs need pullups */ @@ -922,19 +952,15 @@ static void __init crag6410_machine_init(void) s3c_fb_set_platdata(&crag6410_lcd_pdata); dwc2_hsotg_set_platdata(&crag6410_hsotg_pdata); - gpiod_add_lookup_table(&crag_pmic_gpiod_table); i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0)); - gpiod_add_lookup_table(&crag_wm1250_ev1_gpiod_table); i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); - gpiod_add_lookup_table(&crag_spi0_gpiod_table); - s3c64xx_spi0_set_platdata(0, 2); - pwm_add_table(crag6410_pwm_lookup, ARRAY_SIZE(crag6410_pwm_lookup)); platform_add_devices(crag6410_devs0, ARRAY_SIZE(crag6410_devs0)); crag6410_setup_keypad(); crag6410_setup_gpio_keys(); + crag6410_setup_spi0(); platform_add_devices(crag6410_devs1, ARRAY_SIZE(crag6410_devs1));