From patchwork Tue Aug 13 12:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761912 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 D1549187348 for ; Tue, 13 Aug 2024 12:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551233; cv=none; b=UuqA8L+TbjfxfqL5zXAe6XWc+I54CkcFztl50xCCiF2hdbKk56hp8aDXjrQJoqVzzh8x50KXpenNdVVDTVB6Vg4cuUCAWUI7w15YIn9HtKKW3TFBc0Qyj35ps0z56xBF6doLwNkBmCZJw/Knvzzu8/4u4gpi88mzKMKVy3AT93c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551233; c=relaxed/simple; bh=g+rNwochslFeeyi6Ofw/XN2e0QyEqWoJrguFWPehPrQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LHGuHLwHkYjyVMS7k9+PFCSlEU1MPRUIS4V/qGT9Z3ZehYzjktht/+Fd5gVP8nEsJlPtwiv3/5oeMmxg/gT71oJ3fYn27wLxgUHjox7xrjiFkOGjcLL2IOVrEM4heWgsJ65j0Kb7fKb98S8FxVip/f/yDXmZHP1HTy6fGmwfjGA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=FJkGtUgx; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FJkGtUgx" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7a35eff1d06so333578285a.0 for ; Tue, 13 Aug 2024 05:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551231; x=1724156031; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q2YaJNxhLs5F8lLYTx7H4r6rahb3C2THbGnEdQxh/xA=; b=FJkGtUgx8jqlftw8QTjDYEKtLyHy8f9YTd5QchYiWhdyy/JfMkuBkTjwL1crIZUAS5 HtLarB/W4OKIThoR8D8o9Zae/kav761oIEJM7b/yirEuR9tQhWbkz592Q9bKQLdmgQ1u 4oHAqvrrbX1veu3+e4o5vwveSlEKHnWD4pPsQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551231; x=1724156031; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q2YaJNxhLs5F8lLYTx7H4r6rahb3C2THbGnEdQxh/xA=; b=wkXLBSUXgd2c8j+pNx+2WwldEE0EQaIy0zhWfpPotSWAKYTyCTnuT5JET4UMaKYrBy kp/Ov8b6RzJXUZTLjARX5HctNKKDiO3f0QaS7euL5CTjxnEAPtFKEvTvnH/iHR56yejX BPARLeeMY8XruB+DA4VqIK9TGjTNkw5kUDL1ccsbojevparFt1lWIoUVAZa1ZT8aYzFv PIAERmfFLs8neFCHuSIbtfAraYa8SzZ9eKE05Y6B4G6Fj2i3qSPBMz4PSSaLL6vScsty y8NZxZokor+14soNVOITJ50huIbLNhnuaJUhnvIGxPLSmGJH5z4eCxgUXGVd5tAdjd3W YBRw== X-Forwarded-Encrypted: i=1; AJvYcCWhqchdFfUFyqxwl4gvIb7hddl1t96g8ikmD6QJMy+cba3iPQVsrImPZPoitD4iBMfvrYMruDq290jCfbvlbLKf/XVX1cTfSB6/kns= X-Gm-Message-State: AOJu0Yx0ARl3oo8xo7cnoCm+I7lr8b5koW6Aq8O5w8gdxK4bKHQMucO8 3KG5hHnCh8fV4Kha4HBqSaRtcTf82Jxxg8GCzAI6ifJ//OUj+PLFZ89QKpfXzA== X-Google-Smtp-Source: AGHT+IEbPwywblqg1PHmJ6WOVqLAFdQNUuhFh7OmJ87lW/f5GlJN4YVEnCjKh12Gxxs2z0IijZihGw== X-Received: by 2002:a05:620a:4109:b0:7a1:e2e0:b3c9 with SMTP id af79cd13be357-7a4e151ba74mr391481985a.24.1723551230715; Tue, 13 Aug 2024 05:13:50 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4c7d71ca8sm331765485a.50.2024.08.13.05.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:50 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:48 +0000 Subject: [PATCH 1/6] media: ar0521: Refactor ar0521_power_off() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-1-664c84295b1c@chromium.org> References: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> In-Reply-To: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Factor out all the power off logic, except the clk_disable_unprepare(), to a new function __ar0521_power_off(). This allows ar0521_power_on() to explicitly clean-out the clock during the error-path. The following smatch warning is fixed: drivers/media/i2c/ar0521.c:912 ar0521_power_on() warn: 'sensor->extclk' from clk_prepare_enable() not released on lines: 912. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/ar0521.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c index 09331cf95c62..2c528db31ba6 100644 --- a/drivers/media/i2c/ar0521.c +++ b/drivers/media/i2c/ar0521.c @@ -835,7 +835,7 @@ static const struct initial_reg { be(0x0707)), /* 3F44: couple k factor 2 */ }; -static int ar0521_power_off(struct device *dev) +static void __ar0521_power_off(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct ar0521_dev *sensor = to_ar0521_dev(sd); @@ -850,6 +850,16 @@ static int ar0521_power_off(struct device *dev) if (sensor->supplies[i]) regulator_disable(sensor->supplies[i]); } +} + +static int ar0521_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ar0521_dev *sensor = to_ar0521_dev(sd); + + clk_disable_unprepare(sensor->extclk); + __ar0521_power_off(dev); + return 0; } @@ -908,7 +918,8 @@ static int ar0521_power_on(struct device *dev) return 0; off: - ar0521_power_off(dev); + clk_disable_unprepare(sensor->extclk); + __ar0521_power_off(dev); return ret; } From patchwork Tue Aug 13 12:13:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761913 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (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 8CE1F199250 for ; Tue, 13 Aug 2024 12:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551234; cv=none; b=k6K0VZ2gFWl2nXcrT6Sq6zS/ZejJQCu/RZGodd0dfGwO+JSBst8+P0Vy2csae6QHgoNaY8Bp/PPZ4bjlfUvjZEVaXz086k7Rm3AX+boZB28qHT7K/eyuw/Dk9ribYC8V3OWgy3bIK4q/Edw9dXDCEfJhhk/XqVh8nzt1yMQAGAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551234; c=relaxed/simple; bh=m5XHSgRo8F8WjUA+xwLRz6jjxaEE3qje9U5hDygSCPc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qvdIpFfLUZ72lHrH4yjf0i2z8FM4FvF69bfORQoC9zsaRfCb5sSRHfLKVgqWd7a6xxEWaPJFRV231inW9CF9yevLQ0QA9q9vjjRNkT/85te7LOdvVCDAGiCGOT3TV7ktuuQPe0CeQ2QgMzP7E3ZTpIw+LpO352/7+IsMMqILByE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=NnIzU98n; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="NnIzU98n" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7a1dd2004e1so337971485a.3 for ; Tue, 13 Aug 2024 05:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551231; x=1724156031; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1NN4I3pMa1z6u3JhFybH/YMr+WwEfsG16l3i3ACZ6OI=; b=NnIzU98n9usdqMARhJaHFWnNolZkXw26IDzbHeoG5B7YyN0PWOcS9L5BpW4Pp/7auz 52cS2XhOE9rF10zd0rpeT443ZXJi9T8UcHr2GejupbfT5CDmiafZLAUM+T9uIGKPNhH8 sTlMcitR5WIFfnZl7RvWKbuTHXB4zG1exPgtw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551231; x=1724156031; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1NN4I3pMa1z6u3JhFybH/YMr+WwEfsG16l3i3ACZ6OI=; b=FyBL1D15TekOo08ON6YluRwDl51CYKPom+/xSiULADjbl9miLNAqiudhO90exmCfxH pTibHUKo0T7k2AsYmvNVhr3kd84AEfV0KJkE4im/NWxqw63MtUcqTEO8S0Nk3K2PbynP h7W6f/af6uDpu9re9YwDD38TeUx6qeLtLDBx5kAc6NIRb9ySuXFsV/NZA9N+MH3gWBPH VaQcZ5yCoEUgPJNLxF/xW+VGT8Gri5+OOvaQEAxPDSBOXE39AuwIkWGoAKcpY0V1Y7+8 7QnPXhzDHOoa8COFBTSXzWPcvcSaMO3f6LbSWdK7VzLuXvWohNACWcumop3Rr6QTjzKZ qFAA== X-Forwarded-Encrypted: i=1; AJvYcCXAH7MY6VPR+qJ+FgeyXnaOj82hMNsJCd4lSDoNMJrXD2bcCFuXIJTS6Vu4fVU+sJpKNo5ohZzbpcI/LSwd8gwVZvFLyW5dOIpWRw0= X-Gm-Message-State: AOJu0YwVXPMaI7uKOCC0BTmQbQW/C8+KhJ62l+ncUhhtY8h0+n8ePp7p FME/+MS0SM4PJNMCihbnXdlSHPg9aUkVATbBkZ/vqQRQowYwEDF9mCI+iBOAPQ== X-Google-Smtp-Source: AGHT+IEbzzCLxiIWDetpY/N6kglqi3rroSN+bG6y6yQxlctkjM/b9mCaiLCXSWS8MVpF1YKtj23MkQ== X-Received: by 2002:a05:620a:4451:b0:79d:76e5:be76 with SMTP id af79cd13be357-7a4e15afa64mr377756785a.41.1723551231504; Tue, 13 Aug 2024 05:13:51 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4c7d71ca8sm331765485a.50.2024.08.13.05.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:51 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:49 +0000 Subject: [PATCH 2/6] media: i2c: ov5645: Refactor ov5645_set_power_off() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-2-664c84295b1c@chromium.org> References: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> In-Reply-To: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Factor out all the power off logic, except clk_disable_unprepare(), to a new function __ov5645_set_power_off(). This allows ov5645_set_power_on() to excplicitly clean-out the clock during the error-path. The following smatch warning is fixed: drivers/media/i2c/ov5645.c:690 ov5645_set_power_on() warn: 'ov5645->xclk' from clk_prepare_enable() not released on lines: 690. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/ov5645.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 6c2d221f6973..0c32bd2940ec 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -635,7 +635,7 @@ static int ov5645_set_register_array(struct ov5645 *ov5645, return 0; } -static int ov5645_set_power_off(struct device *dev) +static void __ov5645_set_power_off(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct ov5645 *ov5645 = to_ov5645(sd); @@ -643,8 +643,16 @@ static int ov5645_set_power_off(struct device *dev) ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x58); gpiod_set_value_cansleep(ov5645->rst_gpio, 1); gpiod_set_value_cansleep(ov5645->enable_gpio, 0); - clk_disable_unprepare(ov5645->xclk); regulator_bulk_disable(OV5645_NUM_SUPPLIES, ov5645->supplies); +} + +static int ov5645_set_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov5645 *ov5645 = to_ov5645(sd); + + __ov5645_set_power_off(dev); + clk_disable_unprepare(ov5645->xclk); return 0; } @@ -686,7 +694,8 @@ static int ov5645_set_power_on(struct device *dev) return 0; exit: - ov5645_set_power_off(dev); + __ov5645_set_power_off(dev); + clk_disable_unprepare(ov5645->xclk); return ret; } From patchwork Tue Aug 13 12:13:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761914 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 38D8A1993B2 for ; Tue, 13 Aug 2024 12:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551235; cv=none; b=gx3voDCLeD1WbnuPDPrX0vS/rtep7oV7MA1rhTruF5iCK6CzZ10qD3+DNtTSEsIJhucsdDQCpANrUsKZD/O3qKidZXUt4oLsO8xL0iS1TpQoPAtTcRIwlgzFiPkxzNM8nAcEWit02ZwTozLHNlMoAvuxMpMhZfR74zsAiYCSD8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551235; c=relaxed/simple; bh=F14N6L/7XjC8oRmavmnQiXfhM7cavcf0lfyqWY/R5js=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sbXTKYot3J7nOSkCABSwZFKK3Efy1az2b5PQLp0OcG82b4RAkI7CuzNiqhHN/mXC/AkEhNb0wBt9VtDE1j2Bq2g0E6SqyWcSBU2/CF8I6RFezo2PCTuG+uOAbuoPkp72R5nqIl5mj2B+YmduqaGtN8RidLDDRlgvXTp0OTSPdwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=UbDlZ6d8; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="UbDlZ6d8" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7a1d7bc07b7so360413085a.0 for ; Tue, 13 Aug 2024 05:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551233; x=1724156033; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LrZdtpz/qyn21riVVQ3i7W1bl9boREamJ7f5SQNbyMY=; b=UbDlZ6d8Kfn+w1WNhEcrYWG1Ri4Yg6sAGi38rXGDkVBS2hTzI7n/I30K5qZrA6nJOP cFt0uzjbN3uArZ/n11SGX9jlXJFmF20O4TfNok4JtQvVNkrFnGbqvZ9GJG4gOoD63Ooj AxvR7kASGCwsSu8hze71fCXDqGeY0x3SJCNtY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551233; x=1724156033; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LrZdtpz/qyn21riVVQ3i7W1bl9boREamJ7f5SQNbyMY=; b=PfLIrxQPRAncF/k6TAzDPvi3O3uAh8bdxZO9xXEv3Eh+LOa6IdUPDlygXvk4KxgXOf +er+dvUvMgXPgGLF7uLxiHoK+ps8FhuTPQQnSxFXB/avAF/YBY/R36GrkV5HsgFvtJE1 CyhftSItCATdMFqMXkbQB5y0WpX6U07KBOfJCkx1xmJqSGiZhacZp/d5CfgziBt4td7w qSYHrzci9yBJVIkbD3zqkB1GfqWlaHnpZf0bt7ba+ob0e3qev77+zxaWypYXZzZidh29 8zh9vyaxL9asETy6zNYyGSfu/AIeQoyf4Ld5RVzMyTPWXP4O18VzmPWrD54kvyfx0MAZ skaQ== X-Forwarded-Encrypted: i=1; AJvYcCUdrUeDVxIMC6FxsLnAa+LAVXptPwsZcD9iJ3H82RDHgV6GBuAaCqU8U1d2d95OPIAmg+Nwscx0YoO9DA==@vger.kernel.org X-Gm-Message-State: AOJu0YwJLibsp6IslgBA4y0r7stpBkCn1DKCFRkxhxIXPmSKqdl2DbNU aaj3/ljTCxquXfFRHxSJF8PXUdytIJITicpWvnd03UWRexfKiFmvJ+5GKvFwiw== X-Google-Smtp-Source: AGHT+IFw/fFUPyShPG2/Ze40YU4KamjQKDfYMrBvg1bfZRKNcTmejJtMfWfYfhDU5SD5ItOdKzwbXQ== X-Received: by 2002:a05:620a:4043:b0:79f:515:e211 with SMTP id af79cd13be357-7a4e15bdc69mr410951685a.46.1723551233113; Tue, 13 Aug 2024 05:13:53 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4c7d71ca8sm331765485a.50.2024.08.13.05.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:52 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:50 +0000 Subject: [PATCH 3/6] media: i2c: s5c73m3: Move clk_prepare to its own function Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-3-664c84295b1c@chromium.org> References: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> In-Reply-To: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Smatch is very confused by a clk_prepare_enable() being called in an error-path. Fix this warning by moving the clk_prepare_enable() to its own function. drivers/media/i2c/s5c73m3/s5c73m3-core.c:1425 __s5c73m3_power_off() warn: 'state->clock' from clk_prepare_enable() not released on lines: 1425. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index e89e888f028e..7716dfe2b8c9 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1392,6 +1392,16 @@ static int __s5c73m3_power_on(struct s5c73m3 *state) return ret; } +/* + * This function has been created just to avoid a smatch warning, + * please do not merge into __s5c73m3_power_off() until you have + * confirmed that it does not introduce a new warning. + */ +static void s5c73m3_enable_clk(struct s5c73m3 *state) +{ + clk_prepare_enable(state->clock); +} + static int __s5c73m3_power_off(struct s5c73m3 *state) { int i, ret; @@ -1421,7 +1431,8 @@ static int __s5c73m3_power_off(struct s5c73m3 *state) state->supplies[i].supply, r); } - clk_prepare_enable(state->clock); + s5c73m3_enable_clk(state); + return ret; } From patchwork Tue Aug 13 12:13:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761916 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 4E628199EA6 for ; Tue, 13 Aug 2024 12:13:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551238; cv=none; b=Qm2UG29F0XdduvjJVEJGmWTa7FFQsOyx7hypOu/XZpp45uL+0dytyNXiqJSOYinbIXkHkEZYuiK5wi1Esxl36eJbgIyJU72FN6xKtR0UBJ3Lcu/BzwnqggfcJuSJoXO71FaVId90WQ6BMjw4Dt7CpPqOgFPw43dEoi3uWOxukaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551238; c=relaxed/simple; bh=Q2wAxRulEUNylV84MEI5qrVLjgN6aDtCQyka6+hlcM4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bdgvgdzqcUEIWTaiMXbI4s2asYvqEwGXCAxWUMA6xlR1JDKY5WPBmjF/+u4l2mHx8G4Wu+cZu9n75to/1O/0VE1JcuIwwxzlME003GIgTREy0Kf2i3teZJXA+ya3y1Z+x8DJmfpeVQ0no3+bRBe1ofJlDc/h6xHG5tPWmKfq5cE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=kXYjvtXC; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kXYjvtXC" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7a1d6f4714bso452434585a.1 for ; Tue, 13 Aug 2024 05:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551234; x=1724156034; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9Etl9GyPmdRz22pfGaoR8C42DApQqo8svGDO8wQI1tI=; b=kXYjvtXC9AQDwE8RQupA4pmEQYRg5Y9TfZt0n0+E6NqgA0wUBgGXZi6KRM7idRWdap f4JutDpECFSfSE0WYFUKzqGQqC+lbc4x+iRL1Gv2JV2LpAcqDFXpThyw6h2m4OQBlPVZ Dy0NGcDr9NzsUB5AQ/HfroBSiAU1cdjLlZMcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551234; x=1724156034; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Etl9GyPmdRz22pfGaoR8C42DApQqo8svGDO8wQI1tI=; b=pJD0sj94jpEjXKsHLwIWetoEUS1/RVEhYbrE43aExtCk4nBTC9i+3W43XcSuMrYTCz c4JK6GJnldHPjf1WeH5INFh+qkyL3oiTdx8ANUp2s7cdZrZZR+nE4bw1GDz+nmRNMtfS gxW+xSIoQvsweKbPhbIPIpjDIWXuUMWNeRezsK9YN/uF/GPH020dpnA7T6Q7x0hfwjVt dRRx5nCDXQ1S2XFnIbXf4LTZZzIcS6rVXsnztdgQJJ8sSWYWFyd1Z7MmxNRMpQUUprmV 0nHE36OM41C3wfuh9XHCaaFEPFcBg2/IjWWug3ChIDoM+nA26Hx6eM9vB6BdB5iFunOw Dr6Q== X-Forwarded-Encrypted: i=1; AJvYcCUD4QxOA6A1sufP0tcsE2NJektLTtdLT2CwGDSfUih26pK2OFAdSpt/2mO2bmoK/YEFwmUhAGxeAzcKJTGzzy9MhTVWiaFzpEkWE/Y= X-Gm-Message-State: AOJu0YyQ0ZNTj+DRkSIMnQrmrmnT8nibmGen8zEzarkdNQo0wn5CJjd9 fXQIIWnfz3dRYKsFnXh6CVGlXJx3YToe2nWTFgWAPsVZSRnDyJesLLBVAhnotw== X-Google-Smtp-Source: AGHT+IE5trF99pt6yxLy0hVGziVuLU740Yhk23ir8obTxxE56RFdMfq2z26jixLlIL2miIGD5ezz0A== X-Received: by 2002:a05:620a:d82:b0:7a1:da71:e73a with SMTP id af79cd13be357-7a4e37605b0mr498168385a.2.1723551234290; Tue, 13 Aug 2024 05:13:54 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4c7d71ca8sm331765485a.50.2024.08.13.05.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:53 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:51 +0000 Subject: [PATCH 4/6] media: tc358746: Move clk_prepare to its own function Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-4-664c84295b1c@chromium.org> References: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> In-Reply-To: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Smatch is very confused by a clk_prepare_enable() being called in an error-path. Fix this warning by moving the clk_prepare_enable() to its own function. drivers/media/i2c/tc358746.c:1631 tc358746_suspend() warn: 'tc358746->refclk' from clk_prepare_enable() not released on lines: 1631. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/tc358746.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index edf79107adc5..389582420ba7 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -1616,6 +1616,16 @@ static void tc358746_remove(struct i2c_client *client) pm_runtime_dont_use_autosuspend(sd->dev); } +/* + * This function has been created just to avoid a smatch warning, + * please do not merge it into tc358746_suspend until you have + * confirmed that it does not introduce a new warning. + */ +static void tc358746_clk_enable(struct tc358746 *tc358746) +{ + clk_prepare_enable(tc358746->refclk); +} + static int tc358746_suspend(struct device *dev) { struct tc358746 *tc358746 = dev_get_drvdata(dev); @@ -1626,7 +1636,7 @@ static int tc358746_suspend(struct device *dev) err = regulator_bulk_disable(ARRAY_SIZE(tc358746_supplies), tc358746->supplies); if (err) - clk_prepare_enable(tc358746->refclk); + tc358746_clk_enable(tc358746); return err; } From patchwork Tue Aug 13 12:13:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761915 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 44E3F19AD97 for ; Tue, 13 Aug 2024 12:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551238; cv=none; b=hrhwX+rFCtdhWuUJ6nLkIoyzBzkTFW4lGHyCWEmhxvsdI8oc81hxoqZnKZhq4mN0420SGE7VtaPKaTCZL7yPmlO/4AqpYxDQNo3OZHWNt9gAcsK/sQbbqxuNH2XL6z+n3fuOyxrdUAUsAvW9Ly7lvZY2pYGakyb8Nlz6ydBwIbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551238; c=relaxed/simple; bh=98X2t2WGiLxxCwmlaq0/ko8VmZHn8l1cDrLmrBX7bbI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=onRJVze87M9kTpNZdq7oMYAY9eAiWot+70LvD669WU0uVyRyl97wgUSGb7Tv2X6pa4+pz2Dkv6c7t6FxILY5tH2e22Sp0YFb04x//wCmk6k0LUes236YqKB9OlC38jqrHVgZ4ZUJALiIx2Hk5PrqOP2AGQ9rLVPgKgTddciMFvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=kaQqtdws; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kaQqtdws" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7a1d5f6c56fso310959285a.0 for ; Tue, 13 Aug 2024 05:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551235; x=1724156035; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ryvSTyFRHLyFB4VqqsDZg/Laqqf7RuuAiNN+vKB3Dic=; b=kaQqtdws1n+9WYWkcqyYKwk96e+SvEU8nQkTp/2R5cZS+HQ/Vs6ezvlTmFuPLKiYVT hImULzf7ogwbUUvdGVDmev8VruMSo/L+bmQq6AHCc99i3L+54QFg39cBiOiuSkGgtEcT h0g846mjMKq9XPun+I/QbC73br7kVmFxMJdow= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551235; x=1724156035; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ryvSTyFRHLyFB4VqqsDZg/Laqqf7RuuAiNN+vKB3Dic=; b=H1WaowlOWZLK7RbiwqiR4Ezi3IwthFmfo/l2G5WXYNlKMgqzHQbDq/Q3JdrjpjuiVF uM7QLNRc8aVLhBHWAiIniHtXofkoHyVPaRCZ0fHCHHeUURb2zOLv/ocS1yER6cozpWKk N7h+qbPdnkqDYG5G4fND+43icyc2fdqCBOGnDkxGiR7N6SQLBOrlooGb5ju8dgcIffY4 f8ckH5oC33P7fWI2H6HnTVQa08NhOxvSbaSO2BIc/xtYxFFSaQrLIszdG5QPCBggobhk 6lkm/fdn8RYPD2zxh4CLFae2mfTZStaRVzqZar1DKF4WFP8wPv6zarxRCYepFhlfxr/+ 2DmA== X-Forwarded-Encrypted: i=1; AJvYcCUPReria7/Ok8sMHwbLHWhhiznQg9Estf1/1uk1jMHQ1bzBKQXqgGDWpywxpCWi0/0KQCKUizOZpk5BEEOc8Dj4gdiRfMdT2m1+6KM= X-Gm-Message-State: AOJu0YxOFs2GF4ruEBOVwMvSy3joa/F03qRyZuD0Du6syX3m119uB6XS 20pcKl/qXr6vGFT6vkSbNJVE+CPjy+/IcSmJTlgT8GgGIPVXgkYL4RL2JDg71g== X-Google-Smtp-Source: AGHT+IEOX25WNCrWUaMxc3lkZuEvbZq3/dMLr0NrYO2cFstfRrmQqZhk/+W2xbcY25YibUai9xTEGw== X-Received: by 2002:a05:620a:31a9:b0:7a1:6062:ed63 with SMTP id af79cd13be357-7a4e15a434dmr379872785a.29.1723551235139; Tue, 13 Aug 2024 05:13:55 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4c7d71ca8sm331765485a.50.2024.08.13.05.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:54 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:52 +0000 Subject: [PATCH 5/6] media: meson: vdec_1: Refactor vdec_1_stop() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-5-664c84295b1c@chromium.org> References: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> In-Reply-To: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Factor out all the power off logic, except the clk_disable_unprepare(), to a new function __vdec_1_stop(). This allows vdec_1_start() to explicitly clean-out the clock during the error-path. The following smatch warning is fixed: drivers/staging/media/meson/vdec/vdec_1.c:239 vdec_1_start() warn: 'core->vdec_1_clk' from clk_prepare_enable() not released on lines: 239. Signed-off-by: Ricardo Ribalda --- drivers/staging/media/meson/vdec/vdec_1.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec_1.c b/drivers/staging/media/meson/vdec/vdec_1.c index 3fe2de0c9331..a65cb4959446 100644 --- a/drivers/staging/media/meson/vdec/vdec_1.c +++ b/drivers/staging/media/meson/vdec/vdec_1.c @@ -129,7 +129,7 @@ static u32 vdec_1_vififo_level(struct amvdec_session *sess) return amvdec_read_dos(core, VLD_MEM_VIFIFO_LEVEL); } -static int vdec_1_stop(struct amvdec_session *sess) +static void __vdec_1_stop(struct amvdec_session *sess) { struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; @@ -158,10 +158,17 @@ static int vdec_1_stop(struct amvdec_session *sess) regmap_update_bits(core->regmap_ao, AO_RTI_GEN_PWR_SLEEP0, GEN_PWR_VDEC_1, GEN_PWR_VDEC_1); - clk_disable_unprepare(core->vdec_1_clk); - if (sess->priv) codec_ops->stop(sess); +} + +static int vdec_1_stop(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + + __vdec_1_stop(sess); + + clk_disable_unprepare(core->vdec_1_clk); return 0; } @@ -235,7 +242,8 @@ static int vdec_1_start(struct amvdec_session *sess) return 0; stop: - vdec_1_stop(sess); + __vdec_1_stop(sess); + clk_disable_unprepare(core->vdec_1_clk); return ret; } From patchwork Tue Aug 13 12:13:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761917 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 40FE019B3D8 for ; Tue, 13 Aug 2024 12:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551239; cv=none; b=MH7ZUkDsdIx5fJ4XEZgELIGMMfDaFzbJewT/Ks4Kt5szfLRVKt/YKK96LXgH6c0AjuLU/H5/LXDCjHFkmGjLMbOrjtMA0emIuYpbwtjH/a3rk4jnIuNm1EQHdoJTJHmbLirThd2qNJJJftBm6hb3aBlozXVnKvUJulqjq2iC9ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723551239; c=relaxed/simple; bh=jH7TrqthPbyuatpm9k3mnNi3VlOKWR/v7KyFH3wuPGA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Mqttpc5XqjD2YDVLOCmezW1xvx+cAhpnh4mOpATxgOpwV8vunUbF+4RXbnmS1PcDwWRCL3Gx/grQf+G2ZdoM0sQzY/0Vh0VRQwGQG7bfxtDf7XTgb1/8jGmwHuJR4B6DLXF7FH7AmvzOM88dOOV96PV1gbk791wQ4NTfoOYtKEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=fDvvYQh+; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fDvvYQh+" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-709485aca4bso2852028a34.1 for ; Tue, 13 Aug 2024 05:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551236; x=1724156036; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tbox2ZoitlY78mZ2yFdlFoyXWXf8v8pDSpmA621vz/E=; b=fDvvYQh+g7IkDt64D6KWdNujPXX001pS8SBuLzJjCJZiKkIZx4McB+OVlTdt3DZzeB kRrUq1Mw+cmm1q8s2ywwXAMLNKm3lpu2dnFA6lJ0I2gtxNEsCBhQYkRCrXqZtb6JnSZk 02tCQzypa0MFgeFkhMnI6ZZ35CSS7Jx4zz7vo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551236; x=1724156036; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tbox2ZoitlY78mZ2yFdlFoyXWXf8v8pDSpmA621vz/E=; b=fiR5dHzcwFf0JsY5OffpgSQtSPu8fUWYvSp3ctCyqwVpsNkBo9EL2XPGLSPZ2bpuFk Tp6VPmRT8s9ssjbRDtA33uP1roAxBNWktNpZH7vEzeRiNJ+2Z4iLIeKgO/ElFVeFxMZp 5gQxzfLqo1oHmTQI673eBWkP09HiYWPfs5apuhOO17J1Md4DMftFJIzCp1EN92Fj2n8L 7EKJXSMaj5C/jvzU/Qi/T8My9T5MxtkOrUoGUQZftQGtkc/xYKji7xyRzjYACqCC+p7x zs7Q/AkvtiD4EDOcm9wCA2Zj0eJHPdRsrlF87BFPnI1MHiyN2wE6halq2wvt7iPevqIx 0JUQ== X-Forwarded-Encrypted: i=1; AJvYcCU6hhmnpAnrFcmiy8WNejNMhIqu9lE9flu324vuI+SQ0xgrYjai5LmRiv+LLX9EnVGGpXtcY1vC6sYECWwaS28pdAb58/U7aWG867s= X-Gm-Message-State: AOJu0YzzSCGY8gmW79q2m/ytsESBhdzrP0dzzuN+LgxwYqtW4Sv+Du+e pz5prH+1ahD8NU6aYZMKH7mO/5xDyi9gka/dK1NzODjUXy5k3pc6VKzq5Sx3Ow== X-Google-Smtp-Source: AGHT+IGgXIJUCN4cjOUkGFgon+WiB2P8zLnuNtMLuoWTLxNw2YXdYtwoDqVO1oPdH1blkel8OnEpNw== X-Received: by 2002:a05:6358:e4a4:b0:1af:1105:49b7 with SMTP id e5c5f4694b2df-1b19d2f4c8fmr402139355d.30.1723551236049; Tue, 13 Aug 2024 05:13:56 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4c7d71ca8sm331765485a.50.2024.08.13.05.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:55 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:53 +0000 Subject: [PATCH 6/6] media: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-6-664c84295b1c@chromium.org> References: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> In-Reply-To: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 Make a new function __vdec_hevc_start(), that does all the initialization, except the clock initialization for G12A and SM1. Factor out all the stop logic, except the clk_disable_unprepare(), to a new function __vdec_hevc_stop. This allows vdec_hevc_start() to explicitly celan-out the clock during the error-path. The following smatch warnings are fixed: drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevc_clk' from clk_prepare_enable() not released on lines: 227. drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevcf_clk' from clk_prepare_enable() not released on lines: 227. Signed-off-by: Ricardo Ribalda --- drivers/staging/media/meson/vdec/vdec_hevc.c | 43 +++++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec_hevc.c b/drivers/staging/media/meson/vdec/vdec_hevc.c index afced435c907..1939c47def58 100644 --- a/drivers/staging/media/meson/vdec/vdec_hevc.c +++ b/drivers/staging/media/meson/vdec/vdec_hevc.c @@ -110,7 +110,7 @@ static u32 vdec_hevc_vififo_level(struct amvdec_session *sess) return readl_relaxed(sess->core->dos_base + HEVC_STREAM_LEVEL); } -static int vdec_hevc_stop(struct amvdec_session *sess) +static void __vdec_hevc_stop(struct amvdec_session *sess) { struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; @@ -142,6 +142,13 @@ static int vdec_hevc_stop(struct amvdec_session *sess) else regmap_update_bits(core->regmap_ao, AO_RTI_GEN_PWR_SLEEP0, GEN_PWR_VDEC_HEVC, GEN_PWR_VDEC_HEVC); +} + +static int vdec_hevc_stop(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + + __vdec_hevc_stop(sess); clk_disable_unprepare(core->vdec_hevc_clk); if (core->platform->revision == VDEC_REVISION_G12A || @@ -151,20 +158,12 @@ static int vdec_hevc_stop(struct amvdec_session *sess) return 0; } -static int vdec_hevc_start(struct amvdec_session *sess) +static int __vdec_hevc_start(struct amvdec_session *sess) { int ret; struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; - if (core->platform->revision == VDEC_REVISION_G12A || - core->platform->revision == VDEC_REVISION_SM1) { - clk_set_rate(core->vdec_hevcf_clk, 666666666); - ret = clk_prepare_enable(core->vdec_hevcf_clk); - if (ret) - return ret; - } - clk_set_rate(core->vdec_hevc_clk, 666666666); ret = clk_prepare_enable(core->vdec_hevc_clk); if (ret) { @@ -223,10 +222,32 @@ static int vdec_hevc_start(struct amvdec_session *sess) return 0; stop: - vdec_hevc_stop(sess); + __vdec_hevc_stop(sess); + clk_disable_unprepare(core->vdec_hevc_clk); return ret; } +static int vdec_hevc_start(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + int ret; + + if (core->platform->revision == VDEC_REVISION_G12A || + core->platform->revision == VDEC_REVISION_SM1) { + clk_set_rate(core->vdec_hevcf_clk, 666666666); + ret = clk_prepare_enable(core->vdec_hevcf_clk); + if (ret) + return ret; + + ret = __vdec_hevc_start(sess); + if (ret) + clk_disable_unprepare(core->vdec_hevcf_clk); + return ret; + } + + return __vdec_hevc_start(sess); +} + struct amvdec_ops vdec_hevc_ops = { .start = vdec_hevc_start, .stop = vdec_hevc_stop,