From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49405C433EF for ; Mon, 28 Feb 2022 08:24:57 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K6YMp6Xr7z3bPJ for ; Mon, 28 Feb 2022 19:24:54 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=bewilderbeest.net header.i=@bewilderbeest.net header.a=rsa-sha256 header.s=thorn header.b=Z5obv454; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=bewilderbeest.net (client-ip=2605:2700:0:5::4713:9cab; helo=thorn.bewilderbeest.net; envelope-from=zev@bewilderbeest.net; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=bewilderbeest.net header.i=@bewilderbeest.net header.a=rsa-sha256 header.s=thorn header.b=Z5obv454; dkim-atps=neutral Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [IPv6:2605:2700:0:5::4713:9cab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K6YM23hNXz2xrm for ; Mon, 28 Feb 2022 19:24:14 +1100 (AEDT) Received: from hatter.bewilderbeest.net (174-21-187-98.tukw.qwest.net [174.21.187.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 30F91185; Mon, 28 Feb 2022 00:24:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1646036651; bh=nnBN0dGrBVyqWTSRs7wxqWLOPD9yMdE1ClJpxLloK24=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z5obv454FzMLve6yKLSFEJ65pf1vEvmMRk112EdsRcl1PXOg/EgUAxkBtOCliMhW7 XoUkl096b9oO2nGCait93mHXdMCWqTiCA2KslzcfY04A9CpuWgODXzg3oM8jgE4A/R xzbIf70iH/hNL9AcQOvn8eKrFiH0s5McgsJ8tb2M= Date: Mon, 28 Feb 2022 00:24:07 -0800 From: Zev Weiss To: Guenter Roeck Subject: Re: [PATCH 1/5] hwmon: (nct6775) Rearrange attr-group initialization Message-ID: References: <20220226133047.6226-1-zev@bewilderbeest.net> <20220226133047.6226-2-zev@bewilderbeest.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-hwmon@vger.kernel.org, openbmc@lists.ozlabs.org, Jean Delvare , linux-kernel@vger.kernel.org, Renze Nicolai Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" On Sun, Feb 27, 2022 at 07:01:32AM PST, Guenter Roeck wrote: >On 2/26/22 05:30, Zev Weiss wrote: >>We now track the number of attribute groups in nct6775_data, as a >>measure to simplify handling differences in the set of enabled >>attribute groups between nct6775 drivers (platform & i2c). As a side >>effect, we also reduce the amount of IS_ERR()/PTR_ERR() boilerplate a >>bit. >> >>Signed-off-by: Zev Weiss >>--- >> drivers/hwmon/nct6775.c | 84 ++++++++++++++++++++--------------------- >> 1 file changed, 42 insertions(+), 42 deletions(-) >> >>diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c >>index 2b91f7e05126..139b2fe5ca4d 100644 >>--- a/drivers/hwmon/nct6775.c >>+++ b/drivers/hwmon/nct6775.c >>@@ -1198,6 +1198,7 @@ struct nct6775_data { >> const char *name; >> const struct attribute_group *groups[7]; >>+ u8 num_groups; >> u16 reg_temp[5][NUM_TEMP]; /* 0=temp, 1=temp_over, 2=temp_hyst, >> * 3=temp_crit, 4=temp_lcrit >>@@ -1405,10 +1406,18 @@ struct sensor_template_group { >> int base; >> }; >>-static struct attribute_group * >>-nct6775_create_attr_group(struct device *dev, >>- const struct sensor_template_group *tg, >>- int repeat) >>+static int nct6775_add_attr_group(struct nct6775_data *data, const struct attribute_group *group) >>+{ >>+ /* Need to leave a NULL terminator at the end of data->groups */ >>+ if (WARN_ON(data->num_groups == ARRAY_SIZE(data->groups) - 1)) >>+ return -ENOSPC; >>+ > >At work we are struggling with a whopping 500,000+ (!) WARN backtraces >_each day_. I would be happy if you send me patches removing some of >those, but I am not inclined to accept patches adding them. If people >don't notice that the driver doesn't load, they won't notice the warning >either, and it will just add to all the other warning backtrace noise. > Okay, I can remove that -- I mostly just added it out of concern that "no space left on device" would be a fairly confusing error for someone to potentially end up with modprobe reporting, and some further indication of what went wrong could perhaps make it less mystifying (though yes, with any luck it can hopefully remain unreachable in practice as long as data->groups gets expanded when needed). I'd certainly also be open to suggestions of a more appropriate errno value to return in that case, though I couldn't find one that seemed clearly better to me. ENOMEM seemed vaguely more appropriate in some ways given that it's an in-memory array that's full rather than a storage device, but it's also definitely not the usual ENOMEM meaning of a dynamic allocation failure due to memory pressure, so...(shrug). I think FreedBSD's got an EDOOFUS errno value, but as far as I can see Linux doesn't have one for indicating a purely internal error like this. Thanks, Zev