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: 820467 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BE8B12C52E; Mon, 19 Aug 2024 04:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043509; cv=none; b=mBdN5vE0OJm68BQ+RY6fU+bcXZsW7A607ROqda0WkdZ4DQJttdLFTlOxXgoenS7AOKdhhcpavdOyF5JHt0MIZ+YxiVMBNbLr0JLTVbmNGmjrvdGH7B+/Pg4FGMJ3ws4UI2fTMkGRktNXPpx+gDZVqAWKyN7/uVs/HuUWQF7AGPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043509; c=relaxed/simple; bh=nJ3sgL2CJoUjcmQPCl4x+ltEPA6HADPYCfsYu9lJA5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z1YlcGobYS/arfETAcNNcvcmjHh2VSXj6qH/5hh1ApKOlqjjfn/78YVBNTqQ6q/Pl16aYRw+3/8dEvNPXUGmp7Klzk0VG63ftlyfkVFKY9gv0ZaXTUxrtO2KfNo6f/gYKOrW//jviRJbVOEQn7vv+k4Mc3c/BOk1LpxkQTB5Pq0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XbAMBLTx; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XbAMBLTx" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2021a99af5eso13212115ad.1; 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=vger.kernel.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=XbAMBLTxhaiiKvK4kiNXlV7hEJhosdJN0TkfcxOaykl3NWvI/LYksgx0iV+5lIW2ZK /Un3AHwLuSFN1TS7CpS8P5VqBttM58BbjyP8b6qpJWD0z/NLrUgrm07DVesugG5zTzFO 2CSpxj0UPhdPrj5jfiX+rj6wnOHV6gaFxY44bJUEAyVOeh+hxVgf04YbD5FiD9caiYUi 9VOQm3t3FqVtWdTLdNowIfwHunBtzQ9AZaI3xzcDutEBSls+T4xIlU8WzM6isM8vCv7k 8FcsnoFN8Zw2ExeKLUrku8IrpUG6IoWxAQRAPeOcYF+FiMOMSFY505MZahY/zA7GdSy5 icgw== 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=qwyBMZp1jDn4KBFXBVy1mXKQW4c7PyZ3SLCca8HLbixeFz25ljzYUtaoTPdz8xMf6N B4tsfMaJnaZ9DaMdmQy/g2F8614yqkDRmsEYX7MpNZr6nnF+tx96+wsQSjpTPeMUePrn G0mdaVejGhnzjbZG6KotiyCmpP00jPR7fI5ks/k5zSLxx/kyuYaeUMLaewA/nv82Hai3 qkLIM38jv+58RI5pPiGPcYD1G318EErgN4ECoXD2Q9scI/Oc2PteTJm/FleXYj6dFKlF G8UbvqZetem7IP5McGV5pJaxmFCymZGpCzgv6xrFFrRm7Kj7kA/I8n+FJU2DbyF3KonE pXJA== X-Forwarded-Encrypted: i=1; AJvYcCU/0V9ZVWwaHKcb+QFTNIVXU8nXSntMFVFnF36bX7lAOyCXvlhepfpgY2+/cjjCS9Ef2URpZTkXAsr4EZV59+LOsTA=@vger.kernel.org, AJvYcCW4ducFXpAHhPuawuHO88Qs9JvGIGx+xtivqDjmoYfQ1SC1SsuHPrblbJGPQQL8wYMrnT8vgXW9anMe@vger.kernel.org, AJvYcCXEWQuBMQowk4Ue+rMX3wRMD8R5miBFAshXZm26oVvM/kVgoh/l8mqGXaqrGYlA2qKDByBNwHR2Sr0LkkJG@vger.kernel.org X-Gm-Message-State: AOJu0YwZiBMe7PRBWr+Wb/4S0u9HYuYROUoWy1OZqVwIyMxzioTywEGY oDY21gfDyxDBQKx18jsi1pLqAJN0kxwGa1reqL5aClCBa2+oO987 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820775 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B9E3149C57; Mon, 19 Aug 2024 04:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043510; cv=none; b=c+zXJxD7sr+F4QkPLva9MZiGHJra1iL5d8p2NNg4SJmMh0blNCfPZEpSm5VEL7raueqos5MpOiKd49r9slF04Q9Hr5I7e+jj/xj42Bz/seUf/rhKJ42HgfG+W3XBqwG14ngP10jLhM/SzO4zldtbaZCFv0FMiADPXEhRc8TbCak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043510; c=relaxed/simple; bh=qDttKstohPe0ekAAz8JTCIxL/t3M35NnwMxbeKk1VbI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KRH7wcGA7DYYIZDmMfXa4wH3L9hO0Af67RWJq1UmjK938RzyUCRtCMCarj1oy2jqsX6It1GkMTZDdd/YlzJZW5uRBEt39QnKRxjerC7DOqnAo+3/hEh143p7HnUAIeJw6JJsvA9mO3xbG6hL1w/W9LI6KYP9e0VCxDqTqDQJomo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jIAPbbXu; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jIAPbbXu" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-202376301e6so3616435ad.0; 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=vger.kernel.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=jIAPbbXuCdyBfvfuxNqP6Lhx9nISm//QlWTpxmpugIJxM80MI/wyIXjg1Ih/ZCXdiL v5m1MAvjl0c5u3wQlGKvS4drgestM3Yfr2uHKLEZPcZKm78IUCm7t+mNlzof0J+HhZKZ kUuVeTeWmHevyn9Nc3ATPx6VLIxPZTQzpzuoiStcMzY7bnqnh0A1VCX3UwlHpGB01IHB nvhGnpKutRf8yic9Um46vXkMBXUg/d19f6uZFjPMYyqSVt2KcToPiv8Mw4NHqo4IN2V3 /9P6NyY6dMnv/hKTnDi7GoJQTiToCRhsa9RpAl7ZP9Kp2cTpklT6nJfGr/z8zzRIaV6I h/cA== 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=Kr6vlnP73PpARNxRMRMrVOqG4t8zDS7en+zEeDPIqQQ0BtLvyfudrUnEU0vopo3J2I AG9A/RapcHo9n1TDkZe7zVFYW1Ik7oSZhnAzpDN76rJjbAqyq8iEV1iMcbxrR6tM+Y6b 69XS89Q/h0gWirZF1RZyoiATK5tIvkTTzO6pp2DXPcvDOLlfqKgPH/82YZAXd1cQtKur KUJn/IQ/97EgDMGmPZdwPo1jyBOmIb20i4G+ibt3jnjiEMJqOD+wEqtJ3lj548nXz2kl n1PjqX9I5B8O84qyp9Mc/6pGDsJPqkrjb8iqbzmdHqTW6YZWY5lOntkjkvwuvgbLrrdO NqoA== X-Forwarded-Encrypted: i=1; AJvYcCVz4+pU9sMkG6Sh2APvYPryvOS6XJ2hPcsHMxatKEZFEoauAVzWLSWYyhW2WQGPkZN76GTCmwNg5ILcaWdDFiR5PNc7y1jiwFC59hVkYhno/6I/wEnPpMD/aqBRgTQnloXmoTxbuKfz2a3/V36qprIQ5uBO1KoQzCEp8bYWTYk2NabUYFy5ryxpz66x X-Gm-Message-State: AOJu0YzfWr1mV6jMsjbXpb935/ZE8ev+uawpsybqutSFBBI4UtJ6q8Xh 8yF+CUEqM19+Equvywj/xAANJKrLBjavZfWy9gHPlBmjT1oEdpF0 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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: 820466 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DF3D14B08A; Mon, 19 Aug 2024 04:58:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043511; cv=none; b=LBBeajHYWruTlfyEN8bthB3wPaUCBXtIH3KLLVGRVvqrhcSACP0lrAuFXaW7xYGJd7BaLYI37TmayBnBrMcVlc1J4UpTjhLMpIMVHQrLlRDvw+DZ8QeB6sSOYyISRG+0QAEkh1qWmXors811DTDGt03/SXPiXqsgpJXJjVHOIJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043511; c=relaxed/simple; bh=+TLEQTgetAdHxl33mVkuP0tW9BMEzG2hFbgedVvu2YM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BUpPxwyw0+Wd+QonhBQ8OkdwRyJzLfOlQwCrTeb1TWsF74fYBA/TZDIXo/hwFb2BWSSN4y6R1wAvBwzf3VPIZtyc0eFeHNgXqv0j1Wv9MyESQcN6kWYQJxUjkXTKl57h08QLGpCXWHqRZpywQcx3xVjhvizgTPdV4Y8SXMb5d4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WaY0uZS3; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WaY0uZS3" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2020ac89cabso18180385ad.1; 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=vger.kernel.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=WaY0uZS3S0chqfRup3yTX6MTYNsuJkAzjnQ+zpNPfk+TQ5h56K+hV0elH04RilPDYC ADadAMElFkuv/pdnXfeLcLlTjWwrnfWS1eC5v1742Lxv5ShlPHRQmp+VaULZ4dbymDuN R2HnJIORiiwfz5CJZPrXeeZI30/w0fvLO5lEoacbKNQd8aPXK4/CKgLznFV5yJQxVp+Y pVoWHm8yqbyr6SLFekTdc/KZVMjsv9wQVu5lVDpugt7o1RJm38QVLIk+/6IgKRWPsCez 4m9hIhEGrGqdnrmFjn16O0MPgAL3Rm3odlr0MCasof8worqN4lGKLOyZ7UK6LyBuInEh Fy4Q== 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=vy8rDEdUgpNRnIGLdE3UgcTrh834WsI6QKb3A6arJtE8dC0sxDcIpGwAmHBipriaLL LH6A8Xup10LPDZ/GNAXDzisyFAuIVWWpQ3Eu6b+kfDvwQqueuk1gQgp1tUZNgEkGCjGJ kDMw4ENmftQtRY+zUGEc8QF5lKG82JcqNBfIVf1P9Hx8+Tc4fh1svfzGOO8vEDumYBcc z3x6ersz7SfwXVU67Ue6yczH6E6EgzG8jOy3TeTaGdaLgmlVhmEocuV4eExlbg40RhK5 SCDaVSrbK6s9LTxMgZ1Dw7p8fA/eRGOzQTkzZQrVwhy9vQZdlLyFPytYekLZlZRlkWfM HJ6A== X-Forwarded-Encrypted: i=1; AJvYcCV7Yfh1+sUt6TMkN1cKMf0uWikm0pmEd+F9k+EH/O6L7USZZ9wXmF7Woa6XL981OJ2nWcq9n+K3zYds2/C7PG/96begzFPIV1aPOPGVxse7f1D8SpIDr4R55QixTdWVltzWXAFy6RtvcEjCuYadAsl1YF+lG49MTbV/xuZgzzYRNT/OOUELB8EE26WC X-Gm-Message-State: AOJu0YxMYij1E/ONtx8GqV6Sz2aFcGzwtJhRvDMCe5kvuLpNaa4jEHrc sTFy5RfT/sWQxNraLqsuKGD7LkbJr1xNH3gnXaYDSlDB4TtcGpWi 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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: 820774 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0DB21552F5; Mon, 19 Aug 2024 04:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043514; cv=none; b=qnDDLursbivgc4DwyIGKXuLdeB+3Wxf1wFlsVBc6WjCoDyEDrxXYwAk4LyXx7f8VIrZDN9Wqa9jVKoxDYfG0suvZ0OIQRmNONCPdq6wj59Swdd1uIpgLHOK//mx0m3zOvDxn9vsugfERpgiNxfOhJPW7kwAp9LkIKfPWkIXg7EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043514; c=relaxed/simple; bh=F21f8qUMJlNMhArOFMlRGkgsjYrnEPCk6x9R+1gG2lE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dP3u/69EfaiPTk5GJTgJY1yrYdDyXd1hgAn75x/oyiksyXpAe3vnauvLcGvd9ZpTH0lmwuKuwsynPOz7XSvVftVb36HJzYb3YONXOS7KkK9gb9qd+QvxdTjtgkRCxbuOrboUvx/j2SzbHDvmpfs8LXSi9blZyTfWfaENXDzoDYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SF+vlxDo; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SF+vlxDo" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-202376301e6so3616605ad.0; 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=vger.kernel.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=SF+vlxDokXSrhm4ohLHQE54mAkbPUaqfIpO3CxfDnLE3GFuKR7On7h6aUmEskeTUmO IxR3g1ODK9ALAL69jK4xnSbuAUMmxGw1NTdtCn2Qd2D5I7MkM+KXXf8yqwOCGnh/BHcO KxUIjIcDhPAAkx3P99UFBqH2RQFJfqiHIHIaNIqvfOR3N/QJudmcYwJarQCCkE6VP90E W2yYkUU7L+kHlog60Ab3qs1O3K8r2/n4nBZuPe2nUbV/L7Bf7xBKpFuzEu3tFOwyO2ug Y24+LPuMMRY2YHmLXUuvkgQTOq9PjNXMuhyqKs45UZj0PI2uSJRqcRhSZ+4yQRVUhimX xzCQ== 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=j2oLmKUHqgilAJdk3ikk8nWj5Wor6YZRjvXJmt3IW/eJ0TCDUVuw8lnEgmInmAqbNt 0+NsidI8BMsx+0/QakQuQCRVcXawpTS2W2uJP58N2IqAnV/YKt4iPRSQrABWTtZZOtoe 8kLZoPzeD27B15qeWoIjecGpX39oWrVlf++S7j+day6J6rmE7Jowd3GAHCmJxztOu9bx 9Ba4htiPHmqhnT1Le6PsbqKF+BQm6ykYTVcyqiEhh4Rl3w3kNXJpgjn4fleADayEPHSU q3H9OoFzSJvtPnx7P6Sh9W5ddqeDWfxl3+hKuCijgnRzc4m/cvX0AGgQ9ISPXBqFfVPF Yk8w== X-Forwarded-Encrypted: i=1; AJvYcCVMRchDhDmkePn00V3O9USVGDJHBis/JCe4NncaTi8vQfJAd1p69XMgpGFmw5b961XuY9/7KAP7y97ZtCSiD2I0GQluHv+PFoiAkpeX6KcJpwFMVoJ0fhWpyx0bh1Q98XpJqQMHjGVl+KMKZZ5fPcbqVH4vj8vi9rYtWrVGfl0Z8ZHDl5VpnqOcq5Xx X-Gm-Message-State: AOJu0Yy6LvgpKAjep4fEGNFxNh25Md6wWfv3tceuHiMPUvkH7SoiQ00V whlNFQaHzLoaAGjBvbptS1Pn87etyfL6CZnSSXI3vtYchjxkfkOz 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When allocating memory for the keypad use struct_size() helper to be protected from overflows. Signed-off-by: Dmitry Torokhov --- 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: 820465 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A334015575D; Mon, 19 Aug 2024 04:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043515; cv=none; b=LQ1OPuG5e9KWHDwbU8mOCoQMB/8yKUpxUY6XfVDaCZNBGQWCNydGi5041Me2CNPibnntCtjAHKEbQT1//y9imxJOI1qryaTJcuddv1SWWaTJzHQqEteO9PhkmohTqs2RZfX+R7UIz/5qQxLMOEJUkTotStiCWW7gM+GsodDA3IM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043515; c=relaxed/simple; bh=Q8bepAspR0s9AbncRo7u8oBg2ug+vm1o8Jm67t5RHsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jpqrKy6vswWMRAfQWYtGdZvzhGw9fb8iAYrP4jgXejo1xtHbBvsFeOeWIChkkcP+tBt2cmiHG3xsgWU6nubM/085Wjx6iCeUi1gc9O3AMauXkUcvnJhrmq872qX8TXU22vyRfC58pZTybaouZygV/q4iU5ljtmkH22ncfikaotk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=In1vhGaO; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="In1vhGaO" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-201fbd0d7c2so22032605ad.0; 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=vger.kernel.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=In1vhGaO3u43x5jesqUDHdU73MxnslmaeQnBaGUGjFcYYeAL7p8RgTUcNnnolbjhJx MTdIXhMnXmO1xuc+dKhD2vDa4PcGAWgS42RWoBv0zwF5HXU4Q5VdwKVNfmyOFP2ab8lu 9hXijPq/Ad/JZvjhM8nw4Nl3PFL8SmbCxsw+i/nJSJ0V+wT5j+3juWB42xlpA8zGf5kZ 2I9yx52FymicoMTkz/DY6cgztXX7bXw+/09LlWDjb4g8A+bDsMdbB25hiEMkFHImTeZY yZomV8liYv9H6zFyKwtvN7gtcAkiDzTidzLEHqyRIcQOLI6UeGacwns2PvbEfd7H5TN7 Kcww== 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=X/PO+9VQwx5DDKHwbIY5U0Ght69M20opIbrdhnMk0yTQDSRN7feGLnF0GQ1QqjUujG MjSH1bj+eZ1rn5GpG//6GKTpHcveVQyUK0bD3pl7NJ1ubr0/saWqVhSQ9wmO7Pw4wdN1 q3fCqpee2SrITBkrRlEaHb+e6WO8Rzmp+e2VFKFixliALW9jPOMBWZm4+UDkvvpmGgho 8lEY3ru8xemsNrUM5+Hf+egoqY3baK0WAb/mmbHYFBIxgahNJEwXQc2tZVMdckmP+7Aw PLh176kSEZxMPyx1NwBYHpPe/hOrWUB0xJQBbhHhJ9F+rZK4E2ze0OECayMzjVonUhrh aEsA== X-Forwarded-Encrypted: i=1; AJvYcCU/6nut8v1GKv9Kyf0emjBr783jCd9ENKs6cCIXHJe8YL4UP5oCqMCGHl5+520/lymRN8lBowJzBTU06trCp8E3DOsRKT13iG+hz3TeKN71rHcStY/ZmLPafS8EC0v1a+icBPjFZadEDrKs8QH9UIaleivTJnRm0GYe139b2mkzc1gK9JV7dvTwrSD2 X-Gm-Message-State: AOJu0Yxf2WsFnUO7RQarnQkUea5Vde4a8Co5R2oA/ftc0V8E3t4uraQZ GDSEj8xDq4cry0v+5LwvwfbpQkikhsvud2sAbkym6IH5LjdQbXHF 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820773 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC18E149C57; Mon, 19 Aug 2024 04:58:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043515; cv=none; b=K7M1ebYq1To9Rihy0z332j66anQR5peXXpMtAp7uJ7ibVoKuVGeiazU/ef4zXL5g8PwtPXNoei36HZG0AlOg2BtoeNeLvpSRi5lnHkCSuLb0oRcvCP7SUlfWmHGdWBnp7MPLi/sHHtE+lWvQqXOubTxN7RkXJXAOjKrCgRvuv34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043515; c=relaxed/simple; bh=ZoPgjCMEACTo98nK7vvU3V+27SddMvzdpYlUHESHMZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uK0yNSiG8eF65eQJWGw8b4uvltR5NxSm6Lx8bGwiaw7m1X84giRKRnRVL9ICg6rAJC0EPggo36zSmq1r5KYnf8MkFQoNww4lBEDaehttRpouRpshr9KiHUO1W3xPNyBVQUgfVeLg2y/wkS2w8jWuvq8yzlylK6oohz1RMNM4eG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FwtQ4yOM; arc=none smtp.client-ip=209.85.215.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FwtQ4yOM" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-7a263f6439eso2495266a12.3; 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=vger.kernel.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=FwtQ4yOMrdW3AmDgx+d00+Srkzs/3Nvlsyo3Yym4OW6nUt9nG5HaG9BH71Rrcoogdx lqDhrae/GUWZqOsd2jMATAWcpTy+7Y8NwtaaAHgu3Fp+pA32BUiO2205AD3Y37GmeeBU Qexlh1t1G6fMNUeQM7mwoAHnsyepJeLqf48xMNIEJcfNB15/0kXxx1DkhPj2RYbbV/Ui EMz3WBjwMzgjlJWjj7Pp0ad9l7GwBmsK+BkbQqmocBCFRvZcdPDz7KarBba2LGaotBgG K4WKxQqEB/IbA8L1o+Ih6ATSwG2YxenYjIb4eZX7PdwGaaBEZU5N3N5wk+k5REnZnv9J ZQwQ== 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=QLr6Vbam34f7jHnr87ABvSZjpZI9/2mW8Cx+S+5Zr7tKjHHQCc6eABVasZaWnOP8hQ GCr+MGtEDmKROJH2366VfsH8fKzi8bAFZfW43VzzwGTzTebWnUhZEeQjmCmiQ7CCwhI2 A8/RI8UCqb1rdpJGAWepBZamsZEBVbZajw3e+6umaoSasaCB64uUJ+bqbQ2atzjSJGX+ rYatV2geHFT4qrZwJU45SaXvdE50uvhXSBefbxJd1E3tz78jquKDUZxfbiBEaFzGy+bt npvbfFBFjsP7Y5HO6psh1jkrLdm+MqBh6XcScxiUDCE4JAKren32ldw3C63yfXr0m7CL V8xA== X-Forwarded-Encrypted: i=1; AJvYcCV53LQ671cBhWHGhcgwJbCbpgRA9EeRaAQ1zdSGpw84XVw0SgCFTxjZlkx1W9F8xctDdLOSx+pbdz5OpDGF6oitGoeRsfdpjVkECRIAPA0xws3mBCn4IPfwIMHii3AHncsWzkk0Tz5NWz/BFwCM2Gr2oOGIHb8JRb1RIOlg5iZXROTiUCuoaeKr8yTL X-Gm-Message-State: AOJu0Yw2vaF27BEMmA1gUSABHo5mLVmJyuNARvZyrIW2ybj0uZI2VeDm kFyL7399EZJZWi7/zRlwctNODTX+oNznikVwc8JNabFUICKnIPtcx9y70w== 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820464 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E80F915667B; Mon, 19 Aug 2024 04:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043516; cv=none; b=ur50dqhBKmFiT7XvgyNF+b02i/ixYc9ThXj50BnZJpGPVIIUBlyGORFh8ldEjndV2ho8Kexezziryj2d8eWLmbQ3eL0j+y5Wec0uEOtv0hVFTw+UMF06AQPDs8f+QEIiHO0xdFHWZCsyV6Mfog7eF/gWkBpNOhPbiXfbQPFIa6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043516; c=relaxed/simple; bh=L1yNVVch7VynuUHiOZW+heZcQqH5t748josZ7A+DSBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tx6+59UwdetKFUP4hqrpY5Lruoif5hnmyfN0rgZr4be2dTy+rNTMUu8bJZptL+UE+st2mtAKJAidPEncprUP8mzpnBKZ/uLMfzDt/+pyrZ9l2LfULlqm2ZKmnZrLFSnNF4K5XSQXwjScPspshdPWAdTCG5CRZ7SItLbX0yZjXwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YW4rEh6B; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YW4rEh6B" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-6e7b121be30so2565095a12.1; 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=vger.kernel.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=YW4rEh6BnfsbdDacf9AT4+5H/Lo9KfzdRkNjurqUs+z4faKYLlXRa1pd0in2WB2VeC e6Qoi5aoiUgQv/VV7bs2xOeLVrekim51CA6qMvwv8s36ozgI3uIPezv1SAlWX+BUzuDf 8LKZtsn55SkYN0oBGQDRemO4OkBDc9NhNEFEWruiksxD3LiUpAkp2pRBwRjZb3mtxL5F lXVX/Puqt3yUz9X6Xl6d7+IQ/1s+LOHHDoOSUkzpLIPSF8CftkQlFHXRUZ7QB+2wgs+p IiOzM10hFROkFQuW1AxKs6i0/m34dozB+vXnxIOrPI4RvxhOIluE+PlzVIPuk0a2kjRB F3dA== 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=vgfoSHwyjlHL9SbgNsWSR/Dj5qdwAXrmXyurnLS68MR9x+rcwRjtw2RpeRcD+x5lSU TAUVIfW9DlM5U2mm4VIVmWTTUvMllodAW6gbzKEIhcY2geGnyduRDPewHwt9uUcsu8j8 Y+/HLnNHQLAUS7c9hs+fQ0+XSRzc1003+Idhx5+/erXRUvYAUwKSwIB/H996cV5Oi5D2 g8Vx57Ny+HRsE/dU4ln938c0akS7BgWuMyVEzQER1k3D+TnyEGe194yu9ib+U4Lqr9U2 Im1uWnion9nd9aLEV5ftSzsrKs9ov0SR33/gPjpNtoGckL5uCZe+/41311IfZsI1t7Ot hnyw== X-Forwarded-Encrypted: i=1; AJvYcCWJtcMD9tPDBLf+spd2lq4flWNQf7/PYS8ck0GDXOlNDUKU1D93WrmiXg1bgUZheMNk6lpPwO17FIb285JMFRztw+TUnFwlk3+9+bE0nfZK696ld65QQnSvFtedtUR/oqjl5YIoJ1cW+B8RLTyTpkOweWdBDKiIju67FY0Xm/59ZWN7TojGr/LyOs2m X-Gm-Message-State: AOJu0Yw0DBrDruzXNdLjsUKJ18oAzO3AplyKL0g67I4Oh9AUchCESMo6 SqOJlU1zVleXZAD0R6ZHTuPTOWJUACpI+P4dTKwCfsiWy0Nr7/Vk 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820772 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DE0D15748A; Mon, 19 Aug 2024 04:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043517; cv=none; b=Lx6Jt7fqyisTrp8YnlvQVAt18TOucrBzBTfnhIIUlqvltO9IgyU7FK0ytozOdmPB/RllJdTYC786MznCIFCcwKLdSvVMl8NPzr+ETb4xgyR6JvT5YOugNbf88HcPa+AG9bG4uTxOvnWYUogAeG9ZJ2YSdkuHWz+awSBOTw85lm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043517; c=relaxed/simple; bh=BTiujj2l0WxfCgLrW19jjCl/GAAqW/LU68XtUdnHkGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JM1zS03aGSvRyhGdUxRRQ/hizgPJdUDhtDSJVtuNKZerGwH3iZQkydbykYFCIjBMy1yrN2LAp62jC5uBlFVVPbCBTu/mgZfgh/1pf/tziDR1vluPj2qAcrOcBb6Wt6hVR9hNXbV2GK+gmEU/lif+hbtcCjam8Wb9jtt6yXmLpQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ApDZrw4l; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ApDZrw4l" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7a18ba4143bso2383601a12.2; 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=vger.kernel.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=ApDZrw4lEVhFcqX37kue66/xRju+MrafTcZX7+OVMiMws3TZm2p1XPo0spueymnuAu YrYIY/KiKkKkG8MS7EoDrTZ+fCI+aV3CGVCG0K712c4XzlvosEqRz0q3um7cZI4Q867O VdQMLVvE4KKVFykuws8QKwL+WWnNkOsaACrHTmfWX2MWM5iVhKcMbc0kDS0lx2MQr2gw 5LFhN3UQuGpMu4TCLjgiZNXGldJwSOQ3dOGqizCszh6o52r04LNiItmHXW+RoZFXyguy +6I/Zs7ofTuZ8ruqyQJXCgJqkHOO4MFBN4kPbe6IroXkAoiFj5n0B7Tod4r2zygG0dBZ SNvQ== 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=K9Yl/tlWJeTYl/jwI3Logc4srW9KSrOiCzgjxBZTZ7vPHzaYp7GUJhF5QTq9BfEW5u ez7URrdE1GMlVWb2Ku/yg352hYn1Ia0K0oDuASRIP7Q18AiUVkEw7JzyiX2KuMHJD1M9 QkhKQKqhrO02yHO1/oTsfx42OhTa2wOFwLgn8Mgm2U50z4UtVrqlUKY5h/p5kwiSLwca p8RqRaKYTQlSm17pCSZtXo/6Qzd7cEu03x2Hor9WMBdGq2xbivSc1/DjmnNfjkHu+J0q NGbL8yOH1vI+1gzOHQqXpuJmKcVoTyS6skpm2RI89pCWvay4GxEXGL9r/9bij3nFZz9M 7ZZA== X-Forwarded-Encrypted: i=1; AJvYcCUTB9bxOZ5iWkZGW/n08daFWymWJEqF0j8TqgLkPzxGAOqW7RyuZ1QQkethANJlx8X/OrXPX19+RxjR@vger.kernel.org, AJvYcCVil/ifmLSdTF8n3VzefP+JmAlyqSz1fgL5QBg9SlAfg0lbUW3FxXR3BMCi2Gu6sAYqyBtfkovJlSWIRZjQEEe4diw=@vger.kernel.org, AJvYcCWuLKQfllygAqyX/YNDtDnZGwdYqQqrggARlKJkqhix4JNUDQJFVLSsSmRF0lEfeLU9gUvu6jrTchkOxtlw@vger.kernel.org X-Gm-Message-State: AOJu0Yz9AcWgWuDvTxLxNmLvMACAkJdGCmke6x+Es69MeP/m+CMLWI5k mSJzuWvrHsIGfOQnr4dl8xSRBU1vZ5zFbpJi83gWbvF7Op5O/Q1N 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820463 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81D3C158524; Mon, 19 Aug 2024 04:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043519; cv=none; b=fD3uy6PGZe6qjFNslUUCKpKWrOkJYtUnwJ8Fs0hPrYMmgtAIHSpqtvkiWdTLwEFCydvPvACwOjZZojOMEUtqRko2QumxeAzZ6x9RqchdMCMoQTCPOvhtvxjSj1F8emT56qMe+yZFDcTMZpPxoaG+x6chs1AmzJSpIKisi3/KobU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043519; c=relaxed/simple; bh=pWY6q3L3+rcdHBFJ72AaCd4gwD1AvD5QCAXJ1uEhjds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lP1W+231SzgSHcCMsfzxEX8wDpUurVphRdaKfrdmFFHO3EdeOgT6MSN3u6QIPIZV2J4o8TJ0qV9x1EKxEEklQr7/rxugln96co2lgwWkw9Zf41fvrlbK/QSabVocSpDfCm+3LxWYHVyLZyOlcphHE+jNZHvxih8fAdJ/Gz+sJls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SlyEwvqY; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SlyEwvqY" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-202146e93f6so22585745ad.3; 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=vger.kernel.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=SlyEwvqYDhY1g0i0Fo+Pqec3pwzDzSZNpItUk+o+20w/TkqVhr4yxvfbl3Z8UzU9tU 8Coy7ExWkktRCmFlinQyHmrxPhzc3N8+CvEnurAX815whsVyz8l5zCG03MpeYnx3WoOG iOCOy3athlPiEpg847SdTetv8vGBNFaOd3SA2uv/FCTaYgs6LyK0tYElHfy3UGWRyajK k0/+LiMbUmGR/8QYX7AddT9SJjFxrwmy8UjlAoYBlt081WKHZR1Yu4m8PwtpfIPNzTeH mhaqkIStOR/nCJF0nTs+lJcS+Q++5Ga56fQdQ5KEkZ1EfCkDbB13wfY7JT59OV5PZJE4 N7pQ== 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=IM2sH4jjOZdMz6ZTngtaAnKhG8wHc0191bHhfzOgmA6tlWFf0bTxRzRweUoC3FkqAz FKJWMh8FQZV69TQQJswzzFROpcmPhHuVg8RMd/oGDAf+6dFA2N3idQ35O2ooEZ0qLnyW aHF+T3c5KJcCFhbo/Zaj2krkgDq9XES6CidQRO7lgeyxzeQ8nsXk30/zP974laHLO9gj p/oqZz3hSC60tlsXucWhlpe1EEmg8uFz4du8+OjSafB5p4+tLN4Rhc0dxMHHC3LRaeLC VFdNmFTKpRrwBvcYw35bzpKag1vECDelR++qS/1zIT5j+T/+W6lT/RmOCIViLAUi8uYd ORqQ== X-Forwarded-Encrypted: i=1; AJvYcCU5dTRQT+/qKNvJFHkTlPfcB3a1j5Lab62Vo/a+NOc0ptKJ2wdcDanGJTOSNR6ftlNQYK+WRRHyWd/OYeL9v7DEzc1n/soUdNArxF9e5OE3lopsUi1HcSmlik9vud4J7wWX+pry+OJgeT26owzNjMV4UNhxRC+MCjJQ1Ksv7MTjpYtgCQVhhPU3LvJz X-Gm-Message-State: AOJu0Yytdfbx0aXZPNixB4q22AdwxU0qnixDP05yybBA1UIA0dwGxRBm nScC0WWCTMnTxB5Y3OWJKy+HnIVX38rmgOGsrLobsZtqN2/3W7Qk 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820771 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCB7C158866; Mon, 19 Aug 2024 04:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043520; cv=none; b=WS/fdQEKpOfWSHKTZbLZtZKq3d1rmOUUXZGvv6rFBsIqJbmqj8MK/EHaLvPYiACFHoMqrTUZt2g/aXQZ7JDNYNVkgz0aV4EivuB0CeWWTqmsl9sTjIScdinpX6cDVfuCWTHR87ViRMn/Rr/SNI3CtU+CJjWcva91F+Na5gmDIsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043520; c=relaxed/simple; bh=0Y6SvS6wUHhmrgnziF3Zcfml6zOO2CYzjzMgrYgGEPY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I8R81wnSh3/GZWvdoHeHCa8++d+YcK2wvFGVbjGtq//jDYqAcJnl8Z6ecjQondVN9OToUY8KIy32+d0o/P8q7X0YtWPft41S7EO5vX7qJUHsQoVugK1qQAT0CmnBRoGvAyL40wuqsuW9Kj3Xc5+puy0ntoSh1Pe122bqp4xBqBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OB3UID4h; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OB3UID4h" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-710ce81bf7dso2777397b3a.0; 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=vger.kernel.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=OB3UID4hcemTPekK3ZcGwhQ8IAanJQVrznQBakCGQeszRnj3P5Br85pPMp/yUI6LQ/ ivPyPHKU51a5sx/fBfraLFVe4eq0PJ+NE+W1JUg2mUtzNC9SAIDTXcxHJq7oacRBAS/q nsUve1XIMoQvcNBYo3Sf2FXortJ5WFkjpouGjJKv1nxA2pRoCUGq3jAZs61AsSunSytB gqVPgtESLHOzEf5NX+RQUNlHJAOl1hT8u+tQEGVTay1ADMs1iTXDKJHt6jBJwT6Z1WUh WDpuq6J8chzrWkJ3RttBj6s1Bu8KIMYGXdGk07ZyUlVniNu4gl5biaiOzDr50QNOwKNB oSSg== 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=ghdHiLyN50xrNijK89lRn2M1gSRSNR2crvzoF3CNr2szv7lSoujG06tOEZHyvaAFev Paw6Pm4beqWVH/KsYGfRXHaCck4v+dUD2FMCo19qg2AJlSTyeZH6DRQ7uz7XSSKPElpX QvFnHyj1uFnRFFz4djsi7v3JY03YrDC9oPOYBPZweBFufgxK8CKWTfd7nPW00rjVaZ19 9eAEffx8v3sta5nFfbb5LEciU2EmzAeoC4Ise/uomUW3vfdAdk8rhnGy9RVAv2yajscq MUYr8HdyXgQ88Ibh7Z4P98AQbFSx/FACflACkP3Yonz4AJuW2O6qTZ6CaHfKbxVb7HfD sttQ== X-Forwarded-Encrypted: i=1; AJvYcCXo5/wMf243aHkgLrti56ixPNQTgiE0vXASSCyBSbMEZ4jnH8abGJVSNHTQksVm3cOT9Li6LQOWPd395pIN6LQFCbwGSEr1Hk9lWvOZG8Zn+xZ2rouku8B45YNMQJ2zFRkrlCY0LySoBeeXvC8++luPRERvKfO96L419lEpDpwEJ/4XYnaF/1PJjD1X X-Gm-Message-State: AOJu0YwoFL6ZOqMgndT3Kc5nPOSE6WRXRP85p1doxnKjNJQGb0Uy4Nzy bLrYenVZQCQnC0MdZHaP/TGVHMtZdTiPkTS8drEtYzBfCXcI24Jz 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820462 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07071158D94; Mon, 19 Aug 2024 04:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043521; cv=none; b=L8R9OxDNZQ1Onz6hUA6UHnfIrBPGAOyZnMgSB8xkYhAsBxV7g3GhvM/HCHryRt/y+PeUX+Dzn50CqT542u39SywDlyw7eqvbGkWHN73gwW4VH7V4AEEkIoOiRkZShRq1NhceOZiE5W3eAbDJPcvxO7lxss7xF0qHFTwF1b+D32U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043521; c=relaxed/simple; bh=xymCWFAdt2li2mS6XF3ulx50Wm+dPQnKiQopB489exs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ozGbzHoTvaqW0ea+izSln/Rz0gthhfF4MGC4IA0ntAUpFllQ/+KoVB+2wu3Qj5EFvbGbnL4gcyX65I+1RueXo18VQOx7bObVhWALpIO1CGV3DFwehAzrZUpciE+U4WE25cDgaipJjWYhVj3ALz2vXCHH7FaWs8v8VJztM4d9JYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bTdgmkrK; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bTdgmkrK" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-7a115c427f1so2377395a12.0; 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=vger.kernel.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=bTdgmkrKqdCBpovK7inhD4AJQCLl2qPvAz3Q9zOwlG5KRKU3iWjEq9tMofq7BbJ8B3 99TsDV4HH+fUXeiW8DXBCnAtw0XIZzZnf222b8bFqrqeUHkaBZ92RNXnfECBI5fJJ5Mk uBh59E86FxoEYqb3/zDYM5fJO07/nLr5l9hGEnuivI62CuKtuQPLMBg7IO9sGnlqr8vV tRYwCW9PLeVVle7z1R1/mCscWWllJt8Y7flo7LS9BQ2omCJVL0aq0eRicak5TgK4xQ9l kx7A77Z7M1P80nEjLQUuES3x7HV+YUUYzgvOx7PbAPqhZ5Bw8ARgfwgd8FbZDlmFt6VY Z59Q== 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=nBEQJwOxsbs2qx5mSSYWqe17xVZV6tOvymhfsHfyeg1GhBpThy0YsmZFrI8LuuePAk ujkBBPXHZtmzXBwT+OGLVSTJHtZ9r7T9l6V8SbjbDWskRwGXFG9aKlp6slg54w38d6Ok GZEZMmvRig2PtFScskXZxbHtyfMBbX+RnCkugcmTMoS4jNfIcHS8G+7w3LXr9YGXccz/ vVW83aolSYeImz5prsu4qzsuSSgamXn6fv8Fg5Kpw6DjJfl7lonSyjqSlWTeGASFB4wa /9KZ1tw+6rKPZDd0U+aSr9ZPaiqTu53wB01yhmHsc8XjFgHbEfEIIG8IMZQjDrQgKXsd aZ9Q== X-Forwarded-Encrypted: i=1; AJvYcCUMMM12ViGW+6AB9XzqURR2d5uhC4Vo7kR1wzUSaxLbEoZBnt+Zvz08lzzTyBPL65eQBAGhqEgVcDc/@vger.kernel.org, AJvYcCV50w+Dl9kmGPaMYkVg+vCKkXipGVYHnJbOWHAFc7uZK8upIlFRCVEHFZm9vmgWNjmSE72Vy2Lzv9qP+Vub@vger.kernel.org, AJvYcCWUoupJCn4qB++gMEDkCfFnE9vTwBhwvRHenkZ1Kjb96WSNP6e1GdC5E3K5lbyt0k27tZr1QQ4h1bC0L64VlT+VpEA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2D4bbj2tlPXr2ifRYeDwUz9EPDf/4HGa2Ttf/BQzMOtfOxjQQ mxjNp7ZEowAsRldmt9djCC8vm6GS8J5AqyImvdRgsV8r22UEsBv/iSAWpg== 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820770 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42FDE159217; Mon, 19 Aug 2024 04:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043523; cv=none; b=ihbzy4Ilz6cFXXuVFZivzaUEWFLD/yrlUQgDdOrFFMm7Wu1VaavkSZfr+Mvs3Jxvl5EPdPLuM5ht1pByaC05Go0H9BRY47p8jkq1+lq8BV4mmzUlxWGPMMtYyQClZ9FOJGlN2WGtEsjlxRBPj4ALktHY0VyHdRtc0awZPoOaPBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043523; c=relaxed/simple; bh=sM7+5/or5kXiavB2qY8+Jl/DwHhncIpJwdyy49AMsnQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fL5a5NQByehTmQAH4TpvG3dbw4HSvxv1CB4LdfiewGlU7n+ne7aDoK0ahWpwX2ffJkwwrsJtDHxc1WvGAV318epQlb5BQL8A8g9U6bMan4TIWrRWi/kArZdPv99+VwLnPUbrm6inl3e60n2KjzACqydweZkE7LyWx7g2H6jCCDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=P7+n3VhK; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P7+n3VhK" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fec34f94abso32565645ad.2; 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=vger.kernel.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=P7+n3VhKnlX0zi7aoJVZB+MOGF6s2GLlRqMoWANESZ+9FTE0H13sIZ8NNYcwAgAIgZ AL5syw0OHb5jDPSUoU+FsuNtiKlIYdbktADoj9tb8X8Q6DkU624Bh8YrWHKy8Xhm9yzr h4m/mnEfIBJA98nrAZy37tXDod0x/sSuUSYNUc9uwDmwGiXijISEz0L6PrXyuPvi2WaT ZdOjVxXT50yUCVLAiNdcPCKUgFWHcG7XeBAHZnlIdZyv03eTYHKt9bzh+o6fXrelNLvJ ErwzyAv7VEMbQTrqkr03yxi+SrO4T4Zawbjetjn0RY8CapF2sFX84jYvDMJcR/ORpRSw bwcQ== 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=C7MNuhQq+TPMol2lwh1k/TG3QQHvIr03G92dda3VAVb3KrXyacshV7xPwYVFTOPEXE YbsLA9LxMzVrTR3OBQmGCRQ4R3y9ajN9e6eOaQukokAvYiRnaoIljCa4CbY4Ki2y+rXI KkM4rmgTGtvYgk5koB8woFOveJ0wsFXLBVRNElQklauzsCV8O//yAVbsszGsn6Lug1Et qeeLTYsapecUfbfzIxrfMmYRuveFQob4hTdlV9Q299H/EaJ3L4e/L9pjrd6bD8PzdUuZ bZ5O80ukcaP61NadNQkTMI58AOOVOS44f012TD1+Nqrc+x0pc1O3StKcdt9F45vb0jJs I2+A== X-Forwarded-Encrypted: i=1; AJvYcCXctjQ8hbCwICvoU4VB2S+zoI9oKGkkvmqFCGrhL8YXbyrux7bCNombwz3eJ/xukAh4JLJ1dfnlWMvpFN4lNr5Gwf5pbxWnCJkKwXinRDx/yTu03/4Xo87BJ7HmwOuVpnyrSyZWkJejpJnaqTN97zR5O0feURfFob/iVw9n7qEWtdLJINmp805BwSdp X-Gm-Message-State: AOJu0Yy1YbJql3MR2Xx0OIjC41r2Kg3SQhLI5VIOJm1eAh2v00EXJ8pe UFs1jOaFFOAak8viYwmwCzc8kwvbDl5v9bfpo2c/AHDFCsaHh1bP 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 820461 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E7DE15A848; Mon, 19 Aug 2024 04:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043524; cv=none; b=Zgk7tbx5p22jI82XCaNGqDNrgWB+goN6B+nzXugRabrbX346JPAZMDyJUgf4yRNrJRlRe3o0A0e3DhQHBxV8iNo9igACWPZcd4HHZZ9utTTzLBjMuDt2fsWJbVU1IsFkqKhu5hApK27lQ5Vug4W6z9aeiySGH6X4Ei7RwI5Ek94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043524; c=relaxed/simple; bh=AEeG1xs1Mo6IMy9hjEfxZ0HM7nzDeiYiYP7RwqNj8xU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LyRmdBzmYLKOQd3G00EYhFmqu2kf4AkExstmGN5s73TKfv6JBzLcE08ibA2raWOpch7XT/Zrjl2roJ6NUX5vLl/y2VAXopzEKfi5FphLKBZMlPE14kzgw1OGWwhuQRuT/nfaDG3aiilx0FxCniqP3jQ+4IbpcyJsH8Mf9hcucsw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NiWiQ05z; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NiWiQ05z" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70d1a74a43bso2537815b3a.1; 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=vger.kernel.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=NiWiQ05z7kfjsMXYVJFcftXkHtoRJFT2V8qL7Nyfx3D/Ibqb62EtOciucpNSQVTLL8 e+GVP4AFzWnGwvqz7T4WXS2iBWFBVhfJwqso/ivzNkPfZ+eyORanAPU1XwlQlXsCYTke xEI9kXc5G8mSTOrGUmIjoMj7LlKx6/HMWRVlEKVIHDjXkeS1cKwNcPynhAVDzvTucTq1 5jQjLbZjqXBBj/yUZ9LQLjLWJ8avZU1/ebJybGNk/wJGWErRGFgIu1Gkk+e3hvRBKxBu KR//OxHomfRr/+haOLbXdMH2kABBzDqbzCkrpf4W8wFYDQ3FAJnwVoODssU5jCtuQGX7 iYTw== 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=OdAD7OYdCaliCfLIBHX5OfJe7plpmPKuWxLzkVWQdwEhG/i569qWjxdAwQJtgsRUWs bAWo2drtKH7m5/y3PB5gaa7J+1GZFwM4Vr4lLq8ijf6vu5g0Ro5mTciV59tY1gjEq1WW 1ALL6sCoGNNd9UC57WVWyXi57f0O7u2psAOqMEuq5kuIiA0G6aChqiG9vWdGf/bnKJqc l1BI3SzzzeCPM8klJg+DN/Lau1VasgVxN3AdRfs2VaGEF8zbY9HHvxyOdZxacjMgmnPy Kn/uPzD5zsT6GVX3jfT4EwWP3X+C99DYh1WIi5xOU1Oi5PwyYagzWVZXZaro8Rh9oQcZ 7+5w== X-Forwarded-Encrypted: i=1; AJvYcCU1nRJH0uM7PQoVbwpHF0OEpm5auW06jmi7+FxxGBWPhkXtAvgAPjLcUl6vIfPLlIQEgTQ4wlX09OU3xnKDXN9glBZoOE2EZkR2EO10nMEjv5/lw0LqMacCBEJ6CDOHLgQkp4Gnd2h5gTASIgWCwHgNR5KAg92sYARIKe81ECGzLEnuG+ujQIKiqcCh X-Gm-Message-State: AOJu0YzS508elv8zY6+V7XKQrloAgJvsgkZp8otjKsgxD5ILvTs3ik56 O8iP6DkqNhco8e17lvwat+or/Zsa5pBN80KreagGMLfSeI1YJBS0 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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: 820769 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC5FF15A87F; Mon, 19 Aug 2024 04:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043525; cv=none; b=RfwVOBZFEhFdVdjSgnWk6vA0BDppGyOtpl5fgiFzieYYxm56hn+wAj6ltD91uUiyrzPn3px6MlffWfhd+2oVy/1H9H1JimpfNoNUAQv1SwuaU6GtteLT7e0BmIpWgLSe9Tg2uMNUCgm7JXwgL4wIJcbXrre0aR6mtKXHYnb6I9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724043525; c=relaxed/simple; bh=pujRvm4ARPdX6ZSe8VlYOOI1pXoBBQFVAweJDtzA4fA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gh3C1ybF8rnKkPqZ69AgsDdagsXSEMZaMllgQaS07JcstSVovNN/x9vG+7fS1yuOh4oiWnix4RDWTn9kHZnZCIjW+oYZM0Lk6nA7auoDWrb7zx0gmXmhenGvGX0E8Sc7NSQHnrkFWisbvPeAJBjo7KcI+0qHBDBbe1dl6nXQlIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XOegargB; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XOegargB" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20219a0fe4dso12788645ad.2; 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=vger.kernel.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=XOegargB0Baubnb0XGTm1rpMhRq6rbFhv72wL28uR4VYZaeoDqrbgEaO2IxqBxt2ji atLztTbLjvWcJ0nNKK886fLW3MVk2uPDPum5EWOks5JZHpAK8lckTYd1vXr/eaSC2Ega KEeeVhHo7WyvXprFfbmTlhZxcdz8wL6FI5awDRhGTc/FpHv/NM/sralpaMGMyYuiATzE XyY0mWVjHdWmtb0kGyCCG7i1Cgo55izVCzIUrUygxAO08CUIl+f0/T/UZ/4B2OzubcgX SniGLzz68uHtAB3md4miRyHp3j6fthTSeevv9GxdQ+A6nCX9HLODl0108x+7tF/2hz30 Hh1w== 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=vvF7AN1s5yS6UYCRJRyLbAlzHcE18/R8MHu0iiEgSttOVOonxaFEFMF9cJSbc84PgH zFS9Qy2y/zbaLb/tpLQ+/lKlJ0SqS28/F2q7PNr4cY1w/FxFdVE67PPx3aB1hT0m7EZe czcj0Xbj7FIDW9c76I5BnvoWe+sgh4NHGhjFkeQcam+DKi+Ep4PaGNWo7WLfZsVChNY3 g/QZWMnATcqoPvhpzaKDwQywB0kdx4L8XIp06SFHHwa1UIz3tk2SLTSOVCB9y34vmf09 hIlQZrfOj7A40tSYJhPcm5JlSiZvKgA670ZmHarSKtRcQ+cqbDo4R8Dl6Sb8eCljGKSx aVUQ== X-Forwarded-Encrypted: i=1; AJvYcCWtoJrpgD7U5Nl5AD9FrP+GtApFm0dWdR2m1Pbzsx/0XlIRM1D4k/OfdNSWusyW6KQ+hIlLY8UE+JhdDrlPXqIHYQG1Iy6d1h2adYXcXItqRLceuXLMLlJ3ddN7ZjNUBPVtXaSn1RauLHAHCJ6YZsNI84BbUZp9v59p30xBhBjvMhvinwQiJqmM6nNS X-Gm-Message-State: AOJu0YwqkUP23cBFneZnrtkh2MxU6DJ8lU1M523XDYQnCkhqTdNm9Kez xgoZzH+RRvdaN7fwVPMVx85DcRNs9RgDtVfKnZ2IvvJXEdrbqhtK 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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));