The patch titled sigma-firmware-loader-for-analog-devices-sigmastudio-v2 has been added to the -mm tree. Its filename is sigma-firmware-loader-for-analog-devices-sigmastudio-v2.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: sigma-firmware-loader-for-analog-devices-sigmastudio-v2 From: Mike Frysinger <vapier@xxxxxxxxxx> address feedback from Andrew Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/firmware/sigma.c | 67 +++++++++++++++++++------------------ include/linux/sigma.h | 10 ++--- 2 files changed, 41 insertions(+), 36 deletions(-) diff -puN drivers/firmware/sigma.c~sigma-firmware-loader-for-analog-devices-sigmastudio-v2 drivers/firmware/sigma.c --- a/drivers/firmware/sigma.c~sigma-firmware-loader-for-analog-devices-sigmastudio-v2 +++ a/drivers/firmware/sigma.c @@ -1,9 +1,9 @@ /* * Load Analog Devices SigmaStudio firmware files * -Â * Copyright 2009 Analog Devices Inc. -Â * -Â * Licensed under the GPL-2 or later. + * Copyright 2009-2011 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. */ #include <linux/crc32.h> @@ -14,7 +14,8 @@ #include <linux/sigma.h> /* Return: 0==OK, <0==error, =1 ==no more actions */ -int process_sigma_action(struct i2c_client *client, struct sigma_firmware *ssfw) +static int +process_sigma_action(struct i2c_client *client, struct sigma_firmware *ssfw) { struct sigma_action *sa = (void *)(ssfw->fw->data + ssfw->pos); size_t len = sigma_action_len(sa); @@ -24,27 +25,27 @@ int process_sigma_action(struct i2c_clie sa->instr, sa->addr, len); switch (sa->instr) { - case SIGMA_ACTION_WRITEXBYTES: - case SIGMA_ACTION_WRITESINGLE: - case SIGMA_ACTION_WRITESAFELOAD: - if (ssfw->fw->size < ssfw->pos + len) - return -EINVAL; - ret = i2c_master_send(client, (void *)&sa->addr, len); - if (ret < 0) - return -EINVAL; - break; - - case SIGMA_ACTION_DELAY: - ret = 0; - udelay(len); - len = 0; - break; + case SIGMA_ACTION_WRITEXBYTES: + case SIGMA_ACTION_WRITESINGLE: + case SIGMA_ACTION_WRITESAFELOAD: + if (ssfw->fw->size < ssfw->pos + len) + return -EINVAL; + ret = i2c_master_send(client, (void *)&sa->addr, len); + if (ret < 0) + return -EINVAL; + break; - case SIGMA_ACTION_END: - return 1; + case SIGMA_ACTION_DELAY: + ret = 0; + udelay(len); + len = 0; + break; - default: - return -EINVAL; + case SIGMA_ACTION_END: + return 1; + + default: + return -EINVAL; } /* when arrive here ret=0 or sent data */ @@ -52,7 +53,8 @@ int process_sigma_action(struct i2c_clie return ssfw->pos == ssfw->fw->size; } -int process_sigma_actions(struct i2c_client *client, struct sigma_firmware *ssfw) +static int +process_sigma_actions(struct i2c_client *client, struct sigma_firmware *ssfw) { pr_debug("%s: processing %p\n", __func__, ssfw); @@ -72,6 +74,7 @@ int process_sigma_firmware(struct i2c_cl struct sigma_firmware_header *ssfw_head; struct sigma_firmware ssfw; const struct firmware *fw; + u32 crc; pr_debug("%s: loading firmware %s\n", __func__, name); @@ -84,16 +87,18 @@ int process_sigma_firmware(struct i2c_cl ssfw.fw = fw; /* then verify the header */ - if (fw->size < sizeof(*ssfw_head)) { - ret = -ENODATA; + ret = -EINVAL; + if (fw->size < sizeof(*ssfw_head)) goto done; - } + ssfw_head = (void *)fw->data; - if (memcmp(ssfw_head->magic, SIGMA_MAGIC, ARRAY_SIZE(ssfw_head->magic))) { - ret = -EINVAL; + if (memcmp(ssfw_head->magic, SIGMA_MAGIC, ARRAY_SIZE(ssfw_head->magic))) + goto done; + + crc = crc32(0, fw->data, fw->size); + pr_debug("%s: crc=%x\n", __func__, crc); + if (crc != ssfw_head->crc) goto done; - } - pr_debug("%s: crc=%x\n", __func__, crc32(0, fw->data, fw->size)); ssfw.pos = sizeof(*ssfw_head); diff -puN include/linux/sigma.h~sigma-firmware-loader-for-analog-devices-sigmastudio-v2 include/linux/sigma.h --- a/include/linux/sigma.h~sigma-firmware-loader-for-analog-devices-sigmastudio-v2 +++ a/include/linux/sigma.h @@ -1,9 +1,9 @@ /* * Load firmware files from Analog Devices SigmaStudio * -Â * Copyright 2009 Analog Devices Inc. -Â * -Â * Licensed under the GPL-2 or later. + * Copyright 2009-2011 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. */ #ifndef __SIGMA_FIRMWARE_H__ @@ -12,6 +12,8 @@ #include <linux/firmware.h> #include <linux/types.h> +struct i2c_client; + #define SIGMA_MAGIC "ADISIGM" struct sigma_firmware { @@ -53,8 +55,6 @@ static inline size_t sigma_action_size(s return sizeof(*sa) + payload_len + (payload_len % 2); } -struct i2c_client; - extern int process_sigma_firmware(struct i2c_client *client, const char *name); #endif _ Patches currently in -mm which might be from vapier@xxxxxxxxxx are linux-next.patch llist-add-kconfig-option-arch_have_nmi_safe_cmpxchg.patch llist-lib-add-lock-less-null-terminated-single-list.patch llist-irq_work-use-llist-in-irq_work.patch llist-net-rds-replace-xlist-in-net-rds-xlisth-with-llist.patch sigma-firmware-loader-for-analog-devices-sigmastudio.patch sigma-firmware-loader-for-analog-devices-sigmastudio-v2.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html