From: "james qian wang (Arm Technology China)" Subject: [PATCH v1 1/2] drm/komeda: Add a new file komeda_sysfs.c Date: Tue, 26 Nov 2019 10:54:41 +0000 Message-ID: <20191126105412.5978-2-james.qian.wang@arm.com> References: <20191126105412.5978-1-james.qian.wang@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20191126105412.5978-1-james.qian.wang@arm.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Liviu Dudau , "airlied@linux.ie" , Brian Starkey , Mihail Atanassov Cc: "Jonathan Chai (Arm Technology China)" , "Julien Yin (Arm Technology China)" , "Thomas Sun (Arm Technology China)" , "Lowry Li (Arm Technology China)" , "Tiannan Zhu (Arm Technology China)" , nd , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Ben Davis , "Oscar Zhang (Arm Technology China)" , "Channing Chen (Arm Technology China)" , "james qian wang (Arm Technology China)" List-Id: dri-devel@lists.freedesktop.org From: "James Qian Wang (Arm Technology China)" Add a new file komeda_sysfs.c and move all sysfs related code to it. Signed-off-by: James Qian Wang (Arm Technology China) --- drivers/gpu/drm/arm/display/komeda/Makefile | 1 + .../gpu/drm/arm/display/komeda/komeda_dev.c | 61 +------------- .../gpu/drm/arm/display/komeda/komeda_dev.h | 3 + .../gpu/drm/arm/display/komeda/komeda_sysfs.c | 81 +++++++++++++++++++ 4 files changed, 88 insertions(+), 58 deletions(-) create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c diff --git a/drivers/gpu/drm/arm/display/komeda/Makefile b/drivers/gpu/drm/= arm/display/komeda/Makefile index 1931a7fa1a14..706674ca5928 100644 --- a/drivers/gpu/drm/arm/display/komeda/Makefile +++ b/drivers/gpu/drm/arm/display/komeda/Makefile @@ -7,6 +7,7 @@ ccflags-y :=3D \ komeda-y :=3D \ komeda_drv.o \ komeda_dev.o \ + komeda_sysfs.o \ komeda_format_caps.o \ komeda_color_mgmt.o \ komeda_pipeline.o \ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/= drm/arm/display/komeda/komeda_dev.c index 8e0bce46555b..734b88b88d94 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c @@ -63,59 +63,6 @@ static void komeda_debugfs_init(struct komeda_dev *mdev) } #endif =20 -static ssize_t -core_id_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct komeda_dev *mdev =3D dev_to_mdev(dev); - - return snprintf(buf, PAGE_SIZE, "0x%08x\n", mdev->chip.core_id); -} -static DEVICE_ATTR_RO(core_id); - -static ssize_t -config_id_show(struct device *dev, struct device_attribute *attr, char *bu= f) -{ - struct komeda_dev *mdev =3D dev_to_mdev(dev); - struct komeda_pipeline *pipe =3D mdev->pipelines[0]; - union komeda_config_id config_id; - int i; - - memset(&config_id, 0, sizeof(config_id)); - - config_id.max_line_sz =3D pipe->layers[0]->hsize_in.end; - config_id.side_by_side =3D mdev->side_by_side; - config_id.n_pipelines =3D mdev->n_pipelines; - config_id.n_scalers =3D pipe->n_scalers; - config_id.n_layers =3D pipe->n_layers; - config_id.n_richs =3D 0; - for (i =3D 0; i < pipe->n_layers; i++) { - if (pipe->layers[i]->layer_type =3D=3D KOMEDA_FMT_RICH_LAYER) - config_id.n_richs++; - } - return snprintf(buf, PAGE_SIZE, "0x%08x\n", config_id.value); -} -static DEVICE_ATTR_RO(config_id); - -static ssize_t -aclk_hz_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct komeda_dev *mdev =3D dev_to_mdev(dev); - - return snprintf(buf, PAGE_SIZE, "%lu\n", clk_get_rate(mdev->aclk)); -} -static DEVICE_ATTR_RO(aclk_hz); - -static struct attribute *komeda_sysfs_entries[] =3D { - &dev_attr_core_id.attr, - &dev_attr_config_id.attr, - &dev_attr_aclk_hz.attr, - NULL, -}; - -static struct attribute_group komeda_sysfs_attr_group =3D { - .attrs =3D komeda_sysfs_entries, -}; - static int komeda_parse_pipe_dt(struct komeda_pipeline *pipe) { struct device_node *np =3D pipe->of_node; @@ -277,11 +224,9 @@ struct komeda_dev *komeda_dev_create(struct device *de= v) =20 clk_disable_unprepare(mdev->aclk); =20 - err =3D sysfs_create_group(&dev->kobj, &komeda_sysfs_attr_group); - if (err) { - DRM_ERROR("create sysfs group failed.\n"); + err =3D komeda_dev_sysfs_init(mdev); + if (err) goto err_cleanup; - } =20 mdev->err_verbosity =3D KOMEDA_DEV_PRINT_ERR_EVENTS; =20 @@ -304,7 +249,7 @@ void komeda_dev_destroy(struct komeda_dev *mdev) const struct komeda_dev_funcs *funcs =3D mdev->funcs; int i; =20 - sysfs_remove_group(&dev->kobj, &komeda_sysfs_attr_group); + komeda_dev_sysfs_destroy(mdev); =20 #ifdef CONFIG_DEBUG_FS debugfs_remove_recursive(mdev->debugfs_root); diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h b/drivers/gpu/= drm/arm/display/komeda/komeda_dev.h index dacdb00153e9..6183e0f394f0 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h @@ -248,4 +248,7 @@ void komeda_print_events(struct komeda_events *evts, st= ruct drm_device *dev); int komeda_dev_resume(struct komeda_dev *mdev); int komeda_dev_suspend(struct komeda_dev *mdev); =20 +int komeda_dev_sysfs_init(struct komeda_dev *mdev); +void komeda_dev_sysfs_destroy(struct komeda_dev *mdev); + #endif /*_KOMEDA_DEV_H_*/ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c b/drivers/gp= u/drm/arm/display/komeda/komeda_sysfs.c new file mode 100644 index 000000000000..740f095b4ca5 --- /dev/null +++ b/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) COPYRIGHT 2019 ARM Limited. All rights reserved. + * Author: James.Qian.Wang + * + */ +#include + +#include "komeda_dev.h" + +static ssize_t +core_id_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct komeda_dev *mdev =3D dev_to_mdev(dev); + + return snprintf(buf, PAGE_SIZE, "0x%08x\n", mdev->chip.core_id); +} +static DEVICE_ATTR_RO(core_id); + +static ssize_t +config_id_show(struct device *dev, struct device_attribute *attr, char *bu= f) +{ + struct komeda_dev *mdev =3D dev_to_mdev(dev); + struct komeda_pipeline *pipe =3D mdev->pipelines[0]; + union komeda_config_id config_id; + int i; + + memset(&config_id, 0, sizeof(config_id)); + + config_id.max_line_sz =3D pipe->layers[0]->hsize_in.end; + config_id.side_by_side =3D mdev->side_by_side; + config_id.n_pipelines =3D mdev->n_pipelines; + config_id.n_scalers =3D pipe->n_scalers; + config_id.n_layers =3D pipe->n_layers; + config_id.n_richs =3D 0; + for (i =3D 0; i < pipe->n_layers; i++) { + if (pipe->layers[i]->layer_type =3D=3D KOMEDA_FMT_RICH_LAYER) + config_id.n_richs++; + } + return snprintf(buf, PAGE_SIZE, "0x%08x\n", config_id.value); +} +static DEVICE_ATTR_RO(config_id); + +static ssize_t +aclk_hz_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct komeda_dev *mdev =3D dev_to_mdev(dev); + + return snprintf(buf, PAGE_SIZE, "%lu\n", clk_get_rate(mdev->aclk)); +} +static DEVICE_ATTR_RO(aclk_hz); + +static struct attribute *komeda_sysfs_entries[] =3D { + &dev_attr_core_id.attr, + &dev_attr_config_id.attr, + &dev_attr_aclk_hz.attr, + NULL, +}; + +static struct attribute_group komeda_sysfs_attr_group =3D { + .attrs =3D komeda_sysfs_entries, +}; + +int komeda_dev_sysfs_init(struct komeda_dev *mdev) +{ + struct device *dev =3D mdev->dev; + int err; + + err =3D sysfs_create_group(&dev->kobj, &komeda_sysfs_attr_group); + if (err) + DRM_ERROR("create sysfs group failed.\n"); + + return err; +} + +void komeda_dev_sysfs_destroy(struct komeda_dev *mdev) +{ + struct device *dev =3D mdev->dev; + + sysfs_remove_group(&dev->kobj, &komeda_sysfs_attr_group); +} --=20 2.20.1