Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp563438lqp; Sat, 13 Apr 2024 08:45:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNQYWscFBC/eLKaVunibmsd6mVxiJV+LyF7Vhi1MCpUZd3zi7BHCLKpz/RghoNnfTetxn/g/5/OA3xt0Fc1mLm+FVI9i6ZVJDUau5qLA== X-Google-Smtp-Source: AGHT+IFNlO9Rzjm4DSIKPqrP5I0eNB+NEWyU6B8MW4Tbvbphzk+T+u6gHqeU7QSdKECjHGzDOv5S X-Received: by 2002:a05:620a:135c:b0:78e:c619:7769 with SMTP id c28-20020a05620a135c00b0078ec6197769mr6434694qkl.70.1713023128265; Sat, 13 Apr 2024 08:45:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713023128; cv=pass; d=google.com; s=arc-20160816; b=jG8q1QFfjOTMjVJEx24MYdduRIGtk7NPsnWN63Nkkifx1ylNhN0MJlxkqaQO1meyVC fsVPys68C/2pIcojMICj5ovWYW1cIGgIXKhnTZ4z0HaRcLkp30tvoaDKz0g4HQS2jExh IiEy3ZKqiWiIkpMbTMUNSTcRdQAHS1eXaavIBevj3shXuS9K/0Rge9VAsxMJOEKl0J4o DKrfpyn87hP7Ug8hErkU3cXHPAjimgzRS/S0rjVJpDUuXEQUntvFOSUTfzI7wZj39K2s 9x0Bh75hCjQJosLdtl92IqrmMhQ/RoAbucwvHyHfoDYoN3xmPc80Zml7zKF2Mmhc6RWj LX2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=tlcxDayxy7liV/dNtJA0sj3nxRJNURx3h61HUHMkCRg=; fh=/RCBedfTnq50HcKaksWnyE9mtWNPzadjjks+PhQ5Fak=; b=RDs1oL58y6QP0yleRBXsHe43f44rC7PfNRTAevr76T/lcpC8scyTN2Dt3L16VjG+uA fCcD6tgPLEU3ryYgQfn+WvjySe9D2pW3VR+R8M+5knHXf7GSACTUhk94JvtugGsQFBvf kBIh4U1f390OF7sgzAoIeCRd9Kj2/vCNMeXXrUZcLPtWlJpVl+mW1SGs2IkITRWEapwS XFxTpVf8/jsw2IRiSZtSb0I4Qxk5gWcTEzeRga7dJjk8CxZ4uweRn6uF0FuOntsLs0rg oBx3wNn4Ne7NKsFfr/WCBuNi9MyeIe2uNBQCF67sWJQea0xV9+1Fz8nd3W9hYYJ1nETk L4NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="j51xE/oR"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-143793-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b26-20020a05620a04fa00b0078a36e7bd63si5978002qkh.491.2024.04.13.08.45.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 08:45:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143793-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="j51xE/oR"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-143793-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CD0581C20972 for ; Sat, 13 Apr 2024 15:45:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F245481BA; Sat, 13 Apr 2024 15:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="j51xE/oR" Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 D29E547768 for ; Sat, 13 Apr 2024 15:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713023119; cv=none; b=jJMZZ9eqxEddmJwQz2q9txlwOZ6F0t3dFoQpEGGjKq8wbyHAiMQKq2TVjcrKOEvxnG+/colkm4STyuisMRxspU97V21vIyGevasQHzvJvMnhiN4SkRGTE+kQnwc6TGElzxf9OHmo8OkhfEWz5/aoCP2+TAR+JpHWhOadh1gfulo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713023119; c=relaxed/simple; bh=2JEeEAKK+fM9/amx8WJRJ3XYvGn0sAnfwgksY9PdaRg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=HPglj53LezeOjLUQvMvEURorIMEbNiNjoUuBcw90fvW42UApflC2ynic/28XI2nmzsWt7K5KCRlx2Y/94TUruK34FIAfKPJYfxvS25pLyy/C8wnOEy1epQgysIjq5LQ70jdjnEz7cAYANm1ZPwNFiz9G5M+uw9Zze9Xwgj8OHQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=j51xE/oR; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-570005cdf62so1159286a12.2 for ; Sat, 13 Apr 2024 08:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713023116; x=1713627916; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tlcxDayxy7liV/dNtJA0sj3nxRJNURx3h61HUHMkCRg=; b=j51xE/oRuEn4+A/ufUVddpV+xmkedGMEXILhpMmyu3/9LncXJlXroxt3q9N+mA4Qbx 4GpEWudDcuXF7ntFNPtGIMi4BVs4Lfgugk07CgUYyFHou02nraL3eNoeTKI647jQZicW KNkwJbB7mtBKh9ma7ExTqoZrtzg63aJenGesNH4EIdqB6m0wZAXbpHDOMxcoJc2dCcK1 a3j57/UCzwYOYBsFz1BH/VbM0NDVQuhNOd7XKwZkq4G7s8mKRLPaQDxSN9JvGrI2Ve+k aLSFmezWLAaNI+rZV6dxGVvKNKWKxgenvn4Hcof4ubc/HKGqM+yGv+dZnSWZMGPEFspf U17g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713023116; x=1713627916; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tlcxDayxy7liV/dNtJA0sj3nxRJNURx3h61HUHMkCRg=; b=WuGCHMn7KobSSXAGzxjOnYxzgPHp6bwUvNG6XhjzjzhXhplOw1zSNJ8NaYN696QxLi wseeGwQWVM45GlcXO+udOl1uspKn5Z352lWuGWiYGNDgT9YqCZSabWAmy6DCzwpF1fPz BxyWuniy2895MzuLgdV+ZSoOhl/h+Ndm0MVledhgQ0/GW9YndxMFdgF6Yb7doyX0Lf4v nZ2R1jNYRjqQyHRYLdD1otQFNyURUWbzpbXUT927WCyX+pUgfLxAZItZfjn67zOkObhF CBMf0PQAWIirtzZQVzPXx8ONf9UPFm3xnJjGK598p+iBLO8kWkJquGNmKpnpFKdhzvVn msRg== X-Forwarded-Encrypted: i=1; AJvYcCVHtAK0d3KoHW0Zd8kSUCW/mbUqN363b+VtuY2XtfUtLu4ATYdP8cKUhLk93/R39cLvCASOeHJJcJVl7isqTqv5UMSx+6y6VULsVSyt X-Gm-Message-State: AOJu0Ywu6c0scO0ux1GrtWY2QUZeXut+/qg3tkwbvVNwiGqBb19H5Eh6 7RMak55fmdGGUT59AGzcQt7QEbYWwtLHpBEfGZsTwq3OmwqomUfzo7vdStBujNc= X-Received: by 2002:a17:906:3c49:b0:a52:40b5:aedf with SMTP id i9-20020a1709063c4900b00a5240b5aedfmr1989672ejg.9.1713023116031; Sat, 13 Apr 2024 08:45:16 -0700 (PDT) Received: from krzk-bin.. ([178.197.223.16]) by smtp.gmail.com with ESMTPSA id en5-20020a17090728c500b00a51b8e8c8besm3128294ejc.86.2024.04.13.08.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 08:45:15 -0700 (PDT) From: Krzysztof Kozlowski To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , Arnd Bergmann Subject: [PATCH v3] iio: dac: ad5755: make use of of_device_id table Date: Sat, 13 Apr 2024 17:45:11 +0200 Message-Id: <20240413154511.52576-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Store pointers to chip info (struct ad5755_chip_info) in driver match data, instead of enum, so every value will be != 0, populate the of_device_id table and use it in driver. Even though it is one change, it gives multiple benefits: 1. Allows to use spi_get_device_match_data() dropping local 'type' variable. 2. Makes both ID tables usable, so kernel can match via any of these methods. 3. Code is more obvious as both tables are properly filled. 4. Fixes W=1 warning: ad5755.c:866:34: error: unused variable 'ad5755_of_match' [-Werror,-Wunused-const-variable] Cc: Arnd Bergmann Signed-off-by: Krzysztof Kozlowski --- Changes in v3: 1. Use pointers, according to Jonathan comments. v2: https://lore.kernel.org/all/20240226192555.14aa178e@jic23-huawei/ An old v1: https://lore.kernel.org/all/20230810111933.205619-1-krzysztof.kozlowski@linaro.org/ --- drivers/iio/dac/ad5755.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 404865e35460..0b24cb19ac9d 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -809,7 +809,6 @@ static struct ad5755_platform_data *ad5755_parse_fw(struct device *dev) static int ad5755_probe(struct spi_device *spi) { - enum ad5755_type type = spi_get_device_id(spi)->driver_data; const struct ad5755_platform_data *pdata; struct iio_dev *indio_dev; struct ad5755_state *st; @@ -824,7 +823,7 @@ static int ad5755_probe(struct spi_device *spi) st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); - st->chip_info = &ad5755_chip_info_tbl[type]; + st->chip_info = spi_get_device_match_data(spi); st->spi = spi; st->pwr_down = 0xf; @@ -854,21 +853,21 @@ static int ad5755_probe(struct spi_device *spi) } static const struct spi_device_id ad5755_id[] = { - { "ad5755", ID_AD5755 }, - { "ad5755-1", ID_AD5755 }, - { "ad5757", ID_AD5757 }, - { "ad5735", ID_AD5735 }, - { "ad5737", ID_AD5737 }, + { "ad5755", (kernel_ulong_t)&ad5755_chip_info_tbl[ID_AD5755] }, + { "ad5755-1", (kernel_ulong_t)&ad5755_chip_info_tbl[ID_AD5755] }, + { "ad5757", (kernel_ulong_t)&ad5755_chip_info_tbl[ID_AD5757] }, + { "ad5735", (kernel_ulong_t)&ad5755_chip_info_tbl[ID_AD5735] }, + { "ad5737", (kernel_ulong_t)&ad5755_chip_info_tbl[ID_AD5737] }, {} }; MODULE_DEVICE_TABLE(spi, ad5755_id); static const struct of_device_id ad5755_of_match[] = { - { .compatible = "adi,ad5755" }, - { .compatible = "adi,ad5755-1" }, - { .compatible = "adi,ad5757" }, - { .compatible = "adi,ad5735" }, - { .compatible = "adi,ad5737" }, + { .compatible = "adi,ad5755", &ad5755_chip_info_tbl[ID_AD5755] }, + { .compatible = "adi,ad5755-1", &ad5755_chip_info_tbl[ID_AD5755] }, + { .compatible = "adi,ad5757", &ad5755_chip_info_tbl[ID_AD5757] }, + { .compatible = "adi,ad5735", &ad5755_chip_info_tbl[ID_AD5735] }, + { .compatible = "adi,ad5737", &ad5755_chip_info_tbl[ID_AD5737] }, { } }; MODULE_DEVICE_TABLE(of, ad5755_of_match); @@ -876,6 +875,7 @@ MODULE_DEVICE_TABLE(of, ad5755_of_match); static struct spi_driver ad5755_driver = { .driver = { .name = "ad5755", + .of_match_table = ad5755_of_match, }, .probe = ad5755_probe, .id_table = ad5755_id, -- 2.34.1