From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F74136A34E; Tue, 2 Jun 2026 23:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780443890; cv=none; b=TmmlryZ83hKKuSDm080t6hXQt334CpE+5/Km9Vv8LPn/E2w5RD4AJWu61yS9w9QbKLd/3H4cN6sqmxaS6uHfdKeYyhL9q+NPMKCXEKJY0x8+qygnSmLTUXlkkDUbZYdN5E+8bZ44S33DVyylJjwgfXOTEKSrejeXnjDKVK2khBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780443890; c=relaxed/simple; bh=SJyLOGb6M+e+IMMB0xOlTYjn4owis3x6hI5FqwMXsiw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CamU2cWwHqoGwHuJA+gUyRnXX9amuYvdS0QglVt3qpgHLPMXgR1Qbfxa0eOf4DK6hfH0JTdbopzqsic+TggOpLYOOE/fVLxSd7Re3fF1y+aZY/JdCHXMok0JKksfuY3Phq4d+ENsIAzk6E2tUsYqTIKsbqHRtBV62D/EEl/BQ6U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lSMMhcQg; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lSMMhcQg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780443889; x=1811979889; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=SJyLOGb6M+e+IMMB0xOlTYjn4owis3x6hI5FqwMXsiw=; b=lSMMhcQgLzNU8dEcxfw2KynvwWvmUeZeiJSgyYGr7EwBCC2w97srr31L X0rgf3Aw3aLW4Q+34LEFlGbyQndHAzQe0F9T386lfo5/Wun6pwJ0BsKsc fYvwj2dTPqz1kWFofswR2zK8aa9887wasuTGezRQ3l0exwCJe2jYFyAl+ itYIVxE2JSEfA+Ejj3T+MHc2tj+6dgk6co4QRECVJp63myjtf1bOcwZTs U55n53/c4uitlbfC6Klbopy38rmhVsjfJ/pTzAPejRHPNaWxEFNrHpT+y I8Nq2uwiuLTbzJXZFb6qEXrL51MGOFgD0jh5elWbPeOGg7sfwx1TeL6Ae w==; X-CSE-ConnectionGUID: YjDUoFyZQqGGmxBMK7JKRg== X-CSE-MsgGUID: grwIN1cUShWrSyDEc9CK4A== X-IronPort-AV: E=McAfee;i="6800,10657,11805"; a="68784593" X-IronPort-AV: E=Sophos;i="6.24,184,1774335600"; d="scan'208";a="68784593" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2026 16:44:48 -0700 X-CSE-ConnectionGUID: ZZCjstl7QSmiYwPSErRUeA== X-CSE-MsgGUID: 3YD4qJ0ZRo+HsPggyrC/PQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,184,1774335600"; d="scan'208";a="248360229" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.244.116]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2026 16:44:44 -0700 Date: Wed, 3 Jun 2026 02:44:40 +0300 From: Andy Shevchenko To: Jishnu Prakash Cc: Jonathan Cameron , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , Amit Kucheria , Thara Gopinath , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Kamal Wadhwa , David Collins , Anjelique Melendez , Neil Armstrong , Stephan Gerhold Subject: Re: [PATCH v2 2/2] thermal: qcom: add support for PMIC5 Gen3 ADC thermal monitoring Message-ID: References: <20260526-gen3_adc_tm-v2-0-702fbac919ac@oss.qualcomm.com> <20260526-gen3_adc_tm-v2-2-702fbac919ac@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260526-gen3_adc_tm-v2-2-702fbac919ac@oss.qualcomm.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Tue, May 26, 2026 at 04:26:10PM +0530, Jishnu Prakash wrote: > Add support for ADC_TM part of PMIC5 Gen3. > > This is an auxiliary driver under the Gen3 ADC driver, which implements the > threshold setting and interrupt generating functionalities of QCOM ADC_TM > drivers, used to support thermal trip points. ... > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include Why?! > +#include > +#include > +#include > +#include ... > +/** > + * struct adc_tm5_gen3_channel_props - ADC_TM channel structure > + * @timer: time period of recurring TM measurement. > + * @tm_chan_index: TM channel number used (ranging from 1-7). > + * @sdam_index: SDAM on which this TM channel lies. > + * @common_props: structure with common ADC channel properties. > + * @high_thr_en: TM high threshold crossing detection enabled. > + * @low_thr_en: TM low threshold crossing detection enabled. > + * @chip: ADC TM device. > + * @tzd: pointer to thermal device corresponding to TM channel. > + */ > +struct adc_tm5_gen3_channel_props { > + unsigned int timer; > + unsigned int tm_chan_index; > + unsigned int sdam_index; > + struct adc5_channel_common_prop common_props; > + bool high_thr_en; > + bool low_thr_en; > + struct adc_tm5_gen3_chip *chip; > + struct thermal_zone_device *tzd; Wouldn't `pahole` suggest better layout? > +}; ... > +struct adc_tm5_gen3_chip { > + struct adc5_device_data *dev_data; > + struct adc_tm5_gen3_channel_props *chan_props; > + unsigned int nchannels; > + struct device *dev; Ditto. I would expect the nchannels to be the last. Also play with the position of dev to see if bloat-o-meter will show the difference. > +}; ... > + return adc5_gen3_get_scaled_reading(adc_tm5->dev, &prop->common_props, > + temp); Make it a single line. ... > + /* Low temperature corresponds to high voltage threshold */ > + prop->high_thr_en = (low_temp != -INT_MAX); Can low_temp be INT_MIN at some point? > + if (prop->high_thr_en) { > + adc_code = qcom_adc_tm5_gen2_temp_res_scale(low_temp); > + put_unaligned_le16(adc_code, &buf[10]); > + } ... > +static int adc_tm5_probe(struct auxiliary_device *aux_dev, > + const struct auxiliary_device_id *id) > +{ > + struct adc_tm5_gen3_chip *adc_tm5; > + struct tm5_aux_dev_wrapper *aux_dev_wrapper; > + struct device *dev = &aux_dev->dev; > + int ret; > + > + adc_tm5 = devm_kzalloc(dev, sizeof(*adc_tm5), GFP_KERNEL); > + if (!adc_tm5) > + return -ENOMEM; > + > + aux_dev_wrapper = container_of(aux_dev, struct tm5_aux_dev_wrapper, > + aux_dev); One line is easier to read. > + adc_tm5->dev = dev; > + adc_tm5->dev_data = aux_dev_wrapper->dev_data; > + adc_tm5->nchannels = aux_dev_wrapper->n_tm_channels; > + adc_tm5->chan_props = devm_kcalloc(dev, aux_dev_wrapper->n_tm_channels, > + sizeof(*adc_tm5->chan_props), GFP_KERNEL); > + if (!adc_tm5->chan_props) > + return -ENOMEM; > + > + for (int i = 0; i < adc_tm5->nchannels; i++) { > + adc_tm5->chan_props[i].common_props = aux_dev_wrapper->tm_props[i]; > + adc_tm5->chan_props[i].timer = MEAS_INT_1S; > + adc_tm5->chan_props[i].sdam_index = (i + 1) / 8; > + adc_tm5->chan_props[i].tm_chan_index = (i + 1) % 8; > + adc_tm5->chan_props[i].chip = adc_tm5; > + } > + > + /* This is to disable all ADC_TM channels in case of probe failure. */ > + ret = devm_add_action(dev, adc5_gen3_disable, adc_tm5); > + if (ret) > + return ret; > + > + /* > + * First SDAM's interrupt is shared between main ADC driver > + * and auxiliary TM driver, so its flags must include > + * IRQF_SHARED. This is not needed for other SDAMs as they > + * will be used only for TM functionality. > + */ > + ret = devm_request_threaded_irq(dev, > + adc_tm5->dev_data->base[0].irq, > + adctm5_gen3_isr, adctm5_gen3_isr_thread, > + IRQF_ONESHOT | IRQF_SHARED, > + adc_tm5->dev_data->base[0].irq_name, > + adc_tm5); > + if (ret < 0) > + return ret; > + > + for (int i = 1; i < adc_tm5->dev_data->num_sdams; i++) { > + ret = devm_request_threaded_irq(dev, > + adc_tm5->dev_data->base[i].irq, > + adctm5_gen3_isr, adctm5_gen3_isr_thread, > + IRQF_ONESHOT, adc_tm5->dev_data->base[i].irq_name, > + adc_tm5); > + if (ret < 0) > + return ret; > + } Can't it be combined by using temporary irq_flags variable /* ...the fat comment... */ irq_flags = ... for (int i = 0; ...) { ... irq_flags = ... } ? > + return adc_tm5_register_tzd(adc_tm5); > +} ... > +static const struct auxiliary_device_id adctm5_auxiliary_id_table[] = { > + { .name = "qcom_spmi_adc5_gen3.adc5_tm_gen3", }, Inner comma is redundant. > + { } > +}; > + Unneeded blank line. > +MODULE_DEVICE_TABLE(auxiliary, adctm5_auxiliary_id_table); > + > +static struct auxiliary_driver adctm5gen3_auxiliary_driver = { > + .id_table = adctm5_auxiliary_id_table, > + .probe = adc_tm5_probe, > +}; > + Ditto. > +module_auxiliary_driver(adctm5gen3_auxiliary_driver); -- With Best Regards, Andy Shevchenko