Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2615928pxb; Sat, 30 Jan 2021 08:21:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIBaAW2F3WstnrCm1ZDvINHDSWq8IBTcjr5uJWuA9RVIH6sjne/sTtUneBmq32TnqX/r1a X-Received: by 2002:a17:906:259a:: with SMTP id m26mr9828521ejb.399.1612023690729; Sat, 30 Jan 2021 08:21:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612023690; cv=none; d=google.com; s=arc-20160816; b=uetVYVeHpkwg+UaVUjl8SqgVPD62WLOul/WD0hpOkVz7XmeVpZ+lrZdCMAC3mv8hVM Biq3pmjM9Tg7CKy4PpXUFZlWPxDhHH9jCVbjrkp+afuwX+t+Ru6msqXXgQ6yMEfdd6X+ MHm1mIAdANwEXfzpiSN9iYROXsnS2UmdLNoOOkKoGcypomat1+tjrwGUZFckp8BMNP0E DuvnJ6aZgYV12TjTWKY9VcsJgTmOpsS7D+Pk4WECrlvy7Y2FQsqjgKC5M2VzB7RI7J4S BfQWRzNF6zwLhn3Ss0QT0GmvWm5vInmQzKb4J17aenMGIVo4R1ijiQczVhIjkjdGEb72 RQig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject:sender:dkim-signature; bh=i1Y1GTOXeVZe95V2JMXKUZfz/w0hpueKYPv2Yf7uGAs=; b=Q+YOG91ZE2/R+2kyIoMZ95UVP2dIuGYUKbmszXJ2/PkwwtvBsvi0uyhusnQeFMStkl XFpF8f26oOkIE1NpQD2wX7QVyeF5JNOr9jd4s/lhDAcXnFD0r4abqNM+yqaIcWreQbTj GF4HpUcIdSHrGqLMFnUzgx8znnLtAK3a6aAVRLTPfneOGRwZJmDLv8P0WJAxw45x/Ubm 4LNWZsifHsX9WRopLTxDghIwR25imomUQpZKARpepu2GqNj9jRrBmyZ3IyAtIIHoEzeV G3vXFdN4QwdTWWxhlwLO8W9FLrmX60EZjk1MMuPxhH/yv1xxmp87dPpGpT/aNhPBKN7b jlsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TJk49GIM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si8077940edj.483.2021.01.30.08.21.06; Sat, 30 Jan 2021 08:21:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TJk49GIM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232280AbhA3QMl (ORCPT + 99 others); Sat, 30 Jan 2021 11:12:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232223AbhA3QA4 (ORCPT ); Sat, 30 Jan 2021 11:00:56 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F338C061573; Sat, 30 Jan 2021 08:00:11 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id 36so11768949otp.2; Sat, 30 Jan 2021 08:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=i1Y1GTOXeVZe95V2JMXKUZfz/w0hpueKYPv2Yf7uGAs=; b=TJk49GIMvxm8PC4RfvcwIkVnLjUb9fdi4O9N3k202Cr26Y2EP1cNSNlEqRAj5lUaA6 PU0MBMk2AmnH0cKXOkoyCAPqu0ktzoAhnszUP4cYM/J/sxUVreV5JpuT45qcwMDlZiWG NViamyuqqvUFGmaYOhkSuSrYDSRHRhmzpv3CKRFOWsD/ammnqPCKaEFTtLd5umNR5q+Z QUSS618OeKeAGmNWemzTgu/kq7QBx5FG6jNAukVJQzT5iSUApP3C1dQK0sTy0JupYAyr 8o2qfw8eNprVU9DAA/bGv/NfiYNGlejbq2id2hz0s7x+hMd1DTQCd9EOGNNeqYAS5laP tqBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=i1Y1GTOXeVZe95V2JMXKUZfz/w0hpueKYPv2Yf7uGAs=; b=evSacaWKYtJOp8GSObiuBvzrVgJcS96M6E6BJHa0iLoEMWpzePKROdqW5DZJ+kE6CJ kmn7yBd276EEyyY4hfJVOV66n1wOPtjwBR0GSYgXysDrGjZJ81XOAhakTx3PC/fpNvhx FCbsKedhdYRP5ViOGjc9rfKw7Qu0d+aeJHlHdDOOd4zIVkxT5E7MCf33QXh9aEp9wCS2 EqOOsg4rt+L61Eykl3BAyL9tGUzbvFtbfJ0/4PK5pv5rv41UVr3I7lnoX8JawWBvjyxV or95dOihx2tVmzD9F1a4kGK3ygjEB2uy1tdAiypJG4k99pMZu9DVOvlZCBtq9Uqxgm+B 0Zww== X-Gm-Message-State: AOAM531cJjzujEO2lJnC193BcI1TzpcR2fD5zGiwhto3fo5tNkMNf7JO mPHl8f/PhjsTU0XIdTdW71pluHhHIvQ= X-Received: by 2002:a9d:21ca:: with SMTP id s68mr2090823otb.164.1612022410137; Sat, 30 Jan 2021 08:00:10 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w66sm3171077oif.21.2021.01.30.08.00.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Jan 2021 08:00:09 -0800 (PST) Sender: Guenter Roeck Subject: Re: [PATCH] hwmon: lm75: Use zero lm75_type for lm75 To: "Matwey V. Kornilov" Cc: Jean Delvare , Javier Martinez Canillas , "open list:HARDWARE MONITORING" , open list References: <20210130101038.26331-1-matwey@sai.msu.ru> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7d92Uf3EArDlDShwR2+D+AMon8NULuLBHi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sFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: Date: Sat, 30 Jan 2021 08:00:07 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/30/21 7:43 AM, Matwey V. Kornilov wrote: > > > сб, 30 янв. 2021 г. в 18:31, Guenter Roeck >: >> >> On 1/30/21 2:10 AM, Matwey V. Kornilov wrote: >> > There is a logical flaw in lm75_probe() function introduced in >> > >> >     e97a45f1b460 ("hwmon: (lm75) Add OF device ID table") >> > >> > Note, that of_device_get_match_data() returns NULL when no match >> > found. This is the case when OF node exists but has unknown >> > compatible line, while the module is still loaded via i2c >> > detection. >> > >> > arch/powerpc/boot/dts/fsl/p2041rdb.dts: >> > >> >     lm75b@48 { >> >       compatible = "nxp,lm75a"; >> >       reg = <0x48>; >> >     }; >> > >> > In this case, the sensor is mistakenly considered as ADT75 variant. >> > The simplest way to handle this issue is to make the LM75 code >> > zero. >> > >> >> This doesn't really solve the problem since it would match _all_ >> non-existing entries with lm75 (instead of whatever is intended). > > Just exactly how it happened before e97a45f1b460 > >> That doesn't matter for lm75a, but it would matter if someone >> would enter, say, "bla,adt75". >> >> On a side note, "nxp,lm75a" (nor "nxp,lm75", for that matter) is not a >> documented compatible string for this driver. If anything, we would >> need a means to explicitly reject such undefined compatible strings. >> One option might be to define the first entry in enum lm75_type >> explicitly as invalid, check for it and reject it if returned. > > It is fine for me. I am afraid that this will break some dts files in the tree. > The following compatible strings missed in the driver are currently in use: > > ti,lm75 > nxp,lm75 > nxp,lm75a > > I suppose these boards currently rely on the i2c detection path. > Correct. But relying on a bug doesn't improve the situation. The above compatible strings need to be documented (and properly implemented), or removed. And we really need a better means to handle NULL returns from of_device_get_match_data(). Maybe we should use of_match_device() instead and check for a NULL return. Guenter