diff options
author | Jon Mayo <jmayo@nvidia.com> | 2011-08-31 16:26:29 -0700 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-09-01 21:11:22 -0700 |
commit | e0631d5c41fbfd2de09f10b344a800aed723285c (patch) | |
tree | 31041b964c755da5c23f5a0662c4f9318eb129d5 | |
parent | e353bff76aed0c79e7d27d989da597acdfe48b63 (diff) |
video: tegra: nvsd: code clean up
reformat code to fit with Linux coding style, and made blocks in some
larger if-else chains into functions.
Change-Id: If78038d196c8d5cf0326678a7432092179682182
Reviewed-on: http://git-master/r/50179
Reviewed-by: Matt Wagner <mwagner@nvidia.com>
Tested-by: Matt Wagner <mwagner@nvidia.com>
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
-rw-r--r-- | drivers/video/tegra/dc/nvsd.c | 416 |
1 files changed, 234 insertions, 182 deletions
diff --git a/drivers/video/tegra/dc/nvsd.c b/drivers/video/tegra/dc/nvsd.c index db95171cb9f7..97d687508a1e 100644 --- a/drivers/video/tegra/dc/nvsd.c +++ b/drivers/video/tegra/dc/nvsd.c @@ -84,8 +84,12 @@ static atomic_t *sd_brightness = NULL; static atomic_t man_k_until_blank = ATOMIC_INIT(0); /* Functional initialization */ -void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { - u32 i = 0, val = 0, bw_idx = 0, bw = 0; +void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) +{ + u32 i = 0; + u32 val = 0; + u32 bw_idx = 0; + u32 bw = 0; /* TODO: check if HW says SD's available */ /* If SD's not present or disabled, clear the register and return. */ @@ -93,6 +97,7 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { /* clear the brightness val, too. */ if (sd_brightness) atomic_set(sd_brightness, 255); + sd_brightness = NULL; tegra_dc_writel(dc, 0, DC_DISP_SD_CONTROL); @@ -102,51 +107,67 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { dev_dbg(&dc->ndev->dev, "NVSD Init:\n"); /* WAR: Settings will not be valid until the next flip. - Thus, set manual K to either HW's current value (if - we're already enabled) or a non-effective value (if - we're about to enable). */ + * Thus, set manual K to either HW's current value (if + * we're already enabled) or a non-effective value (if + * we're about to enable). */ val = tegra_dc_readl(dc, DC_DISP_SD_CONTROL); - if (val & SD_ENABLE_NORMAL) { + + if (val & SD_ENABLE_NORMAL) i = tegra_dc_readl(dc, DC_DISP_SD_HW_K_VALUES); - } - else { - /* 0 values for RGB = 1.0, i.e. non-affected */ - i = 0; - } + else + i = 0; /* 0 values for RGB = 1.0, i.e. non-affected */ + tegra_dc_writel(dc, i, DC_DISP_SD_MAN_K_VALUES); /* Enable manual correction mode here so that changing the - settings won't immediately impact display dehavior. */ + * settings won't immediately impact display dehavior. */ val |= SD_CORRECTION_MODE_MAN; tegra_dc_writel(dc, val, DC_DISP_SD_CONTROL); switch (settings->bin_width) { - default: case -1: - /* A -1 bin-width indicates 'automatic' - based upon aggressiveness. */ - settings->bin_width = -1; - switch (settings->aggressiveness) { - default: case 0: case 1: - bw = SD_BIN_WIDTH_ONE; - break; - case 2: case 3: case 4: - bw = SD_BIN_WIDTH_TWO; - break; - case 5: - bw = SD_BIN_WIDTH_FOUR; - break; - } + default: + case -1: + /* A -1 bin-width indicates 'automatic' + * based upon aggressiveness. */ + settings->bin_width = -1; + + switch (settings->aggressiveness) { + default: + case 0: + case 1: + bw = SD_BIN_WIDTH_ONE; + break; + case 2: + case 3: + case 4: + bw = SD_BIN_WIDTH_TWO; break; - case 1: bw = SD_BIN_WIDTH_ONE; break; - case 2: bw = SD_BIN_WIDTH_TWO; break; - case 4: bw = SD_BIN_WIDTH_FOUR; break; - case 8: bw = SD_BIN_WIDTH_EIGHT; break; + case 5: + bw = SD_BIN_WIDTH_FOUR; + break; + } + + break; + case 1: + bw = SD_BIN_WIDTH_ONE; + break; + case 2: + bw = SD_BIN_WIDTH_TWO; + break; + case 4: + bw = SD_BIN_WIDTH_FOUR; + break; + case 8: + bw = SD_BIN_WIDTH_EIGHT; + break; } + bw_idx = bw >> 3; /* Write LUT */ dev_dbg(&dc->ndev->dev, " LUT:\n"); + for (i = 0; i < DC_DISP_SD_LUT_NUM; i++) { - val = SD_LUT_R(settings->lut[bw_idx][i].r) | + val = SD_LUT_R(settings->lut[bw_idx][i].r) | SD_LUT_G(settings->lut[bw_idx][i].g) | SD_LUT_B(settings->lut[bw_idx][i].b); tegra_dc_writel(dc, val, DC_DISP_SD_LUT(i)); @@ -156,8 +177,9 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { /* Write BL TF */ dev_dbg(&dc->ndev->dev, " BL_TF:\n"); + for (i = 0; i < DC_DISP_SD_BL_TF_NUM; i++) { - val = SD_BL_TF_POINT_0(settings->bltf[bw_idx][i][0]) | + val = SD_BL_TF_POINT_0(settings->bltf[bw_idx][i][0]) | SD_BL_TF_POINT_1(settings->bltf[bw_idx][i][1]) | SD_BL_TF_POINT_2(settings->bltf[bw_idx][i][2]) | SD_BL_TF_POINT_3(settings->bltf[bw_idx][i][3]); @@ -167,14 +189,14 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { } /* Write Coeff */ - val = SD_CSC_COEFF_R(settings->coeff.r) | + val = SD_CSC_COEFF_R(settings->coeff.r) | SD_CSC_COEFF_G(settings->coeff.g) | SD_CSC_COEFF_B(settings->coeff.b); tegra_dc_writel(dc, val, DC_DISP_SD_CSC_COEFF); dev_dbg(&dc->ndev->dev, " COEFF: 0x%08x\n", val); /* Write BL Params */ - val = SD_BLP_TIME_CONSTANT(settings->blp.time_constant) | + val = SD_BLP_TIME_CONSTANT(settings->blp.time_constant) | SD_BLP_STEP(settings->blp.step); tegra_dc_writel(dc, val, DC_DISP_SD_BL_PARAMETERS); dev_dbg(&dc->ndev->dev, " BLP: 0x%08x\n", val); @@ -185,7 +207,7 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { dev_dbg(&dc->ndev->dev, " BL_CONTROL: 0x%08x\n", val); /* Write Flicker Control */ - val = SD_FC_TIME_LIMIT(settings->fc.time_limit) | + val = SD_FC_TIME_LIMIT(settings->fc.time_limit) | SD_FC_THRESHOLD(settings->fc.threshold); tegra_dc_writel(dc, val, DC_DISP_SD_FLICKER_CONTROL); dev_dbg(&dc->ndev->dev, " FLICKER_CONTROL: 0x%08x\n", val); @@ -196,8 +218,8 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { val |= SD_CORRECTION_MODE_MAN; /* Enable / One-Shot */ val |= (settings->enable == 2) ? - (SD_ENABLE_ONESHOT | SD_ONESHOT_ENABLE) : - SD_ENABLE_NORMAL; + (SD_ENABLE_ONESHOT | SD_ONESHOT_ENABLE) : + SD_ENABLE_NORMAL; /* HW Update Delay */ val |= SD_HW_UPDATE_DLY(settings->hw_update_delay); /* Video Luma */ @@ -218,7 +240,8 @@ void nvsd_init(struct tegra_dc *dc, struct tegra_dc_sd_settings *settings) { } /* Periodic update */ -bool nvsd_update_brightness(struct tegra_dc *dc) { +bool nvsd_update_brightness(struct tegra_dc *dc) +{ u32 val = 0; int cur_sd_brightness; @@ -236,8 +259,7 @@ bool nvsd_update_brightness(struct tegra_dc *dc) { val = tegra_dc_readl(dc, DC_DISP_SD_BL_CONTROL); val = SD_BLC_BRIGHTNESS(val); - if (val != (u32)cur_sd_brightness) - { + if (val != (u32)cur_sd_brightness) { /* set brightness value and note the update */ atomic_set(sd_brightness, (int)val); return true; @@ -248,6 +270,53 @@ bool nvsd_update_brightness(struct tegra_dc *dc) { return false; } +static ssize_t nvsd_lut_show(struct tegra_dc_sd_settings *sd_settings, + char *buf, ssize_t res) +{ + u32 i; + u32 j; + + for (i = 0; i < NUM_BIN_WIDTHS; i++) { + res += snprintf(buf + res, PAGE_SIZE - res, + "Bin Width: %d\n", 1 << i); + + for (j = 0; j < DC_DISP_SD_LUT_NUM; j++) { + res += snprintf(buf + res, + PAGE_SIZE - res, + "%d: R: %3d / G: %3d / B: %3d\n", + j, + sd_settings->lut[i][j].r, + sd_settings->lut[i][j].g, + sd_settings->lut[i][j].b); + } + } + return res; +} + +static ssize_t nvsd_bltf_show(struct tegra_dc_sd_settings *sd_settings, + char *buf, ssize_t res) +{ + u32 i; + u32 j; + + for (i = 0; i < NUM_BIN_WIDTHS; i++) { + res += snprintf(buf + res, PAGE_SIZE - res, + "Bin Width: %d\n", 1 << i); + + for (j = 0; j < DC_DISP_SD_BL_TF_NUM; j++) { + res += snprintf(buf + res, + PAGE_SIZE - res, + "%d: 0: %3d / 1: %3d / 2: %3d / 3: %3d\n", + j, + sd_settings->bltf[i][j][0], + sd_settings->bltf[i][j][1], + sd_settings->bltf[i][j][2], + sd_settings->bltf[i][j][3]); + } + } + return res; +} + /* Sysfs accessors */ static ssize_t nvsd_settings_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -258,85 +327,47 @@ static ssize_t nvsd_settings_show(struct kobject *kobj, struct tegra_dc_sd_settings *sd_settings = dc->out->sd_settings; ssize_t res = 0; - if(sd_settings) { - if(IS_NVSD_ATTR(enable)) { + if (sd_settings) { + if (IS_NVSD_ATTR(enable)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->enable); - } - else if(IS_NVSD_ATTR(aggressiveness)) { + else if (IS_NVSD_ATTR(aggressiveness)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->aggressiveness); - } - else if(IS_NVSD_ATTR(bin_width)) { + else if (IS_NVSD_ATTR(bin_width)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->bin_width); - } - else if(IS_NVSD_ATTR(hw_update_delay)) { + else if (IS_NVSD_ATTR(hw_update_delay)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->hw_update_delay); - } - else if(IS_NVSD_ATTR(use_vid_luma)) { + else if (IS_NVSD_ATTR(use_vid_luma)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->use_vid_luma); - } - else if(IS_NVSD_ATTR(coeff)) { - res = snprintf(buf, PAGE_SIZE, "R: %d / G: %d / B: %d\n", + else if (IS_NVSD_ATTR(coeff)) + res = snprintf(buf, PAGE_SIZE, + "R: %d / G: %d / B: %d\n", sd_settings->coeff.r, sd_settings->coeff.g, sd_settings->coeff.b); - } - else if(IS_NVSD_ATTR(blp_time_constant)) { + else if (IS_NVSD_ATTR(blp_time_constant)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->blp.time_constant); - } - else if(IS_NVSD_ATTR(blp_step)) { + else if (IS_NVSD_ATTR(blp_step)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->blp.step); - } - else if(IS_NVSD_ATTR(fc_time_limit)) { + else if (IS_NVSD_ATTR(fc_time_limit)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->fc.time_limit); - } - else if(IS_NVSD_ATTR(fc_threshold)) { + else if (IS_NVSD_ATTR(fc_threshold)) res = snprintf(buf, PAGE_SIZE, "%d\n", sd_settings->fc.threshold); - } - else if(IS_NVSD_ATTR(lut)) { - u32 i = 0, j = 0; - for (i = 0; i < NUM_BIN_WIDTHS; i++) { - res += snprintf(buf + res, PAGE_SIZE - res, - "Bin Width: %d\n", 1<<i); - for (j = 0; j < DC_DISP_SD_LUT_NUM; j++) { - res += snprintf(buf + res, PAGE_SIZE - res, - "%d: R: %3d / G: %3d / B: %3d\n", - j, - sd_settings->lut[i][j].r, - sd_settings->lut[i][j].g, - sd_settings->lut[i][j].b); - } - } - } - else if(IS_NVSD_ATTR(bltf)) { - u32 i = 0, j = 0; - for (i = 0; i < NUM_BIN_WIDTHS; i++) { - res += snprintf(buf + res, PAGE_SIZE - res, - "Bin Width: %d\n", 1<<i); - for (j = 0; j < DC_DISP_SD_BL_TF_NUM; j++) { - res += snprintf(buf + res, PAGE_SIZE - res, - "%d: 0: %3d / 1: %3d / 2: %3d / 3: %3d\n", - j, - sd_settings->bltf[i][j][0], - sd_settings->bltf[i][j][1], - sd_settings->bltf[i][j][2], - sd_settings->bltf[i][j][3]); - } - } - } - else { + else if (IS_NVSD_ATTR(lut)) + res = nvsd_lut_show(sd_settings, buf, res); + else if (IS_NVSD_ATTR(bltf)) + res = nvsd_bltf_show(sd_settings, buf, res); + else res = -EINVAL; - } - } - else { + } else { /* This shouldn't be reachable. But just in case... */ res = -EINVAL; } @@ -344,13 +375,14 @@ static ssize_t nvsd_settings_show(struct kobject *kobj, return res; } -#define NVSD_CHECK_AND_UPDATE(_min, _max, _varname) { \ +#define nvsd_check_and_update(_min, _max, _varname) { \ int val = simple_strtol(buf, NULL, 10); \ if (val >= _min && val <= _max) { \ sd_settings->_varname = val; \ settings_updated = true; \ } } -#define NVSD_GET_MULTI(_ele, _num, _act, _min, _max) { \ + +#define nvsd_get_multi(_ele, _num, _act, _min, _max) { \ char *b, *c, *orig_b; \ b = orig_b = kstrdup(buf, GFP_KERNEL); \ for (_act = 0; _act < _num; _act++) { \ @@ -367,6 +399,60 @@ static ssize_t nvsd_settings_show(struct kobject *kobj, if (orig_b) \ kfree(orig_b); \ } + +static int nvsd_lut_store(struct tegra_dc_sd_settings *sd_settings, + const char *buf) +{ + int ele[3 * DC_DISP_SD_LUT_NUM * NUM_BIN_WIDTHS]; + int i = 0; + int j = 0; + int num = 3 * DC_DISP_SD_LUT_NUM * NUM_BIN_WIDTHS; + + nvsd_get_multi(ele, num, i, 0, 255); + + if (i != num) + return -EINVAL; + + for (i = 0; i < NUM_BIN_WIDTHS; i++) { + for (j = 0; j < DC_DISP_SD_LUT_NUM; j++) { + sd_settings->lut[i][j].r = + ele[i * NUM_BIN_WIDTHS + j * 3 + 0]; + sd_settings->lut[i][j].g = + ele[i * NUM_BIN_WIDTHS + j * 3 + 1]; + sd_settings->lut[i][j].b = + ele[i * NUM_BIN_WIDTHS + j * 3 + 2]; + } + } + return 0; +} + +static int nvsd_bltf_store(struct tegra_dc_sd_settings *sd_settings, + const char *buf) +{ + int ele[4 * DC_DISP_SD_BL_TF_NUM]; + int i = 0, j = 0, num = 4 * DC_DISP_SD_BL_TF_NUM; + + nvsd_get_multi(ele, num, i, 0, 255); + + if (i != num) + return -EINVAL; + + for (i = 0; i < NUM_BIN_WIDTHS; i++) { + for (j = 0; j < DC_DISP_SD_BL_TF_NUM; j++) { + sd_settings->bltf[i][j][0] = + ele[i * NUM_BIN_WIDTHS + j * 4 + 0]; + sd_settings->bltf[i][j][1] = + ele[i * NUM_BIN_WIDTHS + j * 4 + 1]; + sd_settings->bltf[i][j][2] = + ele[i * NUM_BIN_WIDTHS + j * 4 + 2]; + sd_settings->bltf[i][j][3] = + ele[i * NUM_BIN_WIDTHS + j * 4 + 3]; + } + } + + return 0; +} + static ssize_t nvsd_settings_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { @@ -377,109 +463,69 @@ static ssize_t nvsd_settings_store(struct kobject *kobj, ssize_t res = count; bool settings_updated = false; - if(sd_settings) { - if(IS_NVSD_ATTR(enable)) { - NVSD_CHECK_AND_UPDATE(0, 1, enable); - } - else if(IS_NVSD_ATTR(aggressiveness)) { - NVSD_CHECK_AND_UPDATE(1, 5, aggressiveness); - } - else if(IS_NVSD_ATTR(bin_width)) { - NVSD_CHECK_AND_UPDATE(0, 8, bin_width); - } - else if(IS_NVSD_ATTR(hw_update_delay)) { - NVSD_CHECK_AND_UPDATE(0, 2, hw_update_delay); - } - else if(IS_NVSD_ATTR(use_vid_luma)) { - NVSD_CHECK_AND_UPDATE(0, 1, use_vid_luma); - } - else if(IS_NVSD_ATTR(coeff)) { + if (sd_settings) { + if (IS_NVSD_ATTR(enable)) { + nvsd_check_and_update(0, 1, enable); + } else if (IS_NVSD_ATTR(aggressiveness)) { + nvsd_check_and_update(1, 5, aggressiveness); + } else if (IS_NVSD_ATTR(bin_width)) { + nvsd_check_and_update(0, 8, bin_width); + } else if (IS_NVSD_ATTR(hw_update_delay)) { + nvsd_check_and_update(0, 2, hw_update_delay); + } else if (IS_NVSD_ATTR(use_vid_luma)) { + nvsd_check_and_update(0, 1, use_vid_luma); + } else if (IS_NVSD_ATTR(coeff)) { int ele[3], i = 0, num = 3; - NVSD_GET_MULTI(ele, num, i, 0, 15); + nvsd_get_multi(ele, num, i, 0, 15); + if (i == num) { sd_settings->coeff.r = ele[0]; sd_settings->coeff.g = ele[1]; sd_settings->coeff.b = ele[2]; settings_updated = true; - } - else { + } else { res = -EINVAL; } - } - else if(IS_NVSD_ATTR(blp_time_constant)) { - NVSD_CHECK_AND_UPDATE(0, 1024, blp.time_constant); - } - else if(IS_NVSD_ATTR(blp_step)) { - NVSD_CHECK_AND_UPDATE(0, 255, blp.step); - } - else if(IS_NVSD_ATTR(fc_time_limit)) { - NVSD_CHECK_AND_UPDATE(0, 255, fc.time_limit); - } - else if(IS_NVSD_ATTR(fc_threshold)) { - NVSD_CHECK_AND_UPDATE(0, 255, fc.threshold); - } - else if(IS_NVSD_ATTR(lut)) { - int ele[3 * DC_DISP_SD_LUT_NUM * NUM_BIN_WIDTHS]; - int i = 0, j = 0, num = 3 * DC_DISP_SD_LUT_NUM * NUM_BIN_WIDTHS; - NVSD_GET_MULTI(ele, num, i, 0, 255); - if (i == num) { - for (i = 0; i < NUM_BIN_WIDTHS; i++) { - for (j = 0; j < DC_DISP_SD_LUT_NUM; j++) { - sd_settings->lut[i][j].r = - ele[i * NUM_BIN_WIDTHS + j * 3 + 0]; - sd_settings->lut[i][j].g = - ele[i * NUM_BIN_WIDTHS + j * 3 + 1]; - sd_settings->lut[i][j].b = - ele[i * NUM_BIN_WIDTHS + j * 3 + 2]; - } - } - settings_updated = true; - } - else { + } else if (IS_NVSD_ATTR(blp_time_constant)) { + nvsd_check_and_update(0, 1024, blp.time_constant); + } else if (IS_NVSD_ATTR(blp_step)) { + nvsd_check_and_update(0, 255, blp.step); + } else if (IS_NVSD_ATTR(fc_time_limit)) { + nvsd_check_and_update(0, 255, fc.time_limit); + } else if (IS_NVSD_ATTR(fc_threshold)) { + nvsd_check_and_update(0, 255, fc.threshold); + } else if (IS_NVSD_ATTR(lut)) { + if (nvsd_lut_store(sd_settings, buf)) res = -EINVAL; - } - } - else if(IS_NVSD_ATTR(bltf)) { - int ele[4 * DC_DISP_SD_BL_TF_NUM]; - int i = 0, j = 0, num = 4 * DC_DISP_SD_BL_TF_NUM; - NVSD_GET_MULTI(ele, num, i, 0, 255); - if (i == num) { - for (i = 0; i < NUM_BIN_WIDTHS; i++) { - for (j = 0; j < DC_DISP_SD_BL_TF_NUM; j++) { - sd_settings->bltf[i][j][0] = - ele[i * NUM_BIN_WIDTHS + j * 4 + 0]; - sd_settings->bltf[i][j][1] = - ele[i * NUM_BIN_WIDTHS + j * 4 + 1]; - sd_settings->bltf[i][j][2] = - ele[i * NUM_BIN_WIDTHS + j * 4 + 2]; - sd_settings->bltf[i][j][3] = - ele[i * NUM_BIN_WIDTHS + j * 4 + 3]; - } - } + else settings_updated = true; - } - else { + } else if (IS_NVSD_ATTR(bltf)) { + if (nvsd_bltf_store(sd_settings, buf)) res = -EINVAL; - } - } - else { + else + settings_updated = true; + } else { res = -EINVAL; } /* Re-init if our settings were updated. */ if (settings_updated) { nvsd_init(dc, sd_settings); + /* Update backlight state IFF we're disabling! */ if (!sd_settings->enable && sd_settings->bl_device) { - /* Do the actual brightness update outside of the mutex */ - struct platform_device *pdev = sd_settings->bl_device; - struct backlight_device *bl = platform_get_drvdata(pdev); + /* Do the actual brightness update outside of + * the mutex */ + struct platform_device *pdev = + sd_settings->bl_device; + struct backlight_device *bl = + platform_get_drvdata(pdev); + if (bl) backlight_update_status(bl); } } - } - else { + } else { /* This shouldn't be reachable. But just in case... */ res = -EINVAL; } @@ -489,16 +535,20 @@ static ssize_t nvsd_settings_store(struct kobject *kobj, #define NVSD_PRINT_REG(__name) { \ u32 val = tegra_dc_readl(dc, __name); \ - res += snprintf(buf + res, PAGE_SIZE - res, #__name ": 0x%08x\n", val); \ + res += snprintf(buf + res, PAGE_SIZE - res, #__name ": 0x%08x\n", \ + val); \ } + #define NVSD_PRINT_REG_ARRAY(__name) { \ u32 val = 0, i = 0; \ res += snprintf(buf + res, PAGE_SIZE - res, #__name ":\n"); \ for (i = 0; i < __name##_NUM; i++) { \ val = tegra_dc_readl(dc, __name(i)); \ - res += snprintf(buf + res, PAGE_SIZE - res, " %d: 0x%08x\n", i, val); \ + res += snprintf(buf + res, PAGE_SIZE - res, " %d: 0x%08x\n", \ + i, val); \ } \ } + static ssize_t nvsd_registers_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -528,10 +578,12 @@ int nvsd_create_sysfs(struct device *dev) int retval = 0; nvsd_kobj = kobject_create_and_add("smartdimmer", &dev->kobj); + if (!nvsd_kobj) return -ENOMEM; retval = sysfs_create_group(nvsd_kobj, &nvsd_attr_group); + if (retval) { kobject_put(nvsd_kobj); dev_err(dev, "%s: failed to create attributes\n", __func__); |