Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1345958rdb; Mon, 19 Feb 2024 12:10:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUBlfKrMvMAmrrAzzwIe6/mKbq69qsnDiziietBGmJwrTpl6UIrkm8Va5nkD6vffYBIH4LvEiqnGNRX1DIa/uCDg3kiPmAZwXeUNqdl3Q== X-Google-Smtp-Source: AGHT+IFYEcNHNrvcVk7xkxnfslztiLhFGZbh30S7OGc5l92oci+jjkwO6FFSOCPx323jGrKEirh1 X-Received: by 2002:a05:6358:2627:b0:179:20bb:d0b6 with SMTP id l39-20020a056358262700b0017920bbd0b6mr16325851rwc.6.1708373433849; Mon, 19 Feb 2024 12:10:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708373433; cv=pass; d=google.com; s=arc-20160816; b=CJj5ufbrAq1DCdfbbkA51aSn38xAO65HSaf0MKUjUN4TLiEjIMet83YU3TCRMXCSop c3spw0OTwl059uGhX6bkdONwkMWXnZld+ZEnkkvT4XcuqMidqORVg1mRTVHWpaY3P6p4 6QDWg4GUZxj6uqVUCCYbQMd12ALNltv1wRRzOZhZXEr1/0VjIHZTkbwmTPJLlaQfKVbW fyTDO96waE3wtMb6RIHt+M1eLJUx3OVjuV1fJ12Ghe2D5Oh8ouhz17UclE7B7gaX4WPV hagn7J16bC/3yDZYo2Dxl8GEDzt31JMAk0QufRtmI+a+Ix0EynHFy/n8iyOTNvpTJ+ku 9Y2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2FLRZHt+3h337Qbti+3R0ENxyz1yIS5pd4wnE0I9xkc=; fh=dqy4saYl98vaBioBitW8P99YvD9vNvqzqRubV0LdUlg=; b=WSyyf3J4afYgBK/sgwrqCau6g6annrYqgTEYnPUbk8Ll8o8eG656dFHRqGXsASeV0J 1fg8nXz2RoMDczpt0heMhKmk7MhB5vHL3cvkqw8d5cIED/DdXHq4OX8D6fLXNK+23vxE LzrRWzQAZzPmLAg0oZ4IcFbb/+HC32vUmjq54LwJBH+4dfwn3kGv0f7wu+VhsvCqZpsa q6KmQaqHxq9qtP9WGU1giQ5DTQ+V1+1rqAW+2H0IdWbTI1OtzukJMo8BZrYfZSPNneg4 WsPCSGbd1GcfiS0fWPGbw3ePlmhYdlZ6qYZFhodXTzTlwknP80zsl/teix5/25dMah2g 4iSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HrDmBRPm; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-71731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c30-20020a63725e000000b005d6d6f8cbddsi4889876pgn.360.2024.02.19.12.10.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 12:10:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HrDmBRPm; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-71731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71731-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 56639281F5B for ; Mon, 19 Feb 2024 17:05:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B992347F70; Mon, 19 Feb 2024 17:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HrDmBRPm" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 26FC244C93; Mon, 19 Feb 2024 17:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708362232; cv=none; b=lMX2NYx+9BEdEtEvi+eS+Ce/2hFzaZ6+XZIfd0sk9nVJC6iUg3bpMx0u4pqQTh/ZPETsWI6pyzzsJckqUfpY4y+K/J/ASkb+Cir+wUHFiZSUPhQJ42toMieyC3lknaDZhyYfyjCfCASfhKiGVFfj4FNKrhvX0ObywudZfXCcas0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708362232; c=relaxed/simple; bh=nTLPN95Vl8V4f80BsBvGNYRqiV1i3kk//8sITOoQ8ck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YE/ooqr4Po46CfkKdfl2Tb5FjJeUY2FiKDe37D9HEufATocrsuXlW4L7OSd1VgGsKC8SdMmmvg6i7VCrkwnmWX4rClvSkDHeH/aEcsWN2mnw6opAPgKsZ1BYn3dxJU324h2YvwmJDRgw9S+S5QWlNQoc0Yy1SI073g67WJKofVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HrDmBRPm; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708362231; x=1739898231; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nTLPN95Vl8V4f80BsBvGNYRqiV1i3kk//8sITOoQ8ck=; b=HrDmBRPm5lUDbn4/JL6Ci2TMDGSFhUsDahImeHq/II8Bhtf2yiXiCgL6 VYPyYIXVNVmnWw5ZMpdk7JN3EyeToPjirfmM8mpMsG6mzr9U2zLylSHKA sEQWfAeQRDO9FmSBKqEue1QIMy511x7+iAqUgDZAoxhx0wjOOxOJq+QDv wq1NvQ4Q3ZM2ola1RC0LOtsRS/fqlsZDEGWnjWNBv5VJJcPRJWnwMySiV UnpYMEDbPgaOSkKWNnBbtJrF+4zUq5gFSmqljsd1oRgYN5xJXkSVnN+oF TKKepMoOwWIwfeT8kY3qoCf6ttk5FUCiuuq43eBPBHyfRmT+LVl2hk/o9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="2577433" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="2577433" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2024 09:03:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="936315369" X-IronPort-AV: E=Sophos;i="6.06,170,1705392000"; d="scan'208";a="936315369" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 19 Feb 2024 09:03:46 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5E5863E5; Mon, 19 Feb 2024 19:03:41 +0200 (EET) From: Andy Shevchenko To: Krzysztof Kozlowski , Andy Shevchenko , Geert Uytterhoeven , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton Subject: [PATCH v3 5/9] auxdisplay: ht16k33: Define a few helper macros Date: Mon, 19 Feb 2024 18:58:04 +0200 Message-ID: <20240219170337.2161754-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240219170337.2161754-1-andriy.shevchenko@linux.intel.com> References: <20240219170337.2161754-1-andriy.shevchenko@linux.intel.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=UTF-8 Content-Transfer-Encoding: 8bit Define a few helper macros — wrappers on contaoner_of)() — for easier maintenance in the future. While at it, include missing container_of.h. Signed-off-by: Andy Shevchenko --- drivers/auxdisplay/ht16k33.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index f016130835b1..b76c4d83528f 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -107,6 +108,15 @@ struct ht16k33_priv { uint8_t blink; }; +#define ht16k33_work_to_priv(p) \ + container_of(p, struct ht16k33_priv, work.work) + +#define ht16k33_led_to_priv(p) \ + container_of(p, struct ht16k33_priv, led) + +#define ht16k33_linedisp_to_priv(p) \ + container_of(p, struct ht16k33_priv, seg.linedisp) + static const struct fb_fix_screeninfo ht16k33_fb_fix = { .id = DRIVER_NAME, .type = FB_TYPE_PACKED_PIXELS, @@ -194,8 +204,7 @@ static int ht16k33_brightness_set(struct ht16k33_priv *priv, static int ht16k33_brightness_set_blocking(struct led_classdev *led_cdev, enum led_brightness brightness) { - struct ht16k33_priv *priv = container_of(led_cdev, struct ht16k33_priv, - led); + struct ht16k33_priv *priv = ht16k33_led_to_priv(led_cdev); return ht16k33_brightness_set(priv, brightness); } @@ -203,8 +212,7 @@ static int ht16k33_brightness_set_blocking(struct led_classdev *led_cdev, static int ht16k33_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - struct ht16k33_priv *priv = container_of(led_cdev, struct ht16k33_priv, - led); + struct ht16k33_priv *priv = ht16k33_led_to_priv(led_cdev); unsigned int delay; uint8_t blink; int err; @@ -246,8 +254,7 @@ static void ht16k33_fb_queue(struct ht16k33_priv *priv) */ static void ht16k33_fb_update(struct work_struct *work) { - struct ht16k33_priv *priv = container_of(work, struct ht16k33_priv, - work.work); + struct ht16k33_priv *priv = ht16k33_work_to_priv(work); struct ht16k33_fbdev *fbdev = &priv->fbdev; uint8_t *p1, *p2; @@ -441,8 +448,7 @@ static void ht16k33_keypad_stop(struct input_dev *dev) static void ht16k33_seg7_update(struct work_struct *work) { - struct ht16k33_priv *priv = container_of(work, struct ht16k33_priv, - work.work); + struct ht16k33_priv *priv = ht16k33_work_to_priv(work); struct ht16k33_seg *seg = &priv->seg; char *s = seg->linedisp.buf; uint8_t buf[9]; @@ -462,8 +468,7 @@ static void ht16k33_seg7_update(struct work_struct *work) static void ht16k33_seg14_update(struct work_struct *work) { - struct ht16k33_priv *priv = container_of(work, struct ht16k33_priv, - work.work); + struct ht16k33_priv *priv = ht16k33_work_to_priv(work); struct ht16k33_seg *seg = &priv->seg; char *s = seg->linedisp.buf; uint8_t buf[8]; @@ -478,8 +483,7 @@ static void ht16k33_seg14_update(struct work_struct *work) static void ht16k33_linedisp_update(struct linedisp *linedisp) { - struct ht16k33_priv *priv = container_of(linedisp, struct ht16k33_priv, - seg.linedisp); + struct ht16k33_priv *priv = ht16k33_linedisp_to_priv(linedisp); schedule_delayed_work(&priv->work, 0); } -- 2.43.0.rc1.1.gbec44491f096