From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 25D1031BCAE for ; Sat, 11 Jul 2026 06:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783750002; cv=none; b=iJhtl9TSXO7PizQYOsFFcOzJlzVe4qbeUckRx6P47LvVii13mRz6I2Rz9abQ5wj0JG5SwL/ywT3mryfGkULJs05zeTbsQFtHUpkzrNA2tm95ufCVIZMQhhvn5KLaCHaqmb4SKxH7CeBv0sXsaaGc8PkCbXmvjW0JWf5lcozeR5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783750002; c=relaxed/simple; bh=vcBuQYC79OZ2bNOfBHguxsdSVRCJCN5GxTbAtsFkitE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DlX3mnVT7bVfxyvhJ5UfWEkwK4+V+BgcgKF34AKPp5P9Go8VGJkc7oWr7KmLHx7IVJgYpJ+ZxwM285M7xVJKTBWgXjM5SU3dgPsUvE93XeLZ1Tum6APtjpsrTtVGzT+9S1YJ4r5xEJH4tBy+T0nRQ79mXlb5H7qnft68Mfh8OJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-37e0a189b0bso1480223a91.1 for ; Fri, 10 Jul 2026 23:06:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783750000; x=1784354800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=hjSf+Hyul1UNVDbvkbtBR3cbH4pAbaZmRn0hhZdfigs=; b=iz4QzGGx0enrHQ1j+8y4Zxe4Q8cABHA3h7aiRCNhCqv56YsH/PbI06yFdjjT/s4bvb JG3vcAjAYc0F8OdTvtxX6K7b5A7Khr9lwsjCnnf8lCyEIrhAwxTqNpwHKg46gesXJ7k/ TuYUkO5RaV0Sr8wGjdwuCTGvXxf8XZYSV07sS25t4l4yG4J2FPsAN0fGUIVz3ghn7bCu wfFXfAgza5LXthsugD133WdZUX+uPqJSsPonWyyeE5dbNK1JMQxgBx/+HK63urmnp7lq 6n7zM2nfEfmNXAE02zwftaxOdM6TwnEf5id3g/YDC8Z5L4XMGYrqXP8bEoR9aC5X/COG lyvg== X-Forwarded-Encrypted: i=1; AHgh+RpFSKiE/eliG4H2ilmYbXt4+fjdUJxDeRSJrOGiYVliAj+IJftOBR87CXnbr5jCkJwf8V2RQL6MGCmdIhw=@vger.kernel.org X-Gm-Message-State: AOJu0YxEEQU7SDsnx89Ydubd+bFpQeDavidKvV9q3cKzZ5ccUKpiBEBH xzsjhZXPZ6/NXkX3fN6hd9ZKGjPUAQSxdxDz0xSKmlN7qZw1mLXDfTk= X-Gm-Gg: AfdE7clRXv16Kb5jZ0bQyWGuHqBofE59/F8ZtCPegr1cp/gAQOd3FHLZs/KFPwyhNWO qHn/3STmXztJf4GvBHS0qaIG/4rdt//vGmpZkeg43+StwKcGNrRJcTdLydGsG3/Qir6MiYfxoax LTCM2JUn0sWK+8WrfQL3vZuURYJYxDMYNTMOIDEC16UXyDAOpVfpyrRiT/zOScfrzXDgH6lA5B4 zIEi8uc6YKt3AMe9nYySx4aN77+hiADRp8wM6xW6zYWMTluv4Dk/whF8bkEMDc0wIF99K5rKnA9 MXZgreTozFpzIq33MoCdX4koCTFm/nTGHk5z9anQkYP15ywAltAGFadUnT86/5XSDi85IzX1hSA wqxQBZi/Bztb033vISPzYK53utWP2KfJrfidb7M26aWKWatvu8/U+YpaZefMwuhbO4FRZgG12Cj TTk00ModlgH7zdBNgFZvMl/WD/iL4VYQ3xlmZvLXX3JjPZFNZQNSmIXFuayepYeHqIr+PpB8Co+ VsUzeKCBHInvaTNlv9tj54NkQ== X-Received: by 2002:a17:90b:1808:b0:36b:77b9:5c8c with SMTP id 98e67ed59e1d1-38dc7a49482mr1855768a91.17.1783750000523; Fri, 10 Jul 2026 23:06:40 -0700 (PDT) Received: from penguin.tail0a1999.ts.net (61-228-52-13.dynamic-ip.hinet.net. [61.228.52.13]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38d11280409sm1185307a91.0.2026.07.10.23.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 23:06:40 -0700 (PDT) From: Shih-Yuan Lee To: Henrik Rydberg , Guenter Roeck Cc: Armin Wolf , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Shih-Yuan Lee Subject: [PATCH v4 0/1] hwmon: (applesmc) Convert to hwmon_device_register_with_info Date: Sat, 11 Jul 2026 14:06:33 +0800 Message-Id: <20260711060634.5794-1-fourdollars@debian.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260710123236.10508-1-fourdollars@debian.org> References: <20260710123236.10508-1-fourdollars@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Guenter, Armin, and Henrik, This is v4 of the patch series converting the applesmc driver from using the deprecated hwmon_device_register() function to the modern hwmon_device_register_with_info() API. Changes in v4: - Convert to devres-managed devm_hwmon_device_register_with_info() to fix a lifetime Use-After-Free mismatch when the driver is unbound via sysfs (releasing devres-managed attributes memory while keeping the hwmon sysfs files active). - Declare hwmon_dev locally in applesmc_init() and remove it from the global static variables, and clean up the redundant manual hwmon_device_unregister() call in applesmc_exit(). Changes in v3: - Fix a recursive mutex deadlock in applesmc_hwmon_write() when writing to pwmX_enable by using applesmc_get_entry_by_key() to resolve the entry locklessly and then calling the underlying raw read_smc/write_smc functions directly under the mutex lock. - Fix a fallback fan label truncation bug by pre-padding the generated fallback string with four spaces so that the "+ 4" pointer arithmetic offset yields the correct label "Fan %d". Changes in v2: - Abandon the minimal dummy registration approach in v1. - Fully convert the driver to modern HWMON ABI standards by dynamically allocating temp and fan channels at initialization. - Rename legacy non-standard attributes to comply with the standard HWMON ABI: - fanX_output -> fanX_target (HWMON_F_TARGET) - fanX_manual -> pwmX_enable (HWMON_PWM_ENABLE) - Dynamically register the remaining non-standard fanX_safe attributes under HWMON class directory via extra_groups. - Load and cache fan positions in smcreg.fan_positions to support returning labels by reference in .read_string. - Clean up unused static attribute groups and show/store callback functions to avoid unused symbol compiler warnings. - Verified compilation and successfully tested on real MacBook hardware. We appreciate your review and comments on this refactoring. Shih-Yuan Lee (1): hwmon: (applesmc) Convert to hwmon_device_register_with_info drivers/hwmon/applesmc.c | 467 ++++++++++++++++++++++++++------------- 1 file changed, 316 insertions(+), 151 deletions(-) -- 2.39.5