From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 8D902182D0 for ; Thu, 30 Oct 2025 10:22:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761819737; cv=none; b=SHPp51IDjrWwoyUGos6S+mGB8J9oHmx3hrqwVS9mOC+c0uG3O+Ck0siIjknUVN249ZOYL4vY+r0ia/RhJo/KoiO5yyQB4Fzb0bRIEmdFS7++8Y6pVOYCVNFtRNryILJ0SGlspoH2Mg6sh05XwpFuvL0fQwloTbqXHvNf3ITbfUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761819737; c=relaxed/simple; bh=G1w0BDUSacW0XOVA8splxjQGwNpkVsIpdBFy2H1rlrk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZZeKvQoY27l/VbuPi0mZ/5SSLRQc7U2yGUOmW7Jyf39zPQID5CqIID76mIYKgDk6ilPa1JXj05+YOrL/dCDw5O8N58ch6nXqNv284RVz+sabtLUZ3eKdPw7YEwi5UfZQFO6J66K9LRfPSJ8QlnQEqkp/t+9C1zTruEUQLv5Z9PA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=O4nziRlZ; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O4nziRlZ" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-429b85c3880so561564f8f.2 for ; Thu, 30 Oct 2025 03:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761819734; x=1762424534; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=T2kUtsOiX/qEGmwwQ7Isl75d5/MBlGm1S9q3l+zR8t4=; b=O4nziRlZhgxJfb1KvMVN2gNQbV2P+Xo4+fuBmNEr9fW8RTQz+B0i7jpMxzFaal93HW k61fraA1ZvcPT12sNxmEgNUZgCz48e3IaclXacyTktXDJ3iypfXBqVTRg3QDalNeTetY Syc5iJsTppy0NmrUPDed117+Dc5ebhdsFbJOjx1Dkdye9vKp0adQA7l1vhQZ9UcAzw4a HQP6CFKG1F1p8u0IwNRWsny0YSGWj9p5GKjNlKx+V4KbJKplu5d1f0lUcV3GQ1es8sMJ Cq60OSKCI0Y74Das+fyAmBL05LtvXZE5ncyaMf2YAdvQhN62ILqJzntogMij8FnV84uO ebMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761819734; x=1762424534; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=T2kUtsOiX/qEGmwwQ7Isl75d5/MBlGm1S9q3l+zR8t4=; b=Gf/5xiS3K2UYZp81GQkfDa2I2+5kGHFB3A+eumOFEM8Fao4JQHKDHhQD/WQqV3VvcT sWSr4jmfZvUvyTQE04LPJzln4OHXgCHSzmXICR/aql8EnOgiDBAEtoRhu0uJt4WXsftx 3LgaJTg6v7wBwxdUIvL/mmXzZbwiC22KcGIljvM3on1j7qdKWeZcg9fo/PHJb/eA2Y0s BVo9BI3YFiX8E+A4b19fmY2W7TWWdDREfqxgpGq5j2LyyO4JBfWTkP0ZUHrkP9C7rDU9 csG08nMEic0hpYddSPUk+VOl32keyBTT/zYfp2v2nG+0nuq8GBXdYVrL0Qb3P+XSeqP8 9/nA== X-Forwarded-Encrypted: i=1; AJvYcCXtUHndLL+qjnHwlQCcqFYrMsbFSpxdVLFxPio3Eanbe5qf8F7X+pW/C4JkJm3BuNPK6wkS/jopMURl6s8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7WbhX01Ji8W+B35ZaKJs2dOmQdgFgZkwcW64ehJoZcaWXnaZc rtn8kyqymHt1uUt6h7jo21pQFpucxeXdiWArEYUK4TMhuitbSJEBNtq2 X-Gm-Gg: ASbGncuxf2c8bPRpBSG0D+6oUwtgRCy6qnun1bUCkSMWQ7cWJtG/rRyrQn8Wzxa+NrC KfdH6PNi1/KzBZrWskV2wx8qdXy+hhP+eV0g9ml/E2r5dogHA3DV8XZTRBED8fRW2J49jhLjcRp 6w9xJqDWh7PrNZVhdvGk6IdWAhIee/VOYpx1Tq73+ZroDu59iRp6QREITVqwWSD66cB4A057Ffg 4SUPMM8ng3wesdgfRXh1J/Fvpl3H+pOSHA0nNh0WNq1J6ILynjdhdxbDrolGuU83fxQWlXGmtaV Rrr0IO8PmhhK/XbL6suufRKYxQOmAhjNYiCPY9WIiXsCt65P9U8CNfj6uuYU9hnhDvt1N1kgveg R/ClVRZCNLSXDsdPm2HqpczoCEkxMZpP3gOIktcqPzMbD8vqkQNSzXjNN7mt8xVJqokBWycnDC1 j4uLTS2IiMxvzhaBR9si779h/JLKdO X-Google-Smtp-Source: AGHT+IG2GvMxb9LZfEwn29dXFAw3jlFUGhKBMnjmh2/V3MU6jJoVJ3uGtYSEM3H6aIAKv8Kvh0ETuA== X-Received: by 2002:a05:6000:4012:b0:429:b7cd:47ff with SMTP id ffacd0b85a97d-429b7cd4e85mr1197378f8f.40.1761819733529; Thu, 30 Oct 2025 03:22:13 -0700 (PDT) Received: from Ansuel-XPS. (93-34-90-37.ip49.fastwebnet.it. [93.34.90.37]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429952da12dsm31773234f8f.29.2025.10.30.03.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Oct 2025 03:22:13 -0700 (PDT) Message-ID: <69033c55.df0a0220.1a33d7.49ff@mx.google.com> X-Google-Original-Message-ID: Date: Thu, 30 Oct 2025 11:22:11 +0100 From: Christian Marangi To: Andy Shevchenko Cc: Ilia Lin , "Rafael J. Wysocki" , Viresh Kumar , Bjorn Andersson , Konrad Dybcio , Raag Jadav , Arnd Bergmann , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] err.h: add ERR_PTR_CONST macro References: <20251029133323.24565-1-ansuelsmth@gmail.com> <69023512.5d0a0220.3cccb7.8e65@mx.google.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: On Thu, Oct 30, 2025 at 10:27:38AM +0200, Andy Shevchenko wrote: > On Wed, Oct 29, 2025 at 04:38:53PM +0100, Christian Marangi wrote: > > On Wed, Oct 29, 2025 at 05:32:48PM +0200, Andy Shevchenko wrote: > > > On Wed, Oct 29, 2025 at 02:33:19PM +0100, Christian Marangi wrote: > > > > Add ERR_PTR_CONST macro to initialize global variables with error > > > > > > ERR_PTR_CONST() > > > > > > > pointers. This might be useful for specific case where there is a global > > > > variables initialized to an error condition and then later set to the > > > > real handle once probe finish/completes. > > > > > > Okay, this has two caveats: > > > > > > 1) naming is bad as it suggests something about const qualifier (and not, it's > > > not about that at all); > > > > > > 2) it doesn't explain what's wrong with ERR_PTR(). > > > > > > > It can't be used for global variables as it does cause compilation > > error. > > Can you show an example, please? > drivers/soc/qcom/smem.c:361:35: error: initializer element is not constant 361 | static struct qcom_smem *__smem = ERR_PTR(-EPROBE_DEFER); | ^~~~~~~ make[9]: *** [scripts/Makefile.build:229: drivers/soc/qcom/smem.o] Error 1 You want me to add this to the commit? Or any hint to better reword this so it's more understandable? > > I wanted to use ERR_PTR to set the __smem handle instead of freecode > > (void *) -EPROBE_DEFER and notice the compiler doesn't like using > > ERR_PTR(). > > > > Then the problem is clear as static declaration require constant value > > for initialization and ERR_PTR is a inline function. > > > > This is why ERR_PTR_CONST following the pattern that was used for > > FIELD_PREP -> FIELD_PREP_CONST that was also introduced for similar > > case. > > > > So yes this is specific for case of static global variables. > > -- > With Best Regards, > Andy Shevchenko > > -- Ansuel